SuperRoles.Model.SuperRoles_UesrRoles user = new SuperRoles.Model.SuperRoles_UesrRoles();
string companyid = Request.QueryString["companyid"];
string name = Request.QueryString["UserName"];
foreach (Control item in this.rep_user.Controls)
{
CheckBox ck = (CheckBox)item.FindControl("isckture");
TextBox tbx = (TextBox)item.FindControl("tbxTableName");
TextBox tbid = (TextBox)item.FindControl("guid");
string role = tbx.Text;
Guid id = Guid.Parse(tbid.Text);
if (ck != null)
{
if (ck.Checked)
{
if (new SuperRoles.BLL.SuperRoles_UserInRoles_BLL().SelectByUserNameAndId(name, id, role))
{
MessageBox.ShowAndRedirect("修改权限成功", "CompanyMember_List.aspx");
}
else {
if (new SuperRoles.BLL.SuperRoles_UserInRoles_BLL().Insert(companyid, id, name, role))
{ MessageBox.ShowAndRedirect("添加用户角色成功", "CompanyMember_List.aspx");
}
}
} else {
if (new SuperRoles.BLL.SuperRoles_UserInRoles_BLL().Delete(id, name))
{ MessageBox.ShowSlideSuccess("修改权限成功");
} } } else
{ MessageBox.ShowSlideError("删除用户全部角色"); }
} }
public void SelectByName()
{
string name = Request.QueryString["UserName"];
foreach (Control item in this.rep_user.Controls)
{
TextBox tbx = (TextBox)item.FindControl("tbxTableName");
TextBox tbid = (TextBox)item.FindControl("guid");
string role = tbx.Text;
Guid id = Guid.Parse(tbid.Text);
CheckBox ck = (CheckBox)item.FindControl("isckture");
if (new SuperRoles.BLL.SuperRoles_UserInRoles_BLL().SelectByUserNameAndId(name, id, role))
{ ck.Checked = true; } }
} } }