//Add data protected void Button1_Click(object sender, EventArgs e) { Hashtable ht = new Hashtable(); string[] Arr1 = new string[] { "num", "depart", "remark" }; for (int i = 0; i < Arr1.Length; i++) { ht.Add(Arr1[i], Util.GetControlValue(this.num.Parent.FindControl(Arr1[i]))); } if (ht["num"].ToString().Trim() == "" || ht["depart"].ToString().Trim() == "") { Util.alert(this.Page, "错误提示:部门编号和部门名称不能为空!"); } else { U_DepartBU depart1 = new U_DepartBU(); bool result = depart1.InsertData(ht); depart1.Close(); if (result) { Response.Redirect("XtGlIndex.aspx", true); } else { Util.alert(this.Page, "错误提示:部门名称【" + ht["depart"].ToString() + "】已经存在!"); } } }
//update data protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { string id = this.GridView1.DataKeys[e.RowIndex].Value.ToString(); Hashtable ht = new Hashtable(); string[] Arr1 = new string[] { "num", "depart", "remark" }; for (int i = 0; i < Arr1.Length; i++) { ht.Add(Arr1[i], Util.GetControlValue(this.GridView1.Rows[e.RowIndex].Cells[i].Controls[0])); } if (ht["num"].ToString().Trim() == "" || ht["depart"].ToString().Trim() == "") { Util.alert(this.Page, "错误提示:部门编号和部门名称不能为空!"); } else { U_DepartBU depart1 = new U_DepartBU(); bool result = depart1.UpdataData(id, ht); depart1.Close(); if (result) { this.GridView1.EditIndex = -1; this.BindData(depart1); } else { Util.alert(this.Page, "错误提示:部门名称【" + ht["depart"].ToString() + "】已经存在!"); } } }
public void BindData() { U_UserNameBU user1 = new U_UserNameBU(); U_DepartBU depart1 = new U_DepartBU(); DataSet ds1 = depart1.GetAllDepart(); for (int i = 0; i < ds1.Tables[0].Rows.Count; i++) { Label lab1 = this.DataList0.Parent.FindControl("Label" + i) as Label; if (lab1 != null && ds1.Tables[0].Rows[i]["depart"] != null && ds1.Tables[0].Rows[i]["depart"].ToString() != "") { lab1.Text = ds1.Tables[0].Rows[i]["depart"].ToString(); DataList datalist1 = this.DataList0.Parent.FindControl("DataList" + i) as DataList; if (datalist1 != null) { DataSet ds2 = user1.GetUserByDepart(lab1.Text); datalist1.DataSource = ds2; datalist1.DataBind(); if (ds2 != null && ds2.Tables[0].Rows.Count >= 0) { lab1.Parent.FindControl("Div" + i).Visible = true; } } } } depart1.Close(); user1.Close(); }
//bind data1 private void BindData() { U_DepartBU depart1 = new U_DepartBU(); this.GridView1.DataSource = depart1.GetAllDepart(); this.GridView1.DataBind(); depart1.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { U_DepartBU depart1 = new U_DepartBU(); depart1.SetDepartList(this.depart, null); this.BindData(); } }
//绑定有人员的部门数据 private void BindData() { U_DepartBU depart1 = new U_DepartBU(); DataSet ds1 = depart1.GetAllDepart1(); this.Repeater1.DataSource = ds1; this.Repeater1.DataBind(); depart1.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { U_DepartBU depart1 = new U_DepartBU(); depart1.SetDepartList(this.depart, "请选择..."); depart1.Close(); } }
//delete data protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string id = this.GridView1.DataKeys[e.RowIndex].Value.ToString(); U_DepartBU depart1 = new U_DepartBU(); depart1.DeleteData(id); this.BindData(depart1); depart1.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //this.leader.Attributes["ReadOnly"] = ""; if (Request["id"] != null) { U_DepartBU depart1 = new U_DepartBU(); depart1.SetDepartList(this.depart, null); U_UserNameBU user1 = new U_UserNameBU(); Hashtable ht = user1.GetDetailByID(Request["id"]); user1.Close(); if (ht != null && ht.Count > 0) { for (int i = 0; i < arr1.Length; i++) { if (ht[arr1[i]] == null) { ht[arr1[i]] = ""; } Util.SetControlValue(this.sname.Parent.FindControl(arr1[i]), ht[arr1[i]]); } } else { Response.Redirect("~/Error.aspx?info=错误信息:此用户不存在!", true); } } else { Response.Redirect("~/Error.aspx", true); } if (this.sname.Text != String.Empty) { U_UserNameBU user1 = new U_UserNameBU(); this.leader1.Text = user1.GetOtherReader(this.sname.Text.Trim()); } } }
//bind data2 private void BindData(U_DepartBU depart1) { this.GridView1.DataSource = depart1.GetAllDepart(); this.GridView1.DataBind(); }