private void btnLogin_Click(object sender, EventArgs e) { //авторизация int role, id; login = LogBox.Text; password = getHashSha256(PassBox.Text); connect.Open(); SqlCommand sql = new SqlCommand($"SELECT * FROM Пользователи WHERE Логин = '{login}' and Пароль = '{password}'", connect); reader = sql.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { role = reader.GetInt32(3); id = reader.GetInt32(0); switch (role) { case 1: AdminForm adm = new AdminForm(); this.StyleManager.Clone(adm); this.Hide(); adm.Show(); break; case 2: ManageForm mng = new ManageForm(id); this.StyleManager.Clone(mng); this.Hide(); mng.Show(); break; case 3: MasterForm mst = new MasterForm(); this.StyleManager.Clone(mst); mst.Show(); break; case 4: OpenClientForm oclt = new OpenClientForm(id); this.StyleManager.Clone(oclt); this.Hide(); oclt.Show(); break; } } } else { MessageBox.Show("Неверный логин или пароль, попробуйте снова", "Ошибка входа", MessageBoxButtons.OK, MessageBoxIcon.Error); attempts++; PassBox.Clear(); } reader.Close(); connect.Close(); if (attempts >= 3) { capcha(); } }
private void btnManage_Click(object sender, EventArgs e) { ManageForm mn = new ManageForm(1004); mn.Show(); }