private async void button5_Click(object sender, EventArgs e) { SqlConnection = new OleDbConnection(connectString); await SqlConnection.OpenAsync(); OleDbDataReader sqlReader = null; if (textBox3.Text != "") { if (textBox4.Text != "") { if (textBox5.Text != "") { if (textBox6.Text != "") { if (textBox7.Text != "") { if (textBox8.Text != "") { OleDbCommand command = new OleDbCommand("INSERT INTO [Клиенты] (ФИО, [E-mail], Дата, Телефон, Тема, Текст, Статус)VALUES(@fio, @mail, @data, @num, @theme, @text, @stat)", SqlConnection); command.Parameters.AddWithValue("fio", textBox3.Text); command.Parameters.AddWithValue("mail", textBox4.Text); command.Parameters.AddWithValue("data", textBox6.Text); command.Parameters.AddWithValue("num", textBox7.Text); command.Parameters.AddWithValue("theme", textBox5.Text); command.Parameters.AddWithValue("text", textBox8.Text); command.Parameters.AddWithValue("stat", "Консультант"); await command.ExecuteNonQueryAsync(); MessageBox.Show("Вопрос клиента был успешно добавлен!"); client_work_page a = new client_work_page(); a.Text = this.Text; a.Show(); this.Hide(); return; } } } } } } MessageBox.Show("Все поля должны бать заполены"); }
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; } } }