温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:无忧劳保库存系统源码
当前文件:
Labor/purchaseIN.aspx.cs,打开代码结构图
Labor/purchaseIN.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using SqlHelper; 12
13
public partial class purchaseIN : System.Web.UI.Page 14
{ 15
static int index;//员工编码号 16
17
static string CNo;//编号 18
19
Helper he = new Helper(); 20
21
static int i = 1;//页数 22
23
24
protected void Page_Load(object sender, EventArgs e) 25
{ 26
GridView1.DataSource = he.BindGoodsInfo(); 27
28
if (!IsPostBack) 29
{ 30
31
if (he.IsAdmin(Session["username"].ToString())) 32
{ 33
; 34
} 35
else 36
{ 37
Response.Write("<script>window.showModalDialog('IsAdmin.aspx','','resizable:yes;scroll:yes;status:no;dialogWidth=320px;dialogHeight=230px;center=yes;help=no');</script>"); 38
39
UpdatePanel2.Visible = false; 40
41
UpdatePanel1.Visible = false; 42
43
return; 44
} 45
46
TxtCode.Focus(); 47
48
Label3.Text = "当前页码是" + Convert.ToString(GridView1.PageIndex + i); 49
50
GridView1.DataBind(); 51
} 52
} 53
protected void BtnAdd_Click(object sender, EventArgs e) 54
{ 55
Label2.Text = ""; 56
if (TxtCode.Text.Trim().Length == 0) 57
{ 58
Label1.Text = "请输入供应商编号"; 59
60
TxtCode.Focus(); 61
} 62
else if (TxtGName.Text.Trim().Length == 0) 63
{ 64
Label1.Text = "请输入物品名字"; 65
66
TxtGName.Focus(); 67
} 68
else 69
{ 70
System.Threading.Thread.Sleep(3000); 71
72
if (he.IsGoodsCF(TxtGName.Text.Trim())) 73
{ 74
Label1.Text = "已经存在此物品了"; 75
76
return; 77
} 78
if (!he.IsSID(TxtCode.Text.Trim())) 79
{ 80
Label1.Text = "不存在此供应商"; 81
82
return; 83
} 84
if (he.IsGSID(TxtCode.Text.Trim())) 85
{ 86
Label1.Text = "供应商重复"; 87
88
return; 89
} 90
if (he.ExecSQL("insert into Goods(SuppliersID,GoodsName) values('" + TxtCode.Text.Trim() + "','" + TxtGName.Text.Trim() + "')")) 91
{ 92
Label1.Text = "数据插入成功"; 93
94
TxtCode.Text = ""; 95
96
TxtGName.Text = ""; 97
98
GridView1.DataSource = he.BindGoodsInfo(); 99
100
GridView1.DataBind(); 101
} 102
else 103
{ 104
Label1.Text = "数据插入失败"; 105
} 106
} 107
} 108
protected void BtnUp_Click(object sender, EventArgs e) 109
{ 110
Label2.Text = ""; 111
if (TxtCode.Text.Trim().Length == 0) 112
{ 113
Label1.Text = "请输入供应商编号"; 114
115
TxtCode.Focus(); 116
} 117
else if (TxtGName.Text.Trim().Length == 0) 118
{ 119
Label1.Text = "请输入物品名字"; 120
121
TxtGName.Focus(); 122
} 123
else 124
{ 125
System.Threading.Thread.Sleep(3000); 126
127
if (he.IsGoodsCF(TxtGName.Text.Trim())) 128
{ 129
Label1.Text = "已经存在此物品了"; 130
131
return; 132
} 133
if (!he.IsSID(TxtCode.Text.Trim())) 134
{ 135
Label1.Text = "不存在此供应商"; 136
137
return; 138
} 139
if (he.ExecSQL("update Goods set GoodsName='" + TxtGName.Text.Trim() + "' where GoodsID="+System.Convert.ToInt32(CNo)+"")) 140
{ 141
Label1.Text = "数据更新成功"; 142
143
TxtCode.Text = ""; 144
145
TxtGName.Text = ""; 146
147
GridView1.DataSource = he.BindGoodsInfo(); 148
149
GridView1.DataBind(); 150
} 151
else 152
{ 153
Label1.Text = "数据更新失败"; 154
} 155
} 156
} 157
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 158
{ 159
switch (e.CommandName) 160
{ 161
case "up": 162
//获取员工的编号 163
index = Convert.ToInt32(e.CommandArgument); 164
//根据行编号,获取选择的整行 165
GridViewRow selectedRowu = this.GridView1.Rows[index]; 166
//获取学生编号 167
CNo = selectedRowu.Cells[0].Text; 168
169
String[] info = he.GetGoodsInfo(CNo); 170
171
TxtCode.Text = info[0]; 172
173
TxtGName.Text = info[1]; 174
175
Label1.Text = ""; 176
177
Label2.Text = ""; 178
179
break; 180
181
case "del": 182
//获取员工的编号 183
index = Convert.ToInt32(e.CommandArgument); 184
//根据行编号,获取选择的整行 185
GridViewRow selectedRowd = this.GridView1.Rows[index]; 186
//获取学生编号 187
CNo = selectedRowd.Cells[0].Text; 188
189
if (he.ExecSQL("DELETE FROM Goods WHERE (GoodsID = '" + CNo + "')")) 190
{ 191
GridView1.DataSource = he.BindGoodsInfo(); 192
193
GridView1.DataBind(); 194
195
Label2.Text = "数据删除成功"; 196
197
Label1.Text = ""; 198
199
} 200
else 201
{ 202
return; 203
} 204
205
break; 206
} 207
} 208
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 209
{ 210
if (e.Row.RowType == DataControlRowType.DataRow) 211
{ 212
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate) 213
{ 214
((LinkButton)e.Row.Cells[4].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除产品:\"" + e.Row.Cells[2].Text.Trim() + "\"吗?')"); 215
} 216
} 217
} 218
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) 219
{ 220
GridView1.PageIndex = e.NewPageIndex; 221
222
Label3.Text = "当前页码是" + Convert.ToString(GridView1.PageIndex + i); 223
224
GridView1.DataBind(); 225
226
} 227
} 228





}
}