/// <summary> /// 绑定Grid /// </summary> protected void BindGrid() { TSOutInTypeBB noPassReasonBB = new TSOutInTypeBB(); DataSet ds = new DataSet(); try { string strWhere = this.StrWhere; strWhere = "1=1"; ds = noPassReasonBB.GetList(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 { noPassReasonBB.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; } TSOutInTypeData model = new TSOutInTypeData(); TSOutInTypeBB tsOutInTypeBB = new TSOutInTypeBB(); try { if (this.State == "1") { this.SetModel(ref model); this.IdValue = tsOutInTypeBB.AddRecord(model); } else if (this.State == "2") { model = tsOutInTypeBB.GetModel(this.IdValue); this.SetModel(ref model); tsOutInTypeBB.ModifyRecord(model); } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { tsOutInTypeBB.Dispose(); } Response.Redirect("LTsOutInList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main", false); }
/// <summary> /// 展示数据 /// </summary> /// <param name="id">记录Id</param> private void ShowInfo(int id) { TSOutInTypeBB noPassReasonBB = new TSOutInTypeBB(); TSOutInTypeData model = new TSOutInTypeData(); try { model = noPassReasonBB.GetModel(id); this.tbOutInName.Text = model.outInTypeName; this.ddlCheckItem.SelectedValue = model.outInType; } finally { noPassReasonBB.Dispose(); } }
/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDel_Click(object sender, EventArgs e) { bool retChecked = false; TSOutInTypeBB noPassReasonBB = new TSOutInTypeBB(); 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); noPassReasonBB.DeleteRecord(id); } } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { noPassReasonBB.Dispose(); } if (retChecked) { this.BindGrid(); } }