예제 #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Maticsoft.Model.ConsumableInfo> DataTableToList(DataTable dt)
        {
            List <Maticsoft.Model.ConsumableInfo> modelList = new List <Maticsoft.Model.ConsumableInfo>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Maticsoft.Model.ConsumableInfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Maticsoft.Model.ConsumableInfo();
                    if (dt.Rows[n]["Csm_ID"] != null && dt.Rows[n]["Csm_ID"].ToString() != "")
                    {
                        model.Csm_ID = decimal.Parse(dt.Rows[n]["Csm_ID"].ToString());
                    }
                    if (dt.Rows[n]["C_Type"] != null && dt.Rows[n]["C_Type"].ToString() != "")
                    {
                        model.C_Type = dt.Rows[n]["C_Type"].ToString();
                    }
                    if (dt.Rows[n]["C_Barcode"] != null && dt.Rows[n]["C_Barcode"].ToString() != "")
                    {
                        model.C_Barcode = dt.Rows[n]["C_Barcode"].ToString();
                    }
                    if (dt.Rows[n]["C_Name"] != null && dt.Rows[n]["C_Name"].ToString() != "")
                    {
                        model.C_Name = dt.Rows[n]["C_Name"].ToString();
                    }
                    if (dt.Rows[n]["C_AliasName"] != null && dt.Rows[n]["C_AliasName"].ToString() != "")
                    {
                        model.C_AliasName = dt.Rows[n]["C_AliasName"].ToString();
                    }
                    if (dt.Rows[n]["C_Model"] != null && dt.Rows[n]["C_Model"].ToString() != "")
                    {
                        model.C_Model = dt.Rows[n]["C_Model"].ToString();
                    }
                    if (dt.Rows[n]["C_Address"] != null && dt.Rows[n]["C_Address"].ToString() != "")
                    {
                        model.C_Address = dt.Rows[n]["C_Address"].ToString();
                    }
                    if (dt.Rows[n]["C_Function"] != null && dt.Rows[n]["C_Function"].ToString() != "")
                    {
                        model.C_Function = dt.Rows[n]["C_Function"].ToString();
                    }
                    if (dt.Rows[n]["C_Lifetime"] != null && dt.Rows[n]["C_Lifetime"].ToString() != "")
                    {
                        model.C_Lifetime = dt.Rows[n]["C_Lifetime"].ToString();
                    }
                    if (dt.Rows[n]["C_LifeUnit"] != null && dt.Rows[n]["C_LifeUnit"].ToString() != "")
                    {
                        model.C_LifeUnit = dt.Rows[n]["C_LifeUnit"].ToString();
                    }
                    if (dt.Rows[n]["C_SafeStock"] != null && dt.Rows[n]["C_SafeStock"].ToString() != "")
                    {
                        model.C_SafeStock = dt.Rows[n]["C_SafeStock"].ToString();
                    }
                    if (dt.Rows[n]["C_Unit"] != null && dt.Rows[n]["C_Unit"].ToString() != "")
                    {
                        model.C_Unit = dt.Rows[n]["C_Unit"].ToString();
                    }
                    if (dt.Rows[n]["C_Picture"] != null && dt.Rows[n]["C_Picture"].ToString() != "")
                    {
                        model.C_Picture = dt.Rows[n]["C_Picture"].ToString();
                    }
                    if (dt.Rows[n]["C_Manufacturer"] != null && dt.Rows[n]["C_Manufacturer"].ToString() != "")
                    {
                        model.C_Manufacturer = dt.Rows[n]["C_Manufacturer"].ToString();
                    }
                    if (dt.Rows[n]["C_Official_Website"] != null && dt.Rows[n]["C_Official_Website"].ToString() != "")
                    {
                        model.C_Official_Website = dt.Rows[n]["C_Official_Website"].ToString();
                    }
                    if (dt.Rows[n]["C_Tel"] != null && dt.Rows[n]["C_Tel"].ToString() != "")
                    {
                        model.C_Tel = dt.Rows[n]["C_Tel"].ToString();
                    }
                    if (dt.Rows[n]["C_After_Sale"] != null && dt.Rows[n]["C_After_Sale"].ToString() != "")
                    {
                        model.C_After_Sale = dt.Rows[n]["C_After_Sale"].ToString();
                    }
                    if (dt.Rows[n]["C_PurchasCycle"] != null && dt.Rows[n]["C_PurchasCycle"].ToString() != "")
                    {
                        model.C_PurchasCycle = dt.Rows[n]["C_PurchasCycle"].ToString();
                    }
                    if (dt.Rows[n]["C_Remarks"] != null && dt.Rows[n]["C_Remarks"].ToString() != "")
                    {
                        model.C_Remarks = dt.Rows[n]["C_Remarks"].ToString();
                    }

                    //通过计算得出当前库存
                    Maticsoft.DAL.ConsumableReceive _M_Re = new Maticsoft.DAL.ConsumableReceive();
                    Maticsoft.DAL.ConsumableStorage _M_St = new Maticsoft.DAL.ConsumableStorage();
                    double _storageCount = _M_St.Get_Stock(model.C_Barcode);
                    double _receiveCount = _M_Re.Get_Stock(model.C_Barcode);
                    model.Stock = (_storageCount - _receiveCount).ToString();

                    modelList.Add(model);
                }
            }
            return(modelList);
        }