Exemplo n.º 1
0
        public void lanza_lreg()
        {
            try
            {
                char t_cte = ' ';
                if (rb_cte_lrg.Checked == true)
                {
                    t_cte = 'C';
                }
                else
                {
                    if (rb_titular_lrg.Checked == true)
                    {
                        t_cte = 'T';
                    }
                    else if (rb_colab_lrg.Checked == true)
                    {
                        t_cte = 'B';
                    }
                }
                char deleg = ' ';
                if (rb_y_lrg.Checked == true)
                {
                    deleg = 'Y';
                }
                else
                {
                    if (rb_m_lrg.Checked == true)
                    {
                        deleg = 'M';
                    }
                    else if (rb_a_lrg.Checked == true)
                    {
                        deleg = 'A';
                    }
                }
                secc_int = cb_secc_lrg.Text.Trim();
                estado   = cb_estado_lrg.Text.Trim();
                seccion  = cb_secc.Text.Trim();
                tramite  = cb_tram.Text.Trim();
                est_reg  = 'T';
                if (cb_treg.Text == "SIN FACTURAR")
                {
                    est_reg = 'S';
                }
                else
                {
                    if (cb_treg.Text == "FACTURADOS")
                    {
                        est_reg = 'F';
                    }
                }

                _registros.Clear();
                _registros.AddRange(Reg_Opera.Buscar_lreg(deleg, Convert.ToInt32(tb_d_rg.Text), Convert.ToInt32(tb_h_rg.Text), dtp_d_freg.Value, dtp_h_freg.Value,
                                                          t_cte, Convert.ToInt32(tb_d_cte.Text), Convert.ToInt32(tb_h_cte.Text), secc_int, estado, est_reg, seccion, tramite));

                if (_registros.Count == 0)
                {
                    MessageBox.Show("No se obtuvo ningún registro.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    printDocument1.DefaultPageSettings.Landscape = true;
                    printDocument1.PrintPage -= new PrintPageEventHandler(printDocument1_PrintPage);
                    printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);

                    printPreviewDialog1.Document = printDocument1;
                    printPreviewDialog1.PrintPreviewControl.Zoom = 1.0;
                    printPreviewDialog1.WindowState = FormWindowState.Maximized;

                    DialogResult respuesta = MessageBox.Show("¿Desea entrar en la vista previa del impreso?", "Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                    if (respuesta == DialogResult.Yes)
                    {
                        printPreviewDialog1.ShowDialog();
                    }
                    else
                    {
                        PrintDialog printDialog1 = new PrintDialog();
                        printDialog1.Document = printDocument1;

                        if (printDialog1.ShowDialog().Equals(DialogResult.OK))
                        {
                            printDialog1.Document.Print();
                        }
                    }
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show("No se seleccionó ningún registro.", e1.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 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;
            //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;
            }
        }
Exemplo n.º 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();
            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;
            }
        }