Ejemplo n.º 1
0
 private void btnSave_Click_1(object sender, EventArgs e)
 {
     try
     {
         companybank   ca   = new companybank();
         CompanyBankDB cadb = new CompanyBankDB();
         ca.RowID       = selectedRow;
         ca.CompanyID   = ((Structures.ComboBoxItem)cmbCompany.SelectedItem).HiddenValue;
         ca.BranchName  = ((Structures.ComboBoxItem)cmbBranch.SelectedItem).HiddenValue; // For Storing BAnk Branch RowID
         ca.AccountType = ((Structures.ComboBoxItem)cmbAccType.SelectedItem).HiddenValue;
         ca.AccountCode = txtAccCode.Text.Trim();
         ca.Status      = getStatusCode(cmbStatus.SelectedItem.ToString());
         System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button;
         string btnText = btn.Text;
         if (cadb.validateCompanyBank(ca))
         {
             if (btnText.Equals("Update"))
             {
                 if (cadb.updateCompBAnk(ca))
                 {
                     MessageBox.Show("Company Bank updated");
                     closeAllPanels();
                     ListCompanyBank();
                 }
                 else
                 {
                     MessageBox.Show("Failed to update Company Bank");
                 }
             }
             else if (btnText.Equals("Save"))
             {
                 if (cadb.insertCompBank(ca))
                 {
                     MessageBox.Show("Company Bank Added");
                     closeAllPanels();
                     ListCompanyBank();
                 }
                 else
                 {
                     MessageBox.Show("Failed to Insert Company Bank");
                 }
             }
         }
         else
         {
             MessageBox.Show("Company Bank Data Validation failed");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Failed Adding / Editing Company Bank");
     }
 }