private void _helper_LoadGridDataSource(object sender, EventArgs e) { if (!_checkRequireFields()) { return; } this.ViewState["ItemCode"] = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtItemCodeQuery.Text)); this.ViewState["MoCode"] = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtMoCodeQuery.Text)); FacadeFactory facadeFactory = new FacadeFactory(base.DataProvider); object[] dataSource = facadeFactory.CreateQueryTSInfoFacade().QueryTSLocECode( this.ViewState["ItemCode"].ToString(), this.ViewState["MoCode"].ToString(), FormatHelper.TODateInt(this.dateStartDateQuery.Text), FormatHelper.TODateInt(this.dateEndDateQuery.Text), 1, int.MaxValue); //chart List <string> fixedColumnList = new List <string>(); fixedColumnList.Add("ErrorLocation"); if (dataSource == null || dataSource.Length <= 0) { this.gridWebGrid.Visible = false; this.columnChart.Visible = false; return; } NewReportDomainObject[] newReportDomainObject = new NewReportDomainObject[dataSource.Length]; for (int i = 0; i < dataSource.Length; i++) { NewReportDomainObject domainObject = new NewReportDomainObject(); domainObject.ErrorCause = ((QDOTSInfo)dataSource[i]).ErrorCauseDesc; domainObject.ErrorLocation = ((QDOTSInfo)dataSource[i]).ErrorLocation; domainObject.Quantity = ((QDOTSInfo)dataSource[i]).Quantity; newReportDomainObject[i] = domainObject; } if (this.rblVisibleStyle.SelectedValue.ToUpper() == VisibleStyle.Pivot.ToUpper()) { this.columnChart.Visible = false; List <ReportGridDim3Property> dim3PropertyList = new List <ReportGridDim3Property>(); dim3PropertyList.Add(new ReportGridDim3Property("Quantity", "0", "SUM", "SUM", false)); ReportGridHelper reportGridHelper = new ReportGridHelper(this.DataProvider, this.languageComponent1, this.gridWebGrid); reportGridHelper.DataSource = newReportDomainObject; reportGridHelper.Dim1PropertyList = fixedColumnList; reportGridHelper.Dim3PropertyList = dim3PropertyList; reportGridHelper.HasDim3PropertyNameRowColumn = true; reportGridHelper.ShowGrid(); this.gridWebGrid.Columns[2].Header.Caption = languageComponent1.GetString("ErrorCauseDesc"); this.gridWebGrid.Visible = true; } if (this.rblVisibleStyle.SelectedValue.ToUpper() == VisibleStyle.Chart.ToUpper()) { this.gridWebGrid.Visible = false; //设置首页报表的大小 if (ViewState["Width"] != null) { columnChart.Width = int.Parse(ViewState["Width"].ToString()); } if (ViewState["Height"] != null) { columnChart.Height = int.Parse(ViewState["Height"].ToString()); } //end DataTable dataTableColumn = new DataTable(); dataTableColumn.Columns.Add("Names", typeof(System.String)); dataTableColumn.Columns.Add(" ", typeof(System.Int32)); for (int i = 0; i < newReportDomainObject.Length; i++) { dataTableColumn.Rows.Add(new object[] { newReportDomainObject[i].ErrorLocation, newReportDomainObject[i].Quantity }); } this.columnChart.DataType = true; this.columnChart.YLabelFormatString = "<DATA_VALUE:0.##>"; this.columnChart.ChartTextFormatString = "<DATA_VALUE:0.##>"; this.columnChart.ColumnDataSource = dataTableColumn; this.columnChart.DataBindTable(); this.columnChart.Visible = true; } }
protected override void DoQuery() { base.DoQuery(); if (this.CheckBeforeQuery()) { this.AutoRefresh = this.chbRefreshAuto.Checked; string compareType = this.UCGroupConditions1.UserSelectCompareType.Trim().ToLower(); string byTimeType = this.UCGroupConditions1.UserSelectByTimeType.Trim().ToLower(); object[] dateSource = null; object[] dateSourceCompare = null; //一般数据 dateSource = this.LoadDataSource(false, compareType.Trim().Length > 0); if (dateSource == null || dateSource.Length <= 0) { this.gridWebGrid.Visible = false; this.cmdGridExport.Visible = false; this.columnChart.Visible = false; this.pieChart.Visible = false; ReportPageHelper.SetPageScrollToBottom(this); return; } //环比/同期比数据 if (compareType.Trim().Length > 0) { dateSourceCompare = this.LoadDataSource(true, true); } if (dateSourceCompare == null) { dateSourceCompare = new NewReportDomainObject[0] { }; } //数据加载到Grid List <string> dim1PropertyList = GetRows(); dim1PropertyList.Add("OQCSampleSize"); dim1PropertyList.Add("TotalGradeTimes"); dim1PropertyList.Add("ZGradeTimes"); dim1PropertyList.Add("AGradeTimes"); dim1PropertyList.Add("BGradeTimes"); dim1PropertyList.Add("CGradeTimes"); List <ReportGridDim3Property> dim3PropertyList = new List <ReportGridDim3Property>(); dim3PropertyList.Add(new ReportGridDim3Property("Input", "0", "SUM", "SUM", false)); ReportGridHelperNew reportGridHelper = new ReportGridHelperNew(this.DataProvider, this.languageComponent1, this.gridWebGrid, this.DtSource); reportGridHelper.DataSource = dateSource; reportGridHelper.DataSourceForCompare = dateSourceCompare; reportGridHelper.Dim1PropertyList = dim1PropertyList; reportGridHelper.Dim3PropertyList = dim3PropertyList; reportGridHelper.HasDim3PropertyNameRowColumn = true; reportGridHelper.CompareType = compareType; reportGridHelper.ByTimeType = byTimeType; reportGridHelper.ShowGrid(); this.gridWebGrid.Behaviors.RowSelectors.RowNumbering = false; this.gridWebGrid.Behaviors.Sorting.Enabled = false; #region 非正规操作 DataTable dtGrid = gridWebGrid.DataSource as DataTable; for (int i = this.gridWebGrid.Columns.Count - 8; i < this.gridWebGrid.Columns.Count - 2; i++) { //数字汇总 string sum = "0"; for (int j = 0; j < this.gridWebGrid.Rows.Count - 1; j++) { try { sum = ReportGridHelper.StringCalc("ADD", sum, this.gridWebGrid.Rows[j].Items[i].Text); } catch { continue; } } dtGrid.Rows[this.gridWebGrid.Rows.Count - 1][i] = sum; this.gridWebGrid.Rows[this.gridWebGrid.Rows.Count - 1].Items[i].Text = sum; //数字右对齐 for (int j = 0; j < this.gridWebGrid.Rows.Count; j++) { this.gridWebGrid.Rows[j].Items[i].CssClass = "TextAlignRight"; } } if (UCQueryDataType1.GetQueryDataType() == NewReportQueryDataType.DataRate) { for (int i = this.gridWebGrid.Columns.Count - 7; i < this.gridWebGrid.Columns.Count - 2; i++) { //换算成百分比 string percent = "0"; for (int j = 0; j < this.gridWebGrid.Rows.Count; j++) { percent = ReportGridHelper.StringCalc("DIV", this.gridWebGrid.Rows[j].Items[i].Text, this.gridWebGrid.Rows[j].Items[this.gridWebGrid.Columns.Count - 5].Text + ".00"); percent = ReportGridHelper.StringCalc("MUL", percent, "100"); dtGrid.Rows[j][i] = float.Parse(percent).ToString("0.00");; this.gridWebGrid.Rows[j].Items[i].Text = float.Parse(percent).ToString("0.00"); } } } //dtGrid.Columns.RemoveAt(this.gridWebGrid.Columns.Count - 1); //dtGrid.Columns.RemoveAt(this.gridWebGrid.Columns.Count - 2); ((BoundDataField)this.gridWebGrid.Columns[this.gridWebGrid.Columns.Count - 1]).Hidden = true; ((BoundDataField)this.gridWebGrid.Columns[this.gridWebGrid.Columns.Count - 2]).Hidden = true; this.gridWebGrid.DataSource = dtGrid; this.gridWebGrid.DataBind(); base.InitWebGrid(); #endregion //获取表格和图示 if (UCDisplayConditions1.GetDisplayType().Trim().ToLower() == NewReportDisplayType.Grid) { this.gridWebGrid.Visible = true; this.cmdGridExport.Visible = true; this.columnChart.Visible = false; this.pieChart.Visible = false; } else if (UCDisplayConditions1.GetDisplayType().Trim().ToLower() == NewReportDisplayType.LineChart || UCDisplayConditions1.GetDisplayType().Trim().ToLower() == NewReportDisplayType.PieChart || UCDisplayConditions1.GetDisplayType().Trim().ToLower() == NewReportDisplayType.HistogramChart) { List <string> rowPropertyList = new List <string>(); rowPropertyList.Add("EAttribute1"); List <string> columnPropertyList = new List <string>(); List <string> dataPropertyList = new List <string>(); if (UCQueryDataType1.GetQueryDataType() == NewReportQueryDataType.DataNumber) { dataPropertyList.Add("TotalGradeTimes"); } else { dataPropertyList.Add("GradeTimesPercent"); } NewReportDomainObject[] dateSourceForOWC = null; //针对于饼图和饼图,数据源只使用最下面的汇总行的数据 if (UCDisplayConditions1.GetDisplayType().Trim().ToLower() == NewReportDisplayType.PieChart) { dateSourceForOWC = new NewReportDomainObject[4]; for (int i = this.gridWebGrid.Columns.Count - 6; i < this.gridWebGrid.Columns.Count - 2; i++) { NewReportDomainObject domainObject = new NewReportDomainObject(); domainObject.EAttribute1 = this.gridWebGrid.Columns[i].Header.Text; if (UCQueryDataType1.GetQueryDataType() == NewReportQueryDataType.DataNumber) { domainObject.TotalGradeTimes = int.Parse(this.gridWebGrid.Rows[this.gridWebGrid.Rows.Count - 1].Items[i].Text); } else { domainObject.GradeTimesPercent = float.Parse(this.gridWebGrid.Rows[this.gridWebGrid.Rows.Count - 1].Items[i].Text.Replace("%", "")) / 100; } dateSourceForOWC[i - this.gridWebGrid.Columns.Count + 6] = domainObject; } } else if (UCDisplayConditions1.GetDisplayType().Trim().ToLower() == NewReportDisplayType.HistogramChart) { columnPropertyList = GetRows(); dateSourceForOWC = new NewReportDomainObject[4 * (this.gridWebGrid.Rows.Count - 1)]; for (int i = this.gridWebGrid.Columns.Count - 6; i < this.gridWebGrid.Columns.Count - 2; i++) { for (int j = 0; j < this.gridWebGrid.Rows.Count - 1; j++) { NewReportDomainObject domainObject = new NewReportDomainObject(); foreach (string property in columnPropertyList) { ReportGridHelper.SetValueByPropertyName(domainObject, property, this.gridWebGrid.Rows[j].Items.FindItemByKey(property).Text); } domainObject.EAttribute1 = this.gridWebGrid.Columns[i].Header.Text; if (UCQueryDataType1.GetQueryDataType() == NewReportQueryDataType.DataNumber) { domainObject.TotalGradeTimes = int.Parse(this.gridWebGrid.Rows[j].Items[i].Text); } else { domainObject.GradeTimesPercent = float.Parse(this.gridWebGrid.Rows[j].Items[i].Text.Replace("%", "")) / 100; } dateSourceForOWC[(i - this.gridWebGrid.Columns.Count + 6) * (this.gridWebGrid.Rows.Count - 1) + j] = domainObject; } } } //add by seven 20110111 foreach (NewReportDomainObject obj in dateSourceForOWC) { if (UCQueryDataType1.GetQueryDataType().Trim().ToLower() == NewReportQueryDataType.DataNumber) { obj.TempValue = obj.TotalGradeTimes.ToString(); } else { obj.TempValue = obj.GradeTimesPercent.ToString(); } obj.PeriodCode = obj.EAttribute1.ToString(); } if (UCDisplayConditions1.GetDisplayType().Trim().ToLower() == NewReportDisplayType.HistogramChart) { this.columnChart.Visible = true; this.pieChart.Visible = false; columnChart.ChartGroupByString = UCGroupConditions1.GetCheckedColumnsString(); //设置首页报表的大小 if (ViewState["Width"] != null) { columnChart.Width = int.Parse(ViewState["Width"].ToString()); } if (ViewState["Height"] != null) { columnChart.Height = int.Parse(ViewState["Height"].ToString()); } //end if (UCQueryDataType1.GetQueryDataType().Trim().ToLower() == NewReportQueryDataType.DataNumber) { this.columnChart.ChartTextFormatString = "<DATA_VALUE:#0.##>"; this.columnChart.YLabelFormatString = "<DATA_VALUE:#0.##>"; } else { this.columnChart.ChartTextFormatString = "<DATA_VALUE:#0.##%>"; this.columnChart.YLabelFormatString = "<DATA_VALUE:#0.##%>"; } this.columnChart.DataType = true; this.columnChart.DataSource = dateSourceForOWC; this.columnChart.DataBindOQC(); } else if (UCDisplayConditions1.GetDisplayType().Trim().ToLower() == NewReportDisplayType.PieChart) { this.columnChart.Visible = false; this.pieChart.Visible = true; pieChart.ChartGroupByString = UCGroupConditions1.GetCheckedColumnsString(); //设置首页报表的大小 if (ViewState["Width"] != null) { pieChart.Width = int.Parse(ViewState["Width"].ToString()); } if (ViewState["Height"] != null) { pieChart.Height = int.Parse(ViewState["Height"].ToString()); } //end if (UCQueryDataType1.GetQueryDataType().Trim().ToLower() == NewReportQueryDataType.DataNumber) { this.pieChart.ChartTextFormatString = "<DATA_VALUE:#0.##>"; this.pieChart.YLabelFormatString = "<DATA_VALUE:#0.##>"; } else { this.pieChart.ChartTextFormatString = "<DATA_VALUE:#0.##%>"; this.pieChart.YLabelFormatString = "<DATA_VALUE:#0.##%>"; } this.pieChart.DataType = true; this.pieChart.DataSource = dateSourceForOWC; this.pieChart.DataBindOQC(); } else { this.columnChart.Visible = false; this.pieChart.Visible = false; } this.gridWebGrid.Visible = false; this.cmdGridExport.Visible = false; } ReportPageHelper.SetPageScrollToBottom(this); //this.gridWebGrid.Columns.RemoveAt(this.gridWebGrid.Columns.Count - 1); //this.gridWebGrid.Columns.RemoveAt(this.gridWebGrid.Columns.Count - 1); //this.gridWebGrid.Columns.RemoveAt(this.gridWebGrid.Columns.Count - 1); } else { this.chbRefreshAuto.Checked = false; this.AutoRefresh = false; } }