Esempio n. 1
0
 private void frmAddEditBank_Load(object sender, EventArgs e)
 {
     try
     {
         if (SelectedBankID == 0)
         {
             txtBankName.Text    = string.Empty;
             chkIsActive.Checked = true;
         }
         else
         {
             TBL_MP_Master_Bank model = (new ServiceBankMaster()).GetBankDbRecord(this.SelectedBankID);
             if (model != null)
             {
                 txtBankName.Text    = model.BankName;
                 chkIsActive.Checked = model.IsActive;
             }
         }
     }
     catch (Exception ex)
     {
         string errMessage = ex.Message;
         if (ex.InnerException != null)
         {
             errMessage += string.Format("\n{0}", ex.InnerException.Message);
         }
         MessageBox.Show(errMessage, "frmAddEditBank::frmAddEditBank_Load", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void frmAddEditBankBranch_Load(object sender, EventArgs e)
 {
     try
     {
         PopulateBankBranchCountry();
         if (BankBranchID == 0)
         {
             txtBranchName.Text  = txtBankBranchAddress.Text = txtBranchIFSCCode.Text = string.Empty;
             chkIsActive.Checked = true;
             int indiaID = Program.LIST_DEFAULTS.Where(x => x.ID == (int)APP_DEFAULT_VALUES.DefaultCountryID).FirstOrDefault().DEFAULT_VALUE;
             cboBranchCountries.SelectedItem = ((List <SelectListItem>)cboBranchCountries.DataSource).Where(x => x.ID == indiaID).FirstOrDefault();
             PopulateBankBranchState();
             if (this.BankID != 0)
             {
                 TBL_MP_Master_Bank model = (new ServiceBankMaster()).GetBankDbRecord(this.BankID);
                 if (model != null)
                 {
                     this.Text = string.Format("{0} - ADD BRANCH", model.BankName);
                 }
             }
         }
         else
         {
             TBL_MP_Master_BankBranch model = (new ServiceBankMaster()).GetBankBranchDbRecord(this.BankBranchID);
             if (model != null)
             {
                 txtBranchName.Text              = model.BranchName;
                 txtBankBranchAddress.Text       = model.BranchAddress;
                 txtBranchIFSCCode.Text          = model.IFSCCode;
                 cboBranchCountries.SelectedItem = ((List <SelectListItem>)cboBranchCountries.DataSource).Where(x => x.ID == model.FK_CountryID).FirstOrDefault();
                 PopulateBankBranchState();
                 cboBranchStates.SelectedItem = ((List <SelectListItem>)cboBranchStates.DataSource).Where(x => x.ID == model.FK_StateID).FirstOrDefault();
                 PopulateBankBranchCity();
                 cboBranchCity.SelectedItem = ((List <SelectListItem>)cboBranchCity.DataSource).Where(x => x.ID == model.FK_CityID).FirstOrDefault();
                 chkIsActive.Checked        = model.IsActive;
             }
         }
     }
     catch (Exception ex)
     {
         string errMessage = ex.Message;
         if (ex.InnerException != null)
         {
             errMessage += string.Format("\n{0}", ex.InnerException.Message);
         }
         MessageBox.Show(errMessage, "frmAddEditBankBranch::frmAddEditBankBranch_Load", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            TBL_MP_Master_Bank model    = null;
            ServiceBankMaster  _service = new ServiceBankMaster();

            try
            {
                errorProvider1.Clear();
                if (!this.ValidateChildren())
                {
                    return;
                }

                if (this.SelectedBankID == 0)
                {
                    model = new TBL_MP_Master_Bank();
                }
                else
                {
                    model = _service.GetBankDbRecord(this.SelectedBankID);
                }

                model.BankName = txtBankName.Text.Trim().ToUpper();
                model.IsActive = chkIsActive.Checked;

                if (this.SelectedBankID == 0)
                {
                    this.SelectedBankID = _service.AddNewBank(model);
                }
                else
                {
                    _service.UpdateBank(model);
                }

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "frmAddEditBank::btnSave_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 4
0
        public int AddNewBank(TBL_MP_Master_Bank model)
        {
            int newID = 0;

            try
            {
                model.IsActive = true;
                _dbContext.TBL_MP_Master_Bank.Add(model);
                _dbContext.SaveChanges();
                newID = model.PK_BankID;
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ServiceBankMaster::AddNewBank", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(newID);
        }
Esempio n. 5
0
        public bool UpdateBank(TBL_MP_Master_Bank model)
        {
            bool result = false;

            try
            {
                TBL_MP_Master_Bank dbModel = _dbContext.TBL_MP_Master_Bank.Where(x => x.PK_BankID == model.PK_BankID).FirstOrDefault();
                dbModel.BankName = model.BankName;
                dbModel.IsActive = model.IsActive;
                _dbContext.SaveChanges();
                result = true;
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ServiceBankMaster::UpdateBank", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(result);
        }