public static InventoryLogNote fnCreateInventoryLogNote(int id) { InventoryLogNote obj = new InventoryLogNote(); using (var db = new EF.CMCSQL03Entities()) { obj.productnoteid = -1; obj.productmasterid = id; // important obj.reasoncode = null; obj.notedate = DateTime.UtcNow; obj.notes = null; obj.ListOfReasonCodes = (from t in db.tblReasonCode orderby t.Reason select new SelectListItem { Value = t.Reason, Text = t.Reason }).ToList(); obj.ListOfReasonCodes.Insert(0, new SelectListItem { Value = "", Text = "Select Reason Code" }); } return obj; }
public static int fnSaveInventoryLogNote(InventoryLogNote obj) { using (var db = new EF.CMCSQL03Entities()) { if (obj.productnoteid == -1) { var newrec = new EF.tblInvPMLogNote(); db.tblInvPMLogNote.Add(newrec); db.SaveChanges(); obj.productnoteid = newrec.InvPMLogNoteIDID; } var q = (from t in db.tblInvPMLogNote where t.InvPMLogNoteIDID == obj.productnoteid select t).FirstOrDefault(); q.ProductMasterID = obj.productmasterid; q.NoteDate = DateTime.UtcNow; q.Notes = obj.notes; q.Comment = obj.reasoncode; db.SaveChanges(); return q.InvPMLogNoteIDID; } }
public static InventoryLogNote fnGetInventoryNote(int id) { InventoryLogNote obj = new InventoryLogNote(); using (var db = new EF.CMCSQL03Entities()) { var q = (from t in db.tblInvPMLogNote where t.InvPMLogNoteIDID == id select t).FirstOrDefault(); obj.productnoteid = q.InvPMLogNoteIDID; obj.productmasterid = q.ProductMasterID; obj.reasoncode = q.Comment; obj.notedate = q.NoteDate; obj.notes = q.Notes; obj.ListOfReasonCodes = (from t in db.tblReasonCode orderby t.Reason select new SelectListItem { Value = t.Reason, Text = t.Reason }).ToList(); obj.ListOfReasonCodes.Insert(0, new SelectListItem { Value = "", Text = "Select Reason Code" }); } return obj; }
public ActionResult SaveInventoryLogNote(InventoryLogNote obj) { int pk = InventoryService.fnSaveInventoryLogNote(obj); return null; }