public LoginWindow() { InitializeComponent(); _loginBUS = new LoginBus(); _accDAO = new BankAccountDAO(); _loginVO = new LoginVO(); }
private void btnRemove_Click(object sender, EventArgs e) { if (txtNumAcc.Text == string.Empty || txtCpfHolder.Text == string.Empty) { MessageBox.Show("Favor preencher todos os campos para evitar erros.\nCaso o erro persista entre em contato com o suporte.", "Erro, algo não está preenchido!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DialogResult result = MessageBox.Show("Você realmente deseja excluir essa conta do sistema?\nClick em (SIM) para excluir e (NÃO) para cancelar a operação.", "Excluir ?", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (result == DialogResult.Yes) { //Atribuindo as informações para a o banco BankAccount bAcc = new BankAccount(txtNumAcc.Text, txtCpfHolder.Text); BankAccountDAO bkAccDao = new BankAccountDAO(); //Atribuindo o objeto ao BankStatement bkAccDao.DeleteAccount(bAcc); MessageBox.Show("Removido !"); metroGrid1.DataSource = bkAccDao.EfetuarConsultaPorCodigo(txtCPFHOLDERparam.Text); this.lDVACCOUNTUSERTableAdapter.Fill(this.lDV_PEDREIRADataSet.LDVACCOUNTUSER); Limpar(this); //this.lDVBANKACCOUNTTableAdapter.Fill(this.lDV_PEDREIRADataSet.LDVBANKACCOUNT); } else if (result == DialogResult.No) { Limpar(this); } } }
private void RentCar_Click(object sender, System.Windows.RoutedEventArgs e) { Vehicle selectedVehicle = VehicleTable.SelectedItem != null ? VehicleTable.SelectedItem as Vehicle : null; if (selectedVehicle != null) { //todo implement pay logic try { List <BlackList> blackLists = new BlackListDAO().GetBlackLists(userId: UserManager.CurrentUser.Id); if (blackLists.Count != 0) { if (blackLists.First().Banned) { NotificationLabel.ShowError("You are banned! You cannot make a rental!"); } } List <BankAccount> list = new BankAccountDAO().GetBankAccounts(userId: UserManager.CurrentUser.Id); if (list.Count == 0) { NotificationLabel.ShowError("Please go to settings and add your bank account info"); return; } new RentDAO().Insert(new Rent() { BeginTime = DateTime.Now, Returned = false, Paid = false, VehicleId = selectedVehicle.Id, VehicleName = selectedVehicle.Name, UserId = UserManager.CurrentUser.Id }); selectedVehicle.UserId = UserManager.CurrentUser.Id; new VehicleDAO().Update(selectedVehicle); ((List <Vehicle>)VehicleTable.ItemsSource).Remove((Vehicle)VehicleTable.SelectedItem); MyFinesTable.Items.Refresh(); NotificationLabel.ShowSuccess("Rental successful !"); } catch (Exception ex) { DebugLog.WriteLine(ex); NotificationLabel.ShowError("Could not process rental"); selectedVehicle.UserId = null; } } else { NotificationLabel.ShowError("Nothing selected"); } }
//Constructor public FormClient() { InitializeComponent(); _bankAccBus = new BankAccountsBUS(); _listBankAccVO = new List <BankAccountsVO>(); _bankAccDAO = new BankAccountDAO(); _bankAccVO = new BankAccountsVO(); _tranzDAO = new TranzactionsDAO(); _tranzVO = new TranzactionsVO(); _listTranzVO = new List <TranzactionsVO>(); _tranzBUS = new TranzactionsBUS(); }
private void SaveBankAccountDetails() { if (string.IsNullOrEmpty(IBANBox.Text.Trim()) && string.IsNullOrEmpty(SecurityNumberBox.Text.Trim()) && CardTypeComboBox.SelectedItem == null && string.IsNullOrEmpty(BankNameBox.Text.Trim()) && ExpiryDatePicker.SelectedDate == null) { return; } else if (!string.IsNullOrEmpty(IBANBox.Text.Trim()) && !string.IsNullOrEmpty(SecurityNumberBox.Text.Trim()) && CardTypeComboBox.SelectedItem != null && !string.IsNullOrEmpty(BankNameBox.Text.Trim()) && ExpiryDatePicker.SelectedDate != null) { try { List <BankAccount> userBankAccounts = new BankAccountDAO().GetBankAccounts(userId: UserManager.CurrentUser.Id); BankAccount account = new BankAccount() { Iban = Encryption.Encrypt(IBANBox.Text.Trim()), SecurityNumber = Int32.Parse(SecurityNumberBox.Text.Trim()), CardType = (BankAccount.CardTypes)CardTypeComboBox.SelectedItem, BankName = BankNameBox.Text.Trim(), ExpiryDate = ExpiryDatePicker.SelectedDate.Value, UserId = UserManager.CurrentUser.Id }; if (userBankAccounts.Count > 0) { account.Id = userBankAccounts.First().Id; new BankAccountDAO().Update(account); } else { new BankAccountDAO().Insert(account); } } catch (Exception ex) { DebugLog.WriteLine(ex); NotificationLabel.ShowError("A problem occured while trying to save settings!"); } } else { NotificationLabel.ShowError("All bank account information fields are mandatory"); } }
private void metroGrid2_CellContentClick(object sender, DataGridViewCellEventArgs e) { /*Melhor solução encontrada para resolver a exception que estava ocorrendo ao clicar * no esquema de filtro do DataGrid, caso aconteça mais algum bug é necessarios arrumar * aqui.*/ try { Limpar(this); DataGridViewRow row = this.metroGrid2.Rows[e.RowIndex]; txtCPFHOLDERparam.Text = row.Cells["CPFUSER"].Value.ToString(); txtCpfHolder.Text = row.Cells["CPFUSER"].Value.ToString(); BankAccountDAO bkDao = new BankAccountDAO(); metroGrid1.DataSource = bkDao.EfetuarConsultaPorCodigo(txtCPFHOLDERparam.Text); } catch (Exception) { } }
private void btnAddAccount_Click(object sender, EventArgs e) { if (txtNumAcc.Text == string.Empty || txtCpfHolder.Text == string.Empty) { MessageBox.Show("Favor preencher todos os campos para evitar erros.\nCaso o erro persista entre em contato com o suporte.", "Erro, algo não está preenchido!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //Atribuindo as informações para a o banco BankAccount bAcc = new BankAccount(txtNumAcc.Text, txtCpfHolder.Text); BankAccountDAO bkAccDao = new BankAccountDAO(); //Atribuindo o objeto ao BankStatement bkAccDao.InsertAccount(bAcc); MessageBox.Show("Cadastrado !"); //this.lDVBANKACCOUNTTableAdapter.Fill(this.lDV_PEDREIRADataSet.LDVBANKACCOUNT); BankAccountDAO bkDao = new BankAccountDAO(); metroGrid1.DataSource = bkDao.EfetuarConsultaPorCodigo(txtCPFHOLDERparam.Text); this.lDVACCOUNTUSERTableAdapter.Fill(this.lDV_PEDREIRADataSet.LDVACCOUNTUSER); Limpar(this); } }
private void FinePay_Click(object sender, System.Windows.RoutedEventArgs e) { Damage selectedDamage = MyFinesTable.SelectedItem != null ? MyFinesTable.SelectedItem as Damage : null; if (selectedDamage != null) { //todo implement pay logic if (!selectedDamage.Paid) { try { List <BankAccount> list = new BankAccountDAO().GetBankAccounts(userId: UserManager.CurrentUser.Id); if (list.Count == 0) { NotificationLabel.ShowError("Please go to settings and add your bank account info"); return; } //todo retrieve bankaccount selectedDamage.Paid = true; new DamageDAO().Update(selectedDamage); MyFinesTable.Items.Refresh(); NotificationLabel.ShowSuccess("Payment successful !"); } catch (Exception ex) { DebugLog.WriteLine(ex); NotificationLabel.ShowError("Could not process paying"); selectedDamage.Paid = false; MyFinesTable.Items.Refresh(); } } } else { NotificationLabel.ShowError("Nothing selected"); } }
private void btnEdit_Click(object sender, EventArgs e) { if (txtNumAcc.Text == string.Empty && txtCpfHolder.Text == string.Empty) { MessageBox.Show("Favor preencher todos os campos para evitar erros.\nCaso o erro persista entre em contato com o suporte.", "Erro, algo não está preenchido!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DialogResult result = MessageBox.Show("Você realmente deseja alterar essa conta do sistema?\n" + "Confirme os dados antes de continuar, se você concorda click em(SIM)\n" + "caso contrario click em (NÃO) para cancelar a edição.\n\n" + "Número da conta: " + txtNumAcc.Text + "\n" + "CPF do titular: " + txtCpfHolder.Text, "Editar ?", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (result == DialogResult.Yes) { //Atribuindo as informações para a o banco BankAccount bAcc = new BankAccount(txtNumAcc.Text, txtCpfHolder.Text, txtNumAccAlter.Text); BankAccountDAO bkAccDao = new BankAccountDAO(); User user = new User(txtCPFHOLDERparam.Text, txtCpfHolder.Text); UserDAO uDal = new UserDAO(); //Atribuindo o objeto ao BankStatement bkAccDao.AlterarAccount(bAcc); uDal.AlterarUser(user); MessageBox.Show("Alterado !"); metroGrid1.DataSource = bkAccDao.EfetuarConsultaPorCodigo(txtCPFHOLDERparam.Text); this.lDVACCOUNTUSERTableAdapter.Fill(this.lDV_PEDREIRADataSet.LDVACCOUNTUSER); Limpar(this); } else if (result == DialogResult.No) { Limpar(this); } } }
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!(e.OriginalSource is TabControl)) { return; } NotificationLabel.Content = ""; if (MyRentalsTab.IsSelected) { List <Rent> myRentals = new RentDAO().GetRents(userId: UserManager.CurrentUser.Id); if (myRentals.Count == 0) { NotificationLabel.ShowError("You don't have any rentals"); } MyRentalsTable.ItemsSource = myRentals; } else if (MyFinesTab.IsSelected) { List <Damage> myDamages = new DamageDAO().GetDamages(userId: UserManager.CurrentUser.Id); if (myDamages.Count == 0) { NotificationLabel.ShowSuccess("You don't have any fines to pay"); } MyFinesTable.ItemsSource = myDamages; } else if (RentACarTab.IsSelected) { IEnumerable <Vehicle> myVehicles = new VehicleDAO().GetVehicles().Where((v) => v.UserId == null); if (myVehicles != null & myVehicles.Count() == 0) { NotificationLabel.ShowError("There are no more vehicles available"); } VehicleTable.ItemsSource = myVehicles.ToList <Vehicle>(); } else if (RentACarTab.IsSelected) { IEnumerable <Vehicle> myVehicles = new VehicleDAO().GetVehicles().Where((v) => v.UserId == 0); if (myVehicles != null & myVehicles.Count() == 0) { NotificationLabel.ShowError("There are no more vehicles available"); } VehicleTable.ItemsSource = myVehicles.ToList <Vehicle>(); } else if (SettingsTab.IsSelected) { CardTypeComboBox.ItemsSource = Enum.GetValues(typeof(BankAccount.CardTypes)); User currentUser = UserManager.CurrentUser; try { UserDetails details = new UserDetailsDAO().GetUserDetails(userId: currentUser.Id).First(); UsernameBox.Text = currentUser.Username; NameBox.Text = currentUser.Name; SurnameBox.Text = currentUser.Surname; EmailBox.Text = details.Email; StreetBox.Text = details.Street; CityBox.Text = details.City; ZipCodeBox.Text = details.ZipCode; CountryBox.Text = details.Country; BirthDatePicker.SelectedDate = details.BirthDate; } catch (Exception ex) { DebugLog.WriteLine(ex); NotificationLabel.ShowError("A problem occured! Could not retrieve your data!"); return; } try { BankAccount bankAccount = new BankAccountDAO().GetBankAccounts(userId: currentUser.Id).First(); IBANBox.Text = Encryption.Decrypt(bankAccount.Iban); SecurityNumberBox.Text = bankAccount.SecurityNumber.ToString(); CardTypeComboBox.SelectedItem = bankAccount.CardType == BankAccount.CardTypes.CREDIT ? CardTypeComboBox.Items.GetItemAt(0) : CardTypeComboBox.Items.GetItemAt(1); BankNameBox.Text = bankAccount.BankName; ExpiryDatePicker.SelectedDate = bankAccount.ExpiryDate; } catch (InvalidOperationException ex) { return;//no bankaccount for this user } catch (Exception ex) { NotificationLabel.ShowError("Could not retrieve bank account information"); } } }
public BankAccountsBUS() { _accountDAO = new BankAccountDAO(); }