public static bool PostPurchaseJournal(Journal j, List <Product_Supplier> listProduct_Supplier, List <Journal_Details> listJournal_Details, int amount, double paymentDue) { int serial = 1; try { if (listJournal_Details.Count > 0) { foreach (var item in listJournal_Details) { item.SNO = serial++; item.Journal = j; } } else { Journal_Details jd = new Journal_Details(); jd.SNO = 1; jd.Sub_Account_ID = 1; ///cash account jd.Amount = amount; jd.Narration = ""; jd.Journal = j; } foreach (var ps in listProduct_Supplier) { ps.Journal = j; } //var ps = db.Product_Suppliers.OrderByDescending(ep => ep.ID).FirstOrDefault(); //ps.Journal = j; ///adding journal id in product supplier db.Journals.Add(j); //db.SubmitChanges(); return(true); } catch (Exception ex) { throw new Exception(ex.Message); } }
public static Journal PostSalesJournal(Sale sale, Journal j, List <Journal_Details> listJournal_Details, int amount, double paymentDue)///DateTime datetime, int sub_accountID1, int sub_accountID2, int jurnalType, int status, int prepBy, int authBy, int amount { try { int serial = 1; if (listJournal_Details.Count > 0) { foreach (var item in listJournal_Details) { item.SNO = serial++; item.Journal = j; } } else { Journal_Details jd = new Journal_Details(); jd.SNO = 1; jd.Sub_Account_ID = 1; ///cash account jd.Amount = amount; jd.Narration = ""; jd.Journal = j; } sale.Journal = j; /// assigning journal id in sales invoice //var sale = db.Sales.OrderByDescending(ep => ep.Invoice_ID).FirstOrDefault(); //sale.Journal = j; db.Journals.Add(j); //db.SubmitChanges(); return(j); } catch (Exception ex) { throw new Exception(ex.Message); } }