您目前尚未登陆,请选择【登陆】或【注册
首页->行政办公->无忧劳保库存系统源码>>supply.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:无忧劳保库存系统源码
当前文件:文件类型 Labor/supply.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using SqlHelper; 12public partial class supply : 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.BindSuppliersInfo(); 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 TxtCode.Focus(); 43 44 Label2.Text = "当前页码是" + Convert.ToString(GridView1.PageIndex + i); 45 46 GridView1.DataBind(); 47 } 48 } 49 protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) 50 { 51 GridView1.PageIndex = e.NewPageIndex; 52 53 Label2.Text = "当前页码是" + Convert.ToString(GridView1.PageIndex + i); 54 55 GridView1.DataBind(); 56 57 } 58 protected void BtnAdd_Click(object sender, EventArgs e) 59 { 60 61 if (TxtCode.Text.Trim().Length == 0) 62 { 63 TxtCode.Focus(); 64 65 Label1.Text = "请输入商家编号"; 66 67 } 68 else if (TxtName.Text.Trim().Length == 0) 69 { 70 TxtName.Focus(); 71 72 Label1.Text = "请输入商家名称"; 73 } 74 else if (TxtZIP.Text.Trim().Length == 0) 75 { 76 TxtZIP.Focus(); 77 78 Label1.Text = "请输入商家邮政编码"; 79 } 80 else if (TxtAddress.Text.Trim().Length == 0) 81 { 82 TxtAddress.Focus(); 83 84 Label1.Text = "请输入商家地址"; 85 } 86 else if (TxtContacts.Text.Trim().Length == 0) 87 { 88 TxtContacts.Focus(); 89 90 Label1.Text = "请输入商家联系人员"; 91 } 92 else if (TxtEmail.Text.Trim().Length == 0) 93 { 94 TxtEmail.Focus(); 95 96 Label1.Text = "请输入商家联系邮箱"; 97 } 98 else if (TxtTel.Text.Trim().Length == 0) 99 { 100 TxtTel.Focus(); 101 102 Label1.Text = "请输入商家联系电话"; 103 } 104 else if (TxtIS.Text.Trim().Length == 0) 105 { 106 TxtIS.Focus(); 107 108 Label1.Text = "请输入商家网址"; 109 } 110 else if (TxtAccount.Text.Trim().Length == 0) 111 { 112 TxtAccount.Focus(); 113 114 Label1.Text = "请输入商家账号"; 115 } 116 else if (TxtLevy.Text.Trim().Length == 0) 117 { 118 TxtLevy.Focus(); 119 120 Label1.Text = "请输入商家税号"; 121 } 122 else 123 { 124 System.Threading.Thread.Sleep(3000); 125 126 if (he.IsSID(TxtCode.Text.Trim())) 127 { 128 Label1.Text = "编号重复,请重新输入"; 129 130 TxtCode.Focus(); 131 } 132 else 133 { 134 if (he.ExecSQL("INSERT INTO Suppliers(SuppliersID, SuppliersName, SuppliersZIP, SuppliersAddress, SuppliersTelPeople, SuppliersEmail, SuppliersTel, SuppliersIS, SuppliersAccount, SuppliersLevy) VALUES ('" + TxtCode.Text.Trim() + "','" + TxtName.Text.Trim() + "','" + TxtZIP.Text.Trim() + "','" + TxtAddress.Text.Trim() + "','" + TxtContacts.Text.Trim() + "','" + TxtEmail.Text.Trim() + "','" + TxtTel.Text.Trim() + "','" + TxtIS.Text.Trim() + "','" + TxtAccount.Text.Trim() + "','" + TxtLevy.Text.Trim() + "')")) 135 { 136 Label1.Text = "数据插入成功"; 137 138 GridView1.DataSource = he.BindSuppliersInfo(); 139 140 GridView1.DataBind(); 141 142 TxtCode.Text = ""; 143 TxtName.Text = ""; 144 TxtZIP.Text = ""; 145 TxtAddress.Text = ""; 146 TxtContacts.Text = ""; 147 TxtEmail.Text = ""; 148 TxtTel.Text = ""; 149 TxtIS.Text = ""; 150 TxtAccount.Text = ""; 151 TxtLevy.Text = ""; 152 TxtCode.Focus(); 153 154 } 155 else 156 { 157 Label1.Text = "数据插入失败"; 158 } 159 } 160 } 161 } 162 protected void BtnUp_Click(object sender, EventArgs e) 163 { 164 if (TxtCode.Text.Trim().Length == 0) 165 { 166 TxtCode.Focus(); 167 168 Label1.Text = "请输入商家编号"; 169 170 } 171 else if (TxtName.Text.Trim().Length == 0) 172 { 173 TxtName.Focus(); 174 175 Label1.Text = "请输入商家名称"; 176 } 177 else if (TxtZIP.Text.Trim().Length == 0) 178 { 179 TxtZIP.Focus(); 180 181 Label1.Text = "请输入商家邮政编码"; 182 } 183 else if (TxtAddress.Text.Trim().Length == 0) 184 { 185 TxtAddress.Focus(); 186 187 Label1.Text = "请输入商家地址"; 188 } 189 else if (TxtContacts.Text.Trim().Length == 0) 190 { 191 TxtContacts.Focus(); 192 193 Label1.Text = "请输入商家联系人员"; 194 } 195 else if (TxtEmail.Text.Trim().Length == 0) 196 { 197 TxtEmail.Focus(); 198 199 Label1.Text = "请输入商家联系邮箱"; 200 } 201 else if (TxtTel.Text.Trim().Length == 0) 202 { 203 TxtTel.Focus(); 204 205 Label1.Text = "请输入商家联系电话"; 206 } 207 else if (TxtIS.Text.Trim().Length == 0) 208 { 209 TxtIS.Focus(); 210 211 Label1.Text = "请输入商家网址"; 212 } 213 else if (TxtAccount.Text.Trim().Length == 0) 214 { 215 TxtAccount.Focus(); 216 217 Label1.Text = "请输入商家账号"; 218 } 219 else if (TxtLevy.Text.Trim().Length == 0) 220 { 221 TxtLevy.Focus(); 222 223 Label1.Text = "请输入商家税号"; 224 } 225 else 226 { 227 System.Threading.Thread.Sleep(3000); 228 229 if (he.ExecSQL("UPDATE Suppliers SET SuppliersName ='" + TxtName.Text.Trim() + "', SuppliersZIP ='" + TxtZIP.Text.Trim() + "', SuppliersAddress ='" + TxtAddress.Text.Trim() + "', SuppliersTelPeople ='" + TxtContacts.Text.Trim() + "', SuppliersEmail ='" + TxtEmail.Text.Trim() + "', SuppliersTel ='" + TxtTel.Text.Trim() + "', SuppliersIS ='" + TxtIS.Text.Trim() + "', SuppliersAccount ='" + TxtAccount.Text.Trim() + "', SuppliersLevy ='" + TxtLevy.Text.Trim() + "'where SuppliersID ='"+CNo+"'")) 230 { 231 Label1.Text = "数据更新成功"; 232 233 Label3.Text = ""; 234 235 GridView1.DataSource = he.BindSuppliersInfo(); 236 237 GridView1.DataBind(); 238 239 TxtCode.Text = ""; 240 TxtName.Text = ""; 241 TxtZIP.Text = ""; 242 TxtAddress.Text = ""; 243 TxtContacts.Text = ""; 244 TxtEmail.Text = ""; 245 TxtTel.Text = ""; 246 TxtIS.Text = ""; 247 TxtAccount.Text = ""; 248 TxtLevy.Text = ""; 249 TxtCode.Focus(); 250 251 } 252 else 253 { 254 Label1.Text = "数据更新失败"; 255 } 256 } 257 } 258 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 259 { 260 switch (e.CommandName) 261 { 262 case "up": 263 //获取员工的编号 264 index = Convert.ToInt32(e.CommandArgument); 265 //根据行编号,获取选择的整行 266 GridViewRow selectedRowu = this.GridView1.Rows[index]; 267 //获取学生编号 268 CNo = selectedRowu.Cells[0].Text; 269 270 String[] info = he.GetSuppliersInfo(CNo); 271 272 TxtCode.Text = info[0]; 273 TxtName.Text = info[1]; 274 TxtZIP.Text = info[2]; 275 TxtAddress.Text = info[3]; 276 TxtContacts.Text = info[4]; 277 TxtEmail.Text = info[5]; 278 TxtTel.Text = info[6]; 279 TxtIS.Text = info[7]; 280 TxtAccount.Text = info[8]; 281 TxtLevy.Text = info[9]; 282 TxtCode.Focus(); 283 TxtCode.Enabled = false; 284 break; 285 286 case "del": 287 //获取员工的编号 288 index = Convert.ToInt32(e.CommandArgument); 289 //根据行编号,获取选择的整行 290 GridViewRow selectedRowd = this.GridView1.Rows[index]; 291 //获取学生编号 292 CNo = selectedRowd.Cells[0].Text; 293 294 if (he.ExecSQL("DELETE FROM Suppliers WHERE (SuppliersID = '" + CNo + "')")) 295 { 296 GridView1.DataSource = he.BindSuppliersInfo(); 297 298 GridView1.DataBind(); 299 300 Label3.Text = "数据删除成功"; 301 302 Label1.Text = ""; 303 304 } 305 else 306 307 { 308 return; 309 } 310