提交代码
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using BLL;
|
||||
|
||||
namespace FineUIPro.Web.Transfer.Chart
|
||||
{
|
||||
public partial class PunchlistFromChart : PageBase
|
||||
{
|
||||
#region 定义项
|
||||
/// <summary>
|
||||
/// 项目主键
|
||||
/// </summary>
|
||||
public string ProjectId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["ProjectId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["ProjectId"] = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 加载页面
|
||||
/// <summary>
|
||||
/// 加载页面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.ProjectId = this.CurrUser.LoginProjectId;
|
||||
if (!string.IsNullOrEmpty(Request.Params["projectId"]))
|
||||
{
|
||||
this.ProjectId = Request.Params["projectId"];
|
||||
}
|
||||
|
||||
this.AnalyseData();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 统计分析
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void BtnAnalyse_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.AnalyseData();
|
||||
}
|
||||
|
||||
#region 统计
|
||||
private void AnalyseData()
|
||||
{
|
||||
if (string.IsNullOrEmpty(ProjectId))
|
||||
{
|
||||
Alert.ShowInTop("项目未获取到,请刷新页面。", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
var forms = from x in Funs.DB.Transfer_PunchlistFrom
|
||||
where x.ProjectId == this.CurrUser.LoginProjectId
|
||||
select x;
|
||||
var dates = (from x in forms where x.PUNCH_ITEM_FINISH_DATE != null orderby x.PUNCH_ITEM_FINISH_DATE select x.PUNCH_ITEM_FINISH_DATE).Distinct().ToList();
|
||||
DataTable dtTime = new DataTable();
|
||||
if (rblType.SelectedValue == "1")
|
||||
{
|
||||
dtTime.Columns.Add("日期", typeof(string));
|
||||
dtTime.Columns.Add("Finished(%)", typeof(string));
|
||||
if (dates.Count() > 0)
|
||||
{
|
||||
List<DateTime> months = new List<DateTime>();
|
||||
DateTime startDate = Convert.ToDateTime(dates.First());
|
||||
DateTime endDate = Convert.ToDateTime(dates.Last());
|
||||
do
|
||||
{
|
||||
months.Add(startDate);
|
||||
startDate = startDate.AddDays(15);
|
||||
} while (startDate <= endDate);
|
||||
var nums = forms.Count();
|
||||
foreach (var item in months)
|
||||
{
|
||||
DataRow rowTime = dtTime.NewRow();
|
||||
Model.SpTDesktopItem newspItem = new Model.SpTDesktopItem();
|
||||
rowTime["日期"] = string.Format("{0:yyyy-MM-dd}", item);
|
||||
var finishedNums = forms.Count(x => x.PUNCH_ITEM_FINISH_DATE <= item && x.PUNCH_ITEM_STATUS == "Finished");
|
||||
if (nums > 0)
|
||||
{
|
||||
rowTime["Finished(%)"] = 1.0 * finishedNums / nums;
|
||||
}
|
||||
dtTime.Rows.Add(rowTime);
|
||||
}
|
||||
this.ChartUc.CreateChartPunchlistFrom(BLL.ChartControlService.GetDataSourceChartByYijiao(dtTime, "PROGRESS REPORT", "Line", 1100, 600, false));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dtTime.Columns.Add("日期", typeof(string));
|
||||
dtTime.Columns.Add("Finished", typeof(string));
|
||||
if (dates.Count() > 0)
|
||||
{
|
||||
List<DateTime> months = new List<DateTime>();
|
||||
DateTime startDate = Convert.ToDateTime(dates.First());
|
||||
DateTime endDate = Convert.ToDateTime(dates.Last());
|
||||
do
|
||||
{
|
||||
months.Add(startDate);
|
||||
startDate = startDate.AddDays(15);
|
||||
} while (startDate <= endDate);
|
||||
var nums = forms.Count();
|
||||
foreach (var item in months)
|
||||
{
|
||||
DataRow rowTime = dtTime.NewRow();
|
||||
Model.SpTDesktopItem newspItem = new Model.SpTDesktopItem();
|
||||
rowTime["日期"] = string.Format("{0:yyyy-MM-dd}", item);
|
||||
var finishedNums = forms.Count(x => x.PUNCH_ITEM_FINISH_DATE <= item && x.PUNCH_ITEM_STATUS == "Finished");
|
||||
rowTime["Finished"] = finishedNums;
|
||||
dtTime.Rows.Add(rowTime);
|
||||
}
|
||||
this.ChartUc.CreateChart(BLL.ChartControlService.GetDataSourceChartByYijiao(dtTime, "PROGRESS REPORT", "Line", 1100, 600, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected void rblType_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.AnalyseData();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user