public void BindGv() { this.AspNetPager1.RecordCount = ConstructReport.GetStuffCount(this.txtResourceCode.Text.Trim(), this.txtResourceName.Text.Trim(), this.txtSpecification.Text.Trim(), this.txtBrand.Text.Trim(), this.prjId); this.dt = ConstructReport.GetMajorStuffAnalysis(this.txtResourceCode.Text.Trim(), this.txtResourceName.Text.Trim(), this.txtSpecification.Text.Trim(), this.txtBrand.Text.Trim(), this.prjId, this.AspNetPager1.PageSize, this.AspNetPager1.CurrentPageIndex); this.gvMajorStuff.DataSource = this.dt; this.gvMajorStuff.DataBind(); }
protected void ComputeTotal() { this.AspNetPager1.CurrentPageIndex = 1; DataTable majorStuffAnalysis = ConstructReport.GetMajorStuffAnalysis(this.txtResourceCode.Text.Trim(), this.txtResourceName.Text.Trim(), this.txtSpecification.Text.Trim(), this.txtBrand.Text.Trim(), this.prjId, 0, 0); string[] array = new string[12]; if (majorStuffAnalysis.Rows.Count != 0) { array[0] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(CurrentBudQuantity)", "1>0")).ToString("0.000"); array[1] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(CurrentBudCost)", "1>0")).ToString("0.000"); array[2] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(CurrentConsQuantity)", "1>0")).ToString("0.000"); array[3] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(CurrentConsCost)", "1>0")).ToString("0.000"); array[4] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(CurrentReductionAmount)", "1>0")).ToString("0.000"); array[6] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(BudQuantity)", "1>0")).ToString("0.000"); array[7] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(BudCost)", "1>0")).ToString("0.000"); array[8] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(ConsQuantity)", "1>0")).ToString("0.000"); array[9] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(ConsCost)", "1>0")).ToString("0.000"); array[10] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(ReductionAmount)", "1>0")).ToString("0.000"); } else { array[0] = "0.000"; array[1] = "0.000"; array[2] = "0.000"; array[3] = "0.000"; array[4] = "0.000"; array[6] = "0.000"; array[7] = "0.000"; array[8] = "0.000"; array[9] = "0.000"; array[10] = "0.000"; } if (System.Convert.ToDecimal(array[1]) != 0m) { decimal d = System.Convert.ToDecimal(array[4]) / System.Convert.ToDecimal(array[1]); array[5] = (decimal.Floor(d * 10000m) / 100m).ToString("0.00") + "%"; } else { array[5] = "0.00%"; } if (System.Convert.ToDecimal(array[7]) != 0m) { decimal d2 = System.Convert.ToDecimal(array[10]) / System.Convert.ToDecimal(array[7]); array[11] = (decimal.Floor(d2 * 10000m) / 100m).ToString("0.00") + "%"; } else { array[11] = "0.00%"; } this.ViewState["Total"] = array; }
protected void btnExcel_Click(object sender, System.EventArgs e) { DataTable dataTable = new DataTable(); dataTable = ConstructReport.GetMajorStuffAnalysis(this.txtResourceCode.Text.Trim(), this.txtResourceName.Text.Trim(), this.txtSpecification.Text.Trim(), this.txtBrand.Text.Trim(), this.prjId, 0, 0); if (dataTable.Rows.Count > 0) { DataRow dataRow = dataTable.NewRow(); dataRow["Num"] = "合计"; dataRow["CurrentBudQuantity"] = dataTable.Compute("sum(CurrentBudQuantity)", "1>0"); dataRow["CurrentBudCost"] = dataTable.Compute("sum(CurrentBudCost)", "1>0"); dataRow["CurrentConsQuantity"] = dataTable.Compute("sum(CurrentConsQuantity)", "1>0"); dataRow["CurrentConsCost"] = dataTable.Compute("sum(CurrentConsCost)", "1>0"); dataRow["CurrentReductionAmount"] = dataTable.Compute("sum(CurrentReductionAmount)", "1>0"); dataRow["BudQuantity"] = dataTable.Compute("sum(BudQuantity)", "1>0"); dataRow["BudCost"] = dataTable.Compute("sum(BudCost)", "1>0"); dataRow["ConsQuantity"] = dataTable.Compute("sum(ConsQuantity)", "1>0"); dataRow["ConsCost"] = dataTable.Compute("sum(ConsCost)", "1>0"); dataRow["ReductionAmount"] = dataTable.Compute("sum(ReductionAmount)", "1>0"); if (System.Convert.ToDecimal(dataRow["CurrentBudCost"]) != 0m) { decimal d = System.Convert.ToDecimal(dataRow["CurrentReductionAmount"]) / System.Convert.ToDecimal(dataRow["CurrentBudCost"]); dataRow["CurrentReductionRate"] = (decimal.Floor(d * 10000m) / 100m).ToString("0.00") + "%"; } else { dataRow["CurrentReductionRate"] = "0.00%"; } if (System.Convert.ToDecimal(dataRow["BudCost"]) != 0m) { decimal d2 = System.Convert.ToDecimal(dataRow["ReductionAmount"]) / System.Convert.ToDecimal(dataRow["BudCost"]); dataRow["ReductionRate"] = (decimal.Floor(d2 * 10000m) / 100m).ToString("0.00") + "%"; } else { dataRow["ReductionRate"] = "0.00%"; } dataTable.Rows.Add(dataRow); } dataTable = this.GetTitleByTable(dataTable); System.Collections.Generic.List <ExcelHeader> list = new System.Collections.Generic.List <ExcelHeader>(); list.Add(ExcelHeader.Create("本月数", 1, 6, 7, 0)); list.Add(ExcelHeader.Create("累计数", 1, 6, 13, 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 < 7) { 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, 2, base.Request.Browser.Browser); }
protected void btn_Search_Click(object sender, System.EventArgs e) { this.AspNetPager1.CurrentPageIndex = 1; DataTable majorStuffAnalysis = ConstructReport.GetMajorStuffAnalysis(this.txtResourceCode.Text.Trim(), this.txtResourceName.Text.Trim(), this.txtSpecification.Text.Trim(), this.txtBrand.Text.Trim(), this.prjId, 0, 0); string[] array = new string[12]; if (majorStuffAnalysis.Rows.Count != 0) { array[0] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(CurrentBudQuantity)", "1>0")).ToString("0.000"); array[1] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(CurrentBudCost)", "1>0")).ToString("0.000"); array[2] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(CurrentConsQuantity)", "1>0")).ToString("0.000"); array[3] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(CurrentConsCost)", "1>0")).ToString("0.000"); array[4] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(CurrentReductionAmount)", "1>0")).ToString("0.000"); array[6] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(BudQuantity)", "1>0")).ToString("0.000"); array[7] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(BudCost)", "1>0")).ToString("0.000"); array[8] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(ConsQuantity)", "1>0")).ToString("0.000"); array[9] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(ConsCost)", "1>0")).ToString("0.000"); array[10] = System.Convert.ToDecimal(majorStuffAnalysis.Compute("sum(ReductionAmount)", "1>0")).ToString("0.000"); } else { array[0] = "0.000"; array[1] = "0.000"; array[2] = "0.000"; array[3] = "0.000"; array[4] = "0.000"; array[6] = "0.000"; array[7] = "0.000"; array[8] = "0.000"; array[9] = "0.000"; array[10] = "0.000"; } if (System.Convert.ToDecimal(array[1]) != 0m) { decimal d = System.Convert.ToDecimal(array[4]) / System.Convert.ToDecimal(array[1]); array[5] = (decimal.Floor(d * 10000m) / 100m).ToString("0.00") + "%"; } else { array[5] = "0.00%"; } if (System.Convert.ToDecimal(array[7]) != 0m) { decimal d2 = System.Convert.ToDecimal(array[10]) / System.Convert.ToDecimal(array[7]); array[11] = (decimal.Floor(d2 * 10000m) / 100m).ToString("0.00") + "%"; } else { array[11] = "0.00%"; } int[] value = new int[] { 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }; this.ViewState["Total"] = array; this.ViewState["index"] = value; this.BindGv(); }