ProjectList.aspx.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:4k
- using System;
- using System.Web.UI.WebControls;
- using qminoa.BLL.PM;
- namespace qminoa.Webs.PM
- {
- public class ProjectList : qminoa.Webs.PageBase
- {
- public const string UserRoleNone = "0";
- public const string UserRoleAdministrator = "1";
- public const string UserRoleProjectManager = "2";
- public const string UserRoleConsultant = "3";
- protected System.Web.UI.WebControls.LinkButton LinkButton1;
- protected System.Web.UI.WebControls.Button NewProjectButton;
- protected System.Web.UI.WebControls.DataGrid ProjectsGrid;
- private PMUser _user;
- private void Page_Load(object sender, System.EventArgs e)
- {
- this.PageBegin("项目管理",true);
- _user = new PMUser(Convert.ToInt16(this.Empid));
- if(_user.Role == UserRoleConsultant || _user.Role == UserRoleNone)
- {
- Response.Redirect(Application["vRoot"]+"/login.aspx");
- }
- if (!IsPostBack)
- {
- BindProjects();
- }
- }
-
- private void BindProjects()
- {
- ProjectsCollection projectList = Project.GetProjects(_user.UserID, _user.Role);
- SortGridData(projectList, SortField, SortAscending);
- ProjectsGrid.DataSource = projectList;
- ProjectsGrid.DataBind();
- }
-
- private void SortGridData(ProjectsCollection list, string sortField, bool asc)
- {
- ProjectsCollection.ProjectFields sortCol = ProjectsCollection.ProjectFields.InitValue;
- switch(sortField)
- {
- case "Name":
- sortCol = ProjectsCollection.ProjectFields.Name;
- break;
- case "Manager":
- sortCol = ProjectsCollection.ProjectFields.ManagerUserName;
- break;
- case "Completion":
- sortCol = ProjectsCollection.ProjectFields.CompletionDate;
- break;
- case "Duration":
- sortCol = ProjectsCollection.ProjectFields.Duration;
- break;
- default:
- break;
- }
- list.Sort(sortCol, asc);
- }
- #region Web Form Designer generated code
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN: This call is required by the ASP.NET Web Form Designer.
- //
- InitializeComponent();
- base.OnInit(e);
- }
-
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.NewProjectButton.Click += new System.EventHandler(this.NewProjectButton_Click);
- this.ProjectsGrid.SortCommand += new System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.ProjectsGrid_Sort);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- private void NewProjectButton_Click(object sender, System.EventArgs e)
- {
- Response.Redirect("ProjectDetails.aspx", false);
- }
- protected void ProjectsGrid_Page(Object sender, DataGridPageChangedEventArgs e)
- {
- ProjectsGrid.CurrentPageIndex = e.NewPageIndex;
- BindProjects();
- }
- private void ProjectsGrid_Sort(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
- {
- SortField = e.SortExpression;
- BindProjects();
- }
- string SortField
- {
- get
- {
- object o = ViewState["SortField"];
- if (o == null)
- {
- return String.Empty;
- }
- return (string)o;
- }
- set
- {
- if (value == SortField)
- {
- SortAscending = !SortAscending;
- }
- ViewState["SortField"] = value;
- }
- }
- bool SortAscending
- {
- get
- {
- object o = ViewState["SortAscending"];
- if (o == null)
- {
- return true;
- }
- return (bool)o;
- }
- set
- {
- ViewState["SortAscending"] = value;
- }
- }
- }
- }