protected void Page_Load(object sender, EventArgs e) { Permissions.ComRedirect(Page, Permissions.redirUrl); Response.Cache.SetExpires(DateTime.Now); Permissions.CheckManagePermission(Model.Other.EnumCompanyPermission.SafeRightManage); if (Session["Company"] == null) { return; } string number = Session["Company"].ToString(); string mangeId = BLL.CommonClass.CommonDataBLL.getManageID(1); if (number != mangeId) { if (!DeptRoleBLL.CheckAllot(number)) { ScriptHelper.SetAlert((Control)sender, GetTran("001071", "不能对管理员进行操作,没有权限!")); return; } } if (!IsPostBack) { PageSet(); } Translations(); }
protected void Page_Load(object sender, EventArgs e) { Permissions.ComRedirect(Page, Permissions.redirUrl); Response.Cache.SetExpires(DateTime.Now); Permissions.CheckManagePermission(Model.Other.EnumCompanyPermission.SafeRightManageEdit); if (!IsPostBack) { if (Request.QueryString["id"] == null || Request.QueryString["id"].ToString() == "") { ScriptHelper.SetAlert((Control)sender, GetTran("001102", "异常访问!"), "ManagerManage.aspx"); return; } string mid = Request.QueryString["id"]; int id = 0; //验证传入参数合法性 try { id = int.Parse(mid); } catch (FormatException) { ScriptHelper.SetAlert(Page, GetTran("001102", "异常访问!"), "ManagerManage.aspx"); return; } ViewState["id"] = id; ManageModel manage = ManagerBLL.GetManage(id); if (manage == null) { ScriptHelper.SetAlert(Page, GetTran("001104", "管理员已经不存在!"), "ManagerManage.aspx"); return; } string manageId = BLL.CommonClass.CommonDataBLL.getManageID(1); if (manage.Number.ToString().Trim() == manageId) { ScriptHelper.SetAlert(Page, GetTran("001106", "不允许修改该管理员!"), "ManagerManage.aspx"); return; } string number = Session["Company"].ToString(); if (number != manageId) { if (!DeptRoleBLL.CheckAllot(number, manage.RoleID)) { ScriptHelper.SetAlert((Control)sender, GetTran("001080", "不能对该管理员进行操作,没有权限!"), "ManagerManage.aspx"); return; } } this.txtName.Text = manage.Name; this.txtNumber.Text = manage.Number; this.txtNumber.Enabled = false; this.RadioButtonList1.SelectedValue = manage.IsViewPermissions.ToString(); this.RadioButtonList2.SelectedValue = manage.IsRecommended.ToString(); deptID = DeptRoleBLL.GetDeptRoleByRoleID(manage.RoleID).DeptID; roleID = manage.RoleID; InitdllDepts(); } Translations(); }
protected void Page_Load(object sender, EventArgs e) { Permissions.ComRedirect(Page, Permissions.redirUrl); Response.Cache.SetExpires(DateTime.Now); Permissions.CheckManagePermission(Model.Other.EnumCompanyPermission.SafeRightManageEdit); if (!IsPostBack) { if (Request.QueryString["id"] == null) { Response.Redirect("DeptRolesManage.aspx"); } int roleId = 0; bool b = int.TryParse(Request.QueryString["id"], out roleId); //验证角色编号的合法性 if (!b) { //编号不合法则转到角色管理页面 Response.Redirect("DeptRolesManage.aspx"); } string number = Session["Company"].ToString(); string manageId = BLL.CommonClass.CommonDataBLL.getManageID(1); if (number != manageId) { if (!DeptRoleBLL.CheckAllot(number, roleId)) { ScriptHelper.SetAlert((Control)sender, GetTran("000975", "不能对该角色进行操作,没有权限!"), "DeptRolesManage.aspx"); return; } } else { ManageModel model = ManagerBLL.GetManage(number); if (model.RoleID == roleId) { ScriptHelper.SetAlert((Control)sender, GetTran("001180", "不能对该系统管理角色进行任何操作."), "DeptRolesManage.aspx"); return; } } DeptRoleModel deptRole = DeptRoleBLL.GetDeptRoleByRoleID(roleId); if (deptRole == null) { Response.Redirect("DeptRolesManage.aspx"); } ViewState["deptId"] = deptRole.DeptID; ViewState["roleid"] = roleId; this.txtRoleName.Text = deptRole.Name; //将角色的名称加载到文本框里 ViewState["Name"] = deptRole.Name; InitdllDepts(); } Translations(); }
protected void gvDeptRoless_RowDataBound(object sender, GridViewRowEventArgs e) { CheckBox chk = (CheckBox)e.Row.FindControl("chk"); if (chk != null) { chk.Enabled = false; } if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onmouseover", "bg=this.style.backgroundColor;this.style.backgroundColor='#FFFFCC';"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=bg;"); int Update = 0; Update = (int)Permissions.GetPermissions(Model.Other.EnumCompanyPermission.SafeUpdateJs); if (Update == 0) { ((HyperLink)e.Row.FindControl("Hyperlink1")).Visible = false; } else { ((HyperLink)e.Row.FindControl("Hyperlink1")).Visible = true; } int Delete = 0; Delete = (int)Permissions.GetPermissions(Model.Other.EnumCompanyPermission.SafeDeleteJs); if (Delete == 0) { ((LinkButton)e.Row.FindControl("lbtnDel")).Visible = false; } else { ((LinkButton)e.Row.FindControl("lbtnDel")).Visible = true; } ((LinkButton)e.Row.FindControl("lbtnDel")).Attributes.Add("onclick", "return confirm('" + GetTran("000947", "是否删除当前记录") + "?')"); string manageId = BLL.CommonClass.CommonDataBLL.getManageID(1); if (Session["Company"].ToString() != manageId) { if (!DeptRoleBLL.CheckAllot(Session["Company"].ToString())) { ((HyperLink)e.Row.FindControl("Hyperlink1")).Visible = false; ((LinkButton)e.Row.FindControl("lbtnDel")).Visible = false; } } Translations(); } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { Application.Lock(); if (e.CommandName == "D") { Permissions.CheckManagePermission(Model.Other.EnumCompanyPermission.SafeRightManageDelete); int manageId = 0; try { manageId = int.Parse(e.CommandArgument.ToString()); } catch (FormatException) { ScriptHelper.SetAlert(Page, GetTran("001074", "管理员编号不存在!")); return; } ManageModel manageModel = ManagerBLL.GetManage(manageId); if (manageModel == null) { ScriptHelper.SetAlert(Page, GetTran("001076", "该记录已经被删除")); return; } string manageId1 = BLL.CommonClass.CommonDataBLL.getManageID(1); if (manageModel.Number.Trim() == manageId1) { ScriptHelper.SetAlert(Page, GetTran("001079", "不允许删除该记录!")); return; } string number = Session["Company"].ToString(); if (number != manageId1) { if (!DeptRoleBLL.CheckAllot(number, manageModel.RoleID)) { ScriptHelper.SetAlert((Control)sender, GetTran("001080", "不能对该管理员进行操作,没有权限!")); return; } } BLL.CommonClass.ChangeLogs cl = new BLL.CommonClass.ChangeLogs("manage", "id"); cl.AddRecord(manageId); if (ManagerBLL.DelManage(manageId) > 0) { cl.DeletedIntoLogs(BLL.CommonClass.ChangeCategory.company26, GetTran("001082", "管理员:") + manageModel.Number.Trim(), BLL.CommonClass.ENUM_USERTYPE.objecttype7); ScriptHelper.SetAlert((Control)sender, GetTran("000749", "删除成功!")); this.Pager1.PageBind(); } } Application.UnLock(); }
protected void Page_Load(object sender, EventArgs e) { Permissions.ComRedirect(Page, Permissions.redirUrl); Response.Cache.SetExpires(DateTime.Now); Permissions.CheckManagePermission(Model.Other.EnumCompanyPermission.SafeRightManageEdit); if (!IsPostBack) { string number = Session["Company"].ToString(); string manageId = BLL.CommonClass.CommonDataBLL.getManageID(1); if (number != manageId) { if (!DeptRoleBLL.CheckAllot(number)) { Response.Write(Transforms.ReturnAlert(GetTran("000997", "当前登录用户没有给下级分配权限的权限!"))); HttpContext.Current.Response.End(); } } InitdllDepts(); } Translations(); }
protected void gvDeptRoless_RowCommand(object sender, GridViewCommandEventArgs e) { Application.Lock(); if (e.CommandName == "D") { Permissions.CheckManagePermission(Model.Other.EnumCompanyPermission.SafeRightManageDelete); string number = Session["Company"].ToString(); int roleId = int.Parse(e.CommandArgument.ToString()); string manageId = BLL.CommonClass.CommonDataBLL.getManageID(1);//返回当前登录管理员的编号,主要为了防止不超时 if (number != manageId) { if (!DeptRoleBLL.CheckAllot(number, roleId)) { ScriptHelper.SetAlert((Control)sender, GetTran("000975", "不能对该角色进行操作,没有权限!")); return; } } if (DeptRoleBLL.GetCountByRoleId(roleId) > 0) { ScriptHelper.SetAlert((Control)sender, GetTran("000977", "该角色下还存在管理员,请先删除该角色下的管理员!")); return; } else { BLL.CommonClass.ChangeLogs cl = new BLL.CommonClass.ChangeLogs("deptRole", "id"); cl.AddRecord(roleId); string msg = DeptRoleBLL.DelDeptRole(HttpContext.Current, int.Parse(e.CommandArgument.ToString())); if (msg == "删除角色成功.") { ScriptHelper.SetAlert((Control)sender, msg, "DeptRolesManage.aspx"); cl.DeletedIntoLogs(BLL.CommonClass.ChangeCategory.company25, GetTran("000981", "角色:") + int.Parse(e.CommandArgument.ToString()), BLL.CommonClass.ENUM_USERTYPE.objecttype7); } ScriptHelper.SetAlert((Control)sender, msg); PageSet(); } } Application.UnLock(); }
/// <summary> /// 修改角色的操作事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpt_Click(object sender, EventArgs e) { Application.Lock(); if (ViewState["roleid"] == null) { Response.Redirect("DeptRolesManage.aspx"); } if (txtRoleName.Text.Trim() == "") { ScriptHelper.SetAlert((Control)sender, GetTran("001183", "请输入角色名称!")); return; } else { if (this.txtRoleName.Text.Trim().Length < 3) { ScriptHelper.SetAlert((Control)sender, GetTran("000999", "角色名称必须3个字符以上!")); return; } } if (txtRoleName.Text != ViewState["Name"].ToString()) { if (DeptRoleBLL.CheckDeptRoleName(this.txtRoleName.Text.Trim(), (int)ViewState["roleid"]) != null) { ScriptHelper.SetAlert((Control)sender, GetTran("001001", "角色名称已经存在!")); return; } } int roleId = (int)ViewState["roleid"]; string number = Session["Company"].ToString(); string manageId = BLL.CommonClass.CommonDataBLL.getManageID(1); if (number != manageId) { if (!DeptRoleBLL.CheckAllot(number, roleId)) { ScriptHelper.SetAlert((Control)sender, GetTran("000975", "不能对该角色进行操作,没有权限!")); return; } } DeptRoleModel deptRole = new DeptRoleModel(roleId); deptRole.DeptID = int.Parse(this.ddlDepts.SelectedValue); string ids = Request.Form["qxCheckBox"]; //获取所有选中的菜单的值(pmID),在生成的页面可以查看(后台拼接而成),qxCheckBox是菜单的name(checkbox的name) string[] id = ids.Split(','); Hashtable htb = (Hashtable)Session["permission"]; htb = DeptRoleBLL.GetAllPermission(Session["Company"].ToString()); Hashtable htb2 = new Hashtable(); int i = -1; if (number != manageId) { foreach (string n in id) { if (htb.Contains(int.Parse(n))) { htb2.Add(n, "0"); } else { i = 0; } } } else { foreach (string n in id) { if (htb.Contains(int.Parse(n))) { htb2.Add(n, "0"); } } } if (i == -1) { BLL.CommonClass.ChangeLogs cl = new BLL.CommonClass.ChangeLogs("deptRole", "id"); cl.AddRecord(roleId); deptRole.htbPerssion = htb2; deptRole.Name = this.txtRoleName.Text.Trim(); deptRole.Allot = ((CheckBox)this.UCPermission1.FindControl("chkAllot")).Checked ? 1 : 0; if (DeptRoleBLL.UptDeptRole(deptRole)) //修改角色 { cl.AddRecord(roleId); cl.ModifiedIntoLogs(BLL.CommonClass.ChangeCategory.company25, "角色:" + deptRole.Name, BLL.CommonClass.ENUM_USERTYPE.objecttype7); ScriptHelper.SetAlert((Control)sender, GetTran("000001", "修改成功."), "DeptRolesManage.aspx"); } else { ScriptHelper.SetAlert((Control)sender, GetTran("000002", "修改失败."), "DeptRolesManage.aspx"); } } else { ScriptHelper.SetAlert((Control)sender, GetTran("001003", "异常数据"), "DeptRolesManage.aspx"); return; } Application.UnLock(); }
/// <summary> /// 执行修改方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BtnUpt_Click(object sender, EventArgs e) { int id = (int)(ViewState["id"] != null ? ViewState["id"] : 0); if (id <= 0) { ScriptHelper.SetAlert((Control)sender, GetTran("001102", "异常访问!"), "ManagerManage.aspx"); return; } ManageModel manager = null; manager = ManagerBLL.GetManage(id); if (manager == null) { ScriptHelper.SetAlert((Control)sender, GetTran("001102", "异常访问!"), "ManagerManage.aspx"); return; } //取出当前登录管理员的编号 string manageId = BLL.CommonClass.CommonDataBLL.getManageID(1); if (manager.Number.ToString().Trim() == manageId) { ScriptHelper.SetAlert(Page, GetTran("001106", "不允许修改该管理员!"), "ManagerManage.aspx"); return; } //验证必填信息 if (this.ddlRoles.Text.Trim() == "") { ScriptHelper.SetAlert((Control)sender, GetTran("001113", "角色信息不能为空")); return; } if (this.ddlDepts.Text.Trim() == "") { ScriptHelper.SetAlert((Control)sender, GetTran("001114", "部门信息不能为空")); return; } if (this.txtName.Text.Trim() == "") { ScriptHelper.SetAlert((Control)sender, GetTran("001116", "管理员姓名不能为空")); return; } if (this.txtNumber.Text.Trim() == "") { ScriptHelper.SetAlert((Control)sender, GetTran("001117", "管理员编号不能为空")); return; } string number = Session["Company"].ToString(); if (number != manageId) { if (!DeptRoleBLL.CheckAllot(number, int.Parse(this.ddlRoles.SelectedValue))) { ScriptHelper.SetAlert((Control)sender, GetTran("000975", "不能对该角色进行操作,没有权限!")); return; } } //验证角色信息 CheckDeptRole(); //验证部门信息 CheckCompanyDept(); //需要验证角色名是否重复 if (manager.Number.Trim() != txtNumber.Text.Trim()) { if (!ManagerBLL.CheckNumber(txtNumber.Text.Trim())) { ScriptHelper.SetAlert((Control)sender, GetTran("001118", "当前管理员编号已经存在!")); return; } } //根据输入信息构建管理员 manager.Number = this.txtNumber.Text.Trim(); manager.Name = txtName.Text.Trim(); manager.Post = this.ddlRoles.SelectedItem.Text.Trim(); manager.Branch = this.ddlDepts.SelectedItem.Text.Trim(); manager.RoleID = int.Parse(this.ddlRoles.SelectedValue); manager.Status = 1; manager.IsViewPermissions = int.Parse(this.RadioButtonList1.SelectedValue); manager.IsRecommended = int.Parse(this.RadioButtonList2.SelectedValue); //存储管理员信息到数据库 BLL.CommonClass.ChangeLogs cl = new BLL.CommonClass.ChangeLogs("manage", "id"); cl.AddRecord(id); if (ManagerBLL.UptManage(manager)) { //存储成功,给出提示ChangeCategory cl.ModifiedIntoLogs(BLL.CommonClass.ChangeCategory.company26, GetTran("001082", "管理员:") + manager.Name, BLL.CommonClass.ENUM_USERTYPE.objecttype7); ScriptHelper.SetAlert((Control)sender, GetTran("001119", "修改管理员成功!"), "ManagerManage.aspx"); } else { //存储失败,给出提示 ScriptHelper.SetAlert((Control)sender, GetTran("001121", "修改管理员失败!")); } }
protected void BtnAdd_Click(object sender, EventArgs e) { //验证必填信息 if (this.ddlRoles.Text.Trim() == "") { ScriptHelper.SetAlert((Control)sender, GetTran("001113", "角色信息不能为空")); } else { if (this.ddlDepts.Text.Trim() == "") { ScriptHelper.SetAlert((Control)sender, GetTran("001114", "部门信息不能为空")); } else { if (this.txtName.Text.Trim() == "") { ScriptHelper.SetAlert((Control)sender, GetTran("001116", "管理员姓名不能为空")); } else { if (this.txtNumber.Text.Trim() == "") { ScriptHelper.SetAlert((Control)sender, GetTran("001117", "管理员编号不能为空")); } else if (this.txtNumber.Text.Trim().Length < 6) { ScriptHelper.SetAlert((Control)sender, GetTran("001163", "管理员编号必须6个字符以上")); } else { //取出当前登录管理员的编号 string number = Session["Company"].ToString(); string manageId = BLL.CommonClass.CommonDataBLL.getManageID(1); if (number != manageId) { if (!DeptRoleBLL.CheckAllot(number, int.Parse(this.ddlRoles.SelectedValue))) { ScriptHelper.SetAlert((Control)sender, GetTran("000975", "不能对该角色进行操作,没有权限!")); return; } } //根据输入信息构建管理员 ManageModel manager = new ManageModel(); if (!ManagerBLL.CheckNumber(txtNumber.Text.Trim())) { ScriptHelper.SetAlert((Control)sender, GetTran("001166", "该编号已经存在")); } else { manager.Number = this.txtNumber.Text.Trim(); manager.Name = txtName.Text.Trim(); manager.PermissionMan = number.Trim(); manager.Post = this.ddlRoles.SelectedItem.Text.Trim(); manager.Branch = this.ddlDepts.SelectedItem.Text.Trim(); manager.RoleID = int.Parse(this.ddlRoles.SelectedValue); manager.BeginDate = DateTime.UtcNow; manager.Status = 1; manager.LastLoginDate = DateTime.UtcNow; manager.IsViewPermissions = int.Parse(this.RadioButtonList1.SelectedValue); manager.IsRecommended = int.Parse(this.RadioButtonList2.SelectedValue); //获取管理员的默认密码 string password = ManagerBLL.GetPassword(this.txtNumber.Text.Trim()); //加密存储管理员的密码 manager.LoginPass = Encryption.Encryption.GetEncryptionPwd(this.txtNumber.Text.Trim(), this.txtNumber.Text.Trim()); //存储管理员信息到数据库 if (ManagerBLL.AddManage(manager, number) > 0) { //存储成功,给出提示 ScriptHelper.SetAlert((Control)sender, GetTran("001167", "添加管理员成功!"), "ManagerManage.aspx"); } else { //存储失败,给出提示 ScriptHelper.SetAlert((Control)sender, GetTran("001169", "添加管理员失败!")); } } } } } } }
/// <summary> /// 添加角色的事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { string number = Session["Company"].ToString(); string manageId = BLL.CommonClass.CommonDataBLL.getManageID(1); if (number != manageId) { if (!DeptRoleBLL.CheckAllot(number)) { ScriptHelper.SetAlert((Control)sender, GetTran("000997", "当前登录用户没有给下级分配权限的权限!")); return; } } if (txtRoleName.Text.Trim() == "") { ScriptHelper.SetAlert((Control)sender, GetTran("000998", "请输入角色名称!")); return; } else { if (this.txtRoleName.Text.Trim().Length < 3) { ScriptHelper.SetAlert((Control)sender, GetTran("000999", "角色名称必须3个字符以上!")); return; } } if (DeptRoleBLL.CheckDeptRoleName(this.txtRoleName.Text, 0) != null) { ScriptHelper.SetAlert((Control)sender, GetTran("001001", "角色名称已经存在!")); return; } string ids = Request.Form["qxCheckBox"]; if (ids == null || ids == "") { ScriptHelper.SetAlert((Control)sender, GetTran("001002", "请选择要分配权限!")); return; } DeptRoleModel deptRole = new DeptRoleModel(); string[] id = ids.Split(','); Hashtable htb = (Hashtable)Session["permission"]; htb = DeptRoleBLL.GetAllPermission(Session["Company"].ToString()); Hashtable htb2 = new Hashtable(); int i = -1; foreach (string n in id) { if (htb.Contains(int.Parse(n))) { htb2.Add(n, "0"); } else { i = 0; break; } } manageId = BLL.CommonClass.CommonDataBLL.getManageID(1); if (number == manageId) { i = -1; } if (i == -1) { deptRole.htbPerssion = htb2; deptRole.Name = this.txtRoleName.Text.Trim(); ManageModel ma = ManagerBLL.GetManage(Session["Company"].ToString()); deptRole.PermissionManID = ma.ID; deptRole.DeptID = int.Parse(this.ddlDepts.SelectedValue); deptRole.Adddate = DateTime.Now; deptRole.ParentId = ma.RoleID; deptRole.Allot = ((CheckBox)this.UCPermission1.FindControl("chkAllot")).Checked?1:0; if (DeptRoleBLL.AddDeptRole(deptRole)) //添加角色 { ScriptHelper.SetAlert((Control)sender, GetTran("000006", "添加成功."), "DeptRolesManage.aspx"); } else { ScriptHelper.SetAlert((Control)sender, GetTran("000007", "添加失败."), "DeptRolesManage.aspx"); } } else { ScriptHelper.SetAlert((Control)sender, GetTran("001003", "异常数据"), "DeptRolesManage.aspx"); return; } }