private void buttonGetDetailsWithdraw_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBoxIbanWithdraw.Text == "")
                {
                    MessageBox.Show("Please enter IBAN on customer !",
                                    "Withdraw .", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                else
                {
                    modelCustomerWithdraw = DataBaseOperations.getCustomer(textBoxIbanWithdraw.Text);

                    textBoxNameCustomerWithdraw.Text = modelCustomerWithdraw.NameCustomer;
                    textBoxEGNCustomerWithdraw.Text  = modelCustomerWithdraw.EgnCustomer;

                    ModelAccountCustomer = DataBaseOperations.getBalance(textBoxIbanWithdraw.Text);
                    textBoxAccountBalanceWithdraw.Text = ModelAccountCustomer.Balance.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void buttonUpdateWithdraw_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridViewWithdraw.Rows.Count == 0)
                {
                    MessageBox.Show("Please add the data to the table.",
                                    "Withdraw .", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                else
                {
                    customer = DataBaseOperations.GetIdAccount(customerWithdraw.account.Iban);

                    DataBaseOperations.UpdateWithdraw(customerWithdraw.WithdrawAmount,
                                                      modeWithdraw, customer, customerWithdraw);

                    MessageBox.Show($"Withdraw with iban {customerWithdraw.account.Iban} was successful .",
                                    "Withdraw .", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);

                    textBoxIbanWithdraw.Clear();
                    textBoxNameCustomerWithdraw.Clear();
                    textBoxEGNCustomerWithdraw.Clear();
                    textBoxAccountBalanceWithdraw.Clear();
                    textBoxAmountWithdraw.Clear();
                    dataGridViewWithdraw.Rows.Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void buttonUpdateDeposit_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridViewDeposit.Rows.Count == 0)
                {
                    MessageBox.Show("Please add the data to the table.",
                                    "Deposit .", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                else
                {
                    customer = DataBaseOperations.GetIdAccount(customerDeposit.account.Iban);

                    DataBaseOperations.UpdateDeposit(customerDeposit.DepositAmount,
                                                     customer, customerDeposit);

                    MessageBox.Show($"Deposit with iban {customerDeposit.account.Iban} was successful .",
                                    "Deposit ", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);

                    textBoxIbanDeposit.Clear();
                    textBoxNameCustomerDeposit.Clear();
                    textBoxEgnCustomerDeposit.Clear();
                    textBoxAccountBalanceDeposit.Clear();
                    textBoxDepositAmount.Clear();
                    dataGridViewDeposit.Rows.Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void buttonGetDetailsTransfer_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBoxFromIBanTransfer.Text == "")
                {
                    MessageBox.Show("Please enter IBAN on customer !",
                                    "Transfer .", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                else
                {
                    modelCustomerTransfer = DataBaseOperations.getCustomer(textBoxFromIBanTransfer.Text);

                    textBoxNameCusotmerTransfer.Text = modelCustomerTransfer.NameCustomer;
                    textBoxEGNCustomerTransfer.Text  = modelCustomerTransfer.EgnCustomer;

                    modelAccountCustomerTransfer       = DataBaseOperations.getBalance(textBoxFromIBanTransfer.Text);
                    textBoxAccountBalanceTransfer.Text = modelAccountCustomerTransfer.Balance.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #5
0
        private void buttonMake_Click(object sender, EventArgs e)
        {
            try
            {
                dataGridCustomers.Rows.Clear();

                List <Customer> customers = DataBaseOperations.GetAllCustomerInformation();

                foreach (var c in customers)
                {
                    dataGridCustomers.Rows.Add(
                        c.Id,
                        c.account.Iban,
                        c.FullName,
                        c.Egn,
                        c.gender,
                        c.Address,
                        c.PostalCode,
                        c.City,
                        c.Country,
                        c.MobilePhone,
                        c.HomePhone,
                        c.Email,
                        c.DataOfAccount);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void Deposit_Load(object sender, EventArgs e)
        {
            AutoCompleteStringCollection collection = new AutoCompleteStringCollection();

            collection.AddRange(DataBaseOperations.getAccountIban().ToArray());

            textBoxIbanDeposit.AutoCompleteCustomSource = collection;
        }
        private void Transfer_Load(object sender, EventArgs e)
        {
            AutoCompleteStringCollection collection = new AutoCompleteStringCollection();

            collection.AddRange(DataBaseOperations.getAccountIban().ToArray());

            textBoxFromIBanTransfer.AutoCompleteCustomSource = collection;
            textBoxDestinationIBAN.AutoCompleteCustomSource  = collection;
        }
        private void WithdrawingMoney_Load(object sender, EventArgs e)
        {
            string[] mode = { "Cash", "Cheque" };

            foreach (string items in mode)
            {
                comboBoxModeWithdraw.Items.Add(items);
            }

            AutoCompleteStringCollection collection = new AutoCompleteStringCollection();

            collection.AddRange(DataBaseOperations.getAccountIban().ToArray());

            textBoxIbanWithdraw.AutoCompleteCustomSource = collection;
        }
            public static void DeleteAccount(string iban)
            {
                string sqlIdAccount = $"select idUserAccount from user_account where iban = @iban;";

                MySqlCommand command = DataBaseOperations.GetCommand(sqlIdAccount,
                                                                     new MySqlParameter[] { new MySqlParameter("@iban", iban) });

                command.Connection.Open();

                int id = Convert.ToInt32(command.ExecuteScalar());

                string sqlClosureAccount = "insert into account_closure " +
                                           "(idUserAccount, Iban, FullName, Egn, Gender, Address, PostalCode, City, " +
                                           "Country, MobilePhone, HomePhone, Email, DataOfAccount) " +
                                           "select * from user_account as ua where ua.iban = @iban;";

                command.CommandText = sqlClosureAccount;
                command.ExecuteScalar();

                string sqlDelete = $"delete from user_account where iban = @iban;";

                command.CommandText = sqlDelete;
                command.ExecuteScalar();

                //Get fee
                //insert
                string sqlFeeChargesAccount = $"insert into fee_charges_account_closure" +
                                              $"(idUserAccount, date_fee, amount) values (" +
                                              $"@idUserAccount," +
                                              $"@date_fee," +
                                              $"@amount);";

                MySqlParameter[] parameterFee =
                {
                    new MySqlParameter("@idUserAccount", id),
                    new MySqlParameter("@date_fee",      DateTime.Now),
                    new MySqlParameter("@amount",        feeDeleteAccount.ToString().Replace(",", "."))
                };

                command.CommandText = sqlFeeChargesAccount;
                command.Parameters.AddRange(parameterFee);

                command.ExecuteScalar();
                command.Connection.Close();
            }
        private void buttonGetDetailsUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBoxIbanUpdate.Text == "")
                {
                    MessageBox.Show("Please enter IBAN on customer !",
                                    "Update account/Search .", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                else
                {
                    customer.account = new AccountCustomer();

                    dataGridViewUpdate.Rows.Clear();

                    customer = DataBaseOperations.GetCustomerInformation(textBoxIbanUpdate.Text);

                    dataGridViewUpdate.Rows.Add(
                        customer.Id,
                        customer.account.Iban,
                        customer.FullName,
                        customer.Egn,
                        customer.gender,
                        customer.Address,
                        customer.PostalCode,
                        customer.City,
                        customer.Country,
                        customer.MobilePhone,
                        customer.HomePhone,
                        customer.Email,
                        customer.DataOfAccount);

                    labelInformationCustomer.Text = $"Information about " +
                                                    $"{customer.FullName}";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #11
0
        private void buttonRandomIban_Click(object sender, EventArgs e)
        {
            Random randomIban = new Random();
            int    ran        = randomIban.Next(100000000, 999999999);

            textBoxIBAN.Text = ran.ToString();

            if (DataBaseOperations.checkIban(ran.ToString()) == true)
            {
                MessageBox.Show("Already exists such a iban. ",
                                "NewAccount .", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("The IBAN is valid.",
                                "NewAccount .", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }
Beispiel #12
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridViewNewAccount.Rows.Count == 0)
                {
                    MessageBox.Show("Please add the data to the table.",
                                    "New Account .", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                else
                {
                    DataBaseOperations.SaveCustomerAccount(customer, customer.account);

                    textBoxIBAN.Clear();
                    textBoxFirstNameCustomer.Clear();
                    textBoxMidddleNameCustomer.Clear();
                    textBoxLastNameCustomer.Clear();
                    textBoxEGNCustomer.Clear();
                    textBoxAddressCustomer.Clear();
                    textBoxPostCodeCustomer.Clear();
                    textBoxCityCustomer.Clear();
                    textBoxCountryCustomer.Clear();
                    textBoxMobilePhoneCustomer.Clear();
                    textBoxHomePhoneCustomer.Clear();
                    textBoxEmailCustomer.Clear();
                    dataGridViewNewAccount.Rows.Clear();

                    MessageBox.Show($"Account IBAN {customer.account.Iban} was successfully saved .",
                                    "NewAccount .", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #13
0
        private void buttonSignIn_Click(object sender, EventArgs e)
        {
            try
            {
                LoginEmployee.LoginEmployee login = new LoginEmployee.LoginEmployee();
                login.Username = textBoxUserName.Text;
                login.Password = textBoxPassword.Text;

                if (DataBaseOperations.checkUser(login.Username, login.Password) == true)
                {
                    МainМenuBank menu = new МainМenuBank();
                    menu.Show();
                    this.Hide();
                }
                else
                {
                    if (++clickFourLogin == 4)
                    {
                        MessageBox.Show("There is no such account ! " +
                                        "Please check your password or username again.",
                                        "Unsuccessful entry .", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show("Please check username or password .",
                                        "Unsuccessful entry .", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
            /// <summary>
            /// Retains the transfer service data in the database table
            /// and the transfer fee in another table
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="receiver"></param>
            /// <param name="amountTransfer"></param>
            public static void TransferMoney(AccountCustomer sender, AccountCustomer receiver,
                                             decimal amountTransfer)
            {
                try
                {
                    if (sender.Iban == null)
                    {
                        throw new ArgumentException("Sender IBAN is null.");
                    }

                    if (DataBaseOperations.getBalance(sender.Iban).Balance >= amountTransfer + GetFeeTransfer(amountTransfer))
                    {
                        string sqlSender = $"select idUserAccount from user_account where iban = @ibanSender;";

                        MySqlCommand command = DataBaseOperations.GetCommand(sqlSender,
                                                                             new MySqlParameter[] { new MySqlParameter("@ibanSender", sender.Iban) });

                        command.Connection.Open();

                        int pkSender = Convert.ToInt32(command.ExecuteScalar());

                        string sqlReseiver = $"select idUserAccount from user_account where iban = @ibanReceiver;";

                        command.CommandText = sqlReseiver;
                        command.Parameters.AddWithValue("@ibanReceiver", receiver.Iban);

                        int pkReceiver = Convert.ToInt32(command.ExecuteScalar());

                        //Transfer
                        string sqlTransfer = $"insert into transfer_customer" +
                                             $"(IDSender_Customer, IDRecipient_Customer, DataOfTransfer, Amount_Transfer) values (" +
                                             $"@IDSender_Customer," +
                                             $"@IDRecipient_Customer," +
                                             $"@DataOfTransfer," +
                                             $"@Amount_Transfer)";

                        MySqlParameter[] parametersTransfer =
                        {
                            new MySqlParameter("@IDSender_Customer",    pkSender),
                            new MySqlParameter("@IDRecipient_Customer", pkReceiver),
                            new MySqlParameter("@DataOfTransfer",       DateTime.Now),
                            new MySqlParameter("@Amount_Transfer",      amountTransfer.ToString().Replace(",", "."))
                        };

                        command.CommandText = sqlTransfer;
                        command.Parameters.AddRange(parametersTransfer);

                        command.ExecuteScalar();

                        //Get Fee
                        //INSERT
                        string sqlChargesTransfer = $"insert into fee_charges_transfer" +
                                                    $"(iduser_account, date_fee, amount) values (" +
                                                    $"@iduser_account," +
                                                    $"@date_fee," +
                                                    $"@amount)";

                        MySqlParameter[] parametersChargesTransfer =
                        {
                            new MySqlParameter("@iduser_account", pkSender),
                            new MySqlParameter("@date_fee",       DateTime.Now),
                            new MySqlParameter("@amount",         GetFeeTransfer(amountTransfer).ToString().Replace(",", "."))
                        };

                        command.CommandText = sqlChargesTransfer;
                        command.Parameters.AddRange(parametersChargesTransfer);

                        command.ExecuteScalar();
                        command.Connection.Close();
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                }
            }