public ActionResult UpdateSubAccount(VMSubAccount SubAccount) { try { if (ModelState.IsValid) { tblUser user = Session[WebUtil.CURRENT_USER] as tblUser; if (!(user != null)) { return(RedirectToAction("RedirectToLogin", "user")); } tblSubAccount Table = (SubAccount).TotblSubAccount(); Table.CompanyId = user.CompanyId; Table.ModifiedBy = user.Id; Table.ModifiedDate = DateTime.Now; new SubAccountHandler().UpdateSubAccount(SubAccount.Id, Table); return(JavaScript("showMessage('success', 'Account updated Successfully','bottom-right','SubAccount', 'Manage')")); } else { return(JavaScript("showMessage('error', 'All fields are required, Please try again','bottom-right','Account', 'Manage')")); } } catch (Exception ex) { return(JavaScript("showMessage('error', 'Failed to update Account, Please Contact to Administrator','bottom-right','Account', 'Manage')")); } }
public static tblSubAccount TotblSubAccount(this VMSubAccount model) { tblSubAccount entity = new tblSubAccount(); entity.SubAccountName = model.SubAccountName; entity.Description = model.Description; entity.Amount = model.Amount; entity.AccountId = model.AccountId; entity.TypeId = model.TypeId; entity.AccountNumber = model.AccountNumber; return(entity); }
public static VMSubAccount ToVMSubAccount(this ViewSubAccount entity) { VMSubAccount model = new VMSubAccount(); model.Id = entity.Id; model.AccountName = entity.ParentAccount; model.CompanyName = entity.Company; model.SubAccountName = entity.SubAccountName; model.Description = entity.Description; model.Amount = (decimal)entity.Amount; model.AccountId = (long)entity.AccountId; model.TypeId = (long)entity.TypeId; model.AccountNumber = entity.AccountNumber; model.SubTypeName = entity.SubtypeName; return(model); }
public ActionResult AddSubAccount(VMSubAccount SubAccount) { try { if (ModelState.IsValid) { if (SubAccount.SubAccountName == "Initial Cash") { return(JavaScript("showMessage('error', 'Please Change Your Sub Account Name','bottom-right','SubAccount', 'Manage')")); } tblUser user = Session[WebUtil.CURRENT_USER] as tblUser; if (!(user != null)) { return(RedirectToAction("RedirectToLogin", "user")); } //decimal? InitialCash = new SubAccountHandler().GetAmountOfInitialCashAccountOfCompany((long)user.CompanyId); //if (InitialCash < SubAccount.Amount) //{ // return JavaScript("showMessage('error', 'You dont have enough money in initial cash account','bottom-right','SubAccount', 'Manage')"); //} //else //{ tblSubAccount Table = (SubAccount).TotblSubAccount(); Table.CompanyId = user.CompanyId; Table.CreatedBy = user.Id; Table.CreatedDate = DateTime.Now; new SubAccountHandler().AddSubAccount(Table); return(JavaScript("showMessage('success', 'SubAccount added Successfully','bottom-right','SubAccount', 'Manage')")); //} } else { return(JavaScript("showMessage('error', 'All fields are required, Please try again','bottom-right','SubAccount', 'Manage')")); } } catch (Exception ex) { return(JavaScript("showMessage('error', 'Failed to Add SubAccount, Please Contact to Administrator','bottom-right','SubAccount', 'Manage')")); } }