Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int             Count = 0;
            String          query = "select count(*) from UsersDB where Login = '******' and Password = '******';";
            MySqlConnection conn  = DB.GetDBConnection();
            MySqlCommand    cmDB  = new MySqlCommand(query, conn);

            cmDB.CommandTimeout = 60;
            try
            {
                conn.Open();
                Count = Convert.ToInt32(cmDB.ExecuteScalar());
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Это просто буква А, ничего подозрительного");
            }

            if (Count > 0 && loginField.Text == "Admin" && passField.Text == "Admin")
            {
                AdminMenu win = new AdminMenu();
                win.Show();
                this.Hide();
            }
            else
            {
                if (Count > 0 && loginField.Text == "Security" && passField.Text == "123Lock")
                {
                    MainForm1 win = new MainForm1();
                    win.Show();
                    this.Hide();
                }
            }
        }
Exemplo n.º 2
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            String loginUser = loginField.Text;
            String passUser  = passField.Text;

            DB db = new DB();

            DataTable table = new DataTable();

            MySqlDataAdapter adapter = new MySqlDataAdapter();

            MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE `login` = @uL AND `pass` = @uP", DB.getConnection());

            command.Parameters.Add("@uL", MySqlDbType.VarChar).Value = loginUser;
            command.Parameters.Add("@uP", MySqlDbType.VarChar).Value = passUser;

            adapter.SelectCommand = command;
            adapter.Fill(table);

            if (table.Rows.Count > 0)
            {
                this.Hide();
                MainForm1 mainForm1 = new MainForm1();
                mainForm1.Show();
            }
            else
            {
                MessageBox.Show("No");
            }
        }
Exemplo n.º 3
0
        private void backmain_Click(object sender, EventArgs e)
        {
            this.Hide();
            MainForm1 mainForm1 = new MainForm1();

            mainForm1.Show();
        }
Exemplo n.º 4
0
        private void buttonaddstat_Click(object sender, EventArgs e)
        {
            if (author.Text == "Введите автора")
            {
                MessageBox.Show("Введите автора");
                return;
            }

            if (name.Text == "Введите название")
            {
                MessageBox.Show("Введите название");
                return;
            }

            if (tag.Text == "Введите тэги")
            {
                MessageBox.Show("Введите тэги");
                return;
            }

            if (stat.Text == "Напишите статью")
            {
                MessageBox.Show("Напишите статью");
                return;
            }

            if (modeS == "add")
            {
                string          query = "insert into article(author, name, tag, stat) values('" + author.Text + "', '" + name.Text + "', '" + tag.Text + "', '" + stat.Text + "');";
                MySqlConnection conn  = DB.GetDBConnection();
                MySqlCommand    cmDB  = new MySqlCommand(query, conn);
                cmDB.CommandTimeout = 60;
                try
                {
                    conn.Open();
                    MySqlDataReader rd = cmDB.ExecuteReader();
                    conn.Close();
                    MessageBox.Show("Статья была создана.");
                    this.Hide();
                    MainForm1 mainForm1 = new MainForm1();
                    mainForm1.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Статья была не создана.");
                    MessageBox.Show(ex.Message);
                }
            }
            if (modeS == "change")
            {
                string          content = stat.Text.ToString();
                string          query   = "update article set author ='" + author.Text + "', name='" + name.Text + "', tag='" + tag.Text + "', stat='" + stat.Text + "' where id = " + item.ToString() + ";";
                MySqlConnection conn    = DB.GetDBConnection();
                MySqlCommand    cmDB    = new MySqlCommand(query, conn);
                cmDB.CommandTimeout = 60;
                try
                {
                    conn.Open();
                    MySqlDataReader rd = cmDB.ExecuteReader();
                    conn.Close();
                    MessageBox.Show("Статья была изменена.");
                    this.Hide();
                    MainForm1 mainForm1 = new MainForm1();
                    mainForm1.Show();


                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Статья не изменена.");
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 5
0
        private void buttonaddstat_Click(object sender, EventArgs e)
        {
            if (author.Text == "Введите ФИО")
            {
                MessageBox.Show("Введите ФИО");
                return;
            }

            if (name.Text == " ")
            {
                MessageBox.Show("Введите температуру");
                return;
            }

            if (tag.Text == " ")
            {
                MessageBox.Show("Введите дату");
                return;
            }

            if (stat.Text == " ")
            {
                MessageBox.Show("Введите статус");
                return;
            }

            if (modeS == "add")
            {
                string          query = "insert into People(FI,Temper, Data, id_Status) values('" + author.Text + "', '" + name.Text + "', '" + tag.Text + "', '" + stat.Text + "');";
                MySqlConnection conn  = DB.GetDBConnection();
                MySqlCommand    cmDB  = new MySqlCommand(query, conn);
                cmDB.CommandTimeout = 60;
                try
                {
                    conn.Open();
                    MySqlDataReader rd = cmDB.ExecuteReader();
                    conn.Close();
                    MessageBox.Show("Данные успешно добавлены.");
                    this.Hide();
                    MainForm1 mainForm1 = new MainForm1();
                    mainForm1.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Не удалось добавить данные.");
                    MessageBox.Show(ex.Message);
                }
            }
            if (modeS == "change")
            {
                string          content = stat.Text.ToString();
                string          query   = "update People set FI ='" + author.Text + "', Temper='" + name.Text + "', Data='" + tag.Text + "', id_Status='" + stat.Text + "' where Id_People = " + item.ToString() + ";";
                MySqlConnection conn    = DB.GetDBConnection();
                MySqlCommand    cmDB    = new MySqlCommand(query, conn);
                cmDB.CommandTimeout = 60;
                try
                {
                    conn.Open();
                    MySqlDataReader rd = cmDB.ExecuteReader();
                    conn.Close();
                    MessageBox.Show("Данные успешно изменены.");
                    this.Hide();
                    MainForm1 mainForm1 = new MainForm1();
                    mainForm1.Show();


                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Не удалось изменить данные.");
                    MessageBox.Show(ex.Message);
                }
            }
        }