예제 #1
0
        private void btnAceptarPedido_Click(object sender, EventArgs e)
        {
            Querys   query = new Querys();
            Producto p;

            if (labelTotal.Text == "")
            {
            }
            else
            {
                actualizarTotal();
                actualizarCambio();
                if (Convert.ToDecimal(cambio.Text) < 0)
                {
                    MessageBox.Show("El pago no cubre el total de la venta");
                    return;
                }
                venta.idVenta = Convert.ToInt32(query.AgregarVenta(Convert.ToInt32(idUsuario), Convert.ToDecimal(labelTotal.Text),
                                                                   txtComen.Text));

                for (int i = 0; i < gridProductos.RowCount - 1; i++)
                {
                    p          = new Producto();
                    p.id       = Convert.ToInt32(gridProductos.Rows[i].Cells[0].Value);
                    p.nombre   = Convert.ToString(gridProductos.Rows[i].Cells[1].Value);
                    p.precio   = Convert.ToDecimal(gridProductos.Rows[i].Cells[2].Value);
                    p.cantidad = Convert.ToDecimal(gridProductos.Rows[i].Cells[3].Value);

                    int idpro = Convert.ToInt32(gridProductos.Rows[i].Cells[0].Value);
                    query.AgregarDetalleVenta(p.cantidad, p.precio, venta.idVenta, p.id);
                    listaProductos.Add(p);
                }
                venta          = query.buscarVenta(venta.idVenta);
                venta.cambio   = Convert.ToDecimal(cambio.Text);
                venta.efectivo = pagoTotal.Value;
                Impresion im = new Impresion();

                im.imprimirVenta("nombre", venta, listaProductos);
                MessageBox.Show("Venta creada exitosamente");
                gridProductos.Rows.Clear();
                pagoTotal.Value = 0;
                venta           = new VentaClas();
                actualizarCambio();
                actualizarTotal();
                listaProductos.Clear();
                txtComen.Text = "";

                //Close();
            }
        }