public static List <Model.SupplierBill> GetModelList(string where) { string sql = "select distinct Corporation,Project,Supplier from SaleInfo"; //目前先从SaleInfo里面拿 if (!string.IsNullOrEmpty(where)) { sql += " where " + where + " "; } DataSet ds = DbHelperSQL.Query(sql); List <Model.SupplierBill> res = new List <Model.SupplierBill>(); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow row in ds.Tables[0].Rows) { Model.SupplierBill model = new Model.SupplierBill(); if (row["Corporation"] != null && row["Corporation"].ToString() != "") { model.Corporation = row["Corporation"].ToString(); } if (row["Project"] != null && row["Project"].ToString() != "") { model.Project = row["Project"].ToString(); } if (row["Supplier"] != null && row["Supplier"].ToString() != "") { model.Supplier = row["Supplier"].ToString(); } res.Add(model); } return(res); } else { return(null); } }
private void FillModel(Model.SupplierBill supplier) { List <Model.PurchaseInfo> purchaseList = _bllPurchaseInfo.GetModelList( string.Format(" Corporation = '{0}' and Project = '{1}' and Supplier = '{2}'", supplier.Corporation, supplier.Project, supplier.Supplier)); foreach (var model in purchaseList) { supplier.TotalPurchase += model.TotalMoney ?? 0; supplier.PurchaseAmount += model.Amount ?? 0; supplier.TransportCost += model.TransportCost ?? 0; } List <Model.SaleInfo> saleInfoList = _bllSaleInfo.GetModelList( string.Format(" Corporation = '{0}' and Project = '{1}' and Supplier = '{2}'", supplier.Corporation, supplier.Project, supplier.Supplier)); foreach (var model in saleInfoList) { supplier.TotalSale += model.TotalSale ?? 0; supplier.SaleAmount += model.Amount ?? 0; } }