private List <AccountsHead> AddAcctHeadToSession(AccountsHead accountHead) { var acctHeadList = new List <AccountsHead>(); try { if (Session["_newAcctHeadList"] == null) { acctHeadList.Add(accountHead); Session["_newAcctHeadList"] = acctHeadList; return(acctHeadList); } var accountHeadList = Session["_newAcctHeadList"] as List <AccountsHead>; if (accountHeadList == null || !accountHeadList.Any()) { acctHeadList.Add(accountHead); Session["_newAcctHeadList"] = acctHeadList; return(accountHeadList); } acctHeadList.Add(accountHead); Session["_newAcctHeadList"] = acctHeadList; return(acctHeadList); } catch (Exception) { return(null); } }
public JsonResult AddAccountHead(AccountsHead accountsHead) { var concernId = Convert.ToInt32(Session["ConcernId"]); var userId = Convert.ToInt32(Session["UserId"]); _settings.AddAccountHead(accountsHead, userId, concernId); return(Json("added succes", JsonRequestBehavior.AllowGet)); }
public void AddAccountHead(AccountsHead accountsHead, int userId, int concernId) { accountsHead.CreationDate = DateTime.Now; accountsHead.IsDelete = 0; accountsHead.CreatorId = userId; accountsHead.ConcernId = concernId; accountsHead.ModificationDate = DateTime.Now; accountsHead.ModifierId = userId; _context.AccountsHeads.Add(accountsHead); _context.SaveChanges(); }
public int UpdateAccountsHead(AccountsHead accountsHead) { try { return(_accountsHeadManager.UpdateAccountsHead(accountsHead)); } catch (Exception ex) { ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public static TR Map <T, TR>(T sourceObject) where T : class where TR : class { if (sourceObject == null) { return(null); } Type myType = typeof(T); if (myType == typeof(AccountsHead)) { var objItem = new ExpenseManager.EF.AccountsHead(); var myItem = sourceObject as AccountsHead; if (myItem == null) { return(null); } ; try { objItem.AccountsHeadId = myItem.AccountsHeadId; objItem.ExpenseCategoryId = myItem.ExpenseCategoryId; objItem.Title = myItem.Title; objItem.Description = myItem.Description; objItem.Code = myItem.Code; objItem.Status = myItem.Status; } catch (Exception ex) { return(new AccountsHead() as TR); } return(objItem as TR); } if (myType == typeof(ExpenseManager.EF.AccountsHead)) { var objItem = new AccountsHead(); var myItem = sourceObject as ExpenseManager.EF.AccountsHead; if (myItem == null) { return(null); } ; try { objItem.AccountsHeadId = myItem.AccountsHeadId; objItem.ExpenseCategoryId = myItem.ExpenseCategoryId; objItem.Title = myItem.Title; objItem.Description = myItem.Description; objItem.Code = myItem.Code; objItem.Status = myItem.Status; #region Included Tables try { objItem.ExpenseCategory = new ExpenseCategory(); objItem.ExpenseCategory.ExpenseCategoryId = myItem.ExpenseCategory.ExpenseCategoryId; objItem.ExpenseCategory.Title = myItem.ExpenseCategory.Title; objItem.ExpenseCategory.Code = myItem.ExpenseCategory.Code; objItem.ExpenseCategory.Status = myItem.ExpenseCategory.Status; } catch {} #endregion } catch (Exception ex) { return(new AccountsHead() as TR); } return(objItem as TR); } return(null); }
private bool AddAccountsHead() { try { string itemCode = string.Empty; var categoryId = int.Parse(ddlExpenseCategory.SelectedValue); var accountHead = ServiceProvider.Instance().GetAccountsHeadServices().GetLastInsertedAccountsHeadsByExpenseCategoryId(categoryId); if (accountHead == null || accountHead.AccountsHeadId < 1) { var expenseCategory = ServiceProvider.Instance().GetExpenseCategoryServices().GetExpenseCategory(categoryId); if (expenseCategory == null || expenseCategory.ExpenseCategoryId < 1) { ConfirmAlertBox1.ShowMessage("Invalid Process call!", ConfirmAlertBox.PopupMessageType.Error); return(false); } itemCode = expenseCategory.Code + "1"; } else { var expenseItemCode = long.Parse(accountHead.Code + 1); itemCode = expenseItemCode.ToString(CultureInfo.InvariantCulture); } var newAccountsHead = new AccountsHead { ExpenseCategoryId = int.Parse(ddlExpenseCategory.SelectedValue), Title = txtTitle.Text.Trim(), Code = itemCode, Description = txtDescription.Text.Trim(), Status = chkAccountsHead.Checked ? 1 : 0, }; var k = ServiceProvider.Instance().GetAccountsHeadServices().AddAccountsHeadCheckDuplicate(newAccountsHead); if (k < 1) { if (k == -3) { ErrorDisplayProcessAccountsHead.ShowError("Accounts Head Information already Exists."); mpeProcessAccountsHead.Show(); return(false); } ErrorDisplayProcessAccountsHead.ShowError("Accounts Head Information could not be added."); mpeProcessAccountsHead.Show(); return(false); } txtDescription.Text = string.Empty; txtTitle.Text = string.Empty; chkAccountsHead.Checked = false; return(true); } catch (Exception ex) { ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error); ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); return(false); } }