/// <summary> /// 数据保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { string strInfo = ""; if (!this.ValidateData(out strInfo)) { strInfo = strInfo.Replace("\"", "'").Replace("\n", ""); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + strInfo + "');", true); return; } LWareData model = new LWareData(); LWareBB wareBB = new LWareBB(); try { if (this.State == "1") { this.SetModel(ref model); model.isrtDt = DateTime.Now.ToString(); model.isrtEmpId = this.currentUser.empId; this.IdValue = wareBB.AddRecord(model); } else if (this.State == "2") { model = wareBB.GetModel(this.IdValue); this.SetModel(ref model); model.updtDt = DateTime.Now.ToString(); model.updtEmpId = this.currentUser.empId; wareBB.ModifyRecord(model); } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { wareBB.Dispose(); } Response.Redirect("LWareList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main", false); }
/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDel_Click(object sender, EventArgs e) { bool retChecked = false; LWareBB wareBB = new LWareBB(); try { //获取选中的数据Id foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { retChecked = true; int id = int.Parse(chkId.ValidationGroup); LWareData wareModel = new LWareData(); wareModel = wareBB.GetModel(id); wareModel.isDel = true; wareModel.updtDt = System.DateTime.Now.ToString(); wareModel.updtEmpId = this.currentUser.empId; wareBB.ModifyRecord(wareModel); } } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { wareBB.Dispose(); } if (retChecked) { this.BindGrid(); } }