Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- string myConnection = "datasource=sql7.freemysqlhosting.net;port=3306;username=sql7148389;password=MisLVjvDUG";
- MySqlConnection myConn = new MySqlConnection(myConnection);
- MySqlCommand SelectCommand = new MySqlCommand("select dzial,admin from sql7148389.user where username='" + this.username_txt.Text + " ' and password='" + this.password_txt.Text + "';", myConn);
- MySqlDataReader myReader;
- myConn.Open();
- myReader = SelectCommand.ExecuteReader();
- int count = 0;
- while(myReader.Read())
- {
- count = count + 1;
- }
- if (count == 1 && (myReader.GetValue(0).ToString()=="Biuro"))
- {
- MessageBox.Show("Login i hasło są poprawne");
- username = username_txt.Text;
- this.Hide();
- Form8 f3 = new Form8(username);
- f3.ShowDialog();
- }
- else if (count == 1 && (myReader.GetValue(1).ToString() == "1"))
- {
- // MessageBox.Show(myReader.GetValue(0).ToString());
- MessageBox.Show("Login i hasło są poprawne");
- this.Hide();
- Form3 f3 = new Form3();
- f3.ShowDialog();
- }
- else if (count == 1 && (myReader.GetValue(0).ToString() == "Warsztat"))
- {
- MessageBox.Show("Login i hasło są poprawne");
- username = username_txt.Text;
- this.Hide();
- Form1 f3 = new Form1(username);
- f3.ShowDialog();
- }
- else if (count > 1)
- {
- MessageBox.Show("Zduplikowany login i hasło. Brak dostępu");
- }
- else
- MessageBox.Show("Login i hasło są niepoprawne");
- myConn.Close();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement