/// <summary> /// 绑定Grid /// </summary> protected void BindGrid() { LCheckGunBB checkGunBB = new LCheckGunBB(); DataSet ds = new DataSet(); try { string strWhere = this.StrWhere; //检测枪编码 if (this.tbCheckGunNo.Text.Trim() != "") { strWhere += " and checkGunNo like '%" + this.tbCheckGunNo.Text.Trim().Replace("'", "''") + "%'"; } //检测枪名称 if (this.tbCheckGunNm.Text.Trim() != "") { strWhere += " and checkGunNm like '%" + this.tbCheckGunNm.Text.Trim().Replace("'", "''") + "%'"; } ds = checkGunBB.GetVList(strWhere); this.grid.DataSource = ds.Tables[0]; this.grid.DataBind(); //赋值记录条数、页面总数 this.Label3.Text = ds.Tables[0].Rows.Count.ToString(); this.Label2.Text = this.grid.PageCount.ToString(); this.currPage.Text = (this.grid.PageIndex + 1).ToString(); } finally { checkGunBB.Dispose(); } }
/// <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; } LCheckGunData model = new LCheckGunData(); LCheckGunBB checkGunBB = new LCheckGunBB(); try { if (this.State == "1") { this.SetModel(ref model); model.isrtDt = DateTime.Now.ToString(); model.isrtEmpId = this.currentUser.empId; this.IdValue = checkGunBB.AddRecord(model); } else if (this.State == "2") { model = checkGunBB.GetModel(this.IdValue); this.SetModel(ref model); model.updtDt = DateTime.Now.ToString(); model.updtEmpId = this.currentUser.empId; checkGunBB.ModifyRecord(model); } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { checkGunBB.Dispose(); } Response.Redirect("LCheckGunList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main", false); }
/// <summary> /// 绑定Grid /// </summary> protected void BindGrid() { LCheckGunBB lCheckGunBB = new LCheckGunBB(); DataSet ds = new DataSet(); try { ds = lCheckGunBB.GetList(""); ddlGun.DataSource = ds; ddlGun.DataValueField = "id"; ddlGun.DataTextField = "checkGunNm"; ddlGun.DataBind(); ddlGun.Items.Insert(0, new ListItem("请选择", "0")); } finally { lCheckGunBB.Dispose(); } }
/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDel_Click(object sender, EventArgs e) { bool retChecked = false; LCheckGunBB checkGunBB = new LCheckGunBB(); 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); LCheckGunData checkGunModel = new LCheckGunData(); checkGunModel = checkGunBB.GetModel(id); checkGunModel.isDel = true; checkGunModel.updtDt = System.DateTime.Now.ToString(); checkGunModel.updtEmpId = this.currentUser.empId; checkGunBB.ModifyRecord(checkGunModel); } } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { checkGunBB.Dispose(); } if (retChecked) { this.BindGrid(); } }
public DataTable GetCheckGun() { LCheckGunBB checkGunBB = new LCheckGunBB(); try { DataTable dt = new DataTable(); dt = checkGunBB.GetList("isDel=0").Tables[0]; return dt; } finally { checkGunBB.Dispose(); } }
/// <summary> /// 展示数据 /// </summary> /// <param name="id">记录Id</param> private void ShowInfo(int id) { LCheckGunBB checkGunBB = new LCheckGunBB(); vLCheckGunData model = new vLCheckGunData(); try { model = checkGunBB.GetVModel(id); this.tbCheckGunNo.Text = model.checkGunNo; this.tbCheckGunNm.Text = model.checkGunNm; } finally { checkGunBB.Dispose(); } }