roleedit.aspx.cs
来自「商机管理系统」· CS 代码 · 共 550 行
CS
550 行
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class role_RoleEdit : System.Web.UI.Page
{
DataSet_sjglxt.roleDataTable dbtable = new DataSet_sjglxt.roleDataTable();
DataSet_sjglxtTableAdapters.roleTableAdapter Role_Control = new DataSet_sjglxtTableAdapters.roleTableAdapter();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string rid = "";
if (Request.QueryString["edit"] == "1")
{
rid = Request.QueryString["rid"];
dbtable.Clear();
Role_Control.FillByRid(dbtable, rid);
Tb_Name.Text = dbtable.Rows[0].ItemArray[1].ToString();
Tb_Dicribe.Text = dbtable.Rows[0].ItemArray[3].ToString();
Tb_Depart.Text = dbtable.Rows[0].ItemArray[5].ToString();
string authorize = dbtable.Rows[0].ItemArray[4].ToString();
#region checkbox control //控制复选框
if (authorize[0] == '1')
{
CheckBox1.Checked = true;
}
else
{
CheckBox1.Checked = false;
}
if (authorize[1] == '1')
{
CheckBox2.Checked = true;
}
else
{
CheckBox2.Checked = false;
}
if (authorize[2] == '1')
{
CheckBox3.Checked = true;
}
else
{
CheckBox3.Checked = false;
}
if (authorize[3] == '1')
{
CheckBox4.Checked = true;
}
else
{
CheckBox4.Checked = false;
}
if (authorize[4] == '1')
{
CheckBox5.Checked = true;
}
else
{
CheckBox5.Checked = false;
}
if (authorize[5] == '1')
{
CheckBox6.Checked = true;
}
else
{
CheckBox6.Checked = false;
}
if (authorize[6] == '1')
{
CheckBox7.Checked = true;
}
else
{
CheckBox7.Checked = false;
}
if (authorize[7] == '1')
{
CheckBox8.Checked = true;
}
else
{
CheckBox8.Checked = false;
}
if (authorize[8] == '1')
{
CheckBox9.Checked = true;
}
else
{
CheckBox9.Checked = false;
}
if (authorize[9] == '1')
{
CheckBox10.Checked = true;
}
else
{
CheckBox10.Checked = false;
}
if (authorize[10] == '1')
{
CheckBox11.Checked = true;
}
else
{
CheckBox11.Checked = false;
}
if (authorize[11] == '1')
{
CheckBox12.Checked = true;
}
else
{
CheckBox12.Checked = false;
}
if (authorize[12] == '1')
{
CheckBox13.Checked = true;
}
else
{
CheckBox13.Checked = false;
}
if (authorize[13] == '1')
{
CheckBox14.Checked = true;
}
else
{
CheckBox14.Checked = false;
}
if (authorize[14] == '1')
{
CheckBox15.Checked = true;
}
else
{
CheckBox15.Checked = false;
}
if (authorize[15] == '1')
{
CheckBox16.Checked = true;
}
else
{
CheckBox16.Checked = false;
}
if (authorize[16] == '1')
{
CheckBox17.Checked = true;
}
else
{
CheckBox17.Checked = false;
}
if (authorize[17] == '1')
{
CheckBox18.Checked = true;
}
else
{
CheckBox18.Checked = false;
}
if (authorize[18] == '1')
{
CheckBox19.Checked = true;
}
else
{
CheckBox19.Checked = false;
}
if (authorize[19] == '1')
{
CheckBox20.Checked = true;
}
else
{
CheckBox20.Checked = false;
}
if (authorize[20] == '1')
{
CheckBox31.Checked = true;
}
else
{
CheckBox31.Checked = false;
}
if (authorize[21] == '1')
{
CheckBox32.Checked = true;
}
else
{
CheckBox32.Checked = false;
}
if (authorize[22] == '1')
{
CheckBox33.Checked = true;
}
else
{
CheckBox33.Checked = false;
}
if (authorize[23] == '1')
{
CheckBox34.Checked = true;
}
else
{
CheckBox34.Checked = false;
}
if (authorize[24] == '1')
{
CheckBox35.Checked = true;
}
else
{
CheckBox35.Checked = false;
}
if (authorize[25] == '1')
{
CheckBox41.Checked = true;
}
else
{
CheckBox41.Checked = false;
}
if (authorize[26] == '1')
{
CheckBox42.Checked = true;
}
else
{
CheckBox42.Checked = false;
}
if (authorize[27] == '1')
{
CheckBox43.Checked = true;
}
else
{
CheckBox43.Checked = false;
}
if (authorize[28] == '1')
{
CheckBox51.Checked = true;
}
else
{
CheckBox51.Checked = false;
}
#endregion
}
}
}
protected void Btn_Confirm_Click(object sender, EventArgs e)
{
string strauthorize = "";
if (Tb_Name.Text == null || Tb_Name.Text == "")
{
ClientScript.RegisterStartupScript(e.GetType(), "", "<script>alert('请输入角色名!')</script>");
return;
}
#region checkbox control //存储授权选项
if (CheckBox1.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox2.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox3.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox4.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox5.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox6.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox7.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox8.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox9.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox10.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox11.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox12.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox13.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox14.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox15.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox16.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox17.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox18.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox19.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox20.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox31.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox32.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox33.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox34.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox35.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox41.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox42.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox43.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
if (CheckBox51.Checked == true)
{
strauthorize += "1";
}
else
{
strauthorize += "0";
}
#endregion
string strroleid;
int introleid;
if (Request.QueryString["add"] == "1")
{
dbtable.Clear();
Role_Control.OrderbyRoleid(dbtable);
if (dbtable.Count > 0)
{
strroleid = dbtable.Rows[dbtable.Rows.Count - 1].ItemArray[2].ToString();
introleid = Convert.ToInt32(strroleid) + 1;
strroleid = introleid.ToString();
Role_Control.InsertQuery(Tb_Name.Text, strroleid, Tb_Dicribe.Text, strauthorize,Tb_Depart.Text);
ClientScript.RegisterStartupScript(e.GetType(), "", "<script>alert('成功添加角色!')</script>");
}
}
if (Request.QueryString["edit"] == "1")
{
strroleid = Request.QueryString["rid"];
Role_Control.UpdateQuery(Tb_Name.Text, Tb_Dicribe.Text, strauthorize,Tb_Depart.Text, strroleid);
ClientScript.RegisterStartupScript(e.GetType(), "", "<script>alert('成功修改角色!')</script>");
}
Response.Redirect("RoleForm.aspx");
}
protected void Btn_Cancel_Click(object sender, EventArgs e)
{
Response.Redirect("RoleForm.aspx");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?