public void SaveUpdateRecord(PenaltySlabViewModel penalty) { Mst_PenaltySlab tblPenaltySlab = new Mst_PenaltySlab(); try { if (penalty.EditID <= 0) { penalty.ID = _context.Mst_PenaltySlab.Any() ? _context.Mst_PenaltySlab.Max(m => m.Ps_Id) + 1 : 1; tblPenaltySlab.Ps_Id = penalty.ID; tblPenaltySlab.Ps_RecordCreated = DateTime.Now; tblPenaltySlab.Ps_RecordCreatedBy = penalty.CreatedBy; _context.Mst_PenaltySlab.Add(tblPenaltySlab); } else { tblPenaltySlab = _context.Mst_PenaltySlab.Where(x => x.Ps_Id == penalty.ID).FirstOrDefault(); } tblPenaltySlab.Ps_Datewef = Convert.ToDateTime(penalty.Datewef); tblPenaltySlab.Ps_Penalty = penalty.PenaltyAmount; tblPenaltySlab.Ps_Accounthead = penalty.AccountHead; tblPenaltySlab.Ps_RecordUpdated = DateTime.Now; tblPenaltySlab.Ps_RecordUpdatedBy = penalty.UpdatedBy; _context.SaveChanges(); } catch (Exception ex) { throw ex; } }
public PenaltySlabViewModel SetRecordinEdit(Mst_PenaltySlab tblPenalty) { PenaltySlabViewModel penalty = new PenaltySlabViewModel(); penalty.ID = tblPenalty.Ps_Id; penalty.EditID = tblPenalty.Ps_Id; penalty.Datewef = tblPenalty.Ps_Datewef.ToString("dd/MM/yyyy"); penalty.PenaltyAmount = tblPenalty.Ps_Penalty; penalty.AccountHead = tblPenalty.Ps_Accounthead; return(penalty); }
public ActionResult GetPenaltySlabById(int ID) { string operation = Session["Operation"].ToString(); ButtonVisiblity(operation); ViewBag.AccountHeadList = new SelectList(dd._context.tblaccountmasters.ToList(), "AccountID", "Name"); Mst_PenaltySlab tblPenalty = dd._context.Mst_PenaltySlab.Where(x => x.Ps_Id == ID).FirstOrDefault(); PenaltySlabViewModel penalty = new PenaltySlabViewModel(); penalty.ID = tblPenalty.Ps_Id; penalty.EditID = tblPenalty.Ps_Id; penalty.Datewef = tblPenalty.Ps_Datewef.ToString("dd/MM/yyyy"); penalty.PenaltyAmount = tblPenalty.Ps_Penalty; penalty.AccountHead = tblPenalty.Ps_Accounthead; penalty.operation = operation; return(View("PenaltySlab", penalty)); }
public bool InsertData(PenaltySlabViewModel penalty) { bool retVal = false; penalty.CreatedBy = Convert.ToInt32(Session["UserLoginId"]); penalty.UpdatedBy = Convert.ToInt32(Session["UserLoginId"]); Mst_PenaltySlab tblPenaltySlab = new Mst_PenaltySlab(); try { if (penalty.EditID <= 0) { penalty.ID = dd._context.Mst_PenaltySlab.Any() ? dd._context.Mst_PenaltySlab.Max(m => m.Ps_Id) + 1 : 1; tblPenaltySlab.Ps_Id = penalty.ID; tblPenaltySlab.Ps_RecordCreated = DateTime.Now; tblPenaltySlab.Ps_RecordCreatedBy = penalty.CreatedBy; dd._context.Mst_PenaltySlab.Add(tblPenaltySlab); } else { tblPenaltySlab = dd._context.Mst_PenaltySlab.Where(x => x.Ps_Id == penalty.ID).FirstOrDefault(); } tblPenaltySlab.Ps_Datewef = Convert.ToDateTime(penalty.Datewef); tblPenaltySlab.Ps_Penalty = penalty.PenaltyAmount; tblPenaltySlab.Ps_Accounthead = penalty.AccountHead; tblPenaltySlab.Ps_RecordUpdated = DateTime.Now; tblPenaltySlab.Ps_RecordUpdatedBy = penalty.UpdatedBy; dd._context.SaveChanges(); retVal = true; } catch (Exception ex) { throw ex; } return(retVal); }
public PenaltySlabViewModel SetDataOnEdit(Mst_PenaltySlab tblPenalty) { var item = _penaltyslabRepository.SetRecordinEdit(tblPenalty); return(item); }