//cargar tamaño hoja private void TamPrinter() { //datos boleta string datos = System.IO.Directory.GetCurrentDirectory() + @"\config.cfg"; if (System.IO.File.Exists(datos)) //personal { cargar_config aux = new cargar_config(); aux.guarda_variables(@"\printer.ini"); hoja_alto = Int32.Parse(aux.get_nombre_empresa()); hoja_ancho = Int32.Parse(aux.get_nombre_dueno()); font1 = new Font("Courier new", Int32.Parse(aux.get_color1())); font2 = new Font("Courier new", Int32.Parse(aux.get_color2())); font3 = new Font("Courier new", Int32.Parse(aux.get_color3())); font4 = new Font("Courier new", Int32.Parse(aux.get_color4())); } else //default { hoja_alto = 350; hoja_ancho = 302; font1 = new Font("Courier new", 10); font2 = new Font("Courier new", 12); font3 = new Font("Courier new", 16); font4 = new Font("Courier new", 18); } }
//cargar archivo configuracion private void readfile() { cargar_config aux = new cargar_config(); aux.guarda_variables(@"\config.cfg"); //titulo Forma_principal.Text = "Soft Venta - " + aux.get_nombre_empresa(); //color fondo picture_logo1.BackColor = ColorTranslator.FromHtml(aux.get_color4()); //fecha actual menu_lb_leyenda.BackColor = ColorTranslator.FromHtml(aux.get_color4()); menu_lb_leyenda.Text = aux.get_nombre_empresa() + " - " + String.Format("{0:dddd, MMMM d, yyyy}", DateTime.Now); //color contenedor1 contenedor1.BackColor = ColorTranslator.FromHtml(aux.get_color4()); contenedor1.Panel2.BackColor = ColorTranslator.FromHtml(aux.get_color4()); //datos empleado menu_lb_usuario.BackColor = ColorTranslator.FromHtml(aux.get_color4()); menu_lb_tipo.BackColor = ColorTranslator.FromHtml(aux.get_color4()); //estado caja lb_estado_caja.BackColor = ColorTranslator.FromHtml(aux.get_color4()); }
//boleta repartidor---------------------------------------------------------------------- void repartidor_PrintPage(object sender, PrintPageEventArgs e) { Graphics graphic = e.Graphics; float fontHeight = font1.GetHeight(); int startX = 10; int startY = 10; int offset = 0; //datos boleta string datos; datos = System.IO.Directory.GetCurrentDirectory() + @"\config.cfg"; if (System.IO.File.Exists(datos)) { cargar_config aux = new cargar_config(); aux.guarda_variables(@"\config.cfg"); graphic.DrawString(aux.get_nombre_empresa(), font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString(aux.get_direccion(), font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString(aux.get_fono(), font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString(aux.get_web(), font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 15; } else { graphic.DrawString("VERSION PIRATA", font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("INGRESE LICENCIA SOFTWARE", font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("LLAME AL 79207762", font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("SIN WEB", font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 15; } graphic.DrawString("Fecha".PadRight(10) + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(), font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("Nro".PadRight(10) + orden_cb_nro_orden.Text, font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("Vendedor".PadRight(10) + orden_nombre_vendedor.Text, font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("Cliente".PadRight(10) + orden_nombrecliente.Text, font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("Direccion".PadRight(10) + orden_direcioncliente.Text, font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 20; graphic.DrawString("TOTAL".PadRight(30) + label_precio_total2.Text, font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("efectivo".PadRight(30) + num_efectivo_cliente.Value.ToString(), font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("Vuelto".PadRight(30) + vuelto_cliente.Text, font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 5; }
//cargar archivo configuracion private void readfile() { aux_config = new cargar_config(); aux_config.guarda_variables(@"\config.cfg"); }
//boleta cocina-------------------------------------------------------------------------- void cocina_PrintPage(object sender, PrintPageEventArgs e) { Graphics graphic = e.Graphics; float fontHeight = font1.GetHeight(); int startX = 10; int startY = 10; int offset = 5; //datos boleta string datos; datos = System.IO.Directory.GetCurrentDirectory() + @"\config.cfg"; if (System.IO.File.Exists(datos)) { cargar_config aux = new cargar_config(); aux.guarda_variables(@"\config.cfg"); graphic.DrawString(aux.get_nombre_empresa().PadLeft(5), font4, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("Copia Cocina".PadLeft(5), font4, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("------------------------------------".PadLeft(5), font4, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; } else { graphic.DrawString("VERSION PIRATA".PadLeft(5), font4, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("INGRESE LICENCIA".PadLeft(5), font4, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("79207762".PadLeft(5), font4, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("SIN WEB".PadLeft(5), font4, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 15; } graphic.DrawString("Fecha".PadRight(10) + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(), font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("Nro".PadRight(10) + orden_cb_nro_orden.Text, font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("Cliente".PadRight(10) + orden_nombrecliente.Text, font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("Pedido".PadRight(6) + orden_lista_pedidos.Text, font1, new SolidBrush(Color.Black), startX, startY + offset); if (lista_pedidos_armado.Items.Count > 0) { offset += ((int)fontHeight + 2); foreach (object item in lista_pedidos_armado.CheckedItems) { MessageBox.Show("-" + item.ToString()); int count = (int)(item.ToString().Length / 35); graphic.DrawString("-" + item.ToString(), font1, new SolidBrush(Color.Black), new Rectangle(startX, startY + offset, 290, (int)fontHeight + (int)fontHeight * (count + 1))); offset += ((int)fontHeight + 2) * count; offset += (int)fontHeight + 2; } } }
//boleta caja---------------------------------------------------------------------------- void caja_PrintPage(object sender, PrintPageEventArgs e) { MessageBox.Show("boleta caja: alto=" + hoja_alto + " ancho=" + hoja_ancho + " "); Graphics graphic = e.Graphics; StringFormat sf = new StringFormat(); sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Center; float fontHeight = font1.GetHeight(); int startX = 10; int startY = 10; int offset = 20; //datos boleta string datos = System.IO.Directory.GetCurrentDirectory() + @"\config.cfg"; if (System.IO.File.Exists(datos)) { cargar_config aux = new cargar_config(); aux.guarda_variables(@"\config.cfg"); //logo if (System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory() + @"\lib\resources\logo_boleta.ico")) { // Create image. Image newImage = Image.FromFile(System.IO.Directory.GetCurrentDirectory() + @"\lib\resources\logo_boleta.ico"); // Create rectangle for displaying image. int alto = 80 + startY / 2; int ancho = 80 + startY / 2; Rectangle destRect = new Rectangle(98, 0, alto, ancho); // Create rectangle for source image. Rectangle srcRect = new Rectangle(50, 50, 150, 150); GraphicsUnit units = GraphicsUnit.Pixel; // Draw image to screen. graphic.DrawImage(newImage, destRect, srcRect, units); offset += 50; } else //nombre { graphic.DrawString(aux.get_nombre_empresa().PadLeft(5), font4, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 5; } graphic.DrawString(aux.get_direccion().PadLeft(5), font4, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString(aux.get_fono().PadLeft(4), font4, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString(aux.get_web().PadLeft(5), font4, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 15; } else { graphic.DrawString("VERSION PIRATA", font4, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("INGRESE LICENCIA", font4, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("FONO: 79207762", font4, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("SIN WEB", font4, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 15; } graphic.DrawString("Fecha".PadRight(10) + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(), font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("Nro".PadRight(10) + orden_cb_nro_orden.Text, font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("Vendedor".PadRight(10) + orden_nombre_vendedor.Text, font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("Cliente".PadRight(10) + orden_nombrecliente.Text, font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("Pedido", font1, new SolidBrush(Color.Black), startX, startY + offset); if (lista_pedidos_armado.Items.Count > 0) { offset += ((int)fontHeight + 2); foreach (object item in lista_pedidos_armado.CheckedItems) { MessageBox.Show("-" + item.ToString()); int count = (int)(item.ToString().Length / 35); graphic.DrawString("-" + item.ToString(), font1, new SolidBrush(Color.Black), new Rectangle(startX, startY + offset, 290, (int)fontHeight + (int)fontHeight * (count + 1))); offset += ((int)fontHeight + 2) * count; offset += (int)fontHeight + 2; } } offset += (int)font1.Height * 2; graphic.DrawString("TOTAL".PadRight(30) + label_precio_total2.Text, font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("efectivo".PadRight(30) + num_efectivo_cliente.Value.ToString(), font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight + 2; graphic.DrawString("Vuelto".PadRight(30) + vuelto_cliente.Text, font1, new SolidBrush(Color.Black), startX, startY + offset); offset += (int)fontHeight * 3; graphic.DrawString(" ", font1, new SolidBrush(Color.Black), startX, startY + offset); }