public void BindGv() { this.AspNetPager1.RecordCount = ConstructReport.GetEvenAnalysisDetailCount(this.txtTaskCode.Text.Trim(), this.txtTaskName.Text.Trim(), this.prjId); this.dt = EReport.GetEvenAnalysisDetail(this.txtTaskCode.Text.Trim(), this.txtTaskName.Text.Trim(), this.prjId, this.AspNetPager1.PageSize, this.AspNetPager1.CurrentPageIndex, this.hfldIsWBSRelevance.Value); this.ViewState["dt"] = this.dt; this.gvCost.DataSource = this.dt; this.gvCost.DataBind(); }
protected void btnExcel_Click(object sender, System.EventArgs e) { DataTable dataTable = new DataTable(); dataTable = EReport.GetEvenAnalysisDetail(this.txtTaskCode.Text.Trim(), this.txtTaskName.Text.Trim(), this.prjId, 0, 0, this.hfldIsWBSRelevance.Value); if (dataTable.Rows.Count > 0) { DataRow dataRow = dataTable.NewRow(); dataRow["No"] = "合计"; dataRow["ContractCost"] = dataTable.Compute("sum(ContractCost)", "1>0"); dataRow["ConstructCost"] = dataTable.Compute("sum(ConstructCost)", "1>0"); dataRow["GainLoss"] = dataTable.Compute("sum(GainLoss)", "1>0"); if (System.Convert.ToDecimal(dataRow["ContractCost"]) != 0m) { decimal d = System.Convert.ToDecimal(dataRow["GainLoss"]) / System.Convert.ToDecimal(dataRow["ContractCost"]); dataRow["RatioGainLoss"] = (decimal.Floor(d * 10000m) / 100m).ToString() + "%"; } else { dataRow["RatioGainLoss"] = "0.00%"; } dataTable.Rows.Add(dataRow); } dataTable = this.GetTitleByTable(dataTable); dataTable.Columns.Remove("OrderNumber"); System.Collections.Generic.List <ExcelHeader> list = new System.Collections.Generic.List <ExcelHeader>(); list.Add(ExcelHeader.Create("累计数", 1, 4, 3, 0)); System.Collections.Generic.List <int> list2 = new System.Collections.Generic.List <int>(); foreach (DataColumn dataColumn in dataTable.Columns) { if (dataColumn.Ordinal >= 3) { list2.Add(dataColumn.Ordinal); } if (dataColumn.Ordinal < 3) { list.Add(ExcelHeader.Create(dataColumn.ColumnName, 2, 0, 0, 2)); } else { list.Add(ExcelHeader.Create(dataColumn.ColumnName, 2, 0, 0, 0)); } } ExcelHelper.ExportExcel(dataTable, "盈亏明细表", "盈亏明细表", "盈亏明细表.xls", list, null, 3, base.Request.Browser.Browser); }
protected void ComputeTotal() { this.txtTaskCode.Text = ""; this.txtTaskName.Text = ""; this.AspNetPager1.CurrentPageIndex = 1; DataTable evenAnalysisDetail = EReport.GetEvenAnalysisDetail(this.txtTaskCode.Text.Trim(), this.txtTaskName.Text.Trim(), this.prjId, 0, 0, this.hfldIsWBSRelevance.Value); string[] array = new string[4]; if (evenAnalysisDetail.Rows.Count != 0) { array[0] = System.Convert.ToDecimal(evenAnalysisDetail.Compute("sum(ContractCost)", "1>0")).ToString("0.000"); array[1] = System.Convert.ToDecimal(evenAnalysisDetail.Compute("sum(ConstructCost)", "1>0")).ToString("0.000"); array[2] = System.Convert.ToDecimal(evenAnalysisDetail.Compute("sum(GainLoss)", "1>0")).ToString("0.000"); } else { array[0] = "0.000"; array[1] = "0.000"; array[2] = "0.000"; } if (System.Convert.ToDecimal(array[0]) != 0m) { decimal d = System.Convert.ToDecimal(array[2]) / System.Convert.ToDecimal(array[0]); array[3] = (decimal.Floor(d * 10000m) / 100m).ToString() + "%"; } else { array[3] = "0.00%"; } int[] value = new int[] { 3, 4, 5, 6 }; this.ViewState["Total"] = array; this.ViewState["index"] = value; }