private void UpdateInvoiceTotal(int invoiceDetailID, bool flag) { PurchaseInvoiceHeader pih = new PurchaseInvoiceHeader(); PurchaseInvoiceDetail pid = new PurchaseInvoiceDetail(); PurchaseInvoiceDetailCollection pidColl = new PurchaseInvoiceDetailCollection(); try { pid = pid.GetPurchaseInvoiceDetails(invoiceDetailID); int invoiceID = pid.InvoiceID; string where = "invoiceID = " + invoiceID; string orderby = String.Empty; pidColl = pid.GetPurchaseInvoiceDetailsCollection(where, orderby); decimal total = 0.00m; foreach (PurchaseInvoiceDetail p in pidColl) { total += (decimal)(p.UnitPrice * p.Quantity); } pih = pih.GetPurchaseInvoiceHeader(invoiceID); pih.TotalDue = total; pih.UpdatePurchaseInvoiceHeader(pih); } catch (Exception ex) { log.Write(ex.Message, "UpdateInvoiceTotal"); throw (ex); } finally { pih = null; pid = null; pidColl = null; } }
public PurchaseInvoiceDetailCollection GetPurchaseInvoiceDetailsCollection(string where, string orderBy) { PurchaseInvoiceDetailData data = new PurchaseInvoiceDetailData(); PurchaseInvoiceDetailCollection col = new PurchaseInvoiceDetailCollection(); try { col = data.GetAllPurchaseInvoiceDetailDynamicCollection(where, orderBy); } catch (Exception ex) { log.Write(ex.Message, "GetPurchaseInvoiceDetailsCollection"); throw (ex); } finally { data = null; } return(col); }
public PurchaseInvoiceDetailCollection GetAllPurchaseInvoiceDetailsCollection(int purchaseInvoiceDetailsID) { PurchaseInvoiceDetailData data = new PurchaseInvoiceDetailData(); PurchaseInvoiceDetailCollection col = new PurchaseInvoiceDetailCollection(); try { col = data.GetAllPurchaseInvoiceDetailCollection(purchaseInvoiceDetailsID); } catch (Exception ex) { log.Write(ex.Message, "GetAllPurchaseInvoiceDetailsCollection"); throw (ex); } finally { data = null; } return(col); }
public bool RemovePurchaseInvoiceDetail(PurchaseInvoiceDetailCollection col) { PurchaseInvoiceDetailData data = new PurchaseInvoiceDetailData(); bool ret = false; try { ret = data.DeletePurchaseInvoiceDetail(col); UpdateInvoiceTotal(col); } catch (Exception ex) { log.Write(ex.Message, "RemovePurchaseInvoiceDetail"); throw (ex); } finally { data = null; } return(ret); }