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"); } } } }
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 MyPage() { string loginname = User.Identity.Name; _user = new UserRoles(loginname); }