ResourceReport.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 ResourceReportForm : qminoa.Webs.PageBase
- {
- protected System.Web.UI.WebControls.DataList UserList;
- protected System.Web.UI.WebControls.HyperLink BackLink1;
- protected System.Web.UI.WebControls.HyperLink BackLink2;
- protected System.Web.UI.WebControls.Label NoData;
- protected DateTime _startDate = DateTime.MinValue;
- protected DateTime _endDate = DateTime.MinValue;
-
- private string _userIDs;
- protected PMUser _user;
- public const string UserRoleAdministrator = "1";
- public const string UserRoleProjectManager = "2";
- private void Page_Load(object sender, System.EventArgs e)
- {
- this.PageBegin("项目统计报告",true);
- _user = new PMUser(Convert.ToInt16(this.Empid));
- if(_user.Role != UserRoleAdministrator && _user.Role != UserRoleProjectManager)
- {
- Response.Redirect(Application["vRoot"]+"/login.aspx");
- }
- _userIDs = Request.QueryString["IDs"]==null? "0" : Request.QueryString["IDs"];
- _startDate = Convert.ToDateTime(Request.QueryString["Start"]==null?
- DateTime.MinValue.ToShortDateString() : Request.QueryString["Start"]);
- _endDate = Convert.ToDateTime(Request.QueryString["End"]==null?
- DateTime.MinValue.ToShortDateString() : Request.QueryString["End"]);
- BackLink1.NavigateUrl = "Reports.aspx";
- BackLink2.NavigateUrl = "Reports.aspx";
- BindList(_userIDs, _startDate, _endDate);
- }
- private void BindList(string userIDs, DateTime start, DateTime end)
- {
- ResourceReportUserCollection userData = ResourceReportUser.GetUserSummary(_user .UserID, userIDs, start, end);
- UserList.DataSource = userData;
- UserList.DataBind();
- if (userData.Count == 0)
- {
- UserList.Visible = false;
- NoData.Visible = true;
- }
- }
- private void SortGridData(TimeEntriesCollection list, string sortField, bool asc)
- {
- TimeEntriesCollection.TimeEntryFields sortCol = TimeEntriesCollection.TimeEntryFields.InitValue;
- switch(sortField)
- {
- case "EntryDate":
- sortCol = TimeEntriesCollection.TimeEntryFields.Day;
- break;
- case "ProjectName":
- sortCol = TimeEntriesCollection.TimeEntryFields.Project;
- break;
- case "CategoryName":
- sortCol = TimeEntriesCollection.TimeEntryFields.Category;
- break;
- case "Duration":
- sortCol = TimeEntriesCollection.TimeEntryFields.Hours;
- break;
- case "Description":
- sortCol = TimeEntriesCollection.TimeEntryFields.Description;
- break;
- }
- list.Sort(sortCol, asc);
- }
- protected TimeEntriesCollection ListTimeEntry(int mgrID, int userID, DateTime start, DateTime end)
- {
- TimeEntriesCollection entryList = BLL.PM.TimeEntry.GetEntries(mgrID, userID, start, end);
- if (entryList.Count > 0)
- SortGridData(entryList, SortField, SortAscending);
- else
- entryList = null;
- return entryList;
- }
- protected void TimeEntryGrid_Sort(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
- {
- SortField = e.SortExpression;
- BindList(_userIDs, _startDate, _endDate);
- }
-
- #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.ID = "ResourceReportForm";
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- 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;
- }
- }
- }
- }