Ejemplo n.º 1
0
        private void LoadData()
        {
            DataBase1 database = new DataBase1();

            MySqlCommand command = new MySqlCommand("SELECT * FROM `info` WHERE `Оформление` = 2", database.getConnection());

            database.openConnection();

            MySqlDataReader reader = command.ExecuteReader();

            List <string[]> data = new List <string[]>();

            while (reader.Read())
            {
                data.Add(new string[8]);

                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();
                data[data.Count - 1][5] = reader[5].ToString();
                data[data.Count - 1][6] = reader[6].ToString();
                data[data.Count - 1][7] = reader[7].ToString();
            }

            reader.Close();

            database.closeConnection();

            foreach (string[] s in data)
            {
                dataGridView1.Rows.Add(s);
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int    ind = dataGridView1.SelectedCells[0].RowIndex;
            String s   = dataGridView1[0, ind].Value.ToString();

            DataBase1 database = new DataBase1();

            MySqlCommand command = new MySqlCommand("DELETE FROM `info` WHERE `id` =" + s, database.getConnection());

            database.openConnection();

            MySqlDataReader reader = command.ExecuteReader();

            List <string[]> data = new List <string[]>();

            while (reader.Read())
            {
                data.Remove(new string[8]);

                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();
                data[data.Count - 1][5] = reader[5].ToString();
                data[data.Count - 1][6] = reader[6].ToString();
                data[data.Count - 1][7] = reader[7].ToString();
            }

            reader.Close();

            database.closeConnection();

            dataGridView1.Rows.RemoveAt(ind);
        }
Ejemplo n.º 3
0
        private void LoadData()
        {
            DataBase1 database = new DataBase1();

            MySqlCommand command = new MySqlCommand("SELECT * FROM `progs` ORDER BY `id`", database.getConnection());

            database.openConnection();

            MySqlDataReader reader = command.ExecuteReader();

            List <string[]> data = new List <string[]>();

            while (reader.Read())
            {
                data.Add(new string[3]);

                data[data.Count - 1][0] = reader[0].ToString();
                data[data.Count - 1][1] = reader[1].ToString();
                data[data.Count - 1][2] = reader[2].ToString();
            }

            reader.Close();

            database.closeConnection();

            foreach (string[] s in data)
            {
                dataGridView1.Rows.Add(s);
            }
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataBase1 database = new DataBase1();

            MySqlCommand command = new MySqlCommand("INSERT INTO `info` (`Клиент`, `ФИО сотрудника`, `Программа`, `Дата принятия заказа`, `Телефон`, `Адрес подразделения`, `Оформление`) VALUES (@client, @namestaff, @prog, @date, @number, @address, 0)", database.getConnection());

            command.Parameters.Add("@client", MySqlDbType.VarChar).Value    = textBox1.Text;
            command.Parameters.Add("@namestaff", MySqlDbType.VarChar).Value = textBox2.Text;
            command.Parameters.Add("@prog", MySqlDbType.VarChar).Value      = comboBox1.Text;
            command.Parameters.Add("@date", MySqlDbType.Date).Value         = dateTimePicker1.Value;
            command.Parameters.Add("@number", MySqlDbType.VarChar).Value    = textBox3.Text;
            command.Parameters.Add("@address", MySqlDbType.VarChar).Value   = textBox4.Text;

            database.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                MessageBox.Show("Добавлено");
            }
            else
            {
                MessageBox.Show("Ошибка!");
            }

            database.closeConnection();
        }
Ejemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataBase1 database = new DataBase1();

            MySqlCommand command = new MySqlCommand("INSERT INTO `progs` (`Программа`, `Количество`) VALUES (@prog, @count)", database.getConnection());

            command.Parameters.Add("@prog", MySqlDbType.VarChar).Value  = comboBox1.Text;
            command.Parameters.Add("@count", MySqlDbType.VarChar).Value = textBox1.Text;

            database.openConnection();

            if (command.ExecuteNonQuery() == 1)
            {
                MessageBox.Show("Добавлено");
            }
            else
            {
                MessageBox.Show("Ошибка!");
            }

            database.closeConnection();
        }