private void OtdelKadrov_Load(object sender, EventArgs e) { ConnectBD connectBD = new ConnectBD(); SqlConnection sqlConnection = connectBD.GetSqlConnection(dataSource, initialCatalog, userID, password, checkSecurity); SqlCommand command = new SqlCommand(qwSotr, sqlConnection); sqlConnection.Open(); SqlDataReader reader = command.ExecuteReader(); List <string[]> data = new List <string[]>(); while (reader.Read()) { data.Add(new string[6]); data[data.Count - 1][0] = reader[0].ToString(); data[data.Count - 1][1] = reader[1].ToString(); data[data.Count - 1][2] = reader[2].ToString(); data[data.Count - 1][3] = reader[3].ToString(); data[data.Count - 1][4] = reader[4].ToString(); } reader.Close(); foreach (string[] s in data) { dataGridView1.Rows.Add(s); } }
private void Button2_Click(object sender, EventArgs e) { if (textBox2.Text == textBox3.Text) { try { SqlConnection sqlConnection = database.DatabaseSQL(); string passwordHash = GetHash(textBox2.Text); ConnectBD connectBD = new ConnectBD(); ConnectBD sqlBD = new ConnectBD(); using (sqlConnection) { sqlConnection.Open(); SqlCommand sqlCommand = new SqlCommand("Authorization_Insert", sqlConnection) { CommandType = CommandType.StoredProcedure }; sqlCommand.Parameters.AddWithValue("@Login", textBox1.Text); sqlCommand.Parameters.AddWithValue("@Password", passwordHash); sqlCommand.Parameters.AddWithValue("@Dolzn_Id", Convert.ToInt32(comboBox1.Text)); sqlCommand.ExecuteNonQuery(); } MessageBox.Show("Пользователь зарегистрирован"); } catch (Exception ex) { MessageBox.Show("Ошибка, проверьте правильность введенных данных" + ex.ToString()); } } else { MessageBox.Show("Пароли не совпадают!!!"); } }
private void Button3_Click(object sender, EventArgs e) { ConnectBD connectBD = new ConnectBD(); SqlConnection sqlConnection = connectBD.GetSqlConnection(dataSource, initialCatalog, userID, password, checkSecurity); try { SqlConnection sqlConnect = database.DatabaseSQL(); using (sqlConnect) { sqlConnect.Open(); SqlCommand sqlCommand = new SqlCommand("Sotrydnik_Delete", sqlConnect) { CommandType = CommandType.StoredProcedure }; sqlCommand.Parameters.AddWithValue("@ID_Sotrydnik", textBox1.Text); sqlCommand.ExecuteNonQuery(); } MessageBox.Show("Сотрудник удален"); this.Hide(); MainForm mf = new MainForm(); mf.Show(); } catch (Exception ex) { MessageBox.Show("Сотрудник не удален " + ex.Message); } }
private void Button1_Click(object sender, EventArgs e) { string loginCheck = textBox1.Text; string passwordCheck = GetHash(textBox2.Text); // MessageBox.Show(GetHash(textBox2.Text)); string checkCmd = $"Select Login, Password from Authorization_ where Login ='******' and Password ='******'"; ConnectBD connectBD = new ConnectBD(); SqlConnection sqlConnection = connectBD.GetSqlConnection(dataSource, initialCatalog, userID, password, checkSecurity); SqlCommand sqlCommand = new SqlCommand(checkCmd, sqlConnection); using (sqlConnection) { try { sqlConnection.Open(); sqlCommand.Prepare(); sqlCommand.ExecuteNonQuery(); MessageBox.Show((string)sqlCommand.ExecuteScalar()); if (loginCheck == (string)sqlCommand.ExecuteScalar()) { this.Hide(); MainForm mf = new MainForm(); mf.Show(); } else { MessageBox.Show("Логин или пароль ведены не верно"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }