Пример #1
0
        private void buttonBuy_Click(object sender, EventArgs e)
        {
            string productname = ProductComboBox.GetItemText(ProductComboBox.SelectedItem);
            string qr          = $"SELECT id_product FROM public.inventory WHERE \"productName\" = '{productname}'";
            var    sl          = ConnectionDB.ExecuteQuery(qr);
            int    id          = int.Parse(sl.Rows[0][2].ToString());
            var    q           = textBox1.Text;
            int    quantity    = int.Parse(q);

            ConnectionDB.ExecuteNonQuery($"INSERT INTO public.orders(username, id_product, quantity)" +
                                         $" VALUES('{username}', {id}, {quantity})");

            MessageBox.Show("La orden ha sido registrada!!");
        }
Пример #2
0
        private void buttonBuy_Click(object sender, EventArgs e)
        {
            int quantity = int.Parse(textBox1.Text);
            var qr       = "SELECT id_product FROM public.inventory WHERE" +
                           $" \"productName\" = '{ProductComboBox.GetItemText(ProductComboBox.SelectedItem)}'";
            DataTable dt = ConnectionDB.ExecuteQuery(qr);
            //var ids = dt.Rows[0][0].ToString();
            int id = Convert.ToInt32(dt.Rows[0][0].ToString());

            ConnectionDB.ExecuteNonQuery($"INSERT INTO public.orders(username, id_product, quantity)" +
                                         $" VALUES('{username}', {id}, {quantity})");

            MessageBox.Show("La orden ha sido registrada!!");
        }