本文介绍了我不知道如何计算avarage奖金的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public List<purchaseaccountbll> PurchaseAccountSelection()
        {
            DataTable dt = prl.SelectPurchaseAccount();
            List<purchaseaccountbll> purchase = new List<purchaseaccountbll>();
            foreach (DataRow row in dt.Rows)
            {
                PurchaseAccountBLL a = new PurchaseAccountBLL();
                a.Itemname = row["item_name"].ToString();
                a.Id = Convert.ToInt32(row["purchase_id"]);

                a.Purchase_Unit_Prize = Convert.ToDecimal(row["unit_prize"]);
                a.Purchase_Item_Quantity1 = Convert.ToDecimal(row["quantity"]);
                a.Purchase_Item_Discount1 = Convert.ToDecimal(row["discount"]);
                a.Purchase_Item_Total1 = Convert.ToDecimal(row["item_total"]);


                purchase.Add(a);
             }
            return purchase;
             }


        public List<stockpagebll> StockSelection()
        {
            DataTable dt = prl.StockSelection();
            List<stockpagebll> stock = new List<stockpagebll>();
            foreach (DataRow row in dt.Rows)
            {
                StockpageBLL add = new StockpageBLL();
                add.Id = Convert.ToInt32(row["item_id"]);
               add.Itemname = Convert.ToString(row["itemname"]);
                add.Item_Quantity1 = Convert.ToDecimal(row["quantity"]);
                add.Barcode = Convert.ToString(row["barcode"]);
                add.Category = Convert.ToString(row["category"]);

                add.ItemUnit_Prize1 = Convert.ToDecimal(row["unitPrize"]);
                add.Profit = Convert.ToDecimal(row["profit"]);


                StockpageDLL stk = new StockpageDLL(Profit,Id);
                stock.Add(add);

            }

            return stock;


        }

推荐答案

decimal total_prize = 0;
foreach (DataRow row in dt.Rows)
{
    PurchaseAccountBLL a = new PurchaseAccountBLL();
    a.Itemname = row["item_name"].ToString();
    a.Id = Convert.ToInt32(row["purchase_id"]);

    a.Purchase_Unit_Prize = Convert.ToDecimal(row["unit_prize"]);
    a.Purchase_Item_Quantity1 = Convert.ToDecimal(row["quantity"]);
    a.Purchase_Item_Discount1 = Convert.ToDecimal(row["discount"]);
    a.Purchase_Item_Total1 = Convert.ToDecimal(row["item_total"]);

    total_prize +=   Convert.ToDecimal(row["unit_prize"]);

    purchase.Add(a);
}
decimal avg = total_prize/dt.Rows.Count;   // this is your average

// user the avg value later...





-KR



-KR


这篇关于我不知道如何计算avarage奖金的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 11:13