Esempio n. 1
0
    public void BindGv()
    {
        this.ViewState["Cost"] = EReport.GetTargetCostDetail(this.prjId, this.txtCode.Text.Trim(), this.txtName.Text.Trim());
        DataTable dataTable = this.ViewState["Cost"] as DataTable;

        this.AspNetPager1.RecordCount = dataTable.Rows.Count;
        this.AspNetPager1.PageSize    = NBasePage.pagesize;
        if (dataTable.Rows.Count != 0)
        {
            string[] array = new string[8];
            array[0] = dataTable.Compute("SUM(MonthBud)", string.Empty).ToString();
            array[1] = dataTable.Compute("SUM(MonthAcc)", string.Empty).ToString();
            array[2] = (System.Convert.ToDecimal(array[0]) - System.Convert.ToDecimal(array[1])).ToString();
            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%";
            }
            array[4] = dataTable.Compute("SUM(Bud)", string.Empty).ToString();
            array[5] = dataTable.Compute("SUM(Acc)", string.Empty).ToString();
            array[6] = (System.Convert.ToDecimal(array[4]) - System.Convert.ToDecimal(array[5])).ToString();
            if (System.Convert.ToDecimal(array[4]) != 0m)
            {
                decimal d2 = System.Convert.ToDecimal(array[6]) / System.Convert.ToDecimal(array[4]);
                array[7] = (decimal.Floor(d2 * 10000m) / 100m).ToString() + "%";
            }
            else
            {
                array[7] = "0.00%";
            }
            this.ViewState["Total"] = array;
            this.gvCost.DataSource  = EReport.GetPageDataTable(dataTable, this.AspNetPager1.CurrentPageIndex, this.AspNetPager1.PageSize);
            this.gvCost.DataBind();
        }
    }