//data: { pdate: pdate, ptype: ptype, pnote: pnote, pinvid: pinvid}, public String save_it(String pdate, String ptype, Int64 pinvid, String pnote) { try { DateTime datenow = Convert.ToDateTime(pdate); using (var db = new dbsmsEntities()) { purchasepayment newdata = new purchasepayment(); newdata.date = datenow; newdata.description = ""; newdata.purchaseinvoiceid = pinvid; newdata.supplierid = db.hpurchaseinvoices.Find(pinvid).supplierid; newdata.projectid = Convert.ToInt64(Session["project"]); newdata.type = ptype; newdata.note = pnote; newdata.total = db.hpurchaseinvoices.Find(pinvid).grandtotal; newdata.number = db.hpurchaseinvoices.Find(pinvid).number; db.hpurchaseinvoices.Find(pinvid).status = 1; db.purchasepayments.Add(newdata); db.projects.Find(Convert.ToInt64(Session["project"])).status1.purchasepayment = 1; db.SaveChanges(); return(GlobalFunction.get_max_id("purchasepayment").ToString()); } } catch (Exception e) { return("fail"); } }
public String delete_it(Int64 id) { try { using (var db = new dbsmsEntities()) { purchasepayment data = db.purchasepayments.Find(id); data.hpurchaseinvoice.status = 0; db.purchasepayments.Remove(data); db.SaveChanges(); return("success"); } } catch { return("fail"); } }