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




Helper he 
}
}