protected void btOK_Click1(object sender, EventArgs e) { if (this.btOK.CommandName.Trim() == "ok") { PowerBll powerBll = new PowerBll(); PowerEntity powerEntity = new PowerEntity(); powerEntity.PowerName = base.Server.HtmlEncode(this.txtName.Text.Trim()); powerEntity.PowerDes = base.Server.HtmlEncode(this.txtDes.Text.Trim()); powerEntity.PowerID = Convert.ToInt32(this.txtID.Text.Trim()); try { if (powerBll.Add(powerEntity)) { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "<script>alert('添加权限成功')</script>"); this.LoadData(); this.txtName.Text = ""; this.txtDes.Text = ""; this.txtID.Text = ""; } return; } catch { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "<script>alert('ID已存在,请重新输入')</script>"); return; } } PowerBll powerBll2 = new PowerBll(); if (powerBll2.Update(new PowerEntity { PowerName = this.txtName.Text.Trim(), PowerDes = this.txtDes.Text.Trim(), PowerID = Convert.ToInt32(this.btOK.CommandArgument.Trim()) })) { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "<script>alert('修改成功')</script>"); } else { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "<script>alert('修改失败')</script>"); } this.Label1.Visible = true; this.txtID.Visible = true; this.RequiredFieldValidator3.Visible = true; this.RegularExpressionValidator1.Visible = true; this.btOK.CommandName = "ok"; this.btReset.CommandName = "reset"; this.LoadData(); this.txtName.Text = ""; this.txtDes.Text = ""; this.txtID.Text = ""; }
public void LoadDrop() { this.dropDepartment.Items.Clear(); this.OkDepartment.Items.Clear(); this.upDepartment.Items.Clear(); this.dropPower.Items.Clear(); this.OkPower.Items.Clear(); this.upPower.Items.Clear(); DepartmentBll departmentBll = new DepartmentBll(); this.dropDepartment.DataTextField = "DepartmentName"; this.dropDepartment.DataValueField = "DepartmentID"; this.dropDepartment.DataSource = departmentBll.GetAll(); this.dropDepartment.DataBind(); this.dropDepartment.Items.Insert(0, "==请选择部门=="); this.OkDepartment.DataTextField = "DepartmentName"; this.OkDepartment.DataValueField = "DepartmentID"; this.OkDepartment.DataSource = departmentBll.GetAll(); this.OkDepartment.DataBind(); this.OkDepartment.Items.Insert(0, "==请选择部门=="); this.upDepartment.DataTextField = "DepartmentName"; this.upDepartment.DataValueField = "DepartmentID"; this.upDepartment.DataSource = departmentBll.GetAll(); this.upDepartment.DataBind(); this.upDepartment.Items.Insert(0, "==请选择部门=="); PowerBll powerBll = new PowerBll(); this.dropPower.DataTextField = "PowerName"; this.dropPower.DataValueField = "PowerID"; this.dropPower.DataSource = powerBll.GetAll(); this.dropPower.DataBind(); this.dropPower.Items.Insert(0, "==请选择角色=="); this.OkPower.DataTextField = "PowerName"; this.OkPower.DataValueField = "PowerID"; this.OkPower.DataSource = powerBll.GetAll(); this.OkPower.DataBind(); this.OkPower.Items.Insert(0, "==请选择角色=="); this.upPower.DataTextField = "PowerName"; this.upPower.DataValueField = "PowerID"; this.upPower.DataSource = powerBll.GetAll(); this.upPower.DataBind(); this.upPower.Items.Insert(0, "==请选择角色=="); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { PowerBll powerBll = new PowerBll(); PowerEntity powerEntity = new PowerEntity(); Label label = (Label)this.GridView1.Rows[e.RowIndex].FindControl("lbID"); powerEntity.PowerID = Convert.ToInt32(label.Text.Trim()); try { if (powerBll.Delete(powerEntity)) { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "<script>alert('删除权限成功')</script>"); } } catch { this.Page.ClientScript.RegisterStartupScript(base.GetType(), "msg", "<script>alert('删除权限失败')</script>"); } this.LoadData(); }
protected void LinkButton1_Command(object sender, CommandEventArgs e) { this.Label1.Visible = false; this.txtID.Visible = false; this.RequiredFieldValidator3.Visible = false; this.RegularExpressionValidator1.Visible = false; this.btOK.CommandName = "edit"; this.btReset.CommandName = "cancel"; PowerBll powerBll = new PowerBll(); DataTable byID = powerBll.GetByID(new PowerEntity { PowerID = Convert.ToInt32(e.CommandArgument.ToString().Trim()) }); if (byID != null && byID.Rows.Count == 1) { this.txtName.Text = byID.Rows[0]["PowerName"].ToString().Trim(); this.txtDes.Text = byID.Rows[0]["PowerDes"].ToString().Trim(); } this.btOK.CommandArgument = e.CommandArgument.ToString().Trim(); }
public void LoadData() { PowerBll powerBll = new PowerBll(); powerBll.Asp(this.GridView1, this.AspNetPager1); }