コード例 #1
0
        //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;
        }
コード例 #2
0
        //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);
        }