Esempio n. 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();
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Impresion imp = new Impresion();

            imp.granTicket(dateReport.Text);
            imp = null;

            /*   System.IO.StreamReader filer = new System.IO.StreamReader("reportsPaths.txt");
             * string path = filer.ReadLine();
             * string fileName = "reporte" + dateReport.Text.Replace("/","-")+".xls";
             * System.IO.File.Copy(path+"/plantilla.xls", "reportes/"+fileName, true);
             * Querys query = new Querys();
             * int cantidad=1;
             * Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
             * if (xlApp == null)
             * {
             *     return;
             * }
             * Workbook wb = xlApp.Workbooks.Open(path+"/reportes/"+fileName, 0, false, 5, null, null, false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, null, true, false, 0, true, false, false);
             * // Workbook wb1 = xlApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
             * Worksheet ws = (Worksheet)wb.Worksheets[1];
             * // Worksheet ws1 = (Worksheet)wb1.Worksheets[1];
             *
             *
             * if (ws == null)
             * {
             *     Console.WriteLine("Worksheet could not be created. Check that your office installation and project references are correct.");
             * }
             * //ws.Copy(ws1);
             * //wb.Close();
             * cantidad = query.contarProducto(1, dateReport.Text);
             * ws.Cells[2, 5] = dateReport.Text;
             * ws.Cells[6, 2] = cantidad;
             * cantidad = query.contarProducto(14, dateReport.Text);
             * ws.Cells[7, 2] = cantidad;
             * cantidad = query.contarProducto(8, dateReport.Text);
             * ws.Cells[12, 2] = cantidad;
             * cantidad = query.contarProducto(21, dateReport.Text);
             * ws.Cells[13, 2] = cantidad;
             * cantidad = query.contarProducto(9, dateReport.Text);
             * ws.Cells[14, 2] = cantidad;
             * cantidad = query.contarProducto(2, dateReport.Text);
             * ws.Cells[20, 2] = cantidad;
             * cantidad = query.contarProducto(3, dateReport.Text);
             * cantidad=cantidad+ query.contarProducto(4, dateReport.Text);
             * cantidad = cantidad + query.contarProducto(5, dateReport.Text);
             * cantidad = cantidad + query.contarProducto(6, dateReport.Text);
             * ws.Cells[24, 2] = cantidad;
             * cantidad = query.contarProducto(20, dateReport.Text);
             * ws.Cells[27, 2] = cantidad;
             * cantidad = query.contarProducto(7, dateReport.Text);
             * ws.Cells[30, 2] = cantidad;
             * cantidad = query.contarProducto(16, dateReport.Text);
             * ws.Cells[31, 2] = cantidad;
             * cantidad = query.contarProducto(19, dateReport.Text);
             * ws.Cells[33, 2] = cantidad;
             * cantidad = query.contarProducto(18, dateReport.Text);
             * ws.Cells[34, 2] = cantidad;
             * xlApp.Visible = true;
             */
        }
Esempio n. 3
0
        private void btnAceptarPedido_Click(object sender, EventArgs e)
        {
            Querys   query = new Querys();
            Producto p;

            c.id = idCliente.Text;
            if (c.id == "")
            {
                c.nombre    = txtNombreCliente.Text;
                c.tel       = txtBuscar.Text;
                c.direccion = txtDireccionCliente.Text;
                c.colonia   = txtColoniaCliente.Text;
                c.calles    = txtEntreCallesCliente.Text;
                c.id        = Convert.ToString(query.AgregarClienteRetornId(txtNombreCliente.Text, txtBuscar.Text, txtDireccionCliente.Text, textColonia.Text, txtEntreCallesCliente.Text));
                //return;
            }

            if (nombreAux != txtNombreCliente.Text || dirAux != txtDireccionCliente.Text || entreAux != txtEntreCallesCliente.Text || colAux != textColonia.Text)
            {
                query.EditarCliente(c.id, txtNombreCliente.Text, txtBuscar.Text, txtDireccionCliente.Text, txtEntreCallesCliente.Text, textColonia.Text);
            }

            //else
            //{
            actualizarTotal();
            pedido.idPedidos = Convert.ToInt32(query.AgregarPedido(Convert.ToInt32(c.id), txtComen.Text, Convert.ToDecimal(labelTotal.Text)));
            pedido           = query.buscarPedido(pedido.idPedidos);
            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.AgregarDetallePedido(p.cantidad, p.precio, Convert.ToInt32(pedido.idPedidos), p.id);
                listaProductos.Add(p);
            }
            pedido.comentarios = txtComen.Text;
            Impresion im = new Impresion();

            c.nombre    = txtNombreCliente.Text;
            c.tel       = txtBuscar.Text;
            c.direccion = txtDireccionCliente.Text;
            c.colonia   = txtColoniaCliente.Text;
            c.calles    = txtEntreCallesCliente.Text;
            im.imprimirPedido(c, pedido, listaProductos);
            // MessageBox.Show("Pedido creado exitosamente");
            Close();
            //}

            /* for (int i = 0; i < listClientes.Items.Count; i++)
             * {
             *   if (listClientes.Items[i].Checked)
             *   {
             *       c.id = listClientes.Items[i].Text;
             *       c.nombre = listClientes.Items[i].SubItems[1].Text;
             *       c.tel = listClientes.Items[i].SubItems[2].Text;
             *
             *
             *   }
             */
            //}
        }