protected void BtnAddNewAccountsHeadClick(object sender, EventArgs e) { ErrorDisplayProcessAccountsHead.ClearError(); txtTitle.Text = string.Empty; txtDescription.Text = string.Empty; LoadExpenseCategories(); lgAccountsTitle.InnerHtml = "Create a New Accounts Head"; chkAccountsHead.Checked = false; btnSubmitAccountsHead.CommandArgument = "1"; btnSubmitAccountsHead.Text = "Submit"; mpeProcessAccountsHead.Show(); }
private bool UpdateAccountsHead() { try { if (Session["_accountsHeads"] == null) { ConfirmAlertBox1.ShowMessage("Your session has expired", ConfirmAlertBox.PopupMessageType.Error); return(false); } var accountsHead = Session["_accountsHead"] as AccountsHead; if (accountsHead == null || accountsHead.AccountsHeadId < 1) { ErrorDisplayProcessAccountsHead.ShowError("Accounts Head list is empty or session has expired"); mpeProcessAccountsHead.Show(); return(false); } accountsHead.Description = txtDescription.Text.Trim(); accountsHead.Title = txtTitle.Text.Trim(); accountsHead.ExpenseCategoryId = int.Parse(ddlExpenseCategory.SelectedValue.ToString(CultureInfo.InvariantCulture)); accountsHead.Status = chkAccountsHead.Checked ? 1 : 0; var k = ServiceProvider.Instance().GetAccountsHeadServices().UpdateAccountsHeadCheckDuplicate(accountsHead); if (k < 1) { if (k == -3) { ErrorDisplayProcessAccountsHead.ShowError("Accounts Head already exists."); txtTitle.Focus(); mpeProcessAccountsHead.Show(); return(false); } ErrorDisplayProcessAccountsHead.ShowError("The Accounts Head information could not be updated."); mpeProcessAccountsHead.Show(); return(false); } return(true); } catch (Exception ex) { ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error); return(false); } }
protected void DgAccountsHeadEditCommand(object source, DataGridCommandEventArgs e) { ErrorDisplayProcessAccountsHead.ClearError(); LoadExpenseCategories(); txtTitle.Text = string.Empty; txtDescription.Text = string.Empty; ddlExpenseCategory.SelectedIndex = 0; chkAccountsHead.Checked = false; try { dgAccountsHead.SelectedIndex = e.Item.ItemIndex; var accountsHeadId = (DataCheck.IsNumeric(dgAccountsHead.DataKeys[e.Item.ItemIndex].ToString())) ? int.Parse(dgAccountsHead.DataKeys[e.Item.ItemIndex].ToString()) : 0; if (accountsHeadId < 1) { ConfirmAlertBox1.ShowMessage("Invalid AccountsHead Selection", ConfirmAlertBox.PopupMessageType.Error); return; } var accountsHead = ServiceProvider.Instance().GetAccountsHeadServices().GetAccountsHead(accountsHeadId); if (accountsHead == null || accountsHead.AccountsHeadId < 1) { ConfirmAlertBox1.ShowMessage("Invalid selection!", ConfirmAlertBox.PopupMessageType.Error); return; } ddlExpenseCategory.SelectedValue = accountsHead.ExpenseCategoryId.ToString(CultureInfo.InvariantCulture); txtTitle.Text = accountsHead.Title; txtDescription.Text = accountsHead.Description; chkAccountsHead.Checked = accountsHead.Status == 1; btnSubmitAccountsHead.CommandArgument = "2"; //update btnSubmitAccountsHead.Text = "Update"; lgAccountsTitle.InnerHtml = "Update Accounts Head information"; mpeProcessAccountsHead.Show(); Session["_accountsHead"] = accountsHead; } catch (Exception ex) { ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error); } }
protected void BtnSubmitAccountsHeadClick(object sender, EventArgs e) { ErrorDisplayProcessAccountsHead.ClearError(); try { if (!ValidateControls()) { return; } switch (int.Parse(btnSubmitAccountsHead.CommandArgument)) { case 1: //Add if (!AddAccountsHead()) { ConfirmAlertBox1.ShowMessage("Accounts Head information could not be added. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error); return; } break; case 2: //Update if (!UpdateAccountsHead()) { ConfirmAlertBox1.ShowMessage("Accounts Head information could not be updated. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error); } break; default: ErrorDisplayProcessAccountsHead.ShowError("Invalid process call!"); mpeProcessAccountsHead.Show(); break; } LoadAccountsHeads(); ConfirmAlertBox1.ShowSuccessAlert("Accounts Head was Saved Successfully."); } catch (Exception ex) { ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error); } }
private bool ValidateControls() { try { if (int.Parse(ddlExpenseCategory.SelectedValue) < 1) { ErrorDisplayProcessAccountsHead.ShowError("Please select an Expense Category"); ddlExpenseCategory.Focus(); mpeProcessAccountsHead.Show(); return(false); } if (string.IsNullOrEmpty(txtTitle.Text.Trim())) { ErrorDisplayProcessAccountsHead.ShowError("Please enter an Accounts Head."); txtTitle.Focus(); mpeProcessAccountsHead.Show(); return(false); } if (string.IsNullOrEmpty(txtDescription.Text.Trim())) { ErrorDisplayProcessAccountsHead.ShowError("Please,Specify Accounts Head Description"); txtDescription.Focus(); mpeProcessAccountsHead.Show(); return(false); } //if (RegExValidation.IsNameValid(txtTitle.Text.Trim())) //{ // ErrorDisplayProcessAccountsHead.ShowError("Invalid entry!"); // txtTitle.Focus(); // mpeProcessAccountsHead.Show(); // return false; //} return(true); } catch (Exception ex) { ErrorDisplayProcessAccountsHead.ShowError("An unknown error was encountered. Please try again soon or contact the Admin."); ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); return(false); } }
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); } }