Exemplo n.º 1
0
        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);
            }
        }
        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);
            }
        }
        /// <summary>
        /// Selects some of the customer information
        /// </summary>
        /// <param name="iban"></param>
        /// <returns>Customer' infomation</returns>
        public static Model.TransactionCustomer getCustomer(string iban)
        {
            Model.TransactionCustomer customer = new Model.TransactionCustomer();

            MySqlConnection con = new MySqlConnection(connectionString);

            MySqlCommand com = new MySqlCommand("Select * from user_account ", con);

            com.Connection.Open();
            MySqlDataReader dr = com.ExecuteReader();

            while (dr.Read())
            {
                if (iban == dr["Iban"].ToString())
                {
                    customer.NameCustomer = dr["FullName"].ToString();
                    customer.EgnCustomer  = dr["EGN"].ToString();

                    break;
                }
            }

            dr.Close();
            com.Connection.Close();

            return(customer);
        }