protected void BtnAddNewExpenseItemClick(object sender, EventArgs e) { ErrorDisplayProcessTransactionItems.ClearError(); lgTitleScope.InnerHtml = "Create new Expense Item"; txtTitle.Text = string.Empty; txtDescription.Text = string.Empty; ccdAccountsHead.SelectedValue = "0"; ccdExpenseCategory.SelectedValue = "0"; chkActivateTransactionItem.Checked = false; btnProcessTransactionItems.Text = "Submit"; btnProcessTransactionItems.CommandArgument = "1"; mpeExpenseItemsPopup.Show(); }
protected void DgExpenseItemEditCommand(object source, DataGridCommandEventArgs e) { ErrorDisplayProcessTransactionItems.ClearError(); try { dgExpenseItem.SelectedIndex = e.Item.ItemIndex; var id = (DataCheck.IsNumeric(dgExpenseItem.DataKeys[e.Item.ItemIndex].ToString())) ? int.Parse(dgExpenseItem.DataKeys[e.Item.ItemIndex].ToString()) : 0; if (id < 1) { ConfirmAlertBox1.ShowMessage("Invalid ExpenseItem Selection", ConfirmAlertBox.PopupMessageType.Error); return; } var expenseItem = ServiceProvider.Instance().GetExpenseItemServices().GetExpenseItem(id); if (expenseItem == null || expenseItem.ExpenseItemId < 1) { ConfirmAlertBox1.ShowMessage("Invalid selection!", ConfirmAlertBox.PopupMessageType.Error); return; } ccdExpenseCategory.SelectedValue = expenseItem.ExpenseCategoryId.ToString(CultureInfo.InvariantCulture); ccdAccountsHead.SelectedValue = expenseItem.AccountsHeadId.ToString(CultureInfo.InvariantCulture); txtTitle.Text = expenseItem.Title; txtDescription.Text = expenseItem.Description; chkActivateTransactionItem.Checked = expenseItem.Status == 1; lgTitleScope.InnerHtml = "Update Expense Item"; Session["_expenseItem"] = expenseItem; btnProcessTransactionItems.CommandArgument = "2"; btnProcessTransactionItems.Text = "Update"; mpeExpenseItemsPopup.Show(); } catch { ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error); } }
private bool AddExpenseItem() { ErrorDisplayProcessTransactionItems.ClearError(); try { string itemCode; var itemsList = ServiceProvider.Instance().GetExpenseItemServices().GetLastInsertedExpenseItem(int.Parse(ddlAccountsHead.SelectedValue)); if (!itemsList.Any()) { var accountsHead = ServiceProvider.Instance().GetAccountsHeadServices().GetAccountsHead(int.Parse(ddlAccountsHead.SelectedValue)); if (accountsHead == null || accountsHead.AccountsHeadId < 1) { return(false); } var accountsHeadCode = accountsHead.Code + "01"; itemCode = accountsHeadCode; } else { var expenseItemCode = long.Parse(itemsList.First().Code) + 1; itemCode = expenseItemCode.ToString(CultureInfo.InvariantCulture); } var newExpenseItem = new ExpenseItem { ExpenseCategoryId = int.Parse(ddlExpenseCategory.SelectedValue), AccountsHeadId = int.Parse(ddlAccountsHead.SelectedValue), Title = txtTitle.Text.Trim(), Code = itemCode, Description = txtDescription.Text, Status = (chkActivateTransactionItem.Checked) ? 1 : 0 }; var k = ServiceProvider.Instance().GetExpenseItemServices().AddExpenseItem(newExpenseItem); if (k < 1) { if (k == -3) { ErrorDisplayProcessTransactionItems.ShowError("Expense Item information already exists."); txtTitle.Focus(); mpeExpenseItemsPopup.Show(); return(false); } ErrorDisplayProcessTransactionItems.ShowError("Expense Item could not be added."); mpeExpenseItemsPopup.Show(); return(false); } ErrorDisplayProcessTransactionItems.ShowSuccess("Expense Item information was added successfully."); txtDescription.Text = string.Empty; txtTitle.Text = string.Empty; ddlAccountsHead.SelectedIndex = 0; ddlExpenseCategory.SelectedIndex = 0; return(true); } catch (Exception ex) { ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); ErrorDisplayProcessTransactionItems.ShowError("An unknown error was encountered. Please try again soon or contact the Admin."); mpeExpenseItemsPopup.Show(); return(false); } }