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"); } }
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); } }