public ActionResult UpdateOPAccount(FormCollection frmcollection) { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User Updated Item! (Maintenance Nature of Payments) - from Terminal:" + ipaddress); OPAccount opaccountinfo = null; ApplicationDbContext context = new ApplicationDbContext(); var OPAFee = frmcollection["OPAccountFee"].ToString().Replace(",", ""); var userid = User.Identity.GetUserId(); string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup; string Division = context.Users.FirstOrDefault(x => x.Id == userid).Division; int ParsedIntCompanyID = int.Parse(frmcollection["OPAccountId1"]); opaccountinfo = db.OPAccount.Find(ParsedIntCompanyID); if (opaccountinfo != null) { opaccountinfo.OPAccountCode = frmcollection["OPAccountCode"].ToString(); opaccountinfo.NGASCode = frmcollection["OPAccountNGASCode"].ToString(); opaccountinfo.OPAccountDescription = frmcollection["OPAccountDescription"].ToString(); opaccountinfo.OPAccountFee = Convert.ToDecimal(OPAFee); opaccountinfo.DivisionCode = frmcollection["DivisionCode"]; opaccountinfo.ZoneGroupCode = ZoneGroup; opaccountinfo.OPAccountDescription = frmcollection["OPAccountDescription"].ToString(); opaccountinfo.OPAccountValidity = frmcollection["OPAccountValidity"].ToString(); opaccountinfo.AccountTag = frmcollection["AccountTag"].ToString(); db.Entry(opaccountinfo).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } foreach (var results in db.OrderOfPaymentDetail.Where(b => b.OPAccountId == ParsedIntCompanyID)) { results.AccountTag = frmcollection["AccountTag"].ToString(); } db.SaveChanges(); int parsedCompanyID = int.Parse(frmcollection["OPAccountId1"]); SearchOPAccountsViewModel searchopaccount = new SearchOPAccountsViewModel(); //searchopaccount.OPAccountList = db.OPAccount.Where(x => x.ZoneGroupCode == ZoneGroup).OrderBy(x => x.OPAccountDescription).Take(10).ToList(); searchopaccount.OPAccountList = db.OPAccount.Where(x => x.OPAccountId == parsedCompanyID).ToList(); searchopaccount.DivisionList = db.Division.SqlQuery("Select * from Divisions").ToList(); ViewBag.TransactionSuccess = "Edit"; ViewBag.CompanySelected = "OK"; return(View("ViewOrderOfPaymentAccounts", searchopaccount)); }
public ActionResult RemoveOPAccounts(FormCollection frm) { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User Deleted Item! (Maintenance Nature of Payments) - from Terminal:" + ipaddress); SearchOPAccountsViewModel SearchOPAccountViewModels = new SearchOPAccountsViewModel(); int parsedID = int.Parse(frm["OPAccountId"]); OPAccount opaccount = db.OPAccount.Find(parsedID); db.OPAccount.Remove(opaccount); db.SaveChanges(); ApplicationDbContext context = new ApplicationDbContext(); var userid = User.Identity.GetUserId(); string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup; string Division = context.Users.FirstOrDefault(x => x.Id == userid).Division; //SearchOPAccountViewModels.OPAccountList = db.OPAccount.SqlQuery("Select * from OPAccounts Where ZoneGroupCode = '" + ZoneGroup + "'").ToList(); SearchOPAccountViewModels.OPAccountList = db.OPAccount.Where(x => x.ZoneGroupCode == ZoneGroup).OrderBy(x => x.OPAccountDescription).ToList(); SearchOPAccountViewModels.DivisionList = db.Division.SqlQuery("Select * from Divisions").ToList(); TempData["TransactionSuccess"] = "delete"; TempData["SearchOPAccountViewModels"] = SearchOPAccountViewModels; return(RedirectToAction("ViewOrderOfPaymentAccounts", "MaintenanceOrderOfPaymentAccounts")); }
public ActionResult AddOPAccount(FormCollection frmcollection) { SL.LogInfo(User.Identity.Name, Request.RawUrl, "User Added Item! (Maintenance Nature of Payments) - from Terminal:" + ipaddress); SearchOPAccountsViewModel SearchOPAccountViewModels = new SearchOPAccountsViewModel(); ApplicationDbContext context = new ApplicationDbContext(); var FeeVal = frmcollection["OPAccountFee"]; if (FeeVal.Contains(".")) { } else { FeeVal = FeeVal + ".00"; } var userid = User.Identity.GetUserId(); string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup; string Division = context.Users.FirstOrDefault(x => x.Id == userid).Division; OPAccount OPAccountAssignment = new OPAccount(); //CONDITION OPAccountAssignment.OPAccountCode = frmcollection["OPAccountCode"].ToString(); OPAccountAssignment.NGASCode = frmcollection["OPAccountNGASCode"].ToString(); OPAccountAssignment.OPAccountDescription = frmcollection["OPAccountDescription"].ToString(); OPAccountAssignment.OPAccountFee = Convert.ToDecimal(FeeVal); OPAccountAssignment.OPAccountValidity = frmcollection["OPAccountValidity"].ToString(); OPAccountAssignment.DivisionCode = frmcollection["DivisionCode"]; OPAccountAssignment.ZoneGroupCode = ZoneGroup; OPAccountAssignment.AccountTag = frmcollection["AddAccountTag"]; db.OPAccount.Add(OPAccountAssignment); db.SaveChanges(); //SearchOPAccountViewModels.OPAccountList = db.OPAccount.Where(x => x.ZoneGroupCode == ZoneGroup).OrderBy(x => x.OPAccountDescription).ToList(); SearchOPAccountViewModels.OPAccountList = db.OPAccount.Where(x => x.ZoneGroupCode == ZoneGroup).OrderBy(x => x.OPAccountDescription).Take(50).ToList(); SearchOPAccountViewModels.DivisionList = db.Division.SqlQuery("Select * from Divisions").ToList(); TempData["TransactionSuccess"] = "Add"; TempData["SearchOPAccountViewModels"] = SearchOPAccountViewModels; return(RedirectToAction("ViewOrderOfPaymentAccounts", "MaintenanceOrderOfPaymentAccounts")); }