Wednesday 4 January 2012

datatable select count sum function

private void TotalQWT()
        {//---sum of total Qty total gwt - //id/SpId/SelectBK/QtyGWt/Unit/Lesswt1//TotalLess/Netwt////
            DataTable total = GridTable;
            //DataTable totalSp = ((DataTable)ViewState["SpDatatable"]);
            Object sumobj;
            sumobj = total.Compute("Sum(QtyGWt)", "");//-----Qty/Gross Wt Sum "" use for where condition
            txtTQtyGwt.Text = sumobj.ToString();

            sumobj = total.Compute("Sum(TotalLess)", "");//--Cross wt or Less Wt Sum
            txtTLessWt.Text = sumobj.ToString();

            sumobj = total.Compute("Sum(Netwt)", "");//---Net Wt Sum
            txtTNetWt.Text = sumobj.ToString();

            // Label5.Text = Label4.Text;
            //Label5.Text = (Convert.ToDouble(Label1.Text)*(Convert.ToDouble(Label2.Text.Trim()) - Convert.ToDouble(Label3.Text.Trim()))).ToString();//--Grand total sum

            // ---count bundle or katta
            txtTBunddle.Text = total.Select("SelectBK='Bundle'").Count().ToString();
            txtTKatta.Text = total.Select("SelectBK='Katta'").Count().ToString();
            //--count By specification
            txtTPacking.Text = total.Select("").Count().ToString();
            //---specification count
            DataTable sf = GridTable.Clone();
            sf = GridTable.DefaultView.ToTable(true, "Specification");
            txtTSpecification.Text = sf.Select("").Count().ToString();

            txtGrandTotal.Text = txtTNetWt.Text;
        }

No comments:

Post a Comment