public int EditGoodReceivedNote(GoodReceivedNoteModel model) { try { using (_context= new HSSNInventoryEntities() ) { var editModel = _context.GoodReceivedNotes.FirstOrDefault(a => a.GoodReceivedNoteId == model.GoodReceivedNoteId); if (editModel != null) { editModel.GoodReceivedBy = model.GoodRecievedBy; editModel.GoodReceivedDate = model.GoodReceivedDate; editModel.CreatedBy = model.CreatedBy; editModel.CreatedDate = model.CreatedDate; } _context.Entry(editModel).State = EntityState.Modified; _context.SaveChanges(); return model.GoodReceivedNoteId; } } catch (Exception e) { Console.WriteLine(e); return 0; } }
public int SaveGoodReceivedNote(MODEL.GoodReceivedNoteModel model) { try { using (_context = new HSSNInventoryEntities()) { var data = new GoodReceivedNote() { JobOrderId = model.JobOrdeId, GoodReceivedDate = model.GoodReceivedDate, GoodReceivedBy = model.GoodRecievedBy, CreatedBy = model.CreatedBy, CreatedDate = model.CreatedDate, ModifiedBy = model.ModifiedBy, ModifiedDate = model.ModifiedDate, }; _context.Entry(data).State = EntityState.Added; _context.SaveChanges(); return(data.GoodReceivedNoteId); } } catch (Exception exception) { Console.WriteLine(exception); throw; } }
private void btnSave_Click(object sender, EventArgs e) { var model = new GoodReceivedNoteModel() { GoodReceivedNoteId = GoodReceivednNoteID, JobOrdeId = Convert.ToInt32(txtJobOrderID.Text), GoodReceivedDate = dtpGoodReceivedDate.Value, GoodRecievedBy = Convert.ToInt32(txtGoodReceivedBy.Text), CreatedBy = Convert.ToInt32(txtCreate.Text), CreatedDate = dtePikerCreate.Value, }; var griddata = datafunc(); if (model.GoodReceivedNoteId == 0) { var goodreceivednoteid = _GoodReceivedNoteService.SaveGoodReceivedNote(model); _GoodReceivedNoteService.SaveGRNDetail(griddata, goodreceivednoteid); RadMessageBox.Show("Saved"); _CommonService.UpdateSerialNumberVoucherType("RGN"); } else { var GRNId = _GoodReceivedNoteService.EditGoodReceivedNote(model); _GoodReceivedNoteService.DeleteGrnDetail(GRNId); _GoodReceivedNoteService.SaveGRNDetail(griddata, GRNId); RadMessageBox.Show("Update Successfull"); } }