Example #1
0
    }//ActionEdit()

    public ActionResult AccountDetail([Bind(Prefix = "ID")] int AccountID) {
      if (!exLogic.User.hasAccess("ACCOUNT.VIEW")) return RedirectToAction("NoAccess", "Home");
      Models.MSTR_Account Account = db.MSTR_Account.Find(AccountID);
      if (Account == null) return RedirectToAction("Error", "Home");
      ViewBag.Title = Account.Name;
      return View(Account);
    }//AccountDetail()
Example #2
0
    public ActionResult AccountEdit(Models.MSTR_Account Account) {
      ViewBag.Title = "Edit Account";
      if (!exLogic.User.hasAccess("ACCOUNT.EDIT")) return RedirectToAction("NoAccess", "Home");

      try {
        if (ModelState.IsValid) {

          if (Session["UserId"] == null) {
            Session["UserId"] = -1;
          }
          Account.ModifiedBy = Util.toInt(Session["UserID"].ToString());
          Account.ModifiedOn = DateTime.Now;

          string SQL = "Update Mstr_Account set Name='" + Account.Name + "',Code='"
                             + Account.Code + "',EmailId='" + Account.EmailId + "',MobileNo='"
                             + Account.MobileNo + "',OfficeNo='" + Account.OfficeNo + "',IsActive='" + Account.IsActive + "',ModifiedBy=" + Session["UserId"] +
                             ",ModifiedOn='" + DateTime.Now.ToString("yyyy - MM - dd") + "', AccountDescription='" + Account.AccountDescription +
                             "',Address1='" + Account.Address1 + "', Address2='" + Account.Address2 + "' ,Address3='" + Account.Address3 +
                             "',CountryCode=" + Account.CountryCode + ",ContactName='" + Account.ContactName + "',ContactTitle='" +
                             Account.ContactTitle + "' where AccountId=" + Account.AccountId;

          int id = Util.doSQL(SQL);

          /* db.Entry(Account).Property(x => x.CreatedBy).IsModified = false;
             db.Entry(Account).Property(x => x.CreatedOn).IsModified = false;
             db.MSTR_Account.Add(Account);
             db.SaveChanges();*/
          return RedirectToAction("Account");
        }
      } catch (Exception ex) {
        //Log the error (uncomment dex variable name and add a line here to write a log.
        return View("InternalError", ex);
      }

      //for the server side validation
      var viewModel = new ViewModel.AccountViewModel {



        Account = db.MSTR_Account.Find(Account.AccountId),

        CountryList = Util.GetCountryLists("Country", "CountryName", "Code", "sp"),
      };
      return View(viewModel);

    }//ActionEdit()