Пример #1
0
 private void LoginQuery()
 {
     string conn;
     //bool login = false;
     Connector c = new Connector();
     bool x = c.testConnection();
     if(x)
     {
         conn = c.getConnector();
         MySqlConnection newConnection = new MySqlConnection(conn);
         MySqlCommand newCommand;
         if (loginFlag == false)
         {
             newCommand = new MySqlCommand("select * from leavedata.employee where userid='" + this.UsernameBox.Text + "' and password='******';", newConnection);
         }
         else
         {
             newCommand = new MySqlCommand("select * from leavedata.employer where userid='" + this.UsernameBox.Text + "' and password='******';", newConnection);
         }
         MySqlDataReader newReader;
         newConnection.Open();
         newReader = newCommand.ExecuteReader();
         int count = 0;
         while(newReader.Read())
         {
             count += 1;
         }
         if(count == 1)
         {
             if (loginFlag == false)
             {
                 MessageBox.Show("Logged in as " + this.UsernameBox.Text);
                 HomeForm h = new HomeForm();
                 h.setLabel(this.UsernameBox.Text);
                 this.Hide();
                 h.Show();
             }
             else
             {
                 MessageBox.Show("Logged in as " + this.UsernameBox.Text);
                 AdminForm a = new AdminForm();
                 a.setLabel(this.UsernameBox.Text);
                 this.Hide();
                 a.Show();
             }
         }
         else if(count > 1)
         {
             MessageBox.Show("Duplicate Error");
         }
         else
         {
             MessageBox.Show("Incorrect Username or Password");
         }
         newConnection.Close();
     }
 }
Пример #2
0
 private void HomeButton_Click(object sender, EventArgs e)
 {
     this.Hide();
     AdminForm home = new AdminForm();
     string u = AdminForm.getLabel();
     home.setLabel(u);
     home.Show();
 }