using BLL; using System; using System.Data; using System.Linq; using System.Text; using System.Web.UI.WebControls; namespace FineUIPro.Web.JDGL.WBS { public partial class WorkloadStatistics : PageBase { #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.drpCnProfession.DataValueField = "CnProfessionId"; this.drpCnProfession.DataTextField = "CnProfessionName"; this.drpCnProfession.DataSource = BLL.CnProfessionInitService.GetCnProfessionInitDropDownList(); this.drpCnProfession.DataBind(); Funs.FineUIPleaseSelect(drpCnProfession); Funs.FineUIPleaseSelect(drpUnitProject); Funs.FineUIPleaseSelect(drpWbsSet); this.txtMonths.Text = string.Format("{0:yyyy-MM}", DateTime.Now); Funs.FineUIPleaseSelect(this.drpWeek); InitWeek(); } } #endregion private void InitWeek() { if (!string.IsNullOrEmpty(this.txtMonths.Text.Trim())) { this.Grid1.Columns[5].HeaderText = "本月计划完成量(B)"; this.Grid1.Columns[6].HeaderText = "本月完成量(C)"; this.Grid1.Columns[8].HeaderText = "本月已完工作实际费用-ACWP(A*C)"; this.Grid1.Columns[9].HeaderText = "本月计划工作预算费用-BCWS(B*D)"; this.Grid1.Columns[10].HeaderText = "本月已完工作预算费用-BCWP(C*D)"; this.drpWeek.Items.Clear(); DateTime months = Convert.ToDateTime(this.txtMonths.Text.Trim() + "-01"); string costControlId = BLL.CostControlDetailService.GetHasWeekPlanCostControlIdByProjectIdAndMonth(this.CurrUser.LoginProjectId, months); if (!string.IsNullOrEmpty(costControlId)) { BLL.CostControlDetailService.InitWeekPlanList(this.drpWeek, costControlId, months, true); this.drpWeek.SelectedValue = BLL.Const._Null; } else { Funs.FineUIPleaseSelect(this.drpWeek); this.drpWeek.SelectedValue = BLL.Const._Null; } } } #region 月份选择事件 /// /// 月份选择事件 /// /// /// protected void txtMonths_TextChanged(object sender, EventArgs e) { InitWeek(); } #endregion #region 查询 /// /// 查询按钮 /// /// /// protected void btnSearch_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtMonths.Text.Trim())) { DateTime months = Convert.ToDateTime(this.txtMonths.Text.Trim()); //if (this.rblStatisticsType.SelectedValue == "1") //{ DataTable table = BLL.WorkloadStatisticsService.GetTreeDataTable(this.CurrUser.LoginProjectId, months, this.drpWeek.SelectedValue, this.drpCnProfession.SelectedValue, this.drpUnitProject.SelectedValue, this.drpWbsSet.SelectedValue); Grid1.DataSource = table; Grid1.DataBind(); //} //else //{ // if (this.drpCnProfession.SelectedValue != BLL.Const._Null) // { // DataTable table = BLL.WorkloadStatisticsService.GetTreeDataTable(this.CurrUser.LoginProjectId, months, this.drpCnProfession.SelectedValue, this.drpUnitProject.SelectedValue); // Grid1.DataSource = table; // Grid1.DataBind(); // } // else // { // Alert.ShowInTop("请选择专业!", MessageBoxIcon.Warning); // } //} } else { Alert.ShowInTop("请选择月份!", MessageBoxIcon.Warning); } } #endregion #region 统计类型选择事件 /// /// 统计类型选择事件 /// /// /// protected void rblStatisticsType_SelectedIndexChanged(object sender, EventArgs e) { //if (this.rblStatisticsType.SelectedValue == "1") //{ // this.drpCnProfession.Hidden = true; // this.drpUnitProject.Hidden = true; // this.drpCnProfession.SelectedValue = BLL.Const._Null; //} //else if (this.rblStatisticsType.SelectedValue == "2") //{ // this.drpCnProfession.Hidden = false; //} } #endregion protected void drpCnProfession_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpCnProfession.SelectedValue != BLL.Const._Null) { this.drpUnitProject.DataValueField = "UnitProjectCode"; this.drpUnitProject.DataTextField = "UnitProjectName"; this.drpUnitProject.DataSource = BLL.UnitProjectInitService.GetUnitProjectInitsByCnProfessionId(this.drpCnProfession.SelectedValue); this.drpUnitProject.DataBind(); Funs.FineUIPleaseSelect(drpUnitProject); this.drpUnitProject.SelectedValue = BLL.Const._Null; this.drpWbsSet.Items.Clear(); Funs.FineUIPleaseSelect(drpWbsSet); this.drpWbsSet.SelectedValue = BLL.Const._Null; } else { this.drpUnitProject.Items.Clear(); Funs.FineUIPleaseSelect(drpUnitProject); this.drpUnitProject.SelectedValue = BLL.Const._Null; this.drpWbsSet.Items.Clear(); Funs.FineUIPleaseSelect(drpWbsSet); this.drpWbsSet.SelectedValue = BLL.Const._Null; } } protected void drpUnitProject_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpUnitProject.SelectedValue != BLL.Const._Null) { this.drpWbsSet.DataValueField = "WbsSetCode"; this.drpWbsSet.DataTextField = "WbsSetName"; this.drpWbsSet.DataSource = BLL.WbsSetInitService.GetWbsSetInitsByUnitProjectCode(this.drpUnitProject.SelectedValue); this.drpWbsSet.DataBind(); Funs.FineUIPleaseSelect(drpWbsSet); this.drpWbsSet.SelectedValue = BLL.Const._Null; } else { this.drpWbsSet.Items.Clear(); Funs.FineUIPleaseSelect(drpWbsSet); this.drpWbsSet.SelectedValue = BLL.Const._Null; } } #region 导出按钮 /// 导出按钮 /// /// /// protected void btnOut_Click(object sender, EventArgs e) { Response.ClearContent(); string filename = Funs.GetNewFileName(); Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("工作量统计" + filename, System.Text.Encoding.UTF8) + ".xls"); Response.ContentType = "application/excel"; Response.ContentEncoding = Encoding.UTF8; this.Grid1.PageSize = Grid1.RecordCount; Response.Write(GetGridTableHtml2(Grid1)); Response.End(); DateTime months = Convert.ToDateTime(this.txtMonths.Text.Trim()); DataTable table = BLL.WorkloadStatisticsService.GetTreeDataTable(this.CurrUser.LoginProjectId, months, this.drpWeek.SelectedValue, this.drpCnProfession.SelectedValue, this.drpUnitProject.SelectedValue, this.drpWbsSet.SelectedValue); Grid1.DataSource = table; Grid1.DataBind(); } #endregion protected void drpWeek_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpWeek.SelectedValue == BLL.Const._Null) { this.Grid1.Columns[5].HeaderText = "本月计划完成量(B)"; this.Grid1.Columns[6].HeaderText = "本月完成量(C)"; this.Grid1.Columns[8].HeaderText = "本月已完工作实际费用-ACWP(A*C)"; this.Grid1.Columns[9].HeaderText = "本月计划工作预算费用-BCWS(B*D)"; this.Grid1.Columns[10].HeaderText = "本月已完工作预算费用-BCWP(C*D)"; } else { this.Grid1.Columns[5].HeaderText = "本周计划完成量(B)"; this.Grid1.Columns[6].HeaderText = "本周完成量(C)"; this.Grid1.Columns[8].HeaderText = "本周已完工作实际费用-ACWP(A*C)"; this.Grid1.Columns[9].HeaderText = "本周计划工作预算费用-BCWS(B*D)"; this.Grid1.Columns[10].HeaderText = "本周已完工作预算费用-BCWP(C*D)"; } } } }