protected void btnSaveAccount_Click(object sender, EventArgs e) { BankAccounts objAccounts = new BankAccounts(); List<BankAccounts> myList = objAccounts.GetAllBankAccounts(_user.CompanyId); objAccounts.BankAccountId = myList.Count+1; objAccounts.BranchName = txtBranchName.Value; objAccounts.AccountNo = txtAccountNo.Value; objAccounts.AccountTitle = txtTitle.Value; objAccounts.AccountType = accountTypeRadDropDownList1.SelectedItem.Text; objAccounts.OpeningDate = (RadDatePicker2.SelectedDate.ToString()); objAccounts.CompanyId = _company.CompanyId; objAccounts.IsActive = chkIsActive.Checked; int success = objAccounts.InsertBankAccounts(); if (success > 0) { this.LoadAccountsTable(); Session["saveBankAccountInfo"] = ("Accounts info Saved successfully"); Response.Redirect(Request.RawUrl); // this.Clear(); } else { Alert.Show("Error occured"); } }
protected void btnSave_Click(object sender, EventArgs e) { try { BankAccounts objAccounts = new BankAccounts(); List<BankAccounts> myList = objAccounts.GetAllBankAccounts(_user.CompanyId); objAccounts.BankAccountId = myList.Count; if (bankIdRadDropDownList1.SelectedIndex > -1) { objAccounts.BankId = int.Parse(bankIdRadDropDownList1.SelectedItem.Value); } else { Alert.Show("Please select a bank"); } objAccounts.BranchName = txtBranchName.Value; objAccounts.AccountNo = txtAccountNo.Value; objAccounts.AccountTitle = txtTitle.Value; objAccounts.AccountType = accountTypeRadDropDownList1.SelectedItem.Text; objAccounts.OpeningDate = (RadDatePicker2.SelectedDate.ToString()); objAccounts.CompanyId = _company.CompanyId; objAccounts.IsActive = chkIsActive.Checked; int sucess = 0; if (lblId.Text == "" || lblId.Text == "0") { objAccounts.BankAccountId=new BankAccounts().GetMaxAccountId()+1; sucess = objAccounts.InsertBankAccounts(); if (sucess > 0) { Alert.Show("Bank Accounts info saved successfully"); this.Clear(); } } else { objAccounts.BankAccountId = int.Parse(lblId.Text); sucess = objAccounts.UpdateBankAccounts(); if (sucess > 0) { Response.Redirect("BankAccoutsList.aspx", true); } } } catch (Exception ex) { Alert.Show(ex.Message); } }