-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMCxTS.aspx.cs
More file actions
executable file
·287 lines (224 loc) · 10.1 KB
/
MCxTS.aspx.cs
File metadata and controls
executable file
·287 lines (224 loc) · 10.1 KB
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
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 MCxTS : System.Web.UI.Page
{
static String mid, toolsk, q, mes;
DBA con = new DBA();
protected void Page_Load(object sender, EventArgs e)
{
getMxtInfo();
if (!IsPostBack)
{
gettsData();
pslistSelect();
addButton.Visible = true;
editButton.Visible = false;
}
}
protected void getMxtInfo()
{
String q = "SELECT f.m_id,F.TOOL_SK,d.tool_id,M.PKG_GROUP_SK,PK.PKG_GROUP_DESC,M.PS_CODE,N.PS_DESC,f.QUAT_CNT,f.WEKLY_CNT FROM a_new_machines_status f LEFT JOIN a_new_tool_set d ON d.tool_sk = f.tool_sk JOIN a_new_machine m ON m.m_id = f.m_id JOIN a_new_pkg_group_desc pk ON PK.PKG_GROUP_SK = M.PKG_GROUP_SK join a_new_process_step n on N.PS_CODE = M.PS_CODE ORDER BY m_id asc";
DataSet ds = con.getData(q);
if (ds.Tables[0].Rows.Count > 0)
{
mxtsData.DataSource = ds;
mxtsData.DataBind();
}
else
{
ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
mxtsData.DataSource = ds;
mxtsData.DataBind();
int columncount = mxtsData.Rows[0].Cells.Count;
mxtsData.Rows[0].Cells.Clear();
mxtsData.Rows[0].Cells.Add(new TableCell());
mxtsData.Rows[0].Cells[0].ColumnSpan = columncount;
mxtsData.Rows[0].Cells[0].Text = "No Records Found";
}
}
protected void getMxtInfo_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
mxtsData.PageIndex = e.NewPageIndex;
getMxtInfo();
}
protected void gettsData_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
tsData.PageIndex = e.NewPageIndex;
gettsData();
}
protected void gettsData()
{
String q = "select a.tool_sk,a.tool_id,a.pkg_code,c.pkg_group_desc from a_new_tool_set a,a_new_pkg_code b, a_new_pkg_group_desc c where a.pkg_code = b.pkg_code and b.pkg_group_sk = c.pkg_group_sk order by tool_sk asc";
DataSet ds = con.getData(q);
if (ds.Tables[0].Rows.Count > 0)
{
tsData.DataSource = ds;
tsData.DataBind();
tsData.Columns[0].Visible = false;
}
else
{
ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
tsData.DataSource = ds;
tsData.DataBind();
int columncount = tsData.Rows[0].Cells.Count;
tsData.Rows[0].Cells.Clear();
tsData.Rows[0].Cells.Add(new TableCell());
tsData.Rows[0].Cells[0].ColumnSpan = columncount;
tsData.Rows[0].Cells[0].Text = "No Records Found";
}
}
protected void pslistSelect()
{
String q = "SELECT PS_CODE,PS_DESC FROM A_NEW_PROCESS_STEP";
DataSet ds = con.getData(q);
ds.Tables[0].Rows.InsertAt(ds.Tables[0].NewRow(), 0);
selectPS.DataSource = ds.Tables[0];
selectPS.DataMember = ds.Tables[0].TableName;
selectPS.DataTextField = ds.Tables[0].Columns["PS_DESC"].ColumnName;
selectPS.DataValueField = ds.Tables[0].Columns["PS_CODE"].ColumnName;
selectPS.DataBind();
}
protected void macSelect(String pscode)
{
String q = "SELECT m.PS_CODE,m.M_ID,M.M_ID || ' ----- '|| pg.PKG_GROUP_DESC AS Title FROM A_NEW_MACHINE m,A_NEW_PKG_GROUP_DESC pg WHERE m.PS_CODE='"+pscode+"' AND M.PKG_GROUP_SK = PG.PKG_GROUP_SK";
DataSet ds = con.getData(q);
ds.Tables[0].Rows.InsertAt(ds.Tables[0].NewRow(), 0);
selectMac.DataSource = ds.Tables[0];
selectMac.DataMember = ds.Tables[0].TableName;
selectMac.DataTextField = ds.Tables[0].Columns["Title"].ColumnName ;
selectMac.DataValueField = ds.Tables[0].Columns["M_ID"].ColumnName;
selectMac.DataBind();
}
protected void selectPS_SelectedIndexChanged(object sender, EventArgs e)
{
String pscode = selectPS.SelectedValue;
macSelect(pscode);
}
protected void tsSelected_click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("TOOL_SK", typeof(string)));
dt.Columns.Add(new DataColumn("TOOL_ID", typeof(string)));
foreach (GridViewRow row in tsData.Rows)
{
CheckBox chkRow = (row.Cells[4].FindControl("chkTS") as CheckBox);
if (chkRow.Checked)
{
dt.Rows.Add(row.Cells[0].Text, row.Cells[1].Text);
}
}
ds.Tables.Add(dt);
if (ds.Tables[0].Rows.Count > 0)
{
selectPC.DataSource = ds.Tables[0];
selectPC.DataMember = ds.Tables[0].TableName;
selectPC.DataTextField = ds.Tables[0].Columns["TOOL_ID"].ColumnName;
selectPC.DataValueField = ds.Tables[0].Columns["TOOL_SK"].ColumnName;
selectPC.DataBind();
}
}
protected void add_Click(object sender, EventArgs e)
{
mid = selectMac.SelectedValue;
for (int i = 0; i < selectPC.Items.Count; i++)
{
toolsk = selectPC.Items[i].Value.ToString();
q = "INSERT INTO A_NEW_MACHINES_STATUS(M_ID,TOOL_SK,CURRENT_STATUS) VALUES ('" + mid + "','" + toolsk + "','001')";
mes = con.querytoDB(q);
this.MessageBox(mes);
}
getMxtInfo();
selectMac.ClearSelection();
selectPS.ClearSelection();
selectPC.Items.Clear();
gettsData();
}
protected void MessageBox(string msg)
{
Label lbl = new Label();
lbl.Text = "<script language='javascript'> window.alert('" + msg + "')</script>";
Page.Controls.Add(lbl);
}
protected void mxtsData_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
int index = Convert.ToInt32(e.CommandArgument);
addButton.Visible = false;
editButton.Visible = true;
selectPS.SelectedValue = mxtsData.DataKeys[index].Values["PS_CODE"].ToString();
macSelect(mxtsData.DataKeys[index].Values["PS_CODE"].ToString());
selectMac.SelectedValue = mxtsData.DataKeys[index].Values["M_ID"].ToString();
selectPS.Enabled = false;
selectMac.Enabled = false;
tsMulSelected(mxtsData.DataKeys[index].Values["TOOL_SK"].ToString());
}
}
protected void tsMulSelected(String tsKey)
{
String q = "SELECT TOOL_SK,TOOL_ID FROM A_NEW_TOOL_SET WHERE TOOL_SK=" + tsKey + " ORDER BY TOOL_ID ASC ";
DataSet ds = con.getData(q);
if (ds.Tables[0].Rows.Count > 0)
{
selectPC.DataSource = ds.Tables[0];
selectPC.DataMember = ds.Tables[0].TableName;
selectPC.DataTextField = ds.Tables[0].Columns["TOOL_ID"].ColumnName;
selectPC.DataValueField = ds.Tables[0].Columns["TOOL_SK"].ColumnName;
selectPC.DataBind();
oldTS.DataSource = ds.Tables[0];
oldTS.DataMember = ds.Tables[0].TableName;
oldTS.DataTextField = ds.Tables[0].Columns["TOOL_ID"].ColumnName;
oldTS.DataValueField = ds.Tables[0].Columns["TOOL_SK"].ColumnName;
oldTS.DataBind();
for (int i = 0; i < selectPC.Items.Count; i++)
{
foreach (GridViewRow row in tsData.Rows)
{
if (row.Cells[1].Text == selectPC.Items[i].ToString())
{
CheckBox chkRow = (row.Cells[4].FindControl("chkTS") as CheckBox);
chkRow.Checked = true;
break;
}
}
}
}
}
protected void edit_click(object sender, EventArgs e)
{
mid = selectMac.SelectedValue;
for (int i = 0; i < selectPC.Items.Count; i++)
{
for (int k = 0; k < oldTS.Items.Count; k++)
{
if (selectPC.Items[i].Value.ToString() != selectPC.Items[k].Value.ToString())
{
toolsk = selectPC.Items[i].Value.ToString();
}
}
q = "INSERT INTO A_NEW_MACHINES_STATUS(M_ID,TOOL_SK,CURRENT_STATUS) VALUES ('" + mid + "','" + toolsk + "',)";
mes = con.querytoDB(q);
}
this.MessageBox(mes);
getMxtInfo();
pslistSelect();
gettsData();
addButton.Visible = true;
editButton.Visible = false;
selectPS.Enabled = true;
selectMac.Enabled = true;
}
}
}