-
Notifications
You must be signed in to change notification settings - Fork 0
/
UntPrStp.aspx.cs
executable file
·177 lines (148 loc) · 6.38 KB
/
UntPrStp.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Data.OracleClient;
namespace Toollife
{
public partial class UntPrStp : System.Web.UI.Page
{
String frameNo, frameNoOld, deviceNo, pkgCo, upsI;
DBA con = new DBA();
protected void Page_Load(object sender, EventArgs e)
{
getUPS();
if (!IsPostBack)
{
pkgGpSelect();
addButton.Visible = true;
editButton.Visible = false;
}
}
protected void getUPS()
{
String q = "SELECT ups.FRAME_NO,ups.DEVICE_NO,ups.PKG_CODE,pc.PKG_GROUP_SK,ups.UNIT_PER_STRP FROM A_NEW_UNIT_PER_STRIP ups LEFT JOIN A_NEW_PKG_CODE pc ON ups.PKG_CODE = pc.PKG_CODE ORDER BY ups.FRAME_NO ASC";
DataSet ds = con.getData(q);
if (ds.Tables[0].Rows.Count > 0)
{
upsData.DataSource = ds;
upsData.DataBind();
}
else
{
ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
upsData.DataSource = ds;
upsData.DataBind();
int columncount = upsData.Rows[0].Cells.Count;
upsData.Rows[0].Cells.Clear();
upsData.Rows[0].Cells.Add(new TableCell());
upsData.Rows[0].Cells[0].ColumnSpan = columncount;
upsData.Rows[0].Cells[0].Text = "No Records Found";
}
}
protected void pkgGpSelect()
{
String q = "SELECT PKG_GROUP_SK,PKG_GROUP_DESC FROM A_NEW_PKG_GROUP_DESC ORDER BY PKG_GROUP_DESC ASC";
DataSet ds = con.getData(q);
ds.Tables[0].Rows.InsertAt(ds.Tables[0].NewRow(), 0);
selectPG.DataSource = ds.Tables[0];
selectPG.DataMember = ds.Tables[0].TableName;
selectPG.DataTextField = ds.Tables[0].Columns["PKG_GROUP_DESC"].ColumnName;
selectPG.DataValueField = ds.Tables[0].Columns["PKG_GROUP_SK"].ColumnName;
selectPG.DataBind();
}
protected void selectPG_SelectedIndexChanged(object sender, EventArgs e)
{
String pkgGp = selectPG.SelectedValue;
pkgCoSelect(pkgGp);
}
protected void pkgCoSelect(String pkgGp)
{
String q = "SELECT PKG_CODE FROM A_NEW_PKG_CODE WHERE PKG_GROUP_SK=" + pkgGp + "ORDER BY PKG_CODE";
DataSet ds = con.getData(q);
selectPC.DataSource = ds.Tables[0];
selectPC.DataMember = ds.Tables[0].TableName;
selectPC.DataTextField = ds.Tables[0].Columns["PKG_CODE"].ColumnName;
selectPC.DataValueField = ds.Tables[0].Columns["PKG_CODE"].ColumnName;
selectPC.DataBind();
}
protected void upsData_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
upsData.PageIndex = e.NewPageIndex;
getUPS();
frameIn.Text = String.Empty;
deviceIn.Text = String.Empty;
unitIn.Text = String.Empty;
selectPG.ClearSelection();
selectPC.Items.Clear();
addButton.Visible = true;
editButton.Visible = false;
}
protected void add_Click(object sender, EventArgs e)
{
String q, mes;
this.frameNo = frameIn.Text;
this.deviceNo = deviceIn.Text;
this.pkgCo = selectPC.SelectedValue;
this.upsI = unitIn.Text;
q = "INSERT INTO A_NEW_UNIT_PER_STRIP(FRAME_NO,DEVICE_NO,PKG_CODE,UNIT_PER_STRP) VALUES ('" + frameNo+ "','" + deviceNo + "','" + pkgCo + "',"+upsI+")";
mes = con.querytoDB(q);
getUPS();
frameIn.Text = String.Empty;
deviceIn.Text = String.Empty;
unitIn.Text = String.Empty;
selectPG.ClearSelection();
selectPC.Items.Clear();
addButton.Visible = true;
editButton.Visible = false;
this.MessageBox(mes);
}
protected void upsData_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
int index = Convert.ToInt32(e.CommandArgument);
frameIn.Text = upsData.DataKeys[index].Values["FRAME_NO"].ToString();
selectPG.SelectedValue = upsData.DataKeys[index].Values["PKG_GROUP_SK"].ToString();
pkgCoSelect(upsData.DataKeys[index].Values["PKG_GROUP_SK"].ToString());
deviceIn.Text = upsData.DataKeys[index].Values["DEVICE_NO"].ToString();
selectPC.SelectedValue = upsData.DataKeys[index].Values["PKG_CODE"].ToString();
unitIn.Text = upsData.DataKeys[index].Values["UNIT_PER_STRP"].ToString();
addButton.Visible = false;
editButton.Visible = true;
TextBox1.Text = upsData.DataKeys[index].Values["FRAME_NO"].ToString();
}
}
protected void edit_onclick(object sender, EventArgs e)
{
String q, mes;
this.frameNo = frameIn.Text;
this.deviceNo = deviceIn.Text;
this.pkgCo = selectPC.SelectedValue;
this.upsI = unitIn.Text;
this.frameNoOld = TextBox1.Text;
q = "UPDATE A_NEW_UNIT_PER_STRIP SET FRAME_NO='" + frameNo + "',DEVICE_NO='" + deviceNo + "',PKG_CODE='" + pkgCo + "',UNIT_PER_STRP="+upsI+" WHERE FRAME_NO = " + frameNoOld + "";
mes = con.querytoDB(q);
getUPS();
frameIn.Text = String.Empty;
deviceIn.Text = String.Empty;
unitIn.Text = String.Empty;
selectPG.ClearSelection();
selectPC.Items.Clear();
addButton.Visible = true;
editButton.Visible = false;
this.MessageBox(mes);
}
protected void MessageBox(string msg)
{
Label lbl = new Label();
lbl.Text = "<script language='javascript'> window.alert('" + msg + "')</script>";
Page.Controls.Add(lbl);
}
}
}