private void userAuthenticationVarification(object sender, EventArgs e)
 {
     this.userAuthenticationVarificationHundler();
     try
     {
         int tempUsernameTxt = Convert.ToInt32((this.user_authentication.username_txt.Text));
         if (BankManagementUserSrc.userAuthentication(tempUsernameTxt, this.user_authentication.password_txt.Password))
         {
             this.boothMainScreenHundler();
         }
         else
         {
             this.user_authentication.wellcom_gettings_txt.Content = "you entered a wrong user name or password ... :(";
         }
     }
     catch (Exception h)
     {
         this.user_authentication.wellcom_gettings_txt.Content = "please enter valid user name ... :(";
     }
     finally
     {
         this.user_authentication.username_txt.Clear();
         this.user_authentication.password_txt.Clear();
         this.databaseOflineMode();
     }
 }
 public void databaseOflineMode()
 {
     this.database_status.Content = BankManagementUserSrc.connectionTest();
     if (!BankManagementUserSrc.ConnectionStatus)
     {
         this.boothMainScreenHundler();
         this.booth_main_screen_default_Loader();
         this.userAuthenticationVarificationHundler();
         this.user_authentication.wellcom_gettings_txt.Content = "database is offline ...:(";
         this.user_authentication.username_txt.IsEnabled       = false;
         this.user_authentication.password_txt.IsEnabled       = false;
         this.user_authentication.login_btn.IsEnabled          = false;
         this.database_status.Content      = "offline";
         this.databse_reload_btn.IsEnabled = true;
     }
     else
     {
         if (this.user_authentication.username_txt.IsEnabled == false && this.user_authentication.password_txt.IsEnabled == false && this.user_authentication.login_btn.IsEnabled == false)
         {
             this.userAuthenticationVarificationHundler();
         }
         this.databse_reload_btn.IsEnabled = false;
         this.database_status.Content      = "online";
     }
 }
 public static Boolean withdraw(int tempUserName, Double tempBalance)
 {
     try
     {
         var connection = new MySqlConnection(connectionString);
         connection.Open();
         MySqlCommand tempBalanceUpdate = new MySqlCommand("SELECT balance FROM `bank_users` WHERE userId = " + tempUserName + ";", connection);
         double       tempMainBalance   = Convert.ToDouble(tempBalanceUpdate.ExecuteScalar().ToString());
         if (tempBalance <= tempMainBalance)
         {
             tempMainBalance -= tempBalance;
             BankManagementUserSrc.updateBalance(tempUserName, tempMainBalance, tempBalance, "Withdraw");
             if (BankManagementUserSrc.userName == tempUserName)
             {
                 BankManagementUserSrc.balance = tempMainBalance;
             }
             BankManagementUserSrc.connectionStatus = true;
             return(true);
         }
         connection.Close();
     }
     catch (Exception ex)
     {
         BankManagementUserSrc.connectionStatus = false;
         return(false);
     }
     return(false);
 }
 public static Boolean userAuthentication(int userName, string password)
 {
     try
     {
         var          connection = new MySqlConnection(connectionString);
         MySqlCommand userNameAndPasswordSerch = new MySqlCommand("SELECT COUNT(*) FROM `bank_users` WHERE userId = " + userName + " and password = '******'", connection);
         connection.Open();
         if (Convert.ToString(userNameAndPasswordSerch.ExecuteScalar()) == "1")
         {
             BankManagementUserSrc.updateData(userName, password);
             BankManagementUserSrc.connectionStatus = true;
             return(true);
         }
         connection.Close();
     }
     catch (Exception ex)
     {
         BankManagementUserSrc.connectionStatus = false;
         return(false);
     }
     return(false);
 }
 public static Boolean transfer(int sender, int recever, Double tempBalance)
 {
     try
     {
         var          reciverConnection = new MySqlConnection(connectionString);
         MySqlCommand reciverSerch      = new MySqlCommand("SELECT COUNT(*) FROM `bank_users` WHERE userId = " + userName + " and password = '******'", reciverConnection);
         reciverConnection.Open();
         if (Convert.ToString(reciverSerch.ExecuteScalar()) == "1")
         {
             if (BankManagementUserSrc.withdraw(sender, tempBalance) && BankManagementUserSrc.deposit(recever, tempBalance))
             {
                 return(true);
             }
         }
         BankManagementUserSrc.connectionStatus = true;
         reciverConnection.Close();
     }
     catch (Exception ex)
     {
         BankManagementUserSrc.connectionStatus = false;
         return(false);
     }
     return(false);
 }