예제 #1
0
        // The PrintPage event is raised for each page to be printed.
        private void printDocument1_PrintPage(object sender, PrintPageEventArgs ev)
        {
            printFont  = new Font("Arial", 11);
            leftMargin = 50; //ev.MarginBounds.Left;
            topMargin  = 20; //ev.MarginBounds.Top;
            StringFormat drawFormat = new StringFormat();

            drawFormat.Alignment = StringAlignment.Far;
            string line;

            // Calculate the number of lines per page.
            linesPerPage = 43; //Convert.ToInt32(ev.MarginBounds.Height /printFont.GetHeight(ev.Graphics));
            n_pag++;
            n_lineas = 0;
            //short pinta_deleg=0;
            char deleg_old = 'Z'; //para cambio de cab. de delegacion
            char deleg_new = deleg_old;

            //Pinta cabecera
            xPos = Convert.ToInt32(leftMargin);
            yPos = Convert.ToInt32(topMargin); //+ (n_lineas * printFont.GetHeight(ev.Graphics));

            ev.Graphics.DrawRectangle(new Pen(Color.Black, 1), xPos, yPos, xPos + 60, yPos + 50);
            printFont = new Font("Arial", 16, FontStyle.Bold);
            ev.Graphics.DrawString("ASEGEST", printFont, Brushes.Black, xPos, yPos + 10);
            ev.Graphics.DrawString("YECMUR", printFont, Brushes.Black, xPos, yPos + 40);
            ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos, yPos + 70, xPos + 1050, yPos + 70);

            string titulo = "REGISTRO DE FACTURAS: " + cb_est_fra.Text.Trim();

            /*
             * if (secc_int != "")
             *  titulo = titulo + secc_int;
             * if (estado != "")
             *  titulo = titulo + " " + estado;
             */
            printFont = new Font("Arial", 14, FontStyle.Bold | FontStyle.Underline);
            ev.Graphics.DrawString(titulo, printFont, Brushes.Black, xPos + 350, yPos + 90);

            n_lineas = n_lineas + 5;
            yPos     = yPos + 90;

            while ((pos_reg < _registros.Count) && (n_lineas < linesPerPage))
            {
                //cabecera
                string n_deleg = "";
                if (deleg_old != _registros.ElementAt(pos_reg).delegacion)
                {
                    if (_registros.ElementAt(pos_reg).delegacion == 'Y')
                    {
                        n_deleg = "YECLA";
                    }
                    else
                    {
                        if (_registros.ElementAt(pos_reg).delegacion == 'M')
                        {
                            n_deleg = "MURCIA";
                        }
                        else
                        {
                            n_deleg = "ALBACETE";
                        }
                    }


                    printFont = new Font("Arial", 12, FontStyle.Bold | FontStyle.Underline);
                    ev.Graphics.DrawString("Delegación:   " + n_deleg, printFont, Brushes.Black, xPos, yPos + 30);

                    printFont = new Font("Arial", 10, FontStyle.Bold);
                    ev.Graphics.DrawString("NUM.FRA.", printFont, Brushes.Black, xPos, yPos + 60);
                    ev.Graphics.DrawString("FEC.FRA.", printFont, Brushes.Black, xPos + 80, yPos + 60);
                    ev.Graphics.DrawString("CLIENTE", printFont, Brushes.Black, xPos + 160, yPos + 60);
                    ev.Graphics.DrawString("BASE", printFont, Brushes.Black, xPos + 560, yPos + 60);
                    ev.Graphics.DrawString("%IVA", printFont, Brushes.Black, xPos + 650, yPos + 60);
                    ev.Graphics.DrawString("IMP.IVA", printFont, Brushes.Black, xPos + 720, yPos + 60);
                    ev.Graphics.DrawString("TASAS", printFont, Brushes.Black, xPos + 830, yPos + 60);
                    ev.Graphics.DrawString("TOTAL FRA.", printFont, Brushes.Black, xPos + 930, yPos + 60);

                    ev.Graphics.DrawLine(new Pen(Color.Black, 2), xPos, yPos + 80, xPos + 1050, yPos + 80);

                    n_lineas  = n_lineas + 4;
                    yPos      = yPos + 80;
                    deleg_old = _registros.ElementAt(pos_reg).delegacion;
                }

                //lineas
                if (_registros.ElementAt(pos_reg).t_cte_fra == 'C') //facturar a cte.
                {
                    ClienteFacturado = Reg_Opera.Calcular_nom_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_cte), 'C');
                }
                else
                {
                    if (_registros.ElementAt(pos_reg).t_cte_fra == 'T') //facturar a titular.
                    {
                        ClienteFacturado = Reg_Opera.Calcular_nom_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_titular), 'T');
                    }
                    else //facturar a colaborador.
                    {
                        ClienteFacturado = Reg_Opera.Calcular_nom_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_colabora), 'B');
                    }
                }

                simpor1     = 0;
                importes[0] = 0;
                importes[1] = 0;
                //sacamos los importes con iva de linfac a simpor1; los sin iva ya estan acumulados en campo tasa.
                importes = Linfac_Opera.Calcular_importes_linfac(_registros.ElementAt(pos_reg).factura);
                simpor1  = importes[1];

                base_imp = _registros.ElementAt(pos_reg).dcho_col + _registros.ElementAt(pos_reg).honorarios + simpor1;
                imp_iva  = ((base_imp * _registros.ElementAt(pos_reg).p_iva) / 100);
                tot_fra  = base_imp + imp_iva + _registros.ElementAt(pos_reg).tasa;

                printFont = new Font("Arial", 10, FontStyle.Regular);
                ev.Graphics.DrawString(Convert.ToString(_registros.ElementAt(pos_reg).factura), printFont, Brushes.Black, xPos + 70, yPos + 10, drawFormat);
                ev.Graphics.DrawString(_registros.ElementAt(pos_reg).fec_fra.ToString("dd/MM/yyyy"), printFont, Brushes.Black, xPos + 80, yPos + 10);
                ev.Graphics.DrawString(ClienteFacturado, printFont
                                       , Brushes.Black, xPos + 160, yPos + 10);
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", base_imp), printFont, Brushes.Black, xPos + 600, yPos + 10, drawFormat);
                ev.Graphics.DrawString(string.Format("{0:##0}", _registros.ElementAt(pos_reg).p_iva), printFont, Brushes.Black, xPos + 690, yPos + 10, drawFormat);
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", imp_iva), printFont, Brushes.Black, xPos + 780, yPos + 10, drawFormat);
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", _registros.ElementAt(pos_reg).tasa), printFont, Brushes.Black, xPos + 880, yPos + 10, drawFormat);
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", tot_fra), printFont, Brushes.Black, xPos + 1010, yPos + 10, drawFormat);

                sd_base_imp = sd_base_imp + base_imp;
                sd_imp_iva  = sd_imp_iva + imp_iva;
                sd_tasas    = sd_tasas + _registros.ElementAt(pos_reg).tasa;
                sd_tot_fra  = sd_tot_fra + tot_fra;

                yPos     = yPos + 30;
                n_lineas = n_lineas + 2;

                //pintamos sumatorio si fin de deleg o final total
                if (pos_reg < _registros.Count - 1)
                {
                    deleg_new = _registros.ElementAt(pos_reg + 1).delegacion;
                }

                /*else
                 *  deleg_new='Z'; //entra siempre
                 */
                if (deleg_old != deleg_new | (pos_reg == _registros.Count - 1))
                {
                    printFont = new Font("Arial", 10, FontStyle.Bold);
                    ev.Graphics.DrawLine(new Pen(Color.Black, 2), xPos, yPos + 10, xPos + 1050, yPos + 10);
                    ev.Graphics.DrawString(string.Format("{0:###,##0.00}", sd_base_imp), printFont, Brushes.Black, xPos + 600, yPos + 20, drawFormat);
                    ev.Graphics.DrawString(string.Format("{0:###,##0.00}", sd_imp_iva), printFont, Brushes.Black, xPos + 780, yPos + 20, drawFormat);
                    ev.Graphics.DrawString(string.Format("{0:###,##0.00}", sd_tasas), printFont, Brushes.Black, xPos + 880, yPos + 20, drawFormat);
                    ev.Graphics.DrawString(string.Format("{0:###,##0.00}", sd_tot_fra), printFont, Brushes.Black, xPos + 1010, yPos + 20, drawFormat);

                    sd_base_imp = 0;
                    sd_imp_iva  = 0;
                    sd_tasas    = 0;
                    sd_tot_fra  = 0;

                    yPos     = yPos + 30;
                    n_lineas = n_lineas + 2;
                }

                //sig. linea de registro.
                pos_reg++;
            }

            //pie
            ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos, 800, xPos + 1050, 800);
            line = "Pag. " + Convert.ToString(n_pag);
            ev.Graphics.DrawString(line, printFont, Brushes.Black, xPos + 500, 805);

            // If more lines exist, print another page.
            if (pos_reg < _registros.Count)//(line != null)
            {
                ev.HasMorePages = true;
            }
            else
            {
                ev.HasMorePages = false;
                pos_reg         = 0; //reinicio para la impresion en papel
                n_pag           = 0;
            }
        }
예제 #2
0
        // The PrintPage event is raised for each page to be printed.
        private void printDocument1_PrintPage(object sender, PrintPageEventArgs ev)
        {
            printFont  = new Font("Arial", 11);
            leftMargin = 50; //ev.MarginBounds.Left;
            topMargin  = 20; //ev.MarginBounds.Top;
            StringFormat drawFormat = new StringFormat();

            drawFormat.Alignment = StringAlignment.Far;
            string line;

            // Calculate the number of lines per page.
            linesPerPage = 43; //Convert.ToInt32(ev.MarginBounds.Height /printFont.GetHeight(ev.Graphics));
            n_pag++;
            n_lineas = 0;
            int id_new = 0;

            //char deleg_old = 'Z'; //para cambio de cab. de delegacion
            //char deleg_new = deleg_old;
            base_imp    = 0;
            imp_iva     = 0;
            tot_fra     = 0;
            simpor1     = 0;
            sc_base_imp = 0;
            sc_imp_iva  = 0;
            sc_tasas    = 0;
            sc_tot_fra  = 0;
            sd_base_imp = 0;
            sd_imp_iva  = 0;
            sd_tasas    = 0;
            sd_tot_fra  = 0;
            //Pinta cabecera
            xPos = Convert.ToInt32(leftMargin);
            yPos = Convert.ToInt32(topMargin); //+ (n_lineas * printFont.GetHeight(ev.Graphics));

            ev.Graphics.DrawRectangle(new Pen(Color.Black, 1), xPos, yPos, xPos + 60, yPos + 50);
            printFont = new Font("Arial", 16, FontStyle.Bold);
            ev.Graphics.DrawString("ASEGEST", printFont, Brushes.Black, xPos, yPos + 10);
            ev.Graphics.DrawString("YECMUR", printFont, Brushes.Black, xPos, yPos + 40);
            ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos, yPos + 70, xPos + 1050, yPos + 70);

            string titulo = "REGISTRO DE FACTURAS X CLIENTE: ";

            /*
             * if (secc_int != "")
             *  titulo = titulo + secc_int;
             * if (estado != "")
             *  titulo = titulo + " " + estado;
             */
            printFont = new Font("Arial", 14, FontStyle.Bold | FontStyle.Underline);
            ev.Graphics.DrawString(titulo, printFont, Brushes.Black, xPos + 350, yPos + 100);

            n_lineas = n_lineas + 2;
            yPos     = yPos + 100;

            //printFont = new Font("Arial", 12, FontStyle.Bold | FontStyle.Underline);
            //ev.Graphics.DrawString("Delegación:   " + n_deleg, printFont, Brushes.Black, xPos, yPos + 30);

            printFont = new Font("Arial", 10, FontStyle.Bold);
            ev.Graphics.DrawString("T", printFont, Brushes.Black, xPos, yPos + 50);
            ev.Graphics.DrawString("ID_CTE", printFont, Brushes.Black, xPos + 20, yPos + 50);
            ev.Graphics.DrawString("NOMBRE CLIENTE", printFont, Brushes.Black, xPos + 70, yPos + 50);
            ev.Graphics.DrawString("BASE", printFont, Brushes.Black, xPos + 560, yPos + 50);
            ev.Graphics.DrawString("%IVA", printFont, Brushes.Black, xPos + 650, yPos + 50);
            ev.Graphics.DrawString("IMP.IVA", printFont, Brushes.Black, xPos + 720, yPos + 50);
            ev.Graphics.DrawString("TASAS", printFont, Brushes.Black, xPos + 830, yPos + 50);
            ev.Graphics.DrawString("TOTAL FRA.", printFont, Brushes.Black, xPos + 930, yPos + 50);

            ev.Graphics.DrawLine(new Pen(Color.Black, 2), xPos, yPos + 70, xPos + 1050, yPos + 70);

            n_lineas = n_lineas + 2;
            yPos     = yPos + 70;


            while ((pos_reg < _registros.Count) && (n_lineas < linesPerPage))
            {
                //lineas
                ClienteFacturado = Reg_Opera.Calcular_nom_cte(Convert.ToString(_registros.ElementAt(pos_reg).id), _registros.ElementAt(pos_reg).t_cte_fra);

                simpor1     = 0;
                importes[0] = 0;
                importes[1] = 0;
                //sacamos los importes con iva de linfac a simpor1; los sin iva ya estan acumulados en campo tasa.
                importes = Linfac_Opera.Calcular_importes_linfac(_registros.ElementAt(pos_reg).factura);
                simpor1  = importes[1];

                base_imp = _registros.ElementAt(pos_reg).base_imp + simpor1;
                imp_iva  = ((base_imp * _registros.ElementAt(pos_reg).p_iva) / 100);
                tot_fra  = base_imp + imp_iva + _registros.ElementAt(pos_reg).tasa;


                sc_base_imp = sc_base_imp + base_imp;
                sc_imp_iva  = sc_imp_iva + imp_iva;
                sc_tasas    = sc_tasas + _registros.ElementAt(pos_reg).tasa;
                sc_tot_fra  = sc_tot_fra + tot_fra;

                //sacamos el sig. id
                if (pos_reg < _registros.Count - 1)
                {
                    id_new = _registros.ElementAt(pos_reg + 1).id;
                }

                /*
                 * else
                 *  deleg_new='Z'; //entra siempre
                 */
                //si la sig. linea es del mismo id, no la pintamos y acumulamos.
                if (_registros.ElementAt(pos_reg).id != id_new | (pos_reg == _registros.Count - 1))
                {
                    printFont = new Font("Arial", 10, FontStyle.Regular);
                    //ev.Graphics.DrawLine(new Pen(Color.Black, 2), xPos, yPos + 10, xPos + 1050, yPos + 10);
                    ev.Graphics.DrawString(Convert.ToString(_registros.ElementAt(pos_reg).t_cte_fra), printFont, Brushes.Black, xPos, yPos + 10);
                    ev.Graphics.DrawString(Convert.ToString(_registros.ElementAt(pos_reg).id), printFont, Brushes.Black, xPos + 70, yPos + 10, drawFormat);
                    ev.Graphics.DrawString(ClienteFacturado, printFont, Brushes.Black, xPos + 70, yPos + 10);
                    ev.Graphics.DrawString(string.Format("{0:###,##0.00}", sc_base_imp), printFont, Brushes.Black, xPos + 600, yPos + 10, drawFormat);
                    ev.Graphics.DrawString(string.Format("{0:##0}", _registros.ElementAt(pos_reg).p_iva), printFont, Brushes.Black, xPos + 690, yPos + 10, drawFormat);
                    ev.Graphics.DrawString(string.Format("{0:###,##0.00}", sc_imp_iva), printFont, Brushes.Black, xPos + 780, yPos + 10, drawFormat);
                    ev.Graphics.DrawString(string.Format("{0:###,##0.00}", sc_tasas), printFont, Brushes.Black, xPos + 880, yPos + 10, drawFormat);
                    ev.Graphics.DrawString(string.Format("{0:###,##0.00}", sc_tot_fra), printFont, Brushes.Black, xPos + 1010, yPos + 10, drawFormat);
                    ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos, yPos + 30, xPos + 1050, yPos + 30);

                    sd_base_imp = sd_base_imp + sc_base_imp;
                    sd_imp_iva  = sd_imp_iva + sc_imp_iva;
                    sd_tasas    = sd_tasas + sc_tasas;
                    sd_tot_fra  = sd_tot_fra + sc_tot_fra;
                    sc_base_imp = 0;
                    sc_imp_iva  = 0;
                    sc_tasas    = 0;
                    sc_tot_fra  = 0;

                    yPos     = yPos + 40;
                    n_lineas = n_lineas + 3;

                    //acumulado final.
                    if (pos_reg == _registros.Count - 1)
                    {
                        printFont = new Font("Arial", 10, FontStyle.Bold);
                        ev.Graphics.DrawLine(new Pen(Color.Black, 2), xPos, yPos + 10, xPos + 1050, yPos + 10);
                        ev.Graphics.DrawString(string.Format("{0:###,##0.00}", sd_base_imp), printFont, Brushes.Black, xPos + 600, yPos + 20, drawFormat);
                        ev.Graphics.DrawString(string.Format("{0:###,##0.00}", sd_imp_iva), printFont, Brushes.Black, xPos + 780, yPos + 20, drawFormat);
                        ev.Graphics.DrawString(string.Format("{0:###,##0.00}", sd_tasas), printFont, Brushes.Black, xPos + 880, yPos + 20, drawFormat);
                        ev.Graphics.DrawString(string.Format("{0:###,##0.00}", sd_tot_fra), printFont, Brushes.Black, xPos + 1010, yPos + 20, drawFormat);

                        yPos     = yPos + 30;
                        n_lineas = n_lineas + 3;
                    }
                }

                //sig. linea de registro.
                pos_reg++;
            }

            //pie
            ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos, 800, xPos + 1050, 800);
            line = "Pag. " + Convert.ToString(n_pag);
            ev.Graphics.DrawString(line, printFont, Brushes.Black, xPos + 500, 805);

            // If more lines exist, print another page.
            if (pos_reg < _registros.Count)//(line != null)
            {
                ev.HasMorePages = true;
            }
            else
            {
                ev.HasMorePages = false;
                pos_reg         = 0; //reinicio para la impresion en papel
                n_pag           = 0;
            }
        }
예제 #3
0
        // The PrintPage event is raised for each page to be printed.
        private void printDocument1_PrintPage(object sender, PrintPageEventArgs ev)
        {
            printFont  = new Font("Arial", 11);
            leftMargin = 50; //ev.MarginBounds.Left;
            topMargin  = 20; //ev.MarginBounds.Top;
            StringFormat drawFormat = new StringFormat();

            drawFormat.Alignment = StringAlignment.Far;
            string line;

            // Calculate the number of lines per page.
            linesPerPage = 43; //Convert.ToInt32(ev.MarginBounds.Height /printFont.GetHeight(ev.Graphics));
            n_pag++;
            n_lineas = 0;
            //num_reg = 0;
            //short pinta_deleg=0;
            char deleg_old = 'Z'; //para cambio de cab. de delegacion

            //Pinta cabecera
            xPos = Convert.ToInt32(leftMargin);
            yPos = Convert.ToInt32(topMargin); //+ (n_lineas * printFont.GetHeight(ev.Graphics));

            ev.Graphics.DrawRectangle(new Pen(Color.Black, 1), xPos, yPos, xPos + 60, yPos + 50);
            printFont = new Font("Arial", 16, FontStyle.Bold);
            ev.Graphics.DrawString("ASEGEST", printFont, Brushes.Black, xPos, yPos + 10);
            ev.Graphics.DrawString("YECMUR", printFont, Brushes.Black, xPos, yPos + 40);
            ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos, yPos + 70, xPos + 1050, yPos + 70);

            string titulo = tb_titulo.Text.Trim(); //+" - " + DateTime.Today.ToString("dd/MM/yyyy");

            printFont = new Font("Arial", 14, FontStyle.Bold | FontStyle.Underline);
            ev.Graphics.DrawString(titulo, printFont, Brushes.Black, xPos + 200, yPos + 90);

            n_lineas = n_lineas + 5;
            yPos     = yPos + 110;

            while ((pos_reg < _registros.Count) && (n_lineas < linesPerPage))
            {
                //cabecera
                string n_deleg = "";
                if (deleg_old != _registros.ElementAt(pos_reg).delegacion)
                {
                    if (_registros.ElementAt(pos_reg).delegacion == 'Y')
                    {
                        n_deleg = "YECLA";
                    }
                    else
                    {
                        if (_registros.ElementAt(pos_reg).delegacion == 'M')
                        {
                            n_deleg = "MURCIA";
                        }
                        else
                        {
                            n_deleg = "ALBACETE";
                        }
                    }

                    //printFont = new Font("Arial", 12, FontStyle.Bold | FontStyle.Underline);
                    //ev.Graphics.DrawString("Delegación:   " + n_deleg, printFont, Brushes.Black, xPos, yPos + 30);

                    printFont = new Font("Arial", 10, FontStyle.Bold);
                    ev.Graphics.DrawString("ASUNTO", printFont, Brushes.Black, xPos, yPos + 30);
                    ev.Graphics.DrawString("FECHA", printFont, Brushes.Black, xPos + 145, yPos + 30);
                    ev.Graphics.DrawString("COMPRADOR", printFont, Brushes.Black, xPos + 220, yPos + 30);
                    ev.Graphics.DrawString("ENTIDAD BANCARIA", printFont, Brushes.Black, xPos + 475, yPos + 30);
                    ev.Graphics.DrawString("Nº OPERACION", printFont, Brushes.Black, xPos + 680, yPos + 30);
                    ev.Graphics.DrawString("NOTARIO", printFont, Brushes.Black, xPos + 800, yPos + 30);
                    ev.Graphics.DrawString("IMPORTE", printFont, Brushes.Black, xPos + 980, yPos + 30);
                    ev.Graphics.DrawLine(new Pen(Color.Black, 2), xPos, yPos + 50, xPos + 1050, yPos + 50);

                    n_lineas  = n_lineas + 3;
                    yPos      = yPos + 50;
                    deleg_old = _registros.ElementAt(pos_reg).delegacion;
                }



                //lineas
                printFont = new Font("Arial", 10, FontStyle.Regular);
                ev.Graphics.DrawString(Convert.ToString(_registros.ElementAt(pos_reg).t_tramite), printFont, Brushes.Black, xPos, yPos + 10);
                ev.Graphics.DrawString(_registros.ElementAt(pos_reg).fec_ent.ToString("dd/MM/yyyy"), printFont, Brushes.Black, xPos + 145, yPos + 10);

                string n_tit = Reg_Opera.Calcular_nom_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_titular), 'T');
                if (n_tit.Trim().Length > 30)
                {
                    ev.Graphics.DrawString(n_tit.Substring(0, 30), printFont, Brushes.Black, xPos + 220, yPos + 10);
                }
                else
                {
                    ev.Graphics.DrawString(n_tit.Trim(), printFont, Brushes.Black, xPos + 220, yPos + 10);
                }


                if (_registros.ElementAt(pos_reg).entidad.Trim().Length > 30)
                {
                    ev.Graphics.DrawString(_registros.ElementAt(pos_reg).entidad.Substring(0, 30), printFont, Brushes.Black, xPos + 475, yPos + 10);
                }
                else
                {
                    ev.Graphics.DrawString(_registros.ElementAt(pos_reg).entidad.Trim(), printFont, Brushes.Black, xPos + 475, yPos + 10);
                }

                ev.Graphics.DrawString(_registros.ElementAt(pos_reg).n_operacion, printFont, Brushes.Black, xPos + 680, yPos + 10);

                if (_registros.ElementAt(pos_reg).notario.Trim().Length > 30)
                {
                    ev.Graphics.DrawString(_registros.ElementAt(pos_reg).notario.Substring(0, 30), printFont, Brushes.Black, xPos + 800, yPos + 10);
                }
                else
                {
                    ev.Graphics.DrawString(_registros.ElementAt(pos_reg).notario, printFont, Brushes.Black, xPos + 800, yPos + 10);
                }

                ev.Graphics.DrawString(string.Format("{0:#,##0.00}", _registros.ElementAt(pos_reg).impor_liq), printFont, Brushes.Black, xPos + 1050, yPos + 10, drawFormat);

                //ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos, yPos + 40, xPos + 1050, yPos + 40);

                sd_tot_impor = sd_tot_impor + _registros.ElementAt(pos_reg).impor_liq;
                yPos         = yPos + 30;
                n_lineas++;
                num_reg++;

                //updateo registro a liquidado
                if (cb_liq.Checked)
                { //actualiza registro a liquidado
                    Reg_Opera.Reg_liquidado(_registros.ElementAt(pos_reg).delegacion, _registros.ElementAt(pos_reg).n_reg);
                }

                if (pos_reg == _registros.Count - 1)
                {
                    printFont = new Font("Arial", 10, FontStyle.Bold);
                    ev.Graphics.DrawLine(new Pen(Color.Black, 2), xPos, yPos + 10, xPos + 1050, yPos + 10);
                    ev.Graphics.DrawString("TOTAL ", printFont, Brushes.Black, xPos + 900, yPos + 20);
                    ev.Graphics.DrawString(string.Format("{0:###,##0.00}", sd_tot_impor), printFont, Brushes.Black, xPos + 1050, yPos + 20, drawFormat);

                    yPos     = yPos + 30;
                    n_lineas = n_lineas + 2;
                }

                //sig. linea de registro.
                pos_reg++;
            }

            //pie
            ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos, 800, xPos + 1050, 800);
            line = "Pag. " + Convert.ToString(n_pag);
            ev.Graphics.DrawString(line, printFont, Brushes.Black, xPos + 500, 805);
            line = "Num. de Registros = " + Convert.ToString(num_reg);
            ev.Graphics.DrawString(line, printFont, Brushes.Black, xPos + 870, 805);

            // If more lines exist, print another page.
            if (pos_reg < _registros.Count)//(line != null)
            {
                ev.HasMorePages = true;
            }
            else
            {
                ev.HasMorePages = false;
                pos_reg         = 0; //reinicio para la impresion en papel
                n_pag           = 0;
                num_reg         = 0;
            }
        }
예제 #4
0
        // The PrintPage event is raised for each page to be printed.
        private void printDocument1_PrintPage(object sender, PrintPageEventArgs ev)
        {
            printFont = new Font("Arial", 12);
            //pintamos en la parte dcha del apaisado, para poder doblar el folio.
            leftMargin = 600; //ev.MarginBounds.Left;
            topMargin  = 50;  //ev.MarginBounds.Top;
            StringFormat drawFormat = new StringFormat();

            // Calculate the number of lines per page.
            linesPerPage = Convert.ToInt32(ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics));


            //Pinta cabecera
            xPos = Convert.ToInt32(leftMargin);
            yPos = Convert.ToInt32(topMargin); //+ (count * printFont.GetHeight(ev.Graphics));

            while (count < linesPerPage)
            {
                string n_deleg = "";
                if (RegAct.delegacion == 'Y')
                {
                    n_deleg = "YECLA";
                }
                else
                {
                    if (RegAct.delegacion == 'M')
                    {
                        n_deleg = "MURCIA";
                    }
                    else
                    {
                        n_deleg = "ALBACETE";
                    }
                }

                ev.Graphics.DrawRectangle(new Pen(Color.Black, 1), xPos, yPos, 110, 100);
                printFont = new Font("Arial", 16, FontStyle.Bold);
                ev.Graphics.DrawString("ASEGEST", printFont, Brushes.Black, xPos, yPos + 30);
                ev.Graphics.DrawString("YECMUR", printFont, Brushes.Black, xPos, yPos + 60);
                ev.Graphics.DrawString("Delegación:", printFont, Brushes.Black, xPos + 200, yPos + 60);
                ev.Graphics.DrawString(n_deleg, printFont, Brushes.Black, xPos + 350, yPos + 60);
                yPos = yPos + 100;
                ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos, yPos, xPos + 550, yPos);
                count = count + 3;


                printFont = new Font("Arial", 14, FontStyle.Bold);
                line      = "Nº Registro:   " + Convert.ToString(RegAct.n_reg);
                ev.Graphics.DrawString(line, printFont, Brushes.Black, xPos, yPos + 15);
                line = "Fecha Ent.:   " + RegAct.fec_ent.ToString("dd/MM/yyyy");
                ev.Graphics.DrawString(line, printFont, Brushes.Black, xPos + 300, yPos + 15);
                count++;
                line = "Matrícula:   " + Convert.ToString(RegAct.matricula);
                ev.Graphics.DrawString(line, printFont, Brushes.Black, xPos, yPos + 45);

                printFont = new Font("Arial", 12, FontStyle.Bold);
                line      = Convert.ToString(RegAct.vehiculo).Trim();
                ev.Graphics.DrawString(line, printFont, Brushes.Black, xPos + 230, yPos + 47);
                count++;

                printFont = new Font("Arial", 12, FontStyle.Regular);
                ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos, yPos + 80, xPos + 550, yPos + 80);
                count++;

                string n_cte = Reg_Opera.Calcular_nom_cte(Convert.ToString(RegAct.id_cte), 'C');
                ev.Graphics.DrawString("Cliente:", printFont, Brushes.Black, xPos, yPos + 100);
                ev.Graphics.DrawString(Convert.ToString(RegAct.id_cte), printFont, Brushes.Black, xPos + 120, yPos + 100);
                ev.Graphics.DrawString(n_cte.Trim(), printFont, Brushes.Black, xPos + 180, yPos + 100);
                string tlfnos = Reg_Opera.Sacar_tlfos_cte(Convert.ToString(RegAct.id_cte), 'C');
                ev.Graphics.DrawString(tlfnos.Trim(), printFont, Brushes.Black, xPos + 180, yPos + 130);
                count++;

                string n_tit = Reg_Opera.Calcular_nom_cte(Convert.ToString(RegAct.id_titular), 'T');
                ev.Graphics.DrawString("Titular:", printFont, Brushes.Black, xPos, yPos + 170);
                ev.Graphics.DrawString(Convert.ToString(RegAct.id_titular), printFont, Brushes.Black, xPos + 120, yPos + 170);
                ev.Graphics.DrawString(n_tit.Trim(), printFont, Brushes.Black, xPos + 180, yPos + 170);
                string tlfnos2 = Reg_Opera.Sacar_tlfos_cte(Convert.ToString(RegAct.id_titular), 'T');
                ev.Graphics.DrawString(tlfnos2.Trim(), printFont, Brushes.Black, xPos + 180, yPos + 200);
                count++;

                if (RegAct.id_colabora > 0)
                {
                    string n_col = Reg_Opera.Calcular_nom_cte(Convert.ToString(RegAct.id_colabora), 'B');
                    ev.Graphics.DrawString("Colaborador:", printFont, Brushes.Black, xPos, yPos + 240);
                    ev.Graphics.DrawString(Convert.ToString(RegAct.id_colabora), printFont, Brushes.Black, xPos + 120, yPos + 240);
                    ev.Graphics.DrawString(n_col.Trim(), printFont, Brushes.Black, xPos + 180, yPos + 240);
                    string tlfnos3 = Reg_Opera.Sacar_tlfos_cte(Convert.ToString(RegAct.id_colabora), 'B');
                    ev.Graphics.DrawString(tlfnos3.Trim(), printFont, Brushes.Black, xPos + 180, yPos + 270);
                    count++;
                    yPos = yPos + 90; //60
                }

                ev.Graphics.DrawString("Sección:", printFont, Brushes.Black, xPos, yPos + 240);
                ev.Graphics.DrawString(RegAct.seccion, printFont, Brushes.Black, xPos + 120, yPos + 240);
                count++;

                ev.Graphics.DrawString("Trámite:", printFont, Brushes.Black, xPos, yPos + 300);
                ev.Graphics.DrawString(RegAct.t_tramite, printFont, Brushes.Black, xPos + 120, yPos + 300);
                count++;

                ev.Graphics.DrawString("Enviar por:", printFont, Brushes.Black, xPos, yPos + 360);
                ev.Graphics.DrawString(RegAct.enviado, printFont, Brushes.Black, xPos + 120, yPos + 360);
                count++;

                ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos, yPos + 410, xPos + 550, yPos + 410);
                count++;

                printFont = new Font("Arial", 14, FontStyle.Bold);
                ev.Graphics.DrawString("Exped.:", printFont, Brushes.Black, xPos, yPos + 420);
                string n_exp = Convert.ToString(RegAct.exp_tl);
                if (n_exp.Length > 16)
                {
                    n_exp = n_exp.Substring(0, 17);
                }
                ev.Graphics.DrawString(n_exp, printFont, Brushes.Black, xPos + 80, yPos + 420);
                //string.Format("{0:dd/MM/yyyy}",RegAct.fec_pre_exp)

                ev.Graphics.DrawString("Fec.Pres.:", printFont, Brushes.Black, xPos + 300, yPos + 420);
                if (!string.IsNullOrWhiteSpace(n_exp))
                {
                    ev.Graphics.DrawString(RegAct.fec_pre_exp.ToString("dd/MM/yyyy"), printFont, Brushes.Black, xPos + 415, yPos + 420);
                }
                count++;

                printFont = new Font("Arial", 12, FontStyle.Bold);
                ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos, yPos + 460, xPos + 550, yPos + 460);
                count++;

                ev.Graphics.DrawString("Observ.:", printFont, Brushes.Black, xPos, yPos + 480);
                if (!string.IsNullOrWhiteSpace(RegAct.observacion))
                {
                    string observ = RegAct.observacion.Trim();
                    printFont = new Font("Arial", 11, FontStyle.Regular);
                    if (observ.Length > 50)
                    {
                        ev.Graphics.DrawString(observ.Substring(0, 50), printFont, Brushes.Black, xPos + 70, yPos + 480);
                        count++;
                        if (observ.Length > 100)
                        {
                            ev.Graphics.DrawString(observ.Substring(50, 50), printFont, Brushes.Black, xPos + 70, yPos + 500);
                            count++;

                            if (observ.Length > 150)
                            {
                                ev.Graphics.DrawString(observ.Substring(100, 50), printFont, Brushes.Black, xPos + 70, yPos + 520);
                                count++;

                                ev.Graphics.DrawString(observ.Substring(150), printFont, Brushes.Black, xPos + 70, yPos + 540);
                                count++;
                            }
                            else
                            {
                                ev.Graphics.DrawString(observ.Substring(100), printFont, Brushes.Black, xPos + 70, yPos + 520);
                                count++;
                            }
                        }
                        else
                        {
                            ev.Graphics.DrawString(observ.Substring(50), printFont, Brushes.Black, xPos + 70, yPos + 500);
                            count++;
                        }
                    }
                    else
                    {
                        ev.Graphics.DrawString(observ.Substring(0), printFont, Brushes.Black, xPos + 70, yPos + 480);
                        count++;
                    }
                }


                //salir del while y no imprimir + pgs.
                count = 100;
                line  = null;
            }

            // If more lines exist, print another page.
            if (line != null)
            {
                ev.HasMorePages = true;
            }
            else
            {
                ev.HasMorePages = false;
                count           = 0; //reinicio para la impresion en papel
            }
        }
예제 #5
0
        // The PrintPage event is raised for each page to be printed.
        private void printDocument1_PrintPage(object sender, PrintPageEventArgs ev)
        {
            printFont  = new Font("Arial", 11);
            leftMargin = 50; //ev.MarginBounds.Left;
            topMargin  = 20; //ev.MarginBounds.Top;
            StringFormat drawFormat = new StringFormat();
            string       line;

            // Calculate the number of lines per page.
            linesPerPage = 43; //Convert.ToInt32(ev.MarginBounds.Height /printFont.GetHeight(ev.Graphics));
            n_pag++;
            n_lineas = 0;
            //num_reg = 0;
            //short pinta_deleg=0;
            char deleg_old = 'Z'; //para cambio de cab. de delegacion

            //Pinta cabecera
            xPos = Convert.ToInt32(leftMargin);
            yPos = Convert.ToInt32(topMargin); //+ (n_lineas * printFont.GetHeight(ev.Graphics));

            ev.Graphics.DrawRectangle(new Pen(Color.Black, 1), xPos, yPos, xPos + 60, yPos + 50);
            printFont = new Font("Arial", 16, FontStyle.Bold);
            ev.Graphics.DrawString("ASEGEST", printFont, Brushes.Black, xPos, yPos + 10);
            ev.Graphics.DrawString("YECMUR", printFont, Brushes.Black, xPos, yPos + 40);
            ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos, yPos + 70, xPos + 1050, yPos + 70);

            string titulo = "LISTADO DE REGISTROS: ";

            if (secc_int != "")
            {
                titulo = titulo + secc_int;
            }
            if (estado != "")
            {
                titulo = titulo + " " + estado;
            }
            //titulo con est_reg.
            titulo = titulo + " - " + cb_treg.Text.Trim();


            printFont = new Font("Arial", 14, FontStyle.Bold | FontStyle.Underline);
            ev.Graphics.DrawString(titulo, printFont, Brushes.Black, xPos + 300, yPos + 90);

            n_lineas = n_lineas + 5;
            yPos     = yPos + 90;

            while ((pos_reg < _registros.Count) && (n_lineas < linesPerPage))
            {
                //cabecera
                string n_deleg = "";
                if (deleg_old != _registros.ElementAt(pos_reg).delegacion)
                {
                    if (_registros.ElementAt(pos_reg).delegacion == 'Y')
                    {
                        n_deleg = "YECLA";
                    }
                    else
                    {
                        if (_registros.ElementAt(pos_reg).delegacion == 'M')
                        {
                            n_deleg = "MURCIA";
                        }
                        else
                        {
                            n_deleg = "ALBACETE";
                        }
                    }

                    printFont = new Font("Arial", 12, FontStyle.Bold | FontStyle.Underline);
                    ev.Graphics.DrawString("Delegación:   " + n_deleg, printFont, Brushes.Black, xPos, yPos + 30);

                    printFont = new Font("Arial", 10, FontStyle.Bold);
                    ev.Graphics.DrawString("N.REG.", printFont, Brushes.Black, xPos, yPos + 60);
                    ev.Graphics.DrawString("F.ENTREGA", printFont, Brushes.Black, xPos + 55, yPos + 60);
                    ev.Graphics.DrawString("CLIENTE", printFont, Brushes.Black, xPos + 140, yPos + 60);
                    ev.Graphics.DrawString("TITULAR", printFont, Brushes.Black, xPos + 430, yPos + 60);
                    ev.Graphics.DrawString("SECCION", printFont, Brushes.Black, xPos + 730, yPos + 60);
                    ev.Graphics.DrawString("ESTADO", printFont, Brushes.Black, xPos + 950, yPos + 60);

                    ev.Graphics.DrawString("EXPEDIENTE", printFont, Brushes.Black, xPos, yPos + 80);
                    ev.Graphics.DrawString("COLABORADOR", printFont, Brushes.Black, xPos + 140, yPos + 80);
                    ev.Graphics.DrawString("SECC. INT./EXP. NO TL.", printFont, Brushes.Black, xPos + 430, yPos + 80);
                    ev.Graphics.DrawString("TRAMITE", printFont, Brushes.Black, xPos + 730, yPos + 80);
                    ev.Graphics.DrawString("NUM.FRA.", printFont, Brushes.Black, xPos + 950, yPos + 80);

                    ev.Graphics.DrawLine(new Pen(Color.Black, 2), xPos, yPos + 100, xPos + 1050, yPos + 100);

                    n_lineas  = n_lineas + 6;
                    yPos      = yPos + 100;
                    deleg_old = _registros.ElementAt(pos_reg).delegacion;
                }



                //lineas
                printFont = new Font("Arial", 10, FontStyle.Regular);
                ev.Graphics.DrawString(Convert.ToString(_registros.ElementAt(pos_reg).n_reg), printFont, Brushes.Black, xPos, yPos + 10);
                ev.Graphics.DrawString(_registros.ElementAt(pos_reg).fec_ent.ToString("dd/MM/yyyy"), printFont, Brushes.Black, xPos + 65, yPos + 10);
                string n_cte = Reg_Opera.Calcular_nom_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_cte), 'C');
                if (n_cte.Trim().Length > 33)
                {
                    ev.Graphics.DrawString(n_cte.Substring(0, 33), printFont, Brushes.Black, xPos + 140, yPos + 10);
                }
                else
                {
                    ev.Graphics.DrawString(n_cte.Trim(), printFont, Brushes.Black, xPos + 140, yPos + 10);
                }

                string n_tit = Reg_Opera.Calcular_nom_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_titular), 'T');
                if (n_tit.Trim().Length > 34)
                {
                    ev.Graphics.DrawString(n_tit.Substring(0, 34), printFont, Brushes.Black, xPos + 430, yPos + 10);
                }
                else
                {
                    ev.Graphics.DrawString(n_tit.Trim(), printFont, Brushes.Black, xPos + 430, yPos + 10);
                }

                ev.Graphics.DrawString(_registros.ElementAt(pos_reg).seccion, printFont, Brushes.Black, xPos + 730, yPos + 10);
                //ev.Graphics.DrawString(_registros.ElementAt(pos_reg).t_tramite.Substring(0,24), printFont, Brushes.Black, xPos + 780, yPos + 10);
                string anulado = _registros.ElementAt(pos_reg).estado.Trim();
                if (anulado.Equals("ANULADO"))
                {
                    ev.Graphics.DrawString("ANUL:" + _registros.ElementAt(pos_reg).fec_anul, printFont, Brushes.Black, xPos + 950, yPos + 10);
                }
                else
                {
                    ev.Graphics.DrawString(_registros.ElementAt(pos_reg).estado, printFont, Brushes.Black, xPos + 950, yPos + 10);
                }

                ev.Graphics.DrawString(_registros.ElementAt(pos_reg).exp_tl, printFont, Brushes.Black, xPos, yPos + 30);
                string n_col = Reg_Opera.Calcular_nom_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_colabora), 'B');
                if (n_col.Trim().Length > 34)
                {
                    ev.Graphics.DrawString(n_col.Substring(0, 34), printFont, Brushes.Black, xPos + 140, yPos + 30);
                }
                else
                {
                    ev.Graphics.DrawString(n_col.Trim(), printFont, Brushes.Black, xPos + 140, yPos + 30);
                }

                ev.Graphics.DrawString(_registros.ElementAt(pos_reg).seccion_int, printFont, Brushes.Black, xPos + 430, yPos + 30);
                ev.Graphics.DrawString(_registros.ElementAt(pos_reg).exp_ntl, printFont, Brushes.Black, xPos + 520, yPos + 30);
                ev.Graphics.DrawString(_registros.ElementAt(pos_reg).t_tramite, printFont, Brushes.Black, xPos + 730, yPos + 30);
                printFont = new Font("Arial", 10, FontStyle.Bold);
                line      = "Nº Factura: " + Convert.ToString(_registros.ElementAt(pos_reg).factura);
                ev.Graphics.DrawString(line, printFont, Brushes.Black, xPos + 930, yPos + 30);

                yPos     = yPos + 30;
                n_lineas = n_lineas + 2;

                printFont = new Font("Arial", 10, FontStyle.Regular);
                if (_registros.ElementAt(pos_reg).observacion.Trim().Length > 0)
                {
                    string observ = "Obs: " + Convert.ToString(_registros.ElementAt(pos_reg).observacion);
                    ev.Graphics.DrawString(observ.Substring(0, 100), printFont, Brushes.Black, xPos, yPos + 20);
                    yPos = yPos + 20;
                    n_lineas++;

                    if (observ.Trim().Length > 100)
                    {
                        ev.Graphics.DrawString(observ.Substring(101), printFont, Brushes.Black, xPos + 40, yPos + 20);
                        yPos = yPos + 20;
                        n_lineas++;
                    }
                }
                ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos, yPos + 20, xPos + 1050, yPos + 20);

                yPos = yPos + 20;
                n_lineas++;
                pos_reg++;
                num_reg++;
            }

            //pie
            ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos, 800, xPos + 1050, 800);
            line = "Pag. " + Convert.ToString(n_pag);
            ev.Graphics.DrawString(line, printFont, Brushes.Black, xPos + 500, 805);
            line = "Num. de Registros = " + Convert.ToString(num_reg);
            ev.Graphics.DrawString(line, printFont, Brushes.Black, xPos + 870, 805);

            // If more lines exist, print another page.
            if (pos_reg < _registros.Count)//(line != null)
            {
                ev.HasMorePages = true;
            }
            else
            {
                ev.HasMorePages = false;
                pos_reg         = 0; //reinicio para la impresion en papel
                n_pag           = 0;
                num_reg         = 0;
            }
        }