Beispiel #1
0
 private void btt_imp_ts_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(tb_nfac.Text) || tb_nfac.Text == "0")
     {
         MessageBox.Show("No se insertó ningún Num. de Fra.", "Atención!!!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         tb_nfac.Focus();
     }
     else
     {
         if (Reg_Opera.Existe_factura(Convert.ToInt32(tb_nfac.Text)) == 0)
         {
             MessageBox.Show("No existe ese Num. de Fra.", "Atención!!!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             if (Linfac_Opera.Existe_Linfac(Convert.ToInt32(tb_nfac.Text)) != 0)
             {
                 MessageBox.Show("Ese N.Fra. tiene detalle, bórrelo y inténtelo de nuevo.", "Atención!!!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             else
             {   //procede a update
                 Desfactura();
                 this.Close();
             }
         }
     }
 }
Beispiel #2
0
        public void Enlaza_fra()
        {
            try
            {
                int  asiento = 0;
                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();

                _registros.Clear();
                _registros.AddRange(Reg_Opera.Buscar_rfra(deleg, Convert.ToInt32(tb_d_fra.Text), Convert.ToInt32(tb_h_fra.Text), dtp_d_ffra.Value, dtp_h_ffra.Value,
                                                          t_cte, Convert.ToInt32(tb_d_cte.Text), Convert.ToInt32(tb_h_cte.Text), 'Z', 1));

                if (_registros.Count == 0)
                {
                    MessageBox.Show("No se obtuvo ningún registro.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    //filePath = = "@\"" + tb_pdf.Text + "\"";
                    fichero_asi = File.CreateText(tb_ruta.Text + "enlace.txt"); //"c:\\temp\\csharp\\enlace.txt"
                    fichero_fra = File.CreateText(tb_ruta.Text + "enlace_fra.txt");
                    fichero_cte = File.CreateText(tb_ruta.Text + "enlace_cte.txt");
                    asiento     = Convert.ToInt32(tb_n_asi.Text);
                    while (pos_reg < _registros.Count)
                    {
                        if (_registros.ElementAt(pos_reg).t_cte_fra == 'C')
                        {
                            //facturar a cte.
                            //cta_cte = Reg_Opera.Sacar_cta_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_cte), 'C');
                            //nom_cte = Reg_Opera.Calcular_nom_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_cte), 'C');
                            //dnicif = Reg_Opera.Sacar_dnicif_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_cte), 'C');
                            Cte_a_enlazar = Ctes_Opera.ObtenerCliente(_registros.ElementAt(pos_reg).id_cte);
                        }
                        else
                        {
                            if (_registros.ElementAt(pos_reg).t_cte_fra == 'T') //facturar a titular.
                            {
                                //cta_cte = Reg_Opera.Sacar_cta_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_titular), 'T');
                                //nom_cte = Reg_Opera.Calcular_nom_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_titular), 'T');
                                //dnicif = Reg_Opera.Sacar_dnicif_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_titular), 'T');
                                Cte_a_enlazar = Ctes_Opera.ObtenerCliente(_registros.ElementAt(pos_reg).id_titular);
                            }
                            else //facturar a colaborador.
                            {
                                //cta_cte = Reg_Opera.Sacar_cta_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_colabora), 'B');
                                //nom_cte = Reg_Opera.Calcular_nom_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_colabora), 'B');
                                //dnicif = Reg_Opera.Sacar_dnicif_cte(Convert.ToString(_registros.ElementAt(pos_reg).id_colabora), 'B');
                                Cte_a_enlazar = Ctes_Opera.ObtenerCliente(_registros.ElementAt(pos_reg).id_colabora);
                            }
                        }
                        //Ctas cliente
                        line = "'" + Cte_a_enlazar.cta_cble.Trim() + "';'" + Cte_a_enlazar.Nombre.Trim() + "';'S';'" + Cte_a_enlazar.Documento.Trim() + Cte_a_enlazar.Letra + "';'" +
                               Cte_a_enlazar.Direccion.Trim() + "';'" + Cte_a_enlazar.Cpostal.Trim() + "';'" + Cte_a_enlazar.Ciudad.Trim() + "';'" + Cte_a_enlazar.Telf1.Trim() + "';'','','" +
                               Cte_a_enlazar.Pers_cont.Trim() + "';'" + Cte_a_enlazar.Email.Trim() + "';";
                        fichero_cte.WriteLine(line.Replace("'", "\""));


                        base_imp    = 0;
                        imp_iva     = 0;
                        tot_fra     = 0;
                        imp_tasa    = 0;
                        imp_det     = 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);

                        base_imp = _registros.ElementAt(pos_reg).dcho_col + _registros.ElementAt(pos_reg).honorarios + importes[1];
                        imp_iva  = ((base_imp * _registros.ElementAt(pos_reg).p_iva) / 100);
                        imp_tasa = _registros.ElementAt(pos_reg).tasa - importes[0]; //le quitamos impor sin iva de detalles
                        tot_fra  = base_imp + imp_iva + _registros.ElementAt(pos_reg).tasa;

                        //creamos fichero de fras.
                        line = "'E';'" + string.Format("{0:000000}", asiento) + "';'" + string.Format("{0:000000}", _registros.ElementAt(pos_reg).factura) + "';'" +
                               _registros.ElementAt(pos_reg).fec_fra.ToString("ddMMyyyy") + "';'" + Cte_a_enlazar.cta_cble.Trim() + "';'" + Cte_a_enlazar.Nombre.Trim() + "';'" + Cte_a_enlazar.Documento.Trim() + Cte_a_enlazar.Letra + "';'" +
                               string.Format("{0:###,##0.00}", base_imp) + "';'" + string.Format("{0:##0}", _registros.ElementAt(pos_reg).p_iva) + "';'" + string.Format("{0:###,##0.00}", imp_iva) + "';'Varias';'" +
                               string.Format("{0:###,##0.00}", _registros.ElementAt(pos_reg).tasa) + "';'0';'0';'705000011';'S';'00';'N';'N';";
                        fichero_fra.WriteLine(line.Replace("'", "\""));

                        //Sacamos ctas de detalle
                        _cuentas = Linfac_Opera.Saca_ctas_x_impor(_registros.ElementAt(pos_reg).factura);

                        concepto = "N/FRA. " + _registros.ElementAt(pos_reg).factura + " - " + Cte_a_enlazar.Nombre.Trim().Trim();
                        line     = "'D';'" + string.Format("{0:000000}", asiento) + "';'" + _registros.ElementAt(pos_reg).fec_fra.ToString("ddMM") + "';'" + Cte_a_enlazar.cta_cble.Trim() + "';'" +
                                   string.Format("{0:###,##0.00}", tot_fra) + "';'" + concepto.Trim() + "';'FE';'N';'';'N';'';";
                        fichero_asi.WriteLine(line.Replace("'", "\""));//deben ser comillas dobles

                        //buscamos el importe de la cta de tasa en detalles
                        imp_det = Busca_cta_det(tb_ctasa.Text.Trim());
                        if (_registros.ElementAt(pos_reg).tasa > 0 | imp_det > 0)
                        {
                            line = "'H';'" + string.Format("{0:000000}", asiento) + "';'" + _registros.ElementAt(pos_reg).fec_fra.ToString("ddMM") + "';'" + tb_ctasa.Text.Trim() + "';'" +
                                   string.Format("{0:###,##0.00}", imp_tasa + imp_det) + "';'" + concepto.Trim() + "';'FE';'N';'" + Cte_a_enlazar.cta_cble.Trim() + "';'N';'';";
                            fichero_asi.WriteLine(line.Replace("'", "\""));
                        }
                        imp_det = Busca_cta_det(tb_cdcol.Text.Trim());
                        if (_registros.ElementAt(pos_reg).dcho_col > 0 | imp_det > 0)
                        {
                            line = "'H';'" + string.Format("{0:000000}", asiento) + "';'" + _registros.ElementAt(pos_reg).fec_fra.ToString("ddMM") + "';'" + tb_cdcol.Text.Trim() + "';'" +
                                   string.Format("{0:###,##0.00}", _registros.ElementAt(pos_reg).dcho_col + imp_det) + "';'" + concepto.Trim() + "';'FE';'N';'" + Cte_a_enlazar.cta_cble.Trim() + "';'N';'';";
                            fichero_asi.WriteLine(line.Replace("'", "\""));
                        }
                        imp_det = Busca_cta_det(tb_chono.Text.Trim());
                        if (_registros.ElementAt(pos_reg).honorarios > 0 | imp_det > 0)
                        {
                            line = "'H';'" + string.Format("{0:000000}", asiento) + "';'" + _registros.ElementAt(pos_reg).fec_fra.ToString("ddMM") + "';'" + tb_chono.Text.Trim() + "';'" +
                                   string.Format("{0:###,##0.00}", _registros.ElementAt(pos_reg).honorarios + imp_det) + "';'" + concepto.Trim() + "';'FE';'N';'" + Cte_a_enlazar.cta_cble.Trim() + "';'N';'';";
                            fichero_asi.WriteLine(line.Replace("'", "\""));
                        }
                        if (imp_iva > 0)
                        {
                            line = "'H';'" + string.Format("{0:000000}", asiento) + "';'" + _registros.ElementAt(pos_reg).fec_fra.ToString("ddMM") + "';'" + tb_civa.Text.Trim() + "';'" +
                                   string.Format("{0:###,##0.00}", imp_iva) + "';'" + concepto.Trim() + "';'FE';'N';'" + Cte_a_enlazar.cta_cble.Trim() + "';'N';'';";
                            fichero_asi.WriteLine(line.Replace("'", "\""));
                        }

                        //Ver ctas de detalle: cta_suplido
                        if (_cuentas.Count > 0)
                        {
                            foreach (Cuentas pcuenta in _cuentas)
                            {
                                line = "'H';'" + string.Format("{0:000000}", asiento) + "';'" + _registros.ElementAt(pos_reg).fec_fra.ToString("ddMM") + "';'" + pcuenta.cta_cble.Trim() + "';'" +
                                       string.Format("{0:###,##0.00}", pcuenta.importe_acu) + "';'" + concepto.Trim() + "';'FE';'N';'" + Cte_a_enlazar.cta_cble.Trim() + "';'N';'';";
                                fichero_asi.WriteLine(line.Replace("'", "\""));
                            }
                        }

                        //updateo facturas a enlazado
                        if (_registros.ElementAt(pos_reg).estado_fac == 'L' & Reg_Opera.Fra_listada_enlazada(_registros.ElementAt(pos_reg).factura, 1) > 0)
                        { //actualiza estado factura a enlazada
                        }

                        pos_reg++;
                        //incremento n_asi
                        asiento++;
                        //tb_n_asi.Text = Convert.ToString(asiento);
                    }
                    fichero_cte.Close();
                    fichero_asi.Close();
                    fichero_fra.Close();
                    MessageBox.Show("Fras. enlazadas con éxito.", "Muy bien!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show("No se seleccionó ningún registro.", e1.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #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", 12);
            leftMargin = 30; //ev.MarginBounds.Left;
            topMargin  = 50; //ev.MarginBounds.Top;
            StringFormat drawFormat = new StringFormat();

            drawFormat.Alignment = StringAlignment.Far;
            // Calculate the number of lines per page.
            linesPerPage = Convert.ToInt32(ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics));
            string dg_direc = " ";
            string dg_pob   = " ";
            string dg_cif   = " ";
            string dg_tel   = " ";

            if (RegAct.delegacion == 'M')
            {
                dg_direc = "C/ RONDA SUR, 32 1ºB";
                dg_pob   = "30012  MURCIA";
                dg_cif   = "CIF:  B73821225";
                dg_tel   = "Tel./Fax: 868078844 /Mov.: 636205206 - 690263439";
            }
            else //yecla y alb la misma direccion
            {
                dg_direc = "PASCUAL AMAT, Nº 7";
                dg_pob   = "30510  YECLA  MURCIA";
                dg_cif   = "CIF:  B73821225";
                dg_tel   = "Tel.: 968752917";
            }

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

            if (RegAct.t_cte_fra == 'C')       //facturar a cte.
            {
                ClienteFacturado = Ctes_Opera.ObtenerCliente(RegAct.id_cte);
            }
            else
            {
                if (RegAct.t_cte_fra == 'T') //facturar a titular.
                {
                    ClienteFacturado = Ctes_Opera.ObtenerCliente(RegAct.id_titular);
                }
                else //facturar a colaborador.
                {
                    ClienteFacturado = Ctes_Opera.ObtenerCliente(RegAct.id_colabora);
                }
            }

            while (count < linesPerPage)
            {
                //CABECERA
                string titulo = "ASEGEST YECMUR, SLP.";
                if (RegAct.delegacion == 'A')
                {
                    titulo = titulo + " - ALBACETE";
                }
                printFont = new Font("Arial", 16, FontStyle.Bold);
                ev.Graphics.DrawString(titulo, printFont, Brushes.Black, xPos, yPos + 20);
                printFont = new Font("Arial", 10, FontStyle.Regular);
                ev.Graphics.DrawString(dg_direc, printFont, Brushes.Black, xPos, yPos + 50);
                ev.Graphics.DrawString(dg_pob, printFont, Brushes.Black, xPos, yPos + 70);
                ev.Graphics.DrawString(dg_cif, printFont, Brushes.Black, xPos, yPos + 90);
                ev.Graphics.DrawString(dg_tel, printFont, Brushes.Black, xPos, yPos + 110);
                count = count + 5;

                printFont = new Font("Arial", 16, FontStyle.Bold | FontStyle.Italic);
                ev.Graphics.DrawString("F A C T U R A", printFont, Brushes.Black, xPos + 60, yPos + 150);
                printFont = new Font("Arial", 8, FontStyle.Regular);
                ev.Graphics.DrawString("Datos Cliente", printFont, Brushes.Black, xPos + 330, yPos + 140);
                count = count + 2;

                //Atencion line: coord. ini y coord. final // rectangle: coord. ini y width y height.
                printFont = new Font("Arial", 12, FontStyle.Regular);
                ev.Graphics.DrawRectangle(new Pen(Color.Black, 1), xPos + 330, yPos + 160, 400, 160);

                ev.Graphics.DrawString(Convert.ToString(ClienteFacturado.Id_Cliente).Trim(), printFont, Brushes.Black, xPos + 340, yPos + 165);
                printFont = new Font("Arial", 13, FontStyle.Bold);
                ev.Graphics.DrawString(ClienteFacturado.Nombre, printFont, Brushes.Black, xPos + 340, yPos + 190);
                printFont = new Font("Arial", 12, FontStyle.Regular);
                ev.Graphics.DrawString(ClienteFacturado.Direccion, printFont, Brushes.Black, xPos + 340, yPos + 215);
                ev.Graphics.DrawString(ClienteFacturado.Cpostal, printFont, Brushes.Black, xPos + 340, yPos + 235);
                ev.Graphics.DrawString(ClienteFacturado.Ciudad, printFont, Brushes.Black, xPos + 400, yPos + 235);
                ev.Graphics.DrawString(ClienteFacturado.Provin, printFont, Brushes.Black, xPos + 340, yPos + 255);
                ev.Graphics.DrawString(ClienteFacturado.Telf1, printFont, Brushes.Black, xPos + 340, yPos + 275);
                ev.Graphics.DrawString(ClienteFacturado.Telf2, printFont, Brushes.Black, xPos + 470, yPos + 275);
                string docu = ClienteFacturado.Tipo_docu.Trim() + ": " + ClienteFacturado.Documento.Trim() + ClienteFacturado.Letra;
                ev.Graphics.DrawString(docu, printFont, Brushes.Black, xPos + 340, yPos + 295);

                ev.Graphics.DrawRectangle(new Pen(Color.Black, 1), xPos + 30, yPos + 210, 120, 60);
                ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos + 30, yPos + 240, xPos + 150, yPos + 240);
                ev.Graphics.DrawString("Nº de Factura", printFont, Brushes.Black, xPos + 35, yPos + 220);
                ev.Graphics.DrawString(string.Format("{0:#######0}", RegAct.factura), printFont, Brushes.Black, xPos + 125, yPos + 250, drawFormat);

                ev.Graphics.DrawRectangle(new Pen(Color.Black, 1), xPos + 180, yPos + 210, 120, 60);
                ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos + 180, yPos + 240, xPos + 300, yPos + 240);
                ev.Graphics.DrawString("Fecha", printFont, Brushes.Black, xPos + 215, yPos + 220);
                ev.Graphics.DrawString(RegAct.fec_fra.ToString("dd/MM/yyyy"), printFont, Brushes.Black, xPos + 195, yPos + 250);

                count = count + 6;

                //LINEAS
                ev.Graphics.DrawRectangle(new Pen(Color.Black, 1), xPos + 30, yPos + 340, 700, 550);
                ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos + 30, yPos + 380, xPos + 730, yPos + 380);
                ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos + 490, yPos + 340, xPos + 490, yPos + 890);
                ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos + 610, yPos + 340, xPos + 610, yPos + 890);
                printFont = new Font("Arial", 14, FontStyle.Bold);
                ev.Graphics.DrawString("CONCEPTO", printFont, Brushes.Black, xPos + 150, yPos + 350);
                ev.Graphics.DrawString("IMPORTE", printFont, Brushes.Black, xPos + 510, yPos + 350);
                ev.Graphics.DrawString("TOTAL", printFont, Brushes.Black, xPos + 630, yPos + 350);

                count = count + 3;

                string descrip2 = RegAct.descripcion.Trim();
                if (descrip2.Length > 42)
                {
                    descrip2 = descrip2.Substring(0, 43);
                }

                printFont = new Font("Arial", 12, FontStyle.Regular);
                ev.Graphics.DrawString(descrip2.ToUpper(), printFont, Brushes.Black, xPos + 40, yPos + 400);
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", "0,00"), printFont, Brushes.Black, xPos + 600, yPos + 400, drawFormat);
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", "0,00"), printFont, Brushes.Black, xPos + 720, yPos + 400, drawFormat);
                if (RegAct.descripcion.Trim().Length > 42)
                {
                    if (RegAct.descripcion.Trim().Length > 87)
                    {
                        descrip2 = RegAct.descripcion.Trim().Substring(43, 45);
                    }
                    else
                    {
                        descrip2 = RegAct.descripcion.Trim().Substring(43);
                    }

                    ev.Graphics.DrawString(descrip2.ToUpper(), printFont, Brushes.Black, xPos + 40, yPos + 420);
                    yPos  = yPos + 20;
                    count = count + 1;
                }
                if (RegAct.descripcion.Trim().Length > 87)
                {
                    descrip2 = RegAct.descripcion.Trim().Substring(88);
                    ev.Graphics.DrawString(descrip2.ToUpper(), printFont, Brushes.Black, xPos + 40, yPos + 420);
                    yPos  = yPos + 20;
                    count = count + 1;
                }

                importes[0] = 0; //sin iva
                importes[1] = 0; //con iva
                //sacamos los importes con iva de linfac a simpor1; los sin iva ya estan acumulados en campo tasa,
                //pero debemos restarlos en tasa, pues luego le pondremos el detalle.
                importes = Linfac_Opera.Calcular_importes_linfac(RegAct.factura);

                //sergio: linea  de separacion
                yPos = yPos + 20;
                ev.Graphics.DrawString("TASA TRAFICO", printFont, Brushes.Black, xPos + 40, yPos + 420);
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", RegAct.tasa - importes[0]), printFont, Brushes.Black, xPos + 600, yPos + 420, drawFormat);
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", RegAct.tasa - importes[0]), printFont, Brushes.Black, xPos + 720, yPos + 420, drawFormat);

                ev.Graphics.DrawString("DERECHOS DE COLEGIO", printFont, Brushes.Black, xPos + 40, yPos + 440);
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", RegAct.dcho_col), printFont, Brushes.Black, xPos + 600, yPos + 440, drawFormat);
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", RegAct.dcho_col), printFont, Brushes.Black, xPos + 720, yPos + 440, drawFormat);

                ev.Graphics.DrawString("HONORARIOS", printFont, Brushes.Black, xPos + 40, yPos + 460);
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", RegAct.honorarios), printFont, Brushes.Black, xPos + 600, yPos + 460, drawFormat);
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", RegAct.honorarios), printFont, Brushes.Black, xPos + 720, yPos + 460, drawFormat);

                count = count + 4;

                decimal simpor0 = 0; //sin iva
                decimal simpor1 = 0; //con iva

                //Detalle de lineas
                if (linfac.Rows.Count > 0)
                {
                    foreach (DataRow linea in linfac.Rows)
                    {
                        ev.Graphics.DrawString(linea[2].ToString().Substring(0, 43).ToUpper(), printFont, Brushes.Black, xPos + 40, yPos + 480);
                        ev.Graphics.DrawString(string.Format("{0:###,##0.00}", linea[3]), printFont, Brushes.Black, xPos + 600, yPos + 480, drawFormat);
                        ev.Graphics.DrawString(string.Format("{0:###,##0.00}", linea[3]), printFont, Brushes.Black, xPos + 720, yPos + 480, drawFormat);
                        if (linea[2].ToString().Trim().Length > 42)
                        {
                            ev.Graphics.DrawString(linea[2].ToString().Substring(43, 45).ToUpper(), printFont, Brushes.Black, xPos + 40, yPos + 500);
                            yPos  = yPos + 20;
                            count = count + 1;
                        }
                        if (linea[2].ToString().Trim().Length > 87)
                        {
                            ev.Graphics.DrawString(linea[2].ToString().Substring(88).ToUpper(), printFont, Brushes.Black, xPos + 40, yPos + 500);
                            yPos  = yPos + 20;
                            count = count + 1;
                        }

                        yPos  = yPos + 20;
                        count = count + 1;
                        //vemos si esta exento de iva el importe: importe[4] columna de piva.
                        if (linea[4].ToString() == "0")
                        {
                            simpor0 = simpor0 + Convert.ToDecimal(linea[3].ToString());
                        }
                        else
                        {
                            simpor1 = simpor1 + Convert.ToDecimal(linea[3].ToString());
                        }
                    }
                }



                //PIE

                ev.Graphics.DrawRectangle(new Pen(Color.Black, 1), xPos + 30, 950, 400, 80);
                ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos + 30, 980, xPos + 430, 980);
                ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos + 130, 950, xPos + 130, 1030);
                ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos + 230, 950, xPos + 230, 1030);
                ev.Graphics.DrawLine(new Pen(Color.Black, 1), xPos + 330, 950, xPos + 330, 1030);
                printFont = new Font("Arial", 12, FontStyle.Bold);
                ev.Graphics.DrawString("Total Bruto", printFont, Brushes.Black, xPos + 33, 960);
                ev.Graphics.DrawString("Base Imp.", printFont, Brushes.Black, xPos + 140, 960);
                ev.Graphics.DrawString("% I.V.A.", printFont, Brushes.Black, xPos + 250, 960);
                ev.Graphics.DrawString("Cuota", printFont, Brushes.Black, xPos + 350, 960);
                printFont = new Font("Arial", 12, FontStyle.Regular);



                decimal base_imp  = RegAct.dcho_col + RegAct.honorarios + simpor1;
                decimal tot_tasas = RegAct.tasa; //+ simpor0; regact.tasas ya guarda el impor d linfac q sea sin iva
                decimal tot_b     = base_imp + tot_tasas;

                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", tot_b), printFont, Brushes.Black, xPos + 120, 990, drawFormat);
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", base_imp), printFont, Brushes.Black, xPos + 220, 990, drawFormat);
                ev.Graphics.DrawString(string.Format("{0:##0}", RegAct.p_iva), printFont, Brushes.Black, xPos + 300, 990, drawFormat);
                decimal imp_iva = ((base_imp * RegAct.p_iva) / 100);
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", imp_iva.ToString("N2")), printFont, Brushes.Black, xPos + 420, 990, drawFormat);

                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", tot_tasas), printFont, Brushes.Black, xPos + 220, 1010, drawFormat);
                ev.Graphics.DrawString(string.Format("{0:##0}", "0"), printFont, Brushes.Black, xPos + 300, 1010, drawFormat);
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", "0,00"), printFont, Brushes.Black, xPos + 420, 1010, drawFormat);

                printFont = new Font("Arial", 14, FontStyle.Bold);
                ev.Graphics.DrawRectangle(new Pen(Color.Black, 2), xPos + 530, 970, 200, 60);
                ev.Graphics.DrawString("TOTAL FACTURA", printFont, Brushes.Black, xPos + 540, 975);
                decimal tot_fra = tot_b + imp_iva;
                ev.Graphics.DrawString(string.Format("{0:###,##0.00}", tot_fra.ToString("N2")) + " €", printFont, Brushes.Black, xPos + 710, 1000, drawFormat);

                count = count + 10;
                //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
            }

            // If there are no more pages, reset the string to be printed.
            //if (!ev.HasMorePages)
            //  streamToPrint = new StreamReader (filePath);
        }
Beispiel #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", 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;
            }
        }
Beispiel #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();

            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;
            }
        }