public static void SaveList(List <HCMIS.Desktop.STVSyncService.STVList> list, int userID) { BLL.ReceiptInvoice bv = new BLL.ReceiptInvoice(); foreach (HCMIS.Desktop.STVSyncService.STVList v in list) { // try to load by primary key bv.LoadBySTVNoAndAccountType(v.STVNo, v.AccountID); // if the entry doesn't exist, create it if (bv.RowCount == 0) { BLL.PO po = new BLL.PO(); po.AddNew(); if (v.AccountID.HasValue) { po.StoreID = v.AccountID.Value; } po.SupplierID = BLL.Supplier.CONSTANTS.HOME_OFFICE; if (v.HubID.HasValue) { po.PONumber = v.HubID.Value + "-" + v.STVNo; } po.Save(); bv.AddNew(); bv.STVOrInvoiceNo = v.STVNo.ToString(); bv.InvoiceTypeID = BLL.ReceiptInvoiceType.InvoiceType.STV; bv.DateOfEntry = DateTimeHelper.ServerDateTime; bv.POID = po.ID; bv.SavedByUserID = userID; } // populate the contents of v on the to the database list bv.TotalValue = v.InvoiceTotalValue; bv.Insurance = v.Insurance; bv.SavedByUserID = userID; bv.Save(); } }
public static void SaveList(List<HCMIS.Desktop.STVSyncService.STVList> list, int userID) { BLL.ReceiptInvoice bv = new BLL.ReceiptInvoice(); foreach (HCMIS.Desktop.STVSyncService.STVList v in list) { // try to load by primary key bv.LoadBySTVNoAndAccountType(v.STVNo, v.AccountID); // if the entry doesn't exist, create it if (bv.RowCount == 0) { BLL.PO po = new BLL.PO(); po.AddNew(); if (v.AccountID.HasValue) po.StoreID = v.AccountID.Value; po.SupplierID = BLL.Supplier.CONSTANTS.HOME_OFFICE; if (v.HubID.HasValue) po.PONumber = v.HubID.Value + "-" + v.STVNo; po.Save(); bv.AddNew(); bv.STVOrInvoiceNo = v.STVNo.ToString(); bv.InvoiceTypeID = BLL.ReceiptInvoiceType.InvoiceType.STV; bv.DateOfEntry = DateTimeHelper.ServerDateTime; bv.POID = po.ID; bv.SavedByUserID = userID; } // populate the contents of v on the to the database list bv.TotalValue = v.InvoiceTotalValue; bv.Insurance = v.Insurance; bv.SavedByUserID = userID; bv.Save(); } }