コード例 #1
0
        private async void button2_Click(object sender, EventArgs e)
        {
            SqlConnection = new OleDbConnection(connectString);
            await SqlConnection.OpenAsync();

            OleDbDataReader sqlReader = null;

            OleDbCommand command = new OleDbCommand("SELECT * FROM [Пользователи]", SqlConnection);

            sqlReader = command.ExecuteReader();

            while (sqlReader.Read())
            {
                if (Convert.ToString(sqlReader["Логин"]) == this.Text)
                {
                    if (Convert.ToString(sqlReader["Роль"]) == "Консультант")
                    {
                        common_cons a = new common_cons();
                        a.Show();
                        a.Text = this.Text;
                        this.Hide();
                    }

                    if (Convert.ToString(sqlReader["Роль"]) == "Главный Консультант")
                    {
                        main_cons a = new main_cons();
                        a.Show();
                        a.Text = this.Text;
                        this.Hide();
                    }
                }
            }
        }
コード例 #2
0
ファイル: main_cons.cs プロジェクト: 663021/KONSULTANT-
        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++;
                    }
                }

                main_cons a = new main_cons();
                a.Text = this.Text;
                a.Show();
                this.Hide();
            }
            else
            {
                textBox2.BackColor = Color.Peru;
            }
        }
コード例 #3
0
ファイル: login_screen.cs プロジェクト: 663021/KONSULTANT-
        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;
                }
            }
        }