public static int fnSaveProductNoteToDB(ProductNote PN) { using (var db = new EF.CMCSQL03Entities()) { if (PN.productnoteid == -1) { var newrec = new EF.tblPPPDLogNote(); db.tblPPPDLogNote.Add(newrec); db.SaveChanges(); PN.productnoteid = newrec.PPPDLogNoteID; } var q = (from t in db.tblPPPDLogNote where t.PPPDLogNoteID == PN.productnoteid select t).FirstOrDefault(); q.ProductDetailID = PN.productdetailid; q.NoteDate = PN.notedate; q.Notes = PN.notes; q.ReasonCode = PN.reasoncode; db.SaveChanges(); return q.PPPDLogNoteID; } }
public static ProductNote fnCreateProductNote(int id) { ProductNote PN = new ProductNote(); using (var db = new EF.CMCSQL03Entities()) { PN.productnoteid = -1; PN.productdetailid = id; // important PN.reasoncode = null; PN.notedate = DateTime.Now; PN.notes = null; PN.ListOfReasonCodes = (from t in db.tblReasonCode orderby t.Reason select new SelectListItem { Value = t.Reason, Text = t.Reason }).ToList(); PN.ListOfReasonCodes.Insert(0, new SelectListItem { Value = "", Text = "Select Reason Code" }); } return PN; }
public static ProductNote fnGetProductNote(int id) { ProductNote PN = new ProductNote(); using (var db = new EF.CMCSQL03Entities()) { var q = (from t in db.tblPPPDLogNote where t.PPPDLogNoteID == id select t).FirstOrDefault(); PN.productnoteid = q.PPPDLogNoteID; PN.productdetailid = q.ProductDetailID; PN.reasoncode = q.ReasonCode; PN.notedate = q.NoteDate; PN.notes = q.Notes; PN.ListOfReasonCodes = (from t in db.tblReasonCode orderby t.Reason select new SelectListItem { Value = t.Reason, Text = t.Reason }).ToList(); PN.ListOfReasonCodes.Insert(0, new SelectListItem { Value = "", Text = "Select Reason Code" }); } return PN; }
public ActionResult SaveProductNote(ProductNote PN) { int pk = ProductsService.fnSaveProductNoteToDB(PN); return Content("Data Updated at " + DateTime.Now); }