datatable和list的遍历

来源:互联网 发布:数控法拉克系统编程 编辑:程序博客网 时间:2024/06/01 08:35
 private void PageInit()
        {
            string SAPOrderNo = Request["SAPOrderNo"].ToString();
            List<Model.SAPOrderStatus> lst = biz.GetOrderProductInfo(SAPOrderNo);
            //DataTable dt = new DataTable();
            //dt = biz.GetOrderProductInfoT(SAPOrderNo);


            //if (dt.Rows.Count > 0)
            //{
            //    double OrderQuantity = 0, DeliveryQuantity = 0, GoodsIssueQt = 0, InvoiceQuantity = 0, BackOrderQuantity = 0;


            //    for (int i = 0; i < dt.Rows.Count; i++)
            //    {
            //        OrderQuantity += Convert.ToDouble(dt.Rows[i]["OrderQuantity"]);
            //        DeliveryQuantity += Convert.ToDouble(dt.Rows[i]["DeliveryQuantity"]);
            //        GoodsIssueQt += Convert.ToDouble(dt.Rows[i]["GoodsIssueQt"]);
            //        InvoiceQuantity += Convert.ToDouble(dt.Rows[i]["InvoiceQuantity"]);
            //        BackOrderQuantity += Convert.ToDouble(dt.Rows[i]["BackOrderQuantity"]);
            //    }
            //    txtOrderQuantity.Text = OrderQuantity.ToString();
            //    txtDeliveryQuantity.Text = DeliveryQuantity.ToString();
            //    txtGoodsIssueQt.Text = GoodsIssueQt.ToString();
            //    txtInvoiceQuantity.Text = InvoiceQuantity.ToString();
            //    txtBackOrderQuantity.Text = BackOrderQuantity.ToString();
            //}




            //if (dt.Rows.Count > 0)
            //{
            //    txtTotalRocords.Text = dt.Rows.Count.ToString();
            //}


            if (lst.Count > 0)
            {
                double OrderQuantity = 0, DeliveryQuantity = 0, GoodsIssueQt = 0, InvoiceQuantity = 0, BackOrderQuantity = 0;


                for (int i = 0; i < lst.Count; i++)
                {
                    OrderQuantity += Convert.ToDouble(lst[i].OrderQuantity);
                    DeliveryQuantity += Convert.ToDouble(lst[i].DeliveryQuantity);
                    GoodsIssueQt += Convert.ToDouble(lst[i].GoodsIssueQt);
                    InvoiceQuantity += Convert.ToDouble(lst[i].InvoiceQuantity);
                    BackOrderQuantity += Convert.ToDouble(lst[i].BackOrderQuantity);
                }
                txtOrderQuantity.Text = OrderQuantity.ToString();
                txtDeliveryQuantity.Text = DeliveryQuantity.ToString();
                txtGoodsIssueQt.Text = GoodsIssueQt.ToString();
                txtInvoiceQuantity.Text = InvoiceQuantity.ToString();
                txtBackOrderQuantity.Text = BackOrderQuantity.ToString();
            }


            txtTotalRocords.Text = lst.Count.ToString();


            this.rptOrderProInfoList.DataSource = lst;
            this.rptOrderProInfoList.DataBind();
        }
    }