Exemplo n.º 1
0
        private void pay_Click(object sender, EventArgs e)
        {
            int price = 0;
            DB  db1   = new DB();

            db1.openConnection();
            MySqlDataAdapter adapter1 = new MySqlDataAdapter();
            MySqlCommand     command1 = new MySqlCommand("SELECT price FROM zakaz WHERE `ID` = @id", db1.getConnection());

            command1.Parameters.Add("@id", MySqlDbType.Int32).Value = Int32.Parse(num_list.SelectedItem.ToString());
            MySqlDataReader reader = command1.ExecuteReader();

            if (reader.Read())
            {
                price = Int32.Parse(reader[0].ToString());
            }
            db1.closeConnection();
            DB db = new restourant.DB();

            db.openConnection();
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand("DELETE FROM zakaz WHERE `ID` = @id", db.getConnection());

            command.Parameters.Add("@id", MySqlDbType.Int32).Value = Int32.Parse(num_list.SelectedItem.ToString());
            if (command.ExecuteNonQuery() == 1)
            {
                MessageBox.Show(String.Format("Оплатите {0} грн", price));
            }
            db.closeConnection();
            zakaz_box.Clear();
        }
Exemplo n.º 2
0
        public void update(object ob)
        {
            Thread.Sleep(600);

            Action action2 = () => num_box.Items.Clear();

            if (InvokeRequired)
            {
                Invoke(action2);
            }
            //zakaz_box.Clear();
            z_dic.Clear();
            DB db = new restourant.DB();

            db.openConnection();
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand("SELECT ID, z_text FROM zakaz where `ready` = 0 and `z_type` = 'Бар'", db.getConnection());
            MySqlDataReader  reader  = command.ExecuteReader();
            Action           action  = () => num_box.Items.Add(reader[0]);

            while (reader.Read())
            {
                if (InvokeRequired)
                {
                    Invoke(action);
                    z_dic.Add(Int32.Parse(reader[0].ToString()), reader[1].ToString());
                }
                else
                {
                    action();
                    z_dic.Add(Int32.Parse(reader[0].ToString()), reader[1].ToString());
                }
            }
            db.closeConnection();
        }
Exemplo n.º 3
0
        private void ready_Click(object sender, EventArgs e)
        {
            /* int price = 0;
             * DB db1 = new DB();
             * db1.openConnection();
             * MySqlDataAdapter adapter1 = new MySqlDataAdapter();
             * MySqlCommand command1 = new MySqlCommand("SELECT price FROM zakaz WHERE `ID` = @id", db1.getConnection());
             * command1.Parameters.Add("@id", MySqlDbType.Int32).Value = Int32.Parse(num_list.SelectedItem.ToString());
             * MySqlDataReader reader = command1.ExecuteReader();
             * if (reader.Read())
             *   price = Int32.Parse(reader[0].ToString());
             * db1.closeConnection();*/
            DB db = new restourant.DB();

            db.openConnection();
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand("UPDATE `zakaz` SET `ready` = '1' WHERE `ID` = @id;", db.getConnection());

            command.Parameters.Add("@id", MySqlDbType.Int32).Value = Int32.Parse(num_box.SelectedItem.ToString());
            if (command.ExecuteNonQuery() == 1)
            {
                MessageBox.Show("Сообщение отослано официанту!");
            }
            db.closeConnection();
            zakaz_box.Clear();
            ready.Enabled = false;
        }
Exemplo n.º 4
0
        private void add_Click(object sender, EventArgs e)
        {
            DB db = new restourant.DB();

            db.openConnection();
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand("INSERT INTO zakaz (`z_type`, `z_table`, `z_text`,  `price`, `ready`) VALUES (@type, @table, @text, @price, 0);", db.getConnection());

            command.Parameters.Add("@type", MySqlDbType.VarChar).Value = type_box.SelectedItem.ToString();
            command.Parameters.Add("@table", MySqlDbType.Int32).Value  = table_box.SelectedItem.ToString();
            command.Parameters.Add("@text", MySqlDbType.VarChar).Value = zakaz_box.ToString();
            command.Parameters.Add("@price", MySqlDbType.Int32).Value  = Int32.Parse(price.Text.ToString());
            if (command.ExecuteNonQuery() == 1)
            {
                MessageBox.Show("Заказ отправлен!");
            }
            db.closeConnection();
        }
Exemplo n.º 5
0
        /*private void ready_Click(object sender, EventArgs e)
         * {
         *  /* int price = 0;
         *   DB db1 = new DB();
         *   db1.openConnection();
         *   MySqlDataAdapter adapter1 = new MySqlDataAdapter();
         *   MySqlCommand command1 = new MySqlCommand("SELECT price FROM zakaz WHERE `ID` = @id", db1.getConnection());
         *   command1.Parameters.Add("@id", MySqlDbType.Int32).Value = Int32.Parse(num_list.SelectedItem.ToString());
         *   MySqlDataReader reader = command1.ExecuteReader();
         *   if (reader.Read())
         *       price = Int32.Parse(reader[0].ToString());
         *   db1.closeConnection();//
         *  DB db = new restourant.DB();
         *  db.openConnection();
         *  MySqlDataAdapter adapter = new MySqlDataAdapter();
         *  MySqlCommand command = new MySqlCommand("UPDATE `zakaz` SET `ready` = '1' WHERE `ID` = @id;", db.getConnection());
         *  command.Parameters.Add("@id", MySqlDbType.Int32).Value = Int32.Parse(num_box.SelectedItem.ToString());
         *  if (command.ExecuteNonQuery() == 1)
         *  {
         *      MessageBox.Show("Сообщение отослано официанту!");
         *  }
         *  db.closeConnection();
         *  zakaz_box.Clear();
         *  ready.Enabled = false;
         * }*/

        private void ready_Click_1(object sender, EventArgs e)
        {
            if (num_box.SelectedIndex != -1)
            {
                DB db = new restourant.DB();
                db.openConnection();
                MySqlDataAdapter adapter = new MySqlDataAdapter();
                MySqlCommand     command = new MySqlCommand("UPDATE `zakaz` SET `ready` = '1' WHERE `ID` = @id;", db.getConnection());
                command.Parameters.Add("@id", MySqlDbType.Int32).Value = Int32.Parse(num_box.SelectedItem.ToString());
                if (command.ExecuteNonQuery() == 1)
                {
                    MessageBox.Show("Сообщение отослано официанту!");
                }
                db.closeConnection();
                zakaz_box.Clear();
                ready.Enabled = false;
            }
        }
Exemplo n.º 6
0
        public void update(object ob)
        {
            Thread.Sleep(600);


            DB db = new restourant.DB();

            db.openConnection();
            MySqlDataAdapter adapter = new MySqlDataAdapter();
            MySqlCommand     command = new MySqlCommand("SELECT ID, z_table FROM zakaz where `ready` = 1", db.getConnection());
            MySqlDataReader  reader  = command.ExecuteReader();
            Action           action  = () => num_list.Items.Add(reader[0]);
            Action           action1 = () => table_list.Items.Add(reader[1].ToString());
            Action           action2 = () => table_list.Items.Clear();
            Action           action3 = () => num_list.Items.Clear();

            if (InvokeRequired)
            {
                Invoke(action2);
                Invoke(action3);
            }
            else
            {
                action2();
                action3();
            }
            while (reader.Read())
            {
                if (InvokeRequired)
                {
                    Invoke(action);
                    Invoke(action1);
                }
                else
                {
                    action();
                    action1();
                }
            }
            db.closeConnection();
        }