private void dgvDatos_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (IndexColumna("clmVer") == e.ColumnIndex) { if (cmbTipo.Text == "Ventas") { PDFInvoice.CreatePDF(TipoInvoice.Venta, ValorCelda(e.RowIndex, "clmFolio"), ValorCelda(e.RowIndex, "clmFecha"), obtenerProductos(ValorCelda(e.RowIndex, "clmFolio")), c, impuesto); PDFFile.Ver(Application.StartupPath + "\\Invoice.pdf"); } else { PDFInvoice.CreatePDF(TipoInvoice.Cotizacions, ValorCelda(e.RowIndex, "clmFolio"), ValorCelda(e.RowIndex, "clmFecha"), obtenerProductosCo(ValorCelda(e.RowIndex, "clmFolio")), c, impuesto); PDFFile.Ver(Application.StartupPath + "\\Invoice.pdf"); } } else if (IndexColumna("clmImprimir") == e.ColumnIndex) { if (cmbTipo.Text == "Ventas") { PDFInvoice.CreatePDF(TipoInvoice.Venta, ValorCelda(e.RowIndex, "clmFolio"), ValorCelda(e.RowIndex, "clmFecha"), obtenerProductos(ValorCelda(e.RowIndex, "clmFolio")), c, impuesto); PDFFile.Imprimir(this, Application.StartupPath + "\\Invoice.pdf"); } else { PDFInvoice.CreatePDF(TipoInvoice.Cotizacions, ValorCelda(e.RowIndex, "clmFolio"), ValorCelda(e.RowIndex, "clmFecha"), obtenerProductosCo(ValorCelda(e.RowIndex, "clmFolio")), c, impuesto); PDFFile.Imprimir(this, Application.StartupPath + "\\Invoice.pdf"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnCorte_Click(object sender, EventArgs e) { try { List <string[]> lista = Corte("SELECT venta.id_venta,clientes.id_cliente, clientes.nombres,clientes.apellido_paterno,clientes.apellido_materno, venta.fecha_de_venta," + "SUM(productos_de_venta.cantidad_comprada*productos_de_venta.precio_al_momento)-(SUM(productos_de_venta.cantidad_comprada*productos_de_venta.precio_al_momento*(productos_de_venta.descuento/100)))," + " venta.cancelada FROM venta,clientes,productos_de_venta" + " WHERE (venta.cancelada=0 AND venta.fecha_de_venta LIKE '%" + dtpFecha.Value.ToString("yyyy-MM-dd") + "%') AND venta.pagada=1" + " AND (clientes.id_cliente=venta.id_cliente) AND (productos_de_venta.id_venta=venta.id_venta) " + "GROUP BY venta.id_venta "); List <string[]> pendientes = Pendientes("SELECT venta.id_venta,clientes.id_cliente, clientes.nombres,clientes.apellido_paterno,clientes.apellido_materno, venta.fecha_de_venta," + "SUM(productos_de_venta.cantidad_comprada*productos_de_venta.precio_al_momento)-(SUM(productos_de_venta.cantidad_comprada*productos_de_venta.precio_al_momento*(productos_de_venta.descuento/100)))," + " venta.cancelada FROM venta,clientes,productos_de_venta" + " WHERE (venta.cancelada=0 AND venta.fecha_de_venta LIKE '%" + dtpFecha.Value.ToString("yyyy-MM-dd") + "%') AND venta.pagada=0" + " AND (clientes.id_cliente=venta.id_cliente) AND (productos_de_venta.id_venta=venta.id_venta) " + "GROUP BY venta.id_venta "); List <string[]> abonos = Abonos("SELECT abonos.id_venta, abonos.fecha_abono, abonos.cantidad_abonada FROM abonos " + "WHERE abonos.fecha_abono LIKE '%" + dtpFecha.Value.ToString("yyyy-MM-dd") + "%'"); InfoReporte rep = GuardarInfoReporte.Leer(); string[,] data = { { "Corte", "Fecha: ", "RFC: ", "Direccion: ", "Telefono: " }, { " ", lista[0][2].ToString(), rep.Reporte.rfc, rep.Reporte.direccion, rep.Reporte.telefono } }; PDFFile pdf = new PDFFile("corte", "corte-"); float total = 0; for (int i = 0; i < lista.Count; i++) { total += float.Parse(lista[i][6].ToString()); } pdf.CrearPDF(); pdf.CrearCabecera(data); pdf.AgregarCorte(lista, pendientes, abonos); pdf.Cerrar(); PDFFile.Ver(pdf.Ruta); } catch (Exception) { } }
private void rbnFormato_Click(object sender, EventArgs e) { try { List <string[]> productos = Sql.BuscarDatos("SELECT codigo,nombre,precio_publico FROM productos WHERE eliminado=0 ORDER BY nombre ASC;"); ProductoCompleto p = new ProductoCompleto(); List <ProductoCompleto> pr = new List <ProductoCompleto>(); foreach (string[] a in productos) { p.Codigo = a[0]; p.Descripcion = a[1]; p.Precio = float.Parse(a[2]); pr.Add(p); } PDFInvoice.FormatoInventario(pr); PDFFile.Ver(Application.StartupPath + "\\Formato.pdf"); } catch (Exception) { MessageBox.Show("Error"); } }
private void rbnBtnReporteImprimir_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.CheckFileExists = true; ofd.CheckPathExists = true; ofd.Multiselect = false; ofd.ShowReadOnly = true; ofd.Title = "Ver archivo reciente"; ofd.Filter = "Archivo PDF (*.pdf)|"; ofd.RestoreDirectory = true; ofd.InitialDirectory = Application.StartupPath + "\\reportes\\"; DialogResult dr = ofd.ShowDialog(); if (dr == DialogResult.OK) { PDFFile.Imprimir(this, ofd.FileName); } }
private void btnImprimir_Click(object sender, EventArgs e) { if (dgvVentas.RowCount > 1) { string id_cliente = Sql.BuscarDatos("SELECT id_cliente FROM clientes WHERE rfc = '" + txtRfc.Text + "'")[0][0]; string fecha = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); float totalParcial = 0; List <ProductoCompleto> productos = new List <ProductoCompleto>(); ProductoCompleto producto; for (int i = 0; i < dgvVentas.RowCount; i++) { producto = new ProductoCompleto(dgvVentas.Rows[i].Cells["codigo"].Value.ToString(), dgvVentas.Rows[i].Cells["descripcion"].Value.ToString(), float.Parse(dgvVentas.Rows[i].Cells["cantidad"].Value.ToString()), int.Parse(dgvVentas.Rows[i].Cells["descuentoPro"].Value.ToString()), float.Parse(dgvVentas.Rows[i].Cells["subtotal"].Value.ToString())); productos.Add(producto); totalParcial += float.Parse(dgvVentas.Rows[i].Cells["subtotal"].Value.ToString()); } ImpresionTickets.ImprimeTicket(fol, productos, totalParcial, totalParcial, fechaT, txtNombre.Text, txtApellidoPaterno.Text, impuesto); PDFFile.Ver(Application.StartupPath + "\\Ticket.pdf"); } }
private void rbnBtnCatalogo_Click(object sender, EventArgs e) { try { List <string[]> productos = Sql.BuscarDatos("SELECT codigo,nombre,precio_publico,precio_distribuidor, precio_minimo, imagen FROM productos WHERE eliminado=0 ORDER BY nombre ASC;"); ProductoCatalogo p = new ProductoCatalogo(); List <ProductoCatalogo> pr = new List <ProductoCatalogo>(); foreach (string[] a in productos) { p.Codigo = a[0]; p.Descripcion = a[1]; p.PrecioPublico = float.Parse(a[2]); p.PrecioDistribuidor = float.Parse(a[3]); p.PrecioMinimo = float.Parse(a[4]); p.Imagen = a[5]; pr.Add(p); } PDFCatalogo.Catalogo(pr); PDFFile.Ver(Application.StartupPath + "\\Catalogo.pdf"); } catch (Exception ae) { MessageBox.Show(ae.Message); } //tempClass.generaNombres(); }
private string Reporte(string folio) { try { List <ProductoCompleto> listaProductos = new List <ProductoCompleto>(); string[] pedido, usuario, cliente; try { pedido = Sql.BuscarDatos("SELECT * FROM venta WHERE id_venta = '" + folio + "'")[0]; } catch (Exception) { pedido = new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " " }; } try { usuario = Sql.BuscarDatos("SELECT usuario, nombre, apellido_paterno, apellido_materno" + " FROM usuarios WHERE id_usuario = '" + pedido[1] + "'")[0]; } catch (Exception) { usuario = new string[] { " ", " ", " ", " " }; } try { cliente = Sql.BuscarDatos("SELECT nombres, apellido_paterno, apellido_materno, rfc, telefono, domicilio, correo_electronico " + " FROM clientes WHERE id_cliente = '" + pedido[2] + "'")[0]; } catch (Exception) { cliente = new string[] { " ", " ", " ", " ", " ", " ", " " }; } foreach (string datos in pedido[5].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { string[] temp = datos.Split(new char[] { ':' }); if (Sql.Existe("SELECT codigo, nombre FROM productos WHERE codigo = '" + temp[0] + "' ")) { string[] producto = Sql.BuscarDatos("SELECT codigo, nombre FROM productos WHERE codigo = '" + temp[0] + "' ")[0]; listaProductos.Add(new ProductoCompleto(producto[0], producto[1], float.Parse(temp[1]), int.Parse(temp[3]), float.Parse(temp[2]))); } else { listaProductos.Add(new ProductoCompleto("Codigo elim.", "Productos elim.", float.Parse(temp[1]), int.Parse(temp[3]), float.Parse(temp[2]))); } } Venta venta = new Venta(int.Parse(pedido[0]), new Usuarios(usuario[0], usuario[1] + " " + usuario[2] + " " + usuario[3]), new Clientes(cliente[0], cliente[1], cliente[2], cliente[3], cliente[4], cliente[5], cliente[6]), bool.Parse(pedido[3]), pedido[4], listaProductos, float.Parse(pedido[6]), float.Parse(pedido[7]), float.Parse(pedido[8])); InfoReporte rep = GuardarInfoReporte.Leer(); string[,] data = { { "Cotización Tienda", "Fecha: ", "RFC: ", "Dirección: ", "Telefono: ", "Atendido por: " }, { folio, venta.Fecha, rep.Reporte.rfc, rep.Reporte.direccion, rep.Reporte.telefono, venta.Usuario.NombreCompleto } }; PDFFile pdf = new PDFFile("reportes", "reporte-"); pdf.CrearPDF(); for (int i = 0; i < 2; i++) { if (i == 1) { data[0, 0] = "Cotización cliente"; pdf.NuevoRenglon(); pdf.CrearCabecera(data); } else { pdf.NuevoRenglon(); pdf.CrearCabecera(data); } pdf.AgregarInfoCliente(venta.Cliente); pdf.AgregarProductos(venta, false); pdf.AgregarAnotaciones(" "); pdf.NuevaPagina(); } data[0, 0] = "Almacen"; pdf.CrearCabecera(data); pdf.AgregarInfoCliente(venta.Cliente); pdf.AgregarProductos(venta, true); pdf.AgregarAnotaciones(" "); pdf.Cerrar(); return(pdf.Ruta); } catch (Exception) { } return(null); }
private string ReporteCotizacion(string id_cotizacion) { try { List <ProductoCompleto> listaProductos = new List <ProductoCompleto>(); string[] cotizacion, usuario, cliente; try { cotizacion = Sql.BuscarDatos("SELECT * FROM cotizacion WHERE id_cotizacion = '" + id_cotizacion + "'")[0]; } catch (Exception) { cotizacion = new string[] { " ", " ", " ", " ", " ", " ", " ", " ", " " }; } try { usuario = Sql.BuscarDatos("SELECT usuario, nombre, apellido_paterno, apellido_materno" + " FROM usuarios WHERE id_usuario = '" + cotizacion[1] + "'")[0]; } catch (Exception) { usuario = new string[] { " ", " ", " ", " " }; } try { cliente = Sql.BuscarDatos("SELECT nombres, apellido_paterno, apellido_materno, rfc, telefono, domicilio, correo_electronico " + " FROM clientes WHERE id_cliente = '" + cotizacion[2] + "'")[0]; } catch (Exception) { cliente = new string[] { " ", " ", " ", " ", " ", " ", " " }; } foreach (string datos in cotizacion[3].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { string[] temp = datos.Split(new char[] { ':' }); string[] producto = Sql.BuscarDatos("SELECT codigo, nombre FROM productos WHERE codigo = '" + temp[0] + "'")[0]; listaProductos.Add(new ProductoCompleto(producto[0], producto[1], float.Parse(temp[1]), int.Parse(temp[3]), float.Parse(temp[2]))); } Cotizacion cotizar = new Cotizacion(int.Parse(cotizacion[0]), new Usuarios(usuario[0], usuario[1] + " " + usuario[2] + " " + usuario[3]), new Clientes(cliente[0], cliente[1], cliente[2], cliente[3], cliente[4], cliente[5], cliente[6]), cotizacion[5], listaProductos, float.Parse(cotizacion[4])); InfoReporte rep = GuardarInfoReporte.Leer(); string[,] data = { { "Precotización", "Fecha: ", "RFC: ", "Dirección: ", "Telefono: ", "Atendido por: " }, { cotizar.Id_cotizacion.ToString(), cotizar.Fecha.ToString(), rep.Reporte.rfc, rep.Reporte.direccion, rep.Reporte.telefono, cotizar.Usuario.NombreCompleto } }; PDFFile pdf = new PDFFile("reportes", "reporte-"); pdf.CrearPDF(); pdf.CrearCabecera(data); pdf.AgregarInfoCliente(cotizar.Cliente); pdf.AgregarProductos(cotizar); pdf.AgregarAnotaciones(" "); pdf.Cerrar(); return(pdf.Ruta); } catch (Exception) { } return(null); }
public static bool ImprimeTicketPago(string prmFolioTicket, float pagoCon, float totalL, string date, string nombre) { try { double cantidadPagada = 0; double restante = 0; double varTOTAL = 0; Ticket ticket = new Ticket(); ticket.Path = Application.StartupPath; ticket.FileName = "\\Pago.pdf"; if (File.Exists(Application.StartupPath + "\\Resources\\ticket.png")) { ticket.HeaderImage = Application.StartupPath + "\\Resources\\ticket.png"; } else { ticket.HeaderImage = Application.StartupPath + "\\ticket.png"; } ticket.AddHeaderLine(" TOSTATRONIC"); ticket.AddHeaderLine(" Venta de componentes electronicos"); ticket.AddSubHeaderLine("\n"); ticket.AddSubHeaderLine("Folio: " + prmFolioTicket); ticket.AddSubHeaderLine("Le atendió: " + Usuario.Instancia().Nombre + " " + Usuario.Instancia().Paterno); ticket.AddSubHeaderLine("Fecha y Hora: " + date + " "); ticket.AddSubHeaderLine("Cliente: " + nombre); ticket.AddSubHeaderLine(" Abono a deuda"); ticket.AddTotal("", ""); ticket.AddTotal("", ""); cantidadPagada = Convert.ToDouble(pagoCon); varTOTAL += Convert.ToDouble(totalL); varTOTAL += pagoCon; restante = varTOTAL - pagoCon; ticket.AddTotal("PENDIENTE", varTOTAL.ToString("$0.00")); ticket.AddTotal("RECIBIDO", cantidadPagada.ToString("$0.00")); restante = varTOTAL - cantidadPagada; if (restante < 0) { restante = 0; } ticket.AddTotal("RESTANTE: ", restante.ToString("$0.00")); ticket.AddTotal("", "");//Ponemos un total //en blanco que sirve de espacio //El metodo AddFooterLine funciona igual que la cabecera ticket.AddFooterLine(" *******GRACIAS POR SU PAGO*******"); ticket.AddFooterLine(" "); ticket.AddFooterLine(" --Tostatronic le desea un buen dia--"); //Generamos if (ticket.PrintAbono()) { PDFFile.Ver(Application.StartupPath + "\\Pago.pdf"); return(true); } else { return(false); } } catch (Exception ex) { throw (ex); } }