public bool billPaid(int BillId) {//upates balance onhand ; bill can not be modified now. //If bill is already paid ; error bill_master v = (from x in dc.GetTable <bill_master>() where x.billid == BillId select x).SingleOrDefault(); var abc = (from x in dc.GetTable <case_master>() where x.caseid == v.caseid select x).SingleOrDefault(); abc.isactive = "no"; dc.SubmitChanges(); v.paid = "yes"; long sal, starting_balance, final_balance; sal = v.total; starting_balance = getBalance(); final_balance = starting_balance + sal; cost c = new cost(); c.date = DateTime.Now; c.starting_balance = starting_balance; c.billid = BillId; c.chequeid = 0; c.final_balance = final_balance; setBalance(final_balance); dc.costs.InsertOnSubmit(c); dc.SubmitChanges(); return(true); }
//Bills public int createBill(int CaseId) { bill_master b = new bill_master(); b.caseid = CaseId; b.date = DateTime.Now; b.paid = "No"; b.total = 0; dc.bill_masters.InsertOnSubmit(b); dc.SubmitChanges(); return(b.billid); }
public bool addItemsToBill(int BillId, int itemid, int qty) { bill_item bi = new bill_item(); bi.billid = BillId; bi.itemid = itemid; bi.qty = qty; dc.bill_items.InsertOnSubmit(bi); dc.SubmitChanges(); bill_master bil = (from x in dc.GetTable <bill_master>() where x.billid == BillId select x).SingleOrDefault(); item cos = (from x in dc.GetTable <item>() where x.itemid == itemid select x).SingleOrDefault(); bil.total += (cos.cost_per_item * qty); dc.SubmitChanges(); return(true); }