Example #1
0
 private void btnAccept_Click(object sender, EventArgs e)
 {
     _clientRepository.Client.Name                       = txtClientName.Text;
     _clientRepository.Client.Surname                    = txtSurname.Text;
     _clientRepository.Client.Title                      = txtTitle.Text;
     _clientRepository.Client.BirthNumber                = txtBirthNumber1.Text + txtBirthNumber2.Text;
     _clientRepository.Client.IdCardNumber               = txtIdCard.Text;
     _clientRepository.Client.Street                     = txtStreet.Text;
     _clientRepository.Client.City                       = txtCity.Text;
     _clientRepository.Client.PhoneNumber                = txtPhoneNum.Text;
     _clientRepository.Client.BankAccount.Iban           = lblAccIban.Text;
     _clientRepository.Client.BankAccount.AccountName    = txtAccName.Text;
     _clientRepository.Client.BankAccount.AccountBalance =
         decimal.Parse(lblAccBalance.Text.Substring(0, lblAccBalance.Text.IndexOf(' ')));
     _clientRepository.Client.BankAccount.AuthOverdraftLimit =
         decimal.Parse(cmbLimit.Text.Substring(0, cmbLimit.Text.IndexOf(' ')));
     _clientRepository.Client.BankAccount.OpeningDate = DateTime.Parse(lblAccOpenDate.Text);
     if (_clientId > 0)
     {
         bool clientIsUpdated  = _clientRepository.UpdateClient(_clientRepository.Client);
         bool accountIsUpdated = _bankAccountRepository.UpdateBankAccount(_clientRepository.Client.BankAccount);
         if (clientIsUpdated && accountIsUpdated)
         {
             DialogResult = DialogResult.OK;
         }
         else
         {
             lblInfoText.Text = MainRepository.NO_DB_CONNECTION;
         }
     }
     else
     {
         _clientRepository.Client.ClientID = _clientRepository.InsertClient(_clientRepository.Client);
         bool accountIsInserted = _bankAccountRepository.InsertBankAccount(_clientRepository.Client);
         if (accountIsInserted)
         {
             DialogResult = DialogResult.OK;
         }
         else
         {
             lblInfoText.Text = MainRepository.NO_DB_CONNECTION;
         }
     }
 }