📄 reports.aspx.cs
字号:
using System;
using System.Data;
using System.Web;
using System.Text;
using System.Web.UI.WebControls;
using qminoa.BLL.PM;
using qminoa.DA;
namespace qminoa.Webs.PM
{
public class Reports : qminoa.Webs.PageBase
{
protected System.Web.UI.WebControls.ListBox ProjectList;
protected System.Web.UI.WebControls.ListBox UserList;
protected System.Web.UI.WebControls.Button GenProjectRpt;
protected System.Web.UI.WebControls.Button GenResourceRpt;
protected System.Web.UI.WebControls.TextBox StartDate;
protected System.Web.UI.WebControls.TextBox EndDate;
protected System.Web.UI.WebControls.RequiredFieldValidator ProjectListRequiredFieldValidator;
protected System.Web.UI.WebControls.RequiredFieldValidator UserListRequiredFieldValidator;
protected System.Web.UI.WebControls.DropDownList BranchDropList;
protected System.Web.UI.WebControls.DropDownList DepartmentDropList;
public const string UserRoleAdministrator = "1";
public const string UserRoleProjectManager = "2";
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 != UserRoleAdministrator && _user.Role != UserRoleProjectManager)
{
Response.Redirect(Application["vRoot"]+"/login.aspx");
}
DateTime startingDate = DateTime.Today;
DateTime endingDate = DateTime.Today;
if (!this.IsPostBack)
{
ProjectList.DataSource = Project.GetProjects(_user.UserID, _user.Role);
ProjectList.DataTextField = "Name";
ProjectList.DataValueField = "ProjectID";
ProjectList.DataBind();
AdminDB admin = new AdminDB();
BranchDropList.DataSource=admin.GetAllBranch();
BranchDropList.DataBind();
BranchDropList.Items[0].Selected=true;
DepartmentDropList.DataSource=admin.GetDepByBranch(Int32.Parse(BranchDropList.SelectedItem.Value));
DepartmentDropList.DataBind();
DepartmentDropList.Items[0].Selected=true;
UserList.DataSource = PMUser.GetUsers(_user.UserID, _user.Role,Int32.Parse(DepartmentDropList.SelectedItem.Value));
UserList.DataTextField = "UserName";
UserList.DataValueField = "UserID";
UserList.DataBind();
BLL.PM.TimeEntry.FillCorrectStartEndDates(DateTime.Today, ref startingDate, ref endingDate);
StartDate.Text = startingDate.ToShortDateString();
EndDate.Text = endingDate.ToShortDateString();
}
}
private string BuildValueList(ListItemCollection items)
{
StringBuilder idList = new StringBuilder();
foreach (ListItem item in items)
{
if (item.Selected)
{
if (idList.ToString() != string.Empty)
idList.Append(",");
idList.Append(item.Value.ToString());
}
}
return idList.ToString();
}
#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.GenProjectRpt.Click += new System.EventHandler(this.GenProjectRpt_Click);
this.BranchDropList.SelectedIndexChanged += new System.EventHandler(this.BranchDropList_SelectedIndexChanged);
this.DepartmentDropList.SelectedIndexChanged += new System.EventHandler(this.DepartmentDropList_SelectedIndexChanged);
this.GenResourceRpt.Click += new System.EventHandler(this.GenResourceRpt_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void GenProjectRpt_Click(object sender, System.EventArgs e)
{
ProjectListRequiredFieldValidator.Validate();
if (ProjectListRequiredFieldValidator.IsValid)
Server.Transfer("ProjectReport.aspx?IDs=" + BuildValueList(ProjectList.Items));
}
private void GenResourceRpt_Click(object sender, System.EventArgs e)
{
UserListRequiredFieldValidator.Validate();
if (UserListRequiredFieldValidator.IsValid)
Response.Redirect("ResourceReport.aspx?IDs=" + BuildValueList(UserList.Items) +
"&Start=" + StartDate.Text + "&End=" + EndDate.Text, false);
}
private void BranchDropList_SelectedIndexChanged(object sender, System.EventArgs e)
{
AdminDB admin = new AdminDB();
DepartmentDropList.DataSource=admin.GetDepByBranch(Int32.Parse(BranchDropList.SelectedItem.Value));
DepartmentDropList.DataBind();
if(DepartmentDropList.Items.Count !=0)
{
UserList.DataSource = PMUser.GetUsers(_user.UserID, _user.Role,Int32.Parse(DepartmentDropList.SelectedItem.Value));
UserList.DataTextField = "UserName";
UserList.DataValueField = "UserID";
UserList.DataBind();
}
else
{
UserList.Items.Clear();
}
}
private void DepartmentDropList_SelectedIndexChanged(object sender, System.EventArgs e)
{
UserList.DataSource = PMUser.GetUsers(_user.UserID, _user.Role,Int32.Parse(DepartmentDropList.SelectedItem.Value));
UserList.DataTextField = "UserName";
UserList.DataValueField = "UserID";
UserList.DataBind();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -