using System; using System.Collections.Generic; using System.Data; using System.Linq; using BLL; namespace FineUIPro.Web.Transfer.Chart { public partial class PunchlistFrom : PageBase { #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { } } #endregion #region 统计 /// /// 统计分析 /// /// /// protected void BtnAnalyse_Click(object sender, EventArgs e) { this.AnalyseData(); } /// /// 统计方法 /// private void AnalyseData() { var forms = from x in Funs.DB.Transfer_PunchlistFrom where x.ProjectId == this.CurrUser.LoginProjectId select x; if (!string.IsNullOrEmpty(this.txtStartTime.Text.Trim())) { forms = forms.Where(x => x.PUNCH_ITEM_FINISH_DATE >= Funs.GetNewDateTime(this.txtStartTime.Text.Trim())); } if (!string.IsNullOrEmpty(this.txtEndTime.Text.Trim())) { forms = forms.Where(x => x.PUNCH_ITEM_FINISH_DATE <= Funs.GetNewDateTime(this.txtEndTime.Text.Trim())); } var list = new List { "Testing", "Pre-Commissioning", "PSSR", "Commissioning" }; if (this.rblState.SelectedValue == "0") { #region 按Identified during/by统计 if (this.drpChartType.SelectedValue != "Pie") //非饼形图 { ///按单位统计 DataTable dtTime = new DataTable(); dtTime.Columns.Add("Identified during/by", typeof(string)); dtTime.Columns.Add("总数量", typeof(string)); dtTime.Columns.Add("A数量", typeof(string)); dtTime.Columns.Add("B数量", typeof(string)); dtTime.Columns.Add("C数量", typeof(string)); dtTime.Columns.Add("Finished", typeof(string)); dtTime.Columns.Add("In Progress", typeof(string)); dtTime.Columns.Add("Not Start", typeof(string)); foreach (var item in list) { DataRow rowTime = dtTime.NewRow(); Model.SpTDesktopItem newspItem = new Model.SpTDesktopItem(); rowTime["Identified during/by"] = item; var types = forms.Where(x => x.Identified == item); rowTime["总数量"] = types.Count(); rowTime["A数量"] = types.Where(x => x.Category == "A").Count(); rowTime["B数量"] = types.Where(x => x.Category == "B").Count(); rowTime["C数量"] = types.Where(x => x.Category == "C").Count(); rowTime["Finished"] = types.Where(x => x.PUNCH_ITEM_STATUS == "Finished").Count(); rowTime["In Progress"] = types.Where(x => x.PUNCH_ITEM_STATUS == "In Progress").Count(); rowTime["Not Start"] = types.Where(x => x.PUNCH_ITEM_STATUS == "Not Start").Count(); dtTime.Rows.Add(rowTime); } this.ChartAccidentTime.CreateChart(BLL.ChartControlService.GetDataSourceChart(dtTime, "尾项分析", this.drpChartType.SelectedValue, 1300, 550, this.ckbShow.Checked)); } else //饼形图 { DataTable dtTime = new DataTable(); dtTime.Columns.Add("Identified during/by", typeof(string)); dtTime.Columns.Add("总数量", typeof(string)); foreach (var item in list) { DataRow rowTime = dtTime.NewRow(); Model.SpTDesktopItem newspItem = new Model.SpTDesktopItem(); rowTime["Identified during/by"] = item; var types = forms.Where(x => x.Identified == item); rowTime["总数量"] = types.Count(); dtTime.Rows.Add(rowTime); } this.ChartAccidentTime.CreateChart(BLL.ChartControlService.GetDataSourceChart(dtTime, "尾项分析", this.drpChartType.SelectedValue, 1300, 550, this.ckbShow.Checked)); } #endregion } else { #region 按Discipline var disciplines = from x in Funs.DB.Base_TransferMajor orderby x.DisciplineCode select x; if (this.drpChartType.SelectedValue != "Pie") //非饼形图 { ///按检查项 DataTable dtTime = new DataTable(); dtTime.Columns.Add("Discipline", typeof(string)); dtTime.Columns.Add("总数量", typeof(string)); dtTime.Columns.Add("A数量", typeof(string)); dtTime.Columns.Add("B数量", typeof(string)); dtTime.Columns.Add("C数量", typeof(string)); dtTime.Columns.Add("Finished", typeof(string)); dtTime.Columns.Add("In Progress", typeof(string)); dtTime.Columns.Add("Not Start", typeof(string)); foreach (var item in disciplines) { DataRow rowTime = dtTime.NewRow(); Model.SpTDesktopItem newspItem = new Model.SpTDesktopItem(); rowTime["Discipline"] = item.Discipline; var types = forms.Where(x => x.Discipline == item.Discipline || x.Discipline==item.DisciplineCode); rowTime["总数量"] = types.Count(); rowTime["A数量"] = types.Where(x => x.Category == "A").Count(); rowTime["B数量"] = types.Where(x => x.Category == "B").Count(); rowTime["C数量"] = types.Where(x => x.Category == "C").Count(); rowTime["Finished"] = types.Where(x => x.PUNCH_ITEM_STATUS == "Finished").Count(); rowTime["In Progress"] = types.Where(x => x.PUNCH_ITEM_STATUS == "In Progress").Count(); rowTime["Not Start"] = types.Where(x => x.PUNCH_ITEM_STATUS == "Not Start").Count(); dtTime.Rows.Add(rowTime); } this.ChartAccidentTime.CreateChart(BLL.ChartControlService.GetDataSourceChart(dtTime, "尾项分析", this.drpChartType.SelectedValue, 1300, 550, this.ckbShow.Checked)); } else //饼形图 { ///按问题类型 DataTable dtTime = new DataTable(); dtTime.Columns.Add("Discipline", typeof(string)); dtTime.Columns.Add("总数量", typeof(string)); foreach (var item in disciplines) { DataRow rowTime = dtTime.NewRow(); Model.SpTDesktopItem newspItem = new Model.SpTDesktopItem(); rowTime["Discipline"] = item.Discipline; var types = forms.Where(x => x.Discipline == item.Discipline || x.Discipline == item.DisciplineCode); rowTime["总数量"] = types.Count(); dtTime.Rows.Add(rowTime); } this.ChartAccidentTime.CreateChart(BLL.ChartControlService.GetDataSourceChart(dtTime, "尾项分析", this.drpChartType.SelectedValue, 1300, 550, this.ckbShow.Checked)); } #endregion } } #endregion #region 图形 /// /// 图形变换 /// /// /// protected void drpChartType_SelectedIndexChanged(object sender, EventArgs e) { this.AnalyseData(); } protected void ckbShow_CheckedChanged(object sender, CheckedEventArgs e) { this.AnalyseData(); } #endregion } }