public List <VentaClas> BuscarVentasId(string id) { MySqlConnection conectar = DB.ObtenerConexion(); List <VentaClas> lista = new List <VentaClas>(); if (conectar != null) { MySqlCommand comando = new MySqlCommand(String.Format( "SELECT * FROM ventas WHERE idventa LIKE '%" + id + "%' and estatus = 'ACTIVA'"), conectar); MySqlDataReader lector = comando.ExecuteReader(); while (lector.Read()) { VentaClas ventas = new VentaClas(); ventas.idVenta = lector.GetInt32(0); ventas.idUsuario = lector.GetInt32(1); ventas.totalVenta = lector.GetDecimal(2); ventas.fechaPedido = lector.GetDateTime(4); ventas.comentarios = lector.GetString(5); lista.Add(ventas); } return(lista); } return(null); }
public int imprimirVenta(String nombre, VentaClas p, List <Producto> listProductos) { StringBuilder tiket = new StringBuilder(); DateTime thisDay = DateTime.Today; //tiket.AppendLine("*****Servicio a domicilio*****"); tiket.AppendLine(""); tiket.AppendLine("Fecha:" + Convert.ToString(p.fechaPedido)); tiket.AppendLine("Nombre:"); tiket.AppendLine("La Barca Rosticerias"); tiket.AppendLine("Telefono:"); tiket.AppendLine("38542175"); tiket.AppendLine("Direccion:"); tiket.AppendLine("Av. de los Maestros 1316"); tiket.AppendLine("Entre:"); tiket.AppendLine("Jose Maria Coss y Federalismo"); // tiket.AppendLine("Telefono:"); //tiket.AppendLine("38542175"); // tiket.AppendLine("Nombre vendedor:"); //tiket.AppendLine(nombre + "\n"); tiket.AppendLine(""); tiket.AppendLine("venta:"); foreach (Producto pr in listProductos) { tiket.AppendLine(pr.cantidad + " " + pr.nombre + " " + pr.cantidad * pr.precio); } tiket.AppendLine(""); tiket.AppendLine("\nTotal: " + p.totalVenta); tiket.AppendLine("Efectivo: " + p.efectivo); tiket.AppendLine("Cambio: " + p.cambio); tiket.AppendLine(p.comentarios); tiket.AppendLine("Nota de venta No. " + Convert.ToString(p.idVenta)); tiket.AppendLine(""); tiket.AppendLine(""); tiket.AppendLine(""); tiket.AppendLine(""); try { System.IO.StreamWriter file = new System.IO.StreamWriter("ticketsVentas/ticket" + Convert.ToString(p.idVenta) + ".txt"); file.WriteLine(tiket.ToString()); RawPrinterHelper.SendStringToPrinter(getImpresoraPorDefecto(), tiket.ToString()); file.Close(); } catch { MessageBox.Show("Ocurrio un error al imprimir tiket"); return(-1); } return(1); }
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(); } }
private void SevicioDomicilio_Load(object sender, EventArgs e) { listClientes.FullRowSelect = true; //Actualizar(); listaProductos = new List <Producto>(); gridProductos.MultiSelect = false; venta = new VentaClas(); DateTime Hoy = DateTime.Today; string fecha_actual = Hoy.ToString("dd-MM-yyyy"); lbFecha.Text = fecha_actual; c = new Clientes(); // AutoSize = true; }
public VentaClas buscarVenta(int idVenta) { VentaClas v = new VentaClas(); MySqlConnection conectar = DB.ObtenerConexion(); if (conectar != null) { MySqlCommand comando = new MySqlCommand(String.Format( "SELECT * FROM ventas WHERE idVenta='{0}'", idVenta), conectar); MySqlDataReader lector = comando.ExecuteReader(); if (lector.Read()) { v.idVenta = Convert.ToInt32(lector.GetString(0)); v.idUsuario = Convert.ToInt32(lector.GetString(1)); v.totalVenta = Convert.ToDecimal(lector.GetString(2)); v.fechaPedido = Convert.ToDateTime(lector.GetString(4)); v.comentarios = lector.GetString(5); } return(v); } return(null); }