/// <summary> /// 绑定Grid /// </summary> protected void BindGrid() { LCheckItemBB checkItemBB = new LCheckItemBB(); DataSet ds = new DataSet(); try { string strWhere = this.StrWhere; if (this.checkItemNo.Text != "")//编码 { strWhere += " and checkItemNo like '%" + this.checkItemNo.Text.Replace("'", "''") + "%'"; } if (checkItemNm.Text != "")//名称 { strWhere += " and checkItemNm like '%" + this.checkItemNm.Text.Replace("'", "''") + "%'"; } ds = checkItemBB.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 { checkItemBB.Dispose(); } }
/// <summary> /// 绑定检测项目下拉框 /// </summary> private void BindCheckItem(DropDownList ddlCheckItem) { using (LCheckItemBB checkItemBB = new LCheckItemBB()) { DataSet ds = new DataSet(); ds = checkItemBB.GetList(""); ddlCheckItem.DataTextField = "checkItemNm"; ddlCheckItem.DataValueField = "id"; ddlCheckItem.DataSource = ds.Tables[0]; ddlCheckItem.DataBind(); ddlCheckItem.Items.Insert(0, new ListItem("-请选择-", "")); } }
private bool ValidatePageControlValue(out string strInfo) { bool ret = true; bool isValidate = true; strInfo = ""; if (this.checkItemNo.Text.Trim() == "") { isValidate = false; strInfo = "编码不能为空!"; } if (this.checkItemNm.Text.Trim() == "") { isValidate = false; strInfo = "名称不能为空!"; } LCheckItemBB checkItemBB = new LCheckItemBB(); DataSet ds = checkItemBB.GetList(" id<>" + this.IdValue.ToString() + " and checkItemNo =" + "'" + this.checkItemNo.Text.Trim() + "'"); DataSet ds2 = checkItemBB.GetList(" id<>" + this.IdValue.ToString() + " and checkItemNm =" + "'" + this.checkItemNm.Text.Trim() + "'"); try { if (ds.Tables[0].Rows.Count > 0) { ret = false; strInfo = "编码已存在,请重新输入!"; return ret; } if (ds2.Tables[0].Rows.Count > 0) { ret = false; strInfo = "名称已存在,请重新输入!"; return ret; } } finally { checkItemBB.Dispose(); } return isValidate; }
/// <summary> /// 检测大类 /// </summary> private void BindCheckItemList() { LCheckItemBB checkItemBB = new LCheckItemBB(); DataSet ds = checkItemBB.GetList(""); this.checkItemId.DataValueField = "id"; this.checkItemId.DataTextField = "checkItemNm"; this.checkItemId.DataSource = ds.Tables[0]; this.checkItemId.DataBind(); }