private void Label3_Click(object sender, EventArgs e) { this.Close(); MainCatalog mainCat = new MainCatalog(); mainCat.Show(); }
private void button1_Click(object sender, EventArgs e) { String login = textBox1.Text; String pass = textBox2.Text; DB db = new DB(); DataTable table1 = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); db.openConnection(); MySqlCommand command = new MySqlCommand("SELECT * FROM users WHERE login = @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(table1); if (table1.Rows.Count > 0) { int id = Convert.ToInt16(command.ExecuteScalar()); veloshop.userID = id; command = new MySqlCommand("SELECT acc_type FROM users WHERE ID = @uID", db.getConnection()); command.Parameters.Add("@uID", MySqlDbType.Int16).Value = veloshop.userID; string acc_type = command.ExecuteScalar().ToString(); if (acc_type == "admin") { this.Hide(); Information inform = new Information(); inform.Show(); db.closeConnection(); } else if (acc_type == "client") { this.Hide(); MainCatalog catalog = new MainCatalog(); catalog.Show(); db.closeConnection(); } } else { MessageBox.Show("Невірний логін або пароль!", "Помилка!"); } db.closeConnection(); }