招聘管理系统设计报告 第5页
()!="")
{
this.Label2.Text = "";
}
if (iCheckPass == 1)
{
wssystem.RoleInfo roleinfo = new RoleInfo();
roleinfo.strRoleName = this.TextBox1.Text.ToString().Trim();
roleinfo.strRoleDescrp = this.TextBox2.Text.ToString().Trim();
wssystem.SystemWebService ss = new SystemWebService();
ss.AddRoleInfo(roleinfo);
this.iRole_ID = ss.GetRole_IDByRoleName(this.TextBox1.Text.ToString().Trim());
for (int i = 0;i<this.ListBox2.Items.Count;i++)
{
ss.AddPopedom(this.iRole_ID,Convert.ToInt16(this.ListBox2.Items[i].Value));
}
Response.Redirect("rolelist.aspx");
}
}
“返回”按钮的click事件代码如下:
private void Button7_Click(object sender, System.EventArgs e)
{
Response.Redirect("rolelist.aspx");
}
5、查看/修改角色
修改角色和添加角色的页面设计是相同的,只需要将addroleinfo.aspx中的如下HTML代码拷到recrolenfo.aspx中即可。
查看角色时调用SystemWebService中的AddRoleInfo方法,修改角色时则需要调用ModifyRoleInfo方法。
Addroleinfo代码如下:
[WebMethod]
public void AddUserInfo(UserInfo ui)
{
UserInfo ui1 = ui;
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlDataAdapter da = new SqlDataAdapter("INSERT INTO UserInfoTab(UserName,Password,Dept_ID,ProjectID) VALUES('"+ui1.strUserName+"','"+ui1.strPassword+"','"+ui1.iDept_ID+"','"+ui1.iProject_ID+"')",con);
DataSet ds = new DataSet();
da.Fill(ds,"AddUserInfo");
SqlDataAdapter da2 = new SqlDataAdapter("select User_ID from UserInfoTab where UserName='"+ui1.strUserName+"'",con);
DataSet ds2 = new DataSet();
da2.Fill(ds2);
SqlDataAdapter da1 = new SqlDataAdapter("INSERT INTO RoleCombTab(User_ID,Role_ID) VALUES('"+ds2.Tables[0].Rows[0][0]+"','"+ui1.iRole_ID+"')",con);
DataSet ds1 = new DataSet();
da1.Fill(ds1);
}
Modifyroleinfo方法的代码如下:
[WebMethod]
public void ModifyRoleInfo(RoleInfo ri)
{
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand cmd= new SqlCommand("UPDATE RoleInfoTab SET Role_ID='+this.iRoler_ID+',RoleName='+this.strRoleName+',RoleDescrp='+this.strRoleDescrp+')",con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
6、角色维护
角色维护列表用一个DataGrid显示所有的角色信息,可以添加新的角色,查看、修改、删除现有角色的信息。角色维护列表页面rolelist.aspx
页面的page_load代码如下:
private void Page_Load(object sender, System.EventArgs e)
{
iAuthority = (int[])Session["Authority"];
int iCheckpass = 0;
for (int i = 0; i<iAuthority.Length;i++)
{
if (iAuthority[i] == this.iPopedom_ID)
{
iCheckpass = 1;
www.751com.cn
{
this.DataGrid1.CurrentPageIndex = this.DataGrid1.PageCount;
this.LoadGrid();
}
}
Click事件的代码如下:
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Redirect("addroleinfo.aspx");
}
删除按钮的代码如下:
private void Button2_Click(object sender, System.EventArgs e)
{
try
{
for (int i = 0;i< this.DataGrid1.Items.Count;i++)
{
CheckBox checkbox = (CheckBox)this.DataGrid1.Items[i].FindControl("CheckBox1");
if (checkbox.Checked == true)
{
int iRole_ID = Convert.ToInt16(this.DataGrid1.Items[i].Cells[1].Text);
wssystem.SystemWebService ss = new SystemWebService();
ss.DeleteRoleInfo(iRole_ID);
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页