Example #1
0
 public static WSUser loginUser(WSDB db, string login, string password)
 {
     try
     {
         String          s      = String.Format("SELECT * FROM users WHERE username='******' AND password='******'", login, password);
         MySqlCommand    cmd    = new MySqlCommand(s, db.getConnection());
         MySqlDataReader reader = cmd.ExecuteReader();
         if (reader.Read())
         {
             WSUser tuser = new WSUser(reader.GetString(1), reader.GetString(4), reader.GetString(5), reader.GetInt32(6), reader.GetInt32(7));
             reader.Close();
             return(tuser);
         }
         else
         {
             reader.Close();
             return(null);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return(null);
     }
 }
 private void SignoutButton_Click(object sender, EventArgs e)
 {
     userpanelGroup.Visible = false;
     loginGroup.Enabled     = true;
     registerGroup.Enabled  = true;
     user             = null;
     loginTxt.Text    = "";
     passwordTxt.Text = "";
 }
 private void SigninBtn_Click(object sender, EventArgs e)
 {
     user = WSAPI.loginUser(db, loginTxt.Text, passwordTxt.Text);
     if (user is null)
     {
         MessageBox.Show("Logowanie nieudane! Sprawdź wpisane dane!");
     }
     else
     {
         setUpPanel();
         loginGroup.Enabled    = false;
         registerGroup.Enabled = false;
     }
 }
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Czy na pewno chcesz usunąć konto w WSBanku ?", "Uwaga!", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                if (WSAPI.deleteUser(db, user.getUserId()))
                {
                    userpanelGroup.Visible = false;
                    loginGroup.Enabled     = true;
                    registerGroup.Enabled  = true;
                    user             = null;
                    loginTxt.Text    = "";
                    passwordTxt.Text = "";
                    MessageBox.Show("Usunięto konto pomyślnie!");
                }
                else
                {
                    MessageBox.Show("Błąd przy usuwaniu konta!");
                }
            }
        }