/// <summary> /// 构造函数:已知用户名和密码,创建用户实例 /// </summary> /// <param name="userName">用户名(即员工号)</param> /// <param name="passWord">密码</param> public UserRoles(string userName, string passWord) { MyWebControlLib.FieldValues fvs= new MyWebControlLib.FieldValues(); MyWebControlLib.FieldValue fv= new MyWebControlLib.FieldValue(); fv.FieldName ="userName"; userName= userName.Replace("'",""); passWord = passWord.Replace("'", ""); fv.Value =userName; username = userName; password = passWord; fvs.Add(fv); fv= new MyWebControlLib.FieldValue(); fv.FieldName ="password"; fv.Value =passWord; fvs.Add(fv); DataTable table = udb.GetDataTable(fvs); if (table.Rows.Count > 0) { isvalid = true; unitcode = table.Rows[0]["unitCode"].ToString(); unitname = table.Rows[0]["unitName"].ToString(); bool flag = true; //flag = false;//上海 if (flag) { truename = table.Rows[0]["truename"].ToString(); if (table.Rows[0]["isonline"].ToString() == "1") isonline = true; if (table.Rows[0]["isprivate"].ToString() == "1") isPrivate = true; for (int i = 0; i < table.Rows.Count; i++) { ModuleRole mr = new ModuleRole(); mr.ModuleKey = table.Rows[i]["ModuleKey"].ToString(); bool first = false; int index = modulekeys.IndexOf(mr.ModuleKey);//该modulekey第一次出现的位置,若此次为第一次出现,则为-1 if (index == -1) first = true; if (table.Rows[i]["isadd"].ToString() == "1") { if (first)//第一次出现 mr.Add = true; else//只对第一次出现该ModuleKey位置的ModuleRole赋值 modulekeys[index].Add = true; } if (table.Rows[i]["ischg"].ToString() == "1") { if (first) mr.Edit = true; else modulekeys[index].Edit = true; } if (table.Rows[i]["isdel"].ToString() == "1") { if (first) mr.Delete = true; else modulekeys[index].Delete = true; } if (table.Rows[i]["isapp"].ToString() == "1") { if (first) mr.Approve = true; else modulekeys[index].Approve = true; } if (table.Rows[i]["iscom"].ToString() == "1") { if (first) mr.Finish = true; else modulekeys[index].Finish = true; } if (table.Rows[i]["isrep"].ToString() == "1") { if (first) mr.Report = true; else modulekeys[index].Report = true; } if (table.Rows[i]["ispub"].ToString() == "1") { if (first) mr.Publish = true; else modulekeys[index].Publish = true; } modulekeys.Add(mr); } } } }
protected override void OnPreRender(EventArgs e) { try { screen = (Screen)Session["screen"]; } catch { screen.Width = 1024; screen.Height = 768; } string loginname = User.Identity.Name; _user = new UserRoles(loginname); base.OnPreRender(e); bool flag = true; //启用权限管理为true,不启用为false。 flag = false; //上海 权限管理不启用 if (loginname == "") { Response.Redirect("default.htm"); } else if (_moduleKey != "" && flag) { //若取权限,把以下语句注释。 //最上级单位没有上报功能 if (_user.UnitCode == "00") { for (int i = 0; i < _reportButtons.Count; i++) { _reportButtons[i].Attributes.Add("style", "display:none"); } } //除最上级单位外的其他单位没有加锁解锁功能 if (_user.UnitCode != "00") { for (int i = 0; i < _lockButtons.Count; i++) { _lockButtons[i].Attributes.Add("style", "display:none"); } } if (_user.UnitCode != "00") { for (int i = 0; i < _unlockButtons.Count; i++) { _unlockButtons[i].Attributes.Add("style", "display:none"); } } if (_user.ModuleKeys.IndexOf(_moduleKey) == -1) { Response.Redirect("ErrorPage.aspx?ID=1"); } ModuleRole role = _user.ModuleKeys[_user.ModuleKeys.IndexOf(_moduleKey)]; if (role.Add) { } else { for (int i = 0; i < _addButtons.Count; i++) { _addButtons[i].Attributes.Add("style", "display:none"); } } if (role.Browse) { } else { for (int i = 0; i < _browseButtons.Count; i++) { _browseButtons[i].Attributes.Add("style", "display:none"); } } if (role.Delete) { } else { for (int i = 0; i < _deleteButtons.Count; i++) { _deleteButtons[i].Attributes.Add("style", "display:none"); } } if (role.Edit) { } else { for (int i = 0; i < _editButtons.Count; i++) { _editButtons[i].Attributes.Add("style", "display:none"); } } if (role.Finish) { } else { for (int i = 0; i < _finishButtons.Count; i++) { _finishButtons[i].Attributes.Add("style", "display:none"); } } if (role.Approve) { } else { for (int i = 0; i < _approveButtons.Count; i++) { _approveButtons[i].Attributes.Add("style", "display:none"); } } if (role.Report) { } else { for (int i = 0; i < _reportButtons.Count; i++) { _reportButtons[i].Attributes.Add("style", "display:none"); } } if (role.Publish) { } else { for (int i = 0; i < _publishButtons.Count; i++) { _publishButtons[i].Attributes.Add("style", "display:none"); } } } }
public void Insert(int index, ModuleRole value) { List.Insert(index, value); }
public void Remove(ModuleRole value) { List.Remove(value); }
public bool Contains(ModuleRole value) { return (List.Contains(value)); }
public int IndexOf(ModuleRole value) { return (List.IndexOf(value)); }
public bool Contains(ModuleRole value) { return(List.Contains(value)); }
/// <summary> /// 增加一个角色 /// </summary> /// <param name="value">角色</param> /// <returns></returns> public int Add(ModuleRole value) { return (List.Add(value)); }
public int IndexOf(ModuleRole value) { return(List.IndexOf(value)); }
/// <summary> /// 增加一个角色 /// </summary> /// <param name="value">角色</param> /// <returns></returns> public int Add(ModuleRole value) { return(List.Add(value)); }
/// <summary> /// 构造函数:已知用户名和密码,创建用户实例 /// </summary> /// <param name="userName">用户名(即员工号)</param> /// <param name="passWord">密码</param> public UserRoles(string userName, string passWord) { MyWebControlLib.FieldValues fvs = new MyWebControlLib.FieldValues(); MyWebControlLib.FieldValue fv = new MyWebControlLib.FieldValue(); fv.FieldName = "userName"; userName = userName.Replace("'", ""); passWord = passWord.Replace("'", ""); fv.Value = userName; username = userName; password = passWord; fvs.Add(fv); fv = new MyWebControlLib.FieldValue(); fv.FieldName = "password"; fv.Value = passWord; fvs.Add(fv); DataTable table = udb.GetDataTable(fvs); if (table.Rows.Count > 0) { isvalid = true; unitcode = table.Rows[0]["unitCode"].ToString(); unitname = table.Rows[0]["unitName"].ToString(); bool flag = true; //flag = false;//上海 if (flag) { truename = table.Rows[0]["truename"].ToString(); if (table.Rows[0]["isonline"].ToString() == "1") { isonline = true; } if (table.Rows[0]["isprivate"].ToString() == "1") { isPrivate = true; } for (int i = 0; i < table.Rows.Count; i++) { ModuleRole mr = new ModuleRole(); mr.ModuleKey = table.Rows[i]["ModuleKey"].ToString(); bool first = false; int index = modulekeys.IndexOf(mr.ModuleKey);//该modulekey第一次出现的位置,若此次为第一次出现,则为-1 if (index == -1) { first = true; } if (table.Rows[i]["isadd"].ToString() == "1") { if (first)//第一次出现 { mr.Add = true; } else//只对第一次出现该ModuleKey位置的ModuleRole赋值 { modulekeys[index].Add = true; } } if (table.Rows[i]["ischg"].ToString() == "1") { if (first) { mr.Edit = true; } else { modulekeys[index].Edit = true; } } if (table.Rows[i]["isdel"].ToString() == "1") { if (first) { mr.Delete = true; } else { modulekeys[index].Delete = true; } } if (table.Rows[i]["isapp"].ToString() == "1") { if (first) { mr.Approve = true; } else { modulekeys[index].Approve = true; } } if (table.Rows[i]["iscom"].ToString() == "1") { if (first) { mr.Finish = true; } else { modulekeys[index].Finish = true; } } if (table.Rows[i]["isrep"].ToString() == "1") { if (first) { mr.Report = true; } else { modulekeys[index].Report = true; } } if (table.Rows[i]["ispub"].ToString() == "1") { if (first) { mr.Publish = true; } else { modulekeys[index].Publish = true; } } modulekeys.Add(mr); } } } }