-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMachine_Set.aspx.cs
More file actions
executable file
·152 lines (132 loc) · 5.62 KB
/
Copy pathMachine_Set.aspx.cs
File metadata and controls
executable file
·152 lines (132 loc) · 5.62 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
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 Machine_Set : System.Web.UI.Page
{
String M_ID, PS_CODE, PKG_GROUP_SK, MODEL;
DBA con = new DBA();
protected void Page_Load(object sender, EventArgs e)
{
getMacINFO();
if (!Page.IsPostBack)
{
pslistSelect();
pkgGpSelect();
}
addButton.Visible = true;
editButton.Visible = false;
macNO.ReadOnly = false;
}
protected void getMacINFO()
{
String q = "SELECT MAC.M_ID,MAC.PS_CODE,P.PS_DESC,MAC.PKG_GROUP_SK,PK.PKG_GROUP_DESC,MAC.MODEL FROM A_NEW_MACHINE MAC,A_NEW_PROCESS_STEP P,A_NEW_PKG_GROUP_DESC PK WHERE MAC.PS_CODE=P.PS_CODE AND MAC.PKG_GROUP_SK = PK.PKG_GROUP_SK ORDER BY M_ID ASC";
DataSet ds = con.getData(q);
if(ds.Tables[0].Rows.Count > 0){
macData.DataSource = ds;
macData.DataBind();
}else {
ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
macData.DataSource = ds;
macData.DataBind();
int columncount = macData.Rows[0].Cells.Count;
macData.Rows[0].Cells.Clear();
macData.Rows[0].Cells.Add(new TableCell());
macData.Rows[0].Cells[0].ColumnSpan = columncount;
macData.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 pkgGpSelect()
{
String q = "SELECT PKG_GROUP_SK,PKG_GROUP_DESC FROM A_NEW_PKG_GROUP_DESC";
DataSet ds = con.getData(q);
ds.Tables[0].Rows.InsertAt(ds.Tables[0].NewRow(), 0);
pkgGp.DataSource = ds.Tables[0];
pkgGp.DataMember = ds.Tables[0].TableName;
pkgGp.DataTextField = ds.Tables[0].Columns["PKG_GROUP_DESC"].ColumnName;
pkgGp.DataValueField = ds.Tables[0].Columns["PKG_GROUP_SK"].ColumnName;
pkgGp.DataBind();
}
protected void macData_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
macData.PageIndex = e.NewPageIndex;
getMacINFO();
pslistSelect();
pkgGpSelect();
macNO.Text = String.Empty;
mod.Text = String.Empty;
addButton.Visible = true;
editButton.Visible = false;
}
protected void MessageBox(string msg)
{
Label lbl = new Label();
lbl.Text = "<script language='javascript'> window.alert('" + msg + "')</script>";
Page.Controls.Add(lbl);
}
protected void addButton_Click(object sender, EventArgs e)
{
this.M_ID = macNO.Text;
this.PS_CODE = selectPS.SelectedItem.Value;
this.PKG_GROUP_SK = pkgGp.SelectedItem.Value;
this.MODEL = mod.Text;
String q = "INSERT INTO A_NEW_MACHINE(M_ID, PS_CODE, PKG_GROUP_SK,MODEL) VALUES ('" + M_ID + "','" + PS_CODE + "'," + PKG_GROUP_SK + ",'" + MODEL + "')";
String mes = con.querytoDB(q);
getMacINFO();
macNO.Text = String.Empty;
mod.Text = String.Empty;
this.MessageBox(mes);
}
protected void macData_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
addButton.Visible = false;
editButton.Visible = true;
int index = Convert.ToInt32(e.CommandArgument);
//GridViewRow selectedRow = macData.Rows[index];
macNO.Text = macData.DataKeys[index].Values["M_ID"].ToString();
macNO.ReadOnly = true;
selectPS.SelectedValue = macData.DataKeys[index].Values["PS_CODE"].ToString();
// selectPS.Enabled = false;
pkgGp.SelectedValue = macData.DataKeys[index].Values["PKG_GROUP_SK"].ToString();
mod.Text = macData.DataKeys[index].Values["MODEL"].ToString();
}
}
protected void edit_Click(object sender, EventArgs e)
{
String pss;
this.M_ID = macNO.Text;
this.PS_CODE = selectPS.SelectedItem.Value;
this.PKG_GROUP_SK = pkgGp.SelectedItem.Value;
this.MODEL = mod.Text;
String q = "UPDATE A_NEW_MACHINE SET PS_CODE='"+PS_CODE+"',PKG_GROUP_SK=" + PKG_GROUP_SK + ",MODEL='" + MODEL + "' WHERE M_ID='" + M_ID + "'";
String mes = con.querytoDB(q);
getMacINFO();
macNO.Text = String.Empty;
mod.Text = String.Empty;
pslistSelect();
pkgGpSelect();
this.MessageBox(mes);
}
}
}