private async void button6_Click(object sender, EventArgs e) { if (comboBox6.Text != "") { SqlConnection = new OleDbConnection(connectString); await SqlConnection.OpenAsync(); OleDbDataReader sqlReader = null; OleDbCommand command = new OleDbCommand("UPDATE [Клиенты] SET [Статус]=@status WHERE [Телефон]=@num", SqlConnection); command.Parameters.AddWithValue("status", comboBox6.Text); command.Parameters.AddWithValue("num", comboBox5.Text); await command.ExecuteNonQueryAsync(); await command.ExecuteNonQueryAsync(); MessageBox.Show("Статус вопроса успешно изменен"); admin_panel open_form = new admin_panel(); open_form.Text = this.Text; open_form.Show(); this.Hide(); } else { comboBox6.BackColor = Color.Peru; } }
private async void button1_Click(object sender, EventArgs e) { SqlConnection = new OleDbConnection(connectString); await SqlConnection.OpenAsync(); OleDbDataReader sqlReader = null; if (textBox2.Text != "") { OleDbCommand command = new OleDbCommand("INSERT INTO [Чат] (Пользователь, Текст, Роль)VALUES(@login, @text, @rol)", SqlConnection); command.Parameters.AddWithValue("login", this.Text); command.Parameters.AddWithValue("text", textBox2.Text); command.Parameters.AddWithValue("rol", "Консультант"); await command.ExecuteNonQueryAsync(); command = new OleDbCommand("SELECT * FROM [Чат]", SqlConnection); sqlReader = command.ExecuteReader(); while (sqlReader.Read()) { int for_id = 0; while (true) { if (for_id == Convert.ToInt32(sqlReader["Код"])) { if (this.Text == Convert.ToString(sqlReader["Пользователь"])) { textBox1.Text += "Вы" + ": " + Convert.ToString(sqlReader["Текст"]) + "\r\n" + "\r\n"; } else { textBox1.Text += Convert.ToString(sqlReader["Пользователь"]) + " (" + Convert.ToString(sqlReader["Роль"]) + "): " + Convert.ToString(sqlReader["Текст"]) + "\r\n" + "\r\n"; } break; } for_id++; } } admin_panel a = new admin_panel(); a.Text = this.Text; a.Show(); this.Hide(); } else { textBox2.BackColor = Color.Peru; } }
private async void button2_Click(object sender, EventArgs e) { SqlConnection = new OleDbConnection(connectString); await SqlConnection.OpenAsync(); OleDbDataReader sqlReader = null; if (textBox4.Text != "") { if (textBox3.Text != "") { if (comboBox1.Text != "") { OleDbCommand command = new OleDbCommand("INSERT INTO [Пользователи] (Логин, Пароль, ФИО, Роль)VALUES(@login, @password, @fio, @rol)", SqlConnection); command.Parameters.AddWithValue("login", textBox4.Text); command.Parameters.AddWithValue("password", textBox3.Text); command.Parameters.AddWithValue("fio", textBox13.Text); command.Parameters.AddWithValue("rol", comboBox1.Text); await command.ExecuteNonQueryAsync(); MessageBox.Show("Пользователь был успешно добавлен!"); admin_panel a = new admin_panel(); a.Text = this.Text; a.Show(); this.Hide(); return; } else { comboBox1.BackColor = Color.Peru; } } else { textBox3.BackColor = Color.Peru; } } else { textBox4.BackColor = Color.Peru; } MessageBox.Show("Все поля должны бать заполены"); }
private async void button3_Click(object sender, EventArgs e) { if (textBox5.Text != "") { if (textBox6.Text != "") { if (comboBox2.Text != "") { SqlConnection = new OleDbConnection(connectString); await SqlConnection.OpenAsync(); OleDbDataReader sqlReader = null; OleDbCommand command = new OleDbCommand("UPDATE [Пользователи] SET [Логин]=@login, [Пароль]=@pass, [Роль]=@rol WHERE [Логин]=@log", SqlConnection); command.Parameters.AddWithValue("login", textBox5.Text); command.Parameters.AddWithValue("pass", textBox6.Text); command.Parameters.AddWithValue("rol", comboBox2.Text); command.Parameters.AddWithValue("log", comboBox3.Text); await command.ExecuteNonQueryAsync(); await command.ExecuteNonQueryAsync(); MessageBox.Show("Данные пользователя успешно изменены"); admin_panel open_form = new admin_panel(); open_form.Text = this.Text; open_form.Show(); this.Hide(); } else { comboBox2.BackColor = Color.Peru; } } else { textBox6.BackColor = Color.Peru; } } else { textBox5.BackColor = Color.Peru; } }
private async void button5_Click(object sender, EventArgs e) { SqlConnection = new OleDbConnection(connectString); await SqlConnection.OpenAsync(); OleDbDataReader sqlReader = null; OleDbCommand command = new OleDbCommand("DELETE * FROM [Пользователи] WHERE [Логин]=@log", SqlConnection); command.Parameters.AddWithValue("log", comboBox4.Text); await command.ExecuteNonQueryAsync(); MessageBox.Show("Пользователь успешно удален"); admin_panel open_form = new admin_panel(); open_form.Text = this.Text; open_form.Show(); this.Hide(); }
private async void button1_Click(object sender, EventArgs e) { if (textBox1.Text != "") { if (textBox2.Text != "") { SqlConnection = new OleDbConnection(connectString); await SqlConnection.OpenAsync(); OleDbDataReader sqlReader = null; OleDbCommand command = new OleDbCommand("SELECT * FROM [Пользователи]", SqlConnection); try { sqlReader = command.ExecuteReader(); while (sqlReader.Read()) { if ((textBox1.Text == Convert.ToString(sqlReader["Логин"])) && (textBox2.Text == Convert.ToString(sqlReader["Пароль"]))) { if (Convert.ToString(sqlReader["Роль"]) == "Консультант") { common_cons a = new common_cons(); a.Show(); a.Text = Convert.ToString(sqlReader["Логин"]); this.Hide(); } if (Convert.ToString(sqlReader["Роль"]) == "Главный Консультант") { main_cons a = new main_cons(); a.Show(); a.Text = Convert.ToString(sqlReader["Логин"]); this.Hide(); } if (Convert.ToString(sqlReader["Роль"]) == "Администратор") { admin_panel a = new admin_panel(); a.Show(); a.Text = Convert.ToString(sqlReader["Логин"]); this.Hide(); } if (Convert.ToString(sqlReader["Роль"]) == "Работа с клиентом") { client_work_page a = new client_work_page(); a.Show(); a.Text = Convert.ToString(sqlReader["Логин"]); this.Hide(); } } label12.Visible = true; textBox1.BackColor = Color.Peru; textBox2.BackColor = Color.Peru; } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { textBox2.BackColor = Color.Peru; } } else { if (textBox2.Text == "") { textBox1.BackColor = Color.Peru; textBox2.BackColor = Color.Peru; } else { textBox1.BackColor = Color.Peru; } } }