CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/JDGL/CostAnalysis/JDReport.aspx.cs

241 lines
12 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using BLL;
using AspNet = System.Web.UI.WebControls;
namespace FineUIPro.Web.JDGL.CostAnalysis
{
public partial class JDReport : PageBase
{
#region
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.txtMonths.Text = string.Format("{0:yyyy-MM}", DateTime.Now);
GetValue();
}
}
private void SetEmpty()
{
this.SimpleForm1.Title = string.Empty;
txt3.Text = string.Empty;
txt4.Text = string.Empty;
txt5.Text = string.Empty;
}
#endregion
#region
private void GetValue()
{
BindChart();
//Model.Information_SafetyBriefing report = Funs.DB.Information_SafetyBriefing.FirstOrDefault(e => e.UnitId == drpUnit.SelectedValue && e.Month == month && e.YearId == year);
//if (report != null)
//{
// string upState = string.Empty;
// if (report.UpState == BLL.Const.UpState_3)
// {
// upState = "(已上报)";
// }
// else
// {
// upState = "(未上报)";
// }
// this.SimpleForm1.Title = "实业安全简报" + report.YearId + "年 " + report.Month + "月" + upState;
// lbUnitName.Text = "填报企业:" + BLL.UnitService.GetUnitNameByUnitId(report.UnitId);
// lbCompileMan.Text = "编制人:" + BLL.UserService.GetUserNameByUserId(report.CompileMan);
// lbAuditor.Text = "审核人:" + report.Auditor;
// lbApprover.Text = "审批人:" + report.Approver;
// this.txtMainWork.Text = report.MainWork;
// this.txtHazardRecording.Text = report.HazardRecording;
// this.txtSafetyAccident.Text = report.SafetyAccident;
// this.txtEPAccident.Text = report.EPAccident;
// this.txtOHAccident.Text = report.OHAccident;
// this.txtWorkPermitNum.Text = report.WorkPermitNum;
// this.txtHiddenDangerDetection.Text = report.HiddenDangerDetection;
// this.txtRectificationSituation.Text = report.RectificationSituation;
// this.txtCheckProblemsRectification.Text = report.CheckProblemsRectification;
// this.txtPendingProject.Text = report.PendingProject;
// this.txtContractorManagement.Text = report.ContractorManagement;
// this.txtEnvironmentalEmissions.Text = report.EnvironmentalEmissions;
// this.txtNextMonthWorkPlan.Text = report.NextMonthWorkPlan;
//}
//else
//{
// SetEmpty();
//}
}
#endregion
#region
/// <summary>
/// 数据绑定
/// </summary>
private void BindChart()
{
Model.Project_Installation installation = BLL.Project_InstallationService.GetProjectInstallationByProjectId(this.CurrUser.LoginProjectId);
if (installation != null && !string.IsNullOrEmpty(this.txtMonths.Text.Trim()))
{
string id = installation.InstallationId;
string date = this.txtMonths.Text.Trim() + "-01";
string strSql = "select distinct (cast(YEAR(Months) as varchar(4))+'.'+cast(MONTH(Months) as varchar(2))) as 月份,t.Months," +
"ThisRealCost as '本月已完工作实际费用-ACWP',ThisPlanCost as '本月已完工作预算费用-BCWP',ThisPlanValue as '本月计划工作预算费用-BCWS',TotalPlanValue as '累计计划工作预算费用-BCWS',TotalRealCost as '累计已完工作实际费用-ACWP',TotalPlanCost as '累计已完工作预算费用-BCWP' " +
"from dbo.View_WBS_CostControlParentDetail as t where ParentId=@Id and t.Months<=@Months order by t.Months";
//string date = DateTime.Now.Year + "-" + DateTime.Now.Month + "-01";
SqlParameter[] parameter = new SqlParameter[]
{
new SqlParameter("@Id",id),
new SqlParameter("@Months",date),
};
DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
decimal lastbcws = 0, bcws = 0, lastacwp = 0, acwp = 0, lastbcwp = 0, bcwp = 0;
for (int i = 0; i < dt.Rows.Count; i++)
{
dt.Rows[i]["本月已完工作实际费用-ACWP"] = Funs.GetNewDecimalOrZero(dt.Rows[i]["本月已完工作实际费用-ACWP"].ToString()) / 10000;
dt.Rows[i]["本月已完工作预算费用-BCWP"] = Funs.GetNewDecimalOrZero(dt.Rows[i]["本月已完工作预算费用-BCWP"].ToString()) / 10000;
dt.Rows[i]["本月计划工作预算费用-BCWS"] = Funs.GetNewDecimalOrZero(dt.Rows[i]["本月计划工作预算费用-BCWS"].ToString()) / 10000;
bcws = Funs.GetNewDecimalOrZero(dt.Rows[i]["累计计划工作预算费用-BCWS"].ToString());
acwp = Funs.GetNewDecimalOrZero(dt.Rows[i]["累计已完工作实际费用-ACWP"].ToString());
bcwp = Funs.GetNewDecimalOrZero(dt.Rows[i]["累计已完工作预算费用-BCWP"].ToString());
if (bcws == lastbcws)
{
if (Funs.GetNewDateTimeOrNow(dt.Rows[i]["Months"].ToString()) > DateTime.Now)
{
dt.Rows[i]["累计计划工作预算费用-BCWS"] = DBNull.Value;
}
else
{
dt.Rows[i]["累计计划工作预算费用-BCWS"] = bcws / 10000;
}
}
else
{
dt.Rows[i]["累计计划工作预算费用-BCWS"] = bcws / 10000;
}
if (acwp == lastacwp)
{
if (Funs.GetNewDateTimeOrNow(dt.Rows[i]["Months"].ToString()) > DateTime.Now)
{
dt.Rows[i]["累计已完工作实际费用-ACWP"] = DBNull.Value;
}
else
{
dt.Rows[i]["累计已完工作实际费用-ACWP"] = acwp / 10000;
}
}
else
{
dt.Rows[i]["累计已完工作实际费用-ACWP"] = acwp / 10000;
}
if (bcwp == lastbcwp)
{
if (Funs.GetNewDateTimeOrNow(dt.Rows[i]["Months"].ToString()) > DateTime.Now)
{
dt.Rows[i]["累计已完工作预算费用-BCWP"] = DBNull.Value;
}
else
{
dt.Rows[i]["累计已完工作预算费用-BCWP"] = bcwp / 10000;
}
}
else
{
dt.Rows[i]["累计已完工作预算费用-BCWP"] = bcwp / 10000;
}
lastbcws = bcws;
lastacwp = acwp;
lastbcwp = bcwp;
}
this.ChartEV.CreateMaryChart(dt, 1220, 420, null);
decimal BCWP = Funs.GetNewDecimalOrZero(dt.Rows[dt.Rows.Count - 1]["累计已完工作预算费用-BCWP"].ToString());
decimal BCWS = Funs.GetNewDecimalOrZero(dt.Rows[dt.Rows.Count - 1]["累计计划工作预算费用-BCWS"].ToString());
decimal ACWP = Funs.GetNewDecimalOrZero(dt.Rows[dt.Rows.Count - 1]["累计已完工作实际费用-ACWP"].ToString());
decimal mBCWP = Funs.GetNewDecimalOrZero(dt.Rows[dt.Rows.Count - 1]["本月已完工作预算费用-BCWP"].ToString());
decimal mBCWS = Funs.GetNewDecimalOrZero(dt.Rows[dt.Rows.Count - 1]["本月计划工作预算费用-BCWS"].ToString());
decimal mACWP = Funs.GetNewDecimalOrZero(dt.Rows[dt.Rows.Count - 1]["本月已完工作实际费用-ACWP"].ToString());
decimal CV = BCWP - ACWP;
decimal SV = BCWP - BCWS;
decimal CPI = 0;
if (ACWP > 0)
{
CPI = BCWP / ACWP;
}
decimal SPI = 0;
if (BCWS > 0)
{
SPI = BCWP / BCWS;
}
decimal mCV = mBCWP - mACWP;
decimal mSV = mBCWP - mBCWS;
decimal mCPI = 0;
if (mACWP > 0)
{
mCPI = mBCWP / mACWP;
}
decimal mSPI = 0;
if (mBCWS > 0)
{
mSPI = mBCWP / mBCWS;
}
DataTable table2 = new DataTable();
//this.txt2.Text = "总体施工进度赢得值参数 BCWP" + BCWP.ToString("0.####") + " BCWS" + BCWS.ToString("0.####") + " ACWP" + ACWP.ToString("0.####") + "\r\n赢得值四个评价指标 CV" + CV.ToString("0.####") + " SV" + SV.ToString("0.####") + " CPI" + CPI.ToString("0.####") + " SPI" + SPI.ToString("0.####");
this.txt3.Text = "施工进度赢得值参数 BCWP" + mBCWP.ToString("0.####") + " BCWS" + mBCWS.ToString("0.####") + " ACWP" + mACWP.ToString("0.####") + "\r\n赢得值四个评价指标 CV" + mCV.ToString("0.####") + " SV" + mSV.ToString("0.####") + " CPI" + mCPI.ToString("0.####") + " SPI" + mSPI.ToString("0.####");
}
}
#endregion
#region
/// <summary>
/// 查询按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSearch_Click(object sender, EventArgs e)
{
GetValue();
}
#endregion
#region
/// <summary>
/// 关闭窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
GetValue();
}
#endregion
#region
/// 导出按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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, BLL.Const._Null, this.drpCnProfession.SelectedValue, this.drpUnitProject.SelectedValue, this.drpWbsSet.SelectedValue);
//Grid1.DataSource = table;
//Grid1.DataBind();
}
#endregion
}
}