示例#1
0
        private void btn_aceptar_Click(object sender, EventArgs e)
        {
            foreach (var item in listBox1.Items)
            {
                ListaProductos.Text += item.ToString() + "\n";
            }

            n_venta reg = new n_venta();


            int cont = 0;

            if (string.IsNullOrEmpty(tbx_cliente_id.Text))
            {
                tbx_cliente_id.BackColor = Color.Red;
                cont++;
            }
            if (cont > 0)
            {
                MessageBox.Show("Falta ingresar campos");
            }


            if (cont == 0)
            {
                if (printPreviewDialog1.ShowDialog() == DialogResult.OK)
                {
                    printDocument1.Print();
                }

                ////////////////////////////////
                n_producto prodd = new n_producto();
                prodd.cargarVenta(tbx_cliente_id.Text, tbx_cliente_telefono.Text, tbx_preciototal.Text);



                foreach (String item in listBox1.Items)

                {
                    string aux = item.ToString();    /////



                    String[] separado;
                    separado = aux.Split(':');
                    string[] resu = separado[1].Split(',');



                    //string resup2 = prod.obtenerproductoid(resu[0]);

                    int        id = Convert.ToInt16(resu[0]), sto = Convert.ToInt16(resu[2]);
                    n_producto prod = new n_producto();
                    prod.actualizarStock(id, sto);
                    int resuu = prodd.cargarDetalleVentas(id, sto);
                    prodd.cargarDETALLECOMPLETO(id, sto, resuu);
                    //MessageBox.Show(id.ToString()+"  " + sto.ToString());
                    //MessageBox.Show(resuu.ToString());
                }

                tbx_id_producto.Text       = "";
                textBox1.Text              = "";
                tbx_nombre_producto.Text   = "";
                tbx_cantidad_producto.Text = "";
                tbx_preciototal.Text       = "";
                tbx_cliente_id.Text        = "";
                tbx_cliente_nombre.Text    = "";
                tbx_cliente_direccion.Text = "";
                tbx_cliente_telefono.Text  = "";
                busXnombre.Text            = "";
                dataGridView1.Visible      = false;
                listBox1.Items.Clear();
            }
        }