private void button2_Click(object sender, EventArgs e) { string connection = "Database=marathon-skills-2020;" + "Data Source=127.0.0.1;" + "User Id=root;" + "Password=root;"; MySqlConnection connect = new MySqlConnection(connection); connect.Open(); try { MySqlCommand command = new MySqlCommand("SELECT * FROM `user` WHERE `Email`= '" + textBox1.Text + "' AND `Password`= '" + textBox2.Text + "';", connect); string countuser; string Role = ""; MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { countuser = reader.GetString(0); Role = reader.GetString("RoleId"); } reader.Close(); // if (countuser == 1) // { if (Role == "R") { Form7 f7 = new Form7(); f7.Show(); } if (Role == "A") { Form7 f9 = new Form7(); f9.Show(); } if (Role == "C") { Form7 f8 = new Form7(); f8.Show(); } // } connect.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click_1(object sender, EventArgs e) { Form7 form = new Form7(); form.Show(); }
private void Buttonlogin_Click(object sender, EventArgs e) { /* String login = loginbox.Text; * String pass = passbox.Text; * Form7 Fr = new Form7(); * db DB = new db(); * * DataTable table = new DataTable(); * * MySqlDataAdapter adapter = new MySqlDataAdapter(); * * MySqlCommand command = new MySqlCommand("SELECT * FROM `user` WHERE `Email`= @uL AND `Password`= @uP", DB.getConnection()); * * command.Parameters.Add("@uL", MySqlDbType.VarChar).Value = login; * command.Parameters.Add("@uP", MySqlDbType.VarChar).Value = pass; * * adapter.SelectCommand = command; * adapter.Fill(table); * * if (table.Rows.Count > 0) * { * Fr.Show(); * Hide(); * } * else * MessageBox.Show("Пользователь не авторизован"); */ string connection = "Database=marathon-skills-2020;" + "Data Source=127.0.0.1;" + "User Id=root;" + "Password=root;"; MySqlConnection connect = new MySqlConnection(connection); connect.Open(); MySqlCommand command = new MySqlCommand("SELECT COUNT(*) ,RoleId,Password,Email,FirstName,LastName " + "FROM user " + "WHERE Email LIKE'" + loginbox.Text + "'" + " AND " + "Password LIKE '" + passbox.Text + "';", connect); int countuser = 0; string role = ""; string firsname = ""; string lasname = ""; string login = ""; MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { countuser = reader.GetInt32(0); role = reader.GetString("RoleId"); login = reader.GetString("Email"); firsname = reader.GetString("FirstName"); lasname = reader.GetString("LastName"); } reader.Close(); if (countuser != 0) { if (role == "R") { Form7 runnermenu = new Form7(); runnermenu.Show(); this.Hide(); } if (role == "A") { Form9 form = new Form9(); form.Show(); this.Hide(); } if (role == "C") { Form8 koordmenu = new Form8(); koordmenu.Show(); this.Hide(); } connect.Close(); } else { MessageBox.Show("Не верно введен логин или пароль"); } }