Exemple #1
0
        private void generarArchivosBanco(string bancoStr, List <Dictionary <string, object> > resultado)
        {
            SaveFileDialog dialogoGuardar = new SaveFileDialog();

            dialogoGuardar.AddExtension = true;
            dialogoGuardar.DefaultExt   = ".dbf";
            dialogoGuardar.FileName     = bancoStr;

            if (dialogoGuardar.ShowDialog() == DialogResult.OK)
            {
                string ruta = dialogoGuardar.FileName;

                Stream ops = File.Open(ruta, FileMode.OpenOrCreate, FileAccess.ReadWrite);

                DotNetDBF.DBFWriter escribir = new DotNetDBF.DBFWriter();
                escribir.DataMemoLoc = ruta.Replace("dbf", "dbt");

                DotNetDBF.DBFField c1 = new DotNetDBF.DBFField("JPP", DotNetDBF.NativeDbType.Char, 3);
                DotNetDBF.DBFField c2 = new DotNetDBF.DBFField("NUM", DotNetDBF.NativeDbType.Numeric, 6, 0);
                DotNetDBF.DBFField c3 = new DotNetDBF.DBFField("NOMBRE", DotNetDBF.NativeDbType.Char, 40);
                DotNetDBF.DBFField c4 = new DotNetDBF.DBFField("NETO", DotNetDBF.NativeDbType.Numeric, 12, 2);
                DotNetDBF.DBFField c5 = new DotNetDBF.DBFField("BANCO", DotNetDBF.NativeDbType.Char, 3);
                DotNetDBF.DBFField c6 = new DotNetDBF.DBFField("TCTA", DotNetDBF.NativeDbType.Char, 2);
                DotNetDBF.DBFField c7 = new DotNetDBF.DBFField("CUENTA", DotNetDBF.NativeDbType.Char, 25);
                DotNetDBF.DBFField c8 = new DotNetDBF.DBFField("RFC", DotNetDBF.NativeDbType.Char, 13);

                DotNetDBF.DBFField[] campos = new DotNetDBF.DBFField[] { c1, c2, c3, c4, c5, c6, c7, c8 };
                escribir.Fields = campos;

                foreach (Dictionary <string, object> item in resultado)
                {
                    string jpp        = Convert.ToString(item["jpp"]);
                    double num        = Convert.ToDouble(item["num"]);
                    string nombre     = Convert.ToString(item["nombre"]);
                    double neto       = globales.convertDouble(Convert.ToString(item["sum"]));
                    string banco      = "072";
                    string tcta       = "01";
                    string cuentabanc = Convert.ToString(item["cuentabanc"]);
                    string rfc        = Convert.ToString(item["rfc"]);

                    List <object> record = new List <object> {
                        jpp, num, nombre, neto, banco, tcta, cuentabanc, rfc
                    };

                    escribir.AddRecord(record.ToArray());
                }


                escribir.Write(ops);
                escribir.Close();
                ops.Close();

                globales.MessageBoxSuccess("Archivo .DBF generado exitosamente", "Archivo generado", globales.menuPrincipal);
            }
        }
Exemple #2
0
        private void btngenerar_Click(object sender, EventArgs e)
        {
            seleccionar s = new seleccionar();

            s.ShowDialog();
            if (!s.seleccionado)
            {
                return;
            }

            DateTime fecha1 = DateTime.Parse(fec1.Text);
            DateTime fecha2 = DateTime.Parse(fec2.Text);

            this.Cursor = Cursors.AppStarting;


            string c1 = string.Format("{0:yyyy-MM-dd}", fecha1);
            string c2 = string.Format("{0:yyyy-MM-dd}", fecha2);


            string query = "delete from datos.r_saldos_p; " +
                           $" insert into datos.r_saldos_p select rfc,(sum(entrada)) as saldo,'{fecha2.Month}' as mes,'{fecha2.Year}' as anio from datos.aportaciones where COALESCE(status, '') = 'p' and fecharegistro between '{c1}' and '{c2}' group by rfc; ";


            globales.consulta(query);

            string query2 = "SELECT emp.rfc, emp.nombre_em, emp.proyecto, sal.saldo, emp.nap, sal.mes, sal.anio FROM ( datos.empleados emp  JOIN datos.r_saldos_p sal ON(( (emp.rfc) ::TEXT = (sal.rfc) ::TEXT))) WHERE( (sal.saldo<>(0) :: NUMERIC) AND(emp.pendiente = TRUE)) ORDER BY emp.nombre_em";

            List <Dictionary <string, object> > lista = globales.consulta(query2);

            if (!s.esDbf)
            {
                object[] aux2     = new object[lista.Count];
                int      contador = 0;
                foreach (Dictionary <string, object> item in lista)
                {
                    string nombre_em = string.Empty;
                    string rfc       = string.Empty;
                    string proyecto  = string.Empty;
                    string nap       = string.Empty;
                    double saldo     = 0;

                    try
                    {
                        nombre_em = Convert.ToString(item["nombre_em"]);
                        rfc       = Convert.ToString(item["rfc"]);
                        proyecto  = Convert.ToString(item["proyecto"]);
                        nap       = Convert.ToString(item["nap"]);
                        saldo     = Convert.ToDouble(item["saldo"]);
                    }
                    catch
                    {
                    }

                    object[] tt1 = { nombre_em, rfc, proyecto, nap, saldo };
                    aux2[contador] = tt1;
                    contador++;
                }
                this.Cursor = Cursors.Default;

                string logo = globales.getImagen(globales.imagenesSispe.logoreportes);

                object[]   parametros       = { "fech1", "fech2", "tiporeporte", "mov", "logo" };
                object[]   valor            = { this.fec1.Text, this.fec2.Text, "PENDIENTES", "", logo };
                object[][] enviarParametros = new object[2][];

                enviarParametros[0] = parametros;
                enviarParametros[1] = valor;

                globales.reportes("frmreportsaldo", "rsaldos_aporta", aux2, "", false, enviarParametros);
            }
            else
            {
                SaveFileDialog dialogoGuardar = new SaveFileDialog();
                dialogoGuardar.AddExtension = true;
                dialogoGuardar.DefaultExt   = ".dbf";
                if (dialogoGuardar.ShowDialog() == DialogResult.OK)
                {
                    string ruta = dialogoGuardar.FileName;

                    Stream ops = File.Open(ruta, FileMode.OpenOrCreate, FileAccess.ReadWrite);

                    DotNetDBF.DBFWriter escribir = new DotNetDBF.DBFWriter();
                    escribir.DataMemoLoc = ruta.Replace("dbf", "dbt");

                    DotNetDBF.DBFField a1 = new DotNetDBF.DBFField("RFC", DotNetDBF.NativeDbType.Char, 20);
                    DotNetDBF.DBFField a2 = new DotNetDBF.DBFField("NOMBRE", DotNetDBF.NativeDbType.Char, 100);
                    DotNetDBF.DBFField a3 = new DotNetDBF.DBFField("PROYECTO", DotNetDBF.NativeDbType.Char, 35);
                    DotNetDBF.DBFField a4 = new DotNetDBF.DBFField("SALDO", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField a5 = new DotNetDBF.DBFField("NAP", DotNetDBF.NativeDbType.Numeric, 10, 2);


                    DotNetDBF.DBFField[] campos = new DotNetDBF.DBFField[] { a1, a2, a3, a4, a5 };
                    escribir.Fields = campos;

                    foreach (Dictionary <string, object> item in lista)
                    {
                        List <object> record = new List <object> {
                            item["rfc"],
                            item["nombre_em"],
                            item["proyecto"],
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["saldo"])))?0:Convert.ToDouble(item["saldo"]),
                            string.IsNullOrWhiteSpace(Convert.ToString(item["nap"]))?0:Convert.ToDouble(item["nap"])
                        };

                        escribir.AddRecord(record.ToArray());
                    }

                    escribir.Write(ops);
                    escribir.Close();
                    ops.Close();

                    globales.MessageBoxSuccess("Archivo .DBF generado exitosamente", "Archivo generado", globales.menuPrincipal);
                }
            }
            this.Cursor = Cursors.Default;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string   nombreDbf     = string.Empty;
            DateTime dFecha        = txtFecha.Value;
            string   qtipoRelacion = string.Empty;
            string   sFecha        = string.Format("{0}-{1}-{2}", dFecha.Year, dFecha.Month, dFecha.Day);

            string query = (this.esReporte) ? "select * from " : "select DISTINCT tipo_rel from ";

            if (rdQuiro.Checked)
            {
                query    += " datos.d_ecqdep ";
                nombreDbf = "PQ_";
            }
            else
            {
                query    += " datos.d_echdep ";
                nombreDbf = "PH_";
            }

            string altas = string.Empty;

            if (rdAltas.Checked)
            {
                altas = "A";
            }
            else if (rdCambios.Checked)
            {
                altas = "C";
            }
            else
            {
                altas = "B";
            }


            if (chkAval.Checked && chkNormal.Checked)
            {
                query        += string.Format(" where (tipo_mov = '{0}N' OR tipo_mov = '{0}A') and f_descuento = '{1}'", altas, sFecha);
                qtipoRelacion = "SUSCRIPTOR Y AVAL";
                nombreDbf    += string.Format("{0}N_{0}A", altas);
            }
            else if (chkAval.Checked)
            {
                query        += string.Format(" where tipo_mov = '{0}A' and f_descuento = '{1}'", altas, sFecha);
                qtipoRelacion = "AVAL";
                nombreDbf    += string.Format("{0}A", altas);
            }
            else if (chkNormal.Checked)
            {
                query        += string.Format(" where tipo_mov = '{0}N' and f_descuento = '{1}'", altas, sFecha);
                qtipoRelacion = "SUSCRIPTOR";
                nombreDbf    += string.Format("{0}N", altas);
            }
            else
            {
                MessageBox.Show("Error en selección", "Aviso!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            query += "  order by tipo_rel desc";
            string queryGlobal = query;

            if (this.esReporte)
            {
                MessageBox.Show(string.Format("Seleccionando altas del {0} de sector central", sFecha), "Seleccionando", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            List <Dictionary <string, object> > resultado = globales.consulta(query);

            if (this.esReporte)
            {
                goto seccionReporte;
            }

            List <Dictionary <string, string> > listaDiskets = new List <Dictionary <string, string> >();

            foreach (Dictionary <string, object> item in resultado)
            {
                string tipoRelacion = Convert.ToString(item["tipo_rel"]);
                if (!string.IsNullOrWhiteSpace(tipoRelacion))
                {
                    query = string.Format("select * from catalogos.disket where cuenta = '{0}'", item["tipo_rel"]);
                    List <Dictionary <string, object> > tmpDisket = globales.consulta(query);
                    if (tmpDisket.Count > 0)
                    {
                        Dictionary <string, string> diccionario = new Dictionary <string, string>();
                        diccionario.Add("cuenta", Convert.ToString(tmpDisket[0]["cuenta"]));
                        diccionario.Add("descripcion", Convert.ToString(tmpDisket[0]["descripcion"]));
                        listaDiskets.Add(diccionario);
                    }
                }
            }

            frmTiporelacion tr = new frmTiporelacion();

            tr.setLista(listaDiskets, queryGlobal, dFecha, qtipoRelacion);
            tr.ShowDialog();
            return;

seccionReporte:

            SaveFileDialog dialogoGuardar = new SaveFileDialog();

            dialogoGuardar.AddExtension = true;
            dialogoGuardar.DefaultExt   = ".dbf";
            if (dialogoGuardar.ShowDialog() == DialogResult.OK)
            {
                string ruta = dialogoGuardar.FileName;

                Stream ops = File.Open(ruta, FileMode.OpenOrCreate, FileAccess.ReadWrite);

                DotNetDBF.DBFWriter escribir = new DotNetDBF.DBFWriter();
                escribir.DataMemoLoc = ruta.Replace("dbf", "dbt");

                DotNetDBF.DBFField c1 = new DotNetDBF.DBFField("Inrfc", DotNetDBF.NativeDbType.Char, 100);
                DotNetDBF.DBFField c2 = new DotNetDBF.DBFField("Innom", DotNetDBF.NativeDbType.Char, 100);
                DotNetDBF.DBFField c3 = new DotNetDBF.DBFField("Inpro", DotNetDBF.NativeDbType.Char, 100);
                DotNetDBF.DBFField c4 = new DotNetDBF.DBFField("Innomina", DotNetDBF.NativeDbType.Char, 100);
                DotNetDBF.DBFField c5 = new DotNetDBF.DBFField("Inimp", DotNetDBF.NativeDbType.Numeric, 10, 2);
                DotNetDBF.DBFField c6 = new DotNetDBF.DBFField("Infolio", DotNetDBF.NativeDbType.Numeric, 10, 2);
                DotNetDBF.DBFField c7 = new DotNetDBF.DBFField("Inpag", DotNetDBF.NativeDbType.Numeric, 10, 2);
                DotNetDBF.DBFField c8 = new DotNetDBF.DBFField("Intpag", DotNetDBF.NativeDbType.Numeric, 10, 2);

                DotNetDBF.DBFField[] campos = new DotNetDBF.DBFField[] { c1, c2, c3, c4, c5, c6, c7, c8 };
                escribir.Fields = campos;

                foreach (Dictionary <string, object> item in resultado)
                {
                    List <object> record = new List <object> {
                        item["rfc"],
                        item["nombre_em"],
                        item["proyecto"],
                        item["tipo_rel"],
                        item["imp_unit"],
                        item["folio"],
                        item["numdesc"],
                        item["totdesc"]
                    };

                    escribir.AddRecord(record.ToArray());
                }

                escribir.Write(ops);
                escribir.Close();
                ops.Close();

                MessageBox.Show("Archivo .DBF generado exitosamente", "Archivo generado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MessageBox.Show(string.Format("El archivo generado ( {0}.DBF ) tiene {1} registros.", nombreDbf, resultado.Count), "Archivo generado", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #4
0
        private void generarListadoDeduccion()
        {
            DialogResult dialogo = globales.MessageBoxQuestion("¿Deseas generar el listado y el archivo de deducción?", "Aviso", globales.menuPrincipal);

            if (dialogo == DialogResult.Yes)
            {
                string mes = this.cmbmes.SelectedIndex < 5 ? $"0{(this.cmbmes.SelectedIndex + 1) * 2}" : Convert.ToString((this.cmbmes.SelectedIndex + 1) * 2);

                string especial = this.chknomina.Checked ? $" nno.tipo_nomina ='{this.tipo_nomina}' ": " nno.tipo_nomina='N' ";

                globales.MessageBoxInformation("Se va a generar el archivo de descuento", "Archivo de descuento", globales.menuPrincipal);
                string query = "select mma.nombre,mma.rfc,concat(mma.jpp,mma.num) as proyecto,nno.clave as cvedesc ,nno.pagon as numdesc ,nno.pagot as totdesc ," +
                               " nno.monto as importe ,nno.tipopago as tipodesc ,nno.folio , nno.fechaini as desde ,nno.fechafin as hasta " +
                               " from nominas_catalogos.maestro mma inner join nominas_catalogos.nominew nno on mma.jpp = nno.jpp and mma.num = nno.numjpp  " +
                               $" and nno.clave in (205,206) where mma.superviven = 'S' and {especial} ";

                List <Dictionary <string, object> > resultado = globales.consulta(query);
                SaveFileDialog dialogoGuardar = new SaveFileDialog();
                dialogoGuardar.AddExtension = true;
                dialogoGuardar.DefaultExt   = ".dbf";
                dialogoGuardar.FileName     = $"D980{mes}{txtfecha.Text.Substring(2)}";



                if (dialogoGuardar.ShowDialog() == DialogResult.OK)
                {
                    string ruta = dialogoGuardar.FileName;

                    Stream ops = File.Open(ruta, FileMode.OpenOrCreate, FileAccess.ReadWrite);

                    DotNetDBF.DBFWriter escribir = new DotNetDBF.DBFWriter();
                    escribir.DataMemoLoc = ruta.Replace("dbf", "dbt");

                    DotNetDBF.DBFField c1  = new DotNetDBF.DBFField("NOMBRE", DotNetDBF.NativeDbType.Char, 40);
                    DotNetDBF.DBFField c2  = new DotNetDBF.DBFField("RFC", DotNetDBF.NativeDbType.Char, 13);
                    DotNetDBF.DBFField c3  = new DotNetDBF.DBFField("PROYECTO", DotNetDBF.NativeDbType.Char, 11);
                    DotNetDBF.DBFField c4  = new DotNetDBF.DBFField("CVEDESC", DotNetDBF.NativeDbType.Numeric, 3);
                    DotNetDBF.DBFField c6  = new DotNetDBF.DBFField("FOLIO", DotNetDBF.NativeDbType.Numeric, 6);
                    DotNetDBF.DBFField c7  = new DotNetDBF.DBFField("NUMDESC", DotNetDBF.NativeDbType.Numeric, 3);
                    DotNetDBF.DBFField c8  = new DotNetDBF.DBFField("TOTDESC", DotNetDBF.NativeDbType.Numeric, 3);
                    DotNetDBF.DBFField c9  = new DotNetDBF.DBFField("IMPORTE", DotNetDBF.NativeDbType.Numeric, 9, 2);
                    DotNetDBF.DBFField c10 = new DotNetDBF.DBFField("TIPODESC", DotNetDBF.NativeDbType.Char, 1);
                    DotNetDBF.DBFField c11 = new DotNetDBF.DBFField("DESDE", DotNetDBF.NativeDbType.Char, 20);
                    DotNetDBF.DBFField c12 = new DotNetDBF.DBFField("HASTA", DotNetDBF.NativeDbType.Char, 20);

                    DotNetDBF.DBFField[] campos = new DotNetDBF.DBFField[] { c1, c2, c3, c4, c6, c7, c8, c9, c10, c11, c12 };
                    escribir.Fields = campos;



                    foreach (Dictionary <string, object> item in resultado)
                    {
                        string nombre   = Convert.ToString(item["nombre"]);
                        string rfc      = Convert.ToString(item["rfc"]);
                        string proyecto = Convert.ToString(item["proyecto"]);
                        string cvedesc  = Convert.ToString(item["cvedesc"]);
                        int    folio    = globales.convertInt(Convert.ToString(item["folio"]));
                        int    numdesc  = globales.convertInt(Convert.ToString(item["numdesc"]));
                        int    totdesc  = globales.convertInt(Convert.ToString(item["totdesc"]));
                        double importe  = globales.convertDouble(Convert.ToString(item["importe"]));
                        string tipodesc = Convert.ToString(item["tipodesc"]);
                        string desde    = Convert.ToString(item["desde"]);
                        string hasta    = Convert.ToString(item["hasta"]);

                        List <object> record = new List <object> {
                            nombre, rfc, proyecto, cvedesc, folio, numdesc, totdesc, importe, tipodesc, desde, hasta
                        };

                        escribir.AddRecord(record.ToArray());
                    }

                    escribir.Write(ops);
                    escribir.Close();
                    ops.Close();

                    globales.MessageBoxSuccess("Archivo .DBF generado exitosamente", "Archivo generado", globales.menuPrincipal);
                }

                globales.MessageBoxInformation("Se va a generar el listado de deducciones", "Listado deducciones", globales.menuPrincipal);

                query = "select mma.nombre,mma.rfc,mma.jpp,mma.num,concat(mma.jpp,mma.num) as proyecto,nno.clave as cvedesc ,nno.pagon as numdesc ,nno.pagot as totdesc ," +
                        " nno.monto as importe ,nno.tipopago as tipodesc ,nno.folio , nno.fechaini as desde ,nno.fechafin as hasta, '' as descri " +
                        " from nominas_catalogos.maestro mma inner join nominas_catalogos.nominew nno on mma.jpp = nno.jpp and mma.num = nno.numjpp  " +
                        $" and nno.clave > 60 and {especial} where mma.superviven = 'S' order by nno.clave,mma.jpp,mma.num";

                resultado = globales.consulta(query);

                query = "select  clave,descri from nominas_catalogos.perded order by clave";
                List <Dictionary <string, object> > perded = globales.consulta(query);

                resultado.ForEach(o =>
                {
                    o["descri"] = perded.Where(p => Convert.ToString(o["cvedesc"]) == Convert.ToString(p["clave"])).First()["descri"];
                    //  o["descri"] += " (RETROACTIVO)";
                });

                object[] objetos  = new object[resultado.Count];
                int      contador = 0;
                foreach (Dictionary <string, object> item in resultado)
                {
                    string nombre         = Convert.ToString(item["nombre"]);
                    string rfc            = Convert.ToString(item["rfc"]);
                    string jpp            = Convert.ToString(item["jpp"]);
                    string num            = Convert.ToString(item["num"]);
                    string proyecto       = Convert.ToString(item["proyecto"]);
                    string cvedesc        = Convert.ToString(item["cvedesc"]);
                    string numdesc        = Convert.ToString(item["numdesc"]);
                    string totdesc        = Convert.ToString(item["totdesc"]);
                    string importe        = Convert.ToString(item["importe"]);
                    string tipodesc       = Convert.ToString(item["tipodesc"]);
                    string folio          = Convert.ToString(item["folio"]);
                    string desde          = Convert.ToString(item["desde"]);
                    string hasta          = Convert.ToString(item["hasta"]);
                    string cvedescripcion = Convert.ToString(item["descri"]);

                    object[] tt1 = { nombre,  rfc,     jpp,      num,   proyecto, cvedesc, numdesc,
                                     totdesc, importe, tipodesc, folio, desde,    hasta,   cvedescripcion };
                    objetos[contador] = tt1;
                    contador++;
                }

                object[][] parametros = new object[2][];
                object[]   header     = { "fecha" };
                object[]   body       = { "" };


                parametros[0] = header;
                parametros[1] = body;

                globales.reportes("nominas_listadoDeducciones", "listadodeduccion", objetos, "", false, parametros);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            object[] obj  = new object[lista.Count];
            string   rfc  = "";
            string   edad = "";
            int      x;
            DateTime anio = DateTime.Now;
            int      y    = Convert.ToInt32(anio.Year);

            int    resultado;
            int    contador = 0;
            double sy       = 0;
            string sexo     = "";

            foreach (Dictionary <string, object> item in this.lista)
            {
                rfc = Convert.ToString(item["rfc"]);

                string querysexo = $"select sexo as setso from datos.empleados where rfc='{rfc}'";
                List <Dictionary <string, object> > resulsexo = globales.consulta(querysexo);
                sexo = resulsexo.Count != 0 ? Convert.ToString(resulsexo[0]["setso"]) : "no hay";

                string value;
                value = rfc;
                int    año;
                int    starindex = 4;
                int    length    = 2;
                string substring = value.Substring(starindex, length);
                edad      = "19" + substring;
                x         = Convert.ToInt32(edad);
                resultado = y - x;
                edad      = Convert.ToString(resultado);

                item.Add("edad", Convert.ToString(edad));
                double folio = Convert.ToDouble(item["folio"]);
                item.Add("sexo", Convert.ToString(sexo));



                string nombre = Convert.ToString(item["nombre_em"]);
                //if (nombre.Contains("fallecido") || nombre.Contains("FALLECIDO") || nombre.Contains("Fallecido") || nombre.Contains("FALLECIMIENTO") || nombre.Contains("fallecimiento") || nombre.Contains("fallecio") || nombre.Contains("FALLECIO"))
                //{

                //    continue;

                //}
                string f_emischeq      = string.IsNullOrWhiteSpace(Convert.ToString(item["f_emischeq"])) ? "" : string.Format("{0:d}", item["f_emischeq"]);
                string ubicPagare      = Convert.ToString(item["ubic_pagare"]);
                string proyecto        = Convert.ToString(item["proyecto"]);
                string numdesc         = Convert.ToString(item["numdesc"]);
                string totdesc         = Convert.ToString(item["totdesc"]);
                double importe         = (string.IsNullOrWhiteSpace(Convert.ToString(item["importe"]))) ? 0 : (Convert.ToDouble(item["importe"]));
                double imp_unit        = (string.IsNullOrWhiteSpace(Convert.ToString(item["imp_unit"]))) ? 0 : (Convert.ToDouble(item["imp_unit"]));;
                double pagado          = (string.IsNullOrWhiteSpace(Convert.ToString(item["pagado"]))) ? 0 : (Convert.ToDouble(item["pagado"]));
                double saldo           = (string.IsNullOrWhiteSpace(Convert.ToString(item["saldo"]))) ? 0 : (Convert.ToDouble(item["saldo"]));
                string cta             = Convert.ToString(item["cuenta"]);
                string cta_descripcion = Convert.ToString(item["descripcion_cta"]);
                string fechaUltimo     = string.IsNullOrWhiteSpace(Convert.ToString(item["ultimop"])) ? "" : string.Format("{0:d}", item["ultimop"]);
                string resultadoFinal  = string.Empty;
                if (!string.IsNullOrWhiteSpace(f_emischeq))
                {
                    DateTime dtInicio = DateTime.Parse(f_emischeq);
                    DateTime dtFinal  = DateTime.Parse(this.fecha);


                    TimeSpan diferencia = dtFinal - dtInicio;
                    double   dias       = diferencia.TotalDays;
                    int      años       = Convert.ToInt32(dias / 365);
                    int      sobraAños  = Convert.ToInt32(dias % 365);

                    int meses    = Convert.ToInt32(sobraAños / 30);
                    int sobraMes = Convert.ToInt32(sobraAños % 30);

                    resultadoFinal = string.Format("{0}A {1}M {2}D", años, meses, sobraMes);
                }
                sy += saldo;
                object[] aux = { folio, rfc, nombre, ubicPagare, proyecto, numdesc + "/" + totdesc, importe, imp_unit, pagado, saldo, cta, cta_descripcion, edad, "", sexo };
                obj[contador] = aux;
                contador++;
            }

            object[] auxArreglo = new object[contador];
            for (int joel = 0; joel < contador; joel++)
            {
                auxArreglo[joel] = obj[joel];
            }

            obj = auxArreglo;

            string opcion1 = (opcion) ? "QUIROGRAFARIOS" : "HIPOTECARIOS";
            string fecha   = this.fecha;

            object[][] parametros = new object[2][];
            object[]   headers    = { "p1", "p2", "fecha" };
            object[]   body       = { opcion1, string.Format("{0:d}", DateTime.Parse(fecha)), string.Format("{0:d}", DateTime.Now) };
            parametros[0] = headers;
            parametros[1] = body;


            if (listBox1.SelectedIndex == 0)
            {
                globales.reportes("reportmensualseguro", "reporteSinSaldo", obj, "", false, parametros);
            }
            else if (listBox1.SelectedIndex == 1)
            {
                SaveFileDialog dialogoGuardar = new SaveFileDialog();
                dialogoGuardar.AddExtension = true;
                dialogoGuardar.DefaultExt   = ".dbf";
                if (dialogoGuardar.ShowDialog() == DialogResult.OK)
                {
                    string ruta = dialogoGuardar.FileName;

                    Stream ops = File.Open(ruta, FileMode.OpenOrCreate, FileAccess.ReadWrite);

                    DotNetDBF.DBFWriter escribir = new DotNetDBF.DBFWriter();
                    escribir.DataMemoLoc = ruta.Replace("dbf", "dbt");

                    DotNetDBF.DBFField c1  = new DotNetDBF.DBFField("FOLIO", DotNetDBF.NativeDbType.Numeric, 20, 2);
                    DotNetDBF.DBFField c2  = new DotNetDBF.DBFField("RFC", DotNetDBF.NativeDbType.Char, 100);
                    DotNetDBF.DBFField c3  = new DotNetDBF.DBFField("NOMBRE_EM", DotNetDBF.NativeDbType.Char, 100);
                    DotNetDBF.DBFField c4  = new DotNetDBF.DBFField("PROYECTO", DotNetDBF.NativeDbType.Char, 100);
                    DotNetDBF.DBFField c5  = new DotNetDBF.DBFField("IMP_UNIT", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c6  = new DotNetDBF.DBFField("F_PRIMDESC", DotNetDBF.NativeDbType.Char, 20);
                    DotNetDBF.DBFField c7  = new DotNetDBF.DBFField("IMPORTE", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c8  = new DotNetDBF.DBFField("UBIC_PAGAR", DotNetDBF.NativeDbType.Char, 20);
                    DotNetDBF.DBFField c9  = new DotNetDBF.DBFField("NUMDESC", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c10 = new DotNetDBF.DBFField("TOTDESC", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c11 = new DotNetDBF.DBFField("PAGADO", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c12 = new DotNetDBF.DBFField("FECHA", DotNetDBF.NativeDbType.Char, 20);
                    DotNetDBF.DBFField c13 = new DotNetDBF.DBFField("CTA", DotNetDBF.NativeDbType.Char, 20);
                    DotNetDBF.DBFField c14 = new DotNetDBF.DBFField("SALDO", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField C15 = new DotNetDBF.DBFField("EDAD", DotNetDBF.NativeDbType.Numeric, 10, 2);

                    DotNetDBF.DBFField[] campos = new DotNetDBF.DBFField[] { c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, C15 };
                    escribir.Fields = campos;

                    foreach (Dictionary <string, object> item in this.lista)
                    {
                        List <object> record = new List <object> {
                            Convert.ToDouble(item["folio"]),
                            Convert.ToString(item["rfc"]),
                            Convert.ToString(item["nombre_em"]),
                            Convert.ToString(item["proyecto"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["imp_unit"])))?0:Convert.ToDouble(item["imp_unit"]),
                            Convert.ToString(item["f_primdesc"]).Replace(" 12:00:00 a. m.", ""),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["importe"])))?0:Convert.ToDouble(item["importe"]),
                            Convert.ToString(item["ubic_pagare"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["numdesc"])))?0:Convert.ToDouble(item["numdesc"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["totdesc"])))?0:Convert.ToDouble(item["totdesc"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["pagado"])))?0:Convert.ToDouble(item["pagado"]),
                            Convert.ToString(item["fecha"]).Replace(" 12:00:00 a. m.", ""),
                            Convert.ToString(item["cuenta"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["saldo"])))?0:Convert.ToDouble(item["saldo"]),
                            //    Convert.ToString(item["edad"])
                        };

                        escribir.AddRecord(record.ToArray());
                    }

                    escribir.Write(ops);
                    escribir.Close();
                    ops.Close();

                    globales.MessageBoxSuccess("Archivo .DBF generado exitosamente", "Archivo generado", globales.menuPrincipal);
                }
            }

            this.Cursor = Cursors.Default;
        }
Exemple #6
0
        private void generarDiscoRecursos()
        {
            DialogResult dialogo = globales.MessageBoxQuestion("¿Deseas generar el listado y disco para recursos humanos?", "Aviso", globales.menuPrincipal);

            if (dialogo == DialogResult.No)
            {
                return;
            }



            if (string.IsNullOrWhiteSpace(txtclave.Text))
            {
                globales.MessageBoxExclamation("Favor de elegir clave de quincena", "Clave quincena", globales.menuPrincipal);
                return;
            }

            if (string.IsNullOrWhiteSpace(txtnomina.Text))
            {
                globales.MessageBoxExclamation("Favor de elegir clave de nomina", "Clave nomina", globales.menuPrincipal);
                return;
            }

            string especial = this.chknomina.Checked ? $" nno.tipo_nomina = '{this.tipo_nomina}' " : " nno.tipo_nomina='N' ";

            string query = "select mma.nombre,mma.curp,mma.rfc,mma.jpp,mma.num,concat(mma.jpp,mma.num) as proyecto,nno.clave  ,nno.pagon ,nno.cheque ,nno.pagot ," +
                           " nno.monto  ,nno.tipopago ,nno.folio , nno.fechaini ,nno.fechafin " +
                           " from nominas_catalogos.maestro mma inner join nominas_catalogos.nominew nno on mma.jpp = nno.jpp and mma.num = nno.numjpp  " +
                           $" and nno.clave in (227,226,221) and {especial} where mma.superviven = 'S'  order by mma.jpp,mma.num,nno.clave";

            List <Dictionary <string, object> > resultado = globales.consulta(query);
            string mes = this.cmbmes.SelectedIndex < 5 ? $"0{(this.cmbmes.SelectedIndex + 1) * 2}" : Convert.ToString((this.cmbmes.SelectedIndex + 1) * 2);

            SaveFileDialog dialogoGuardar = new SaveFileDialog();

            dialogoGuardar.AddExtension = true;
            dialogoGuardar.DefaultExt   = ".dbf";
            dialogoGuardar.FileName     = $"J480{mes}{txtfecha.Text.Substring(2)}";

            if (dialogoGuardar.ShowDialog() == DialogResult.OK)
            {
                string ruta = dialogoGuardar.FileName;

                Stream ops = File.Open(ruta, FileMode.OpenOrCreate, FileAccess.ReadWrite);

                DotNetDBF.DBFWriter escribir = new DotNetDBF.DBFWriter();
                escribir.DataMemoLoc = ruta.Replace("dbf", "dbt");

                DotNetDBF.DBFField c1 = new DotNetDBF.DBFField("NOMBRE", DotNetDBF.NativeDbType.Char, 40);
                DotNetDBF.DBFField c2 = new DotNetDBF.DBFField("RFC", DotNetDBF.NativeDbType.Char, 13);
                DotNetDBF.DBFField c3 = new DotNetDBF.DBFField("PROYECTO", DotNetDBF.NativeDbType.Char, 17);
                DotNetDBF.DBFField c4 = new DotNetDBF.DBFField("CVEDESC", DotNetDBF.NativeDbType.Numeric, 3);
                DotNetDBF.DBFField c5 = new DotNetDBF.DBFField("FOLIO", DotNetDBF.NativeDbType.Numeric, 6);
                DotNetDBF.DBFField c6 = new DotNetDBF.DBFField("NUMDESC", DotNetDBF.NativeDbType.Numeric, 3);
                DotNetDBF.DBFField c7 = new DotNetDBF.DBFField("TOTDESC", DotNetDBF.NativeDbType.Numeric, 3);
                DotNetDBF.DBFField c8 = new DotNetDBF.DBFField("IMPORTE", DotNetDBF.NativeDbType.Numeric, 11, 2);
                DotNetDBF.DBFField c9 = new DotNetDBF.DBFField("REGISTRO", DotNetDBF.NativeDbType.Numeric, 10);

                DotNetDBF.DBFField[] campos = new DotNetDBF.DBFField[] { c1, c2, c3, c4, c5, c6, c7, c8, c9 };
                escribir.Fields = campos;

                foreach (Dictionary <string, object> item in resultado)
                {
                    string nombre   = Convert.ToString(item["nombre"]);
                    string rfc      = Convert.ToString(item["rfc"]);
                    string jpp      = Convert.ToString(item["jpp"]);
                    string num      = Convert.ToString(item["num"]);
                    string proyecto = jpp + num;
                    int    clave    = globales.convertInt(Convert.ToString(item["clave"]));
                    int    folio    = globales.convertInt(Convert.ToString(item["folio"]));
                    int    numdesc  = globales.convertInt(Convert.ToString(item["pagon"]));
                    int    totdesc  = globales.convertInt(Convert.ToString(item["pagot"]));
                    double importe  = globales.convertDouble(Convert.ToString(item["monto"]));
                    int    registro = globales.convertInt(Convert.ToString(item["cheque"]));


                    List <object> record = new List <object> {
                        nombre, rfc, proyecto, clave, folio, numdesc, totdesc,
                        importe, registro
                    };

                    escribir.AddRecord(record.ToArray());
                }


                escribir.Write(ops);
                escribir.Close();
                ops.Close();

                globales.MessageBoxSuccess("Archivo .DBF generado exitosamente", "Archivo generado", globales.menuPrincipal);
            }



            //**********************************

            globales.MessageBoxInformation("Se generara el archivo base", "Archivo base", globales.menuPrincipal);

            dialogoGuardar = new SaveFileDialog();
            dialogoGuardar.AddExtension = true;
            dialogoGuardar.DefaultExt   = ".dbf";
            dialogoGuardar.FileName     = $"BASE{mes}{txtfecha.Text.Substring(2)}";

            if (dialogoGuardar.ShowDialog() == DialogResult.OK)
            {
                string ruta = dialogoGuardar.FileName;

                especial = this.chknomina.Checked ? $" tipo_nomina = '{this.tipo_nomina}' " : " tipo_nomina='N' ";


                string cadena = "Provider=VFPOLEDB.1; Data Source= {0}\\; Extended Properties =dBase IV; ";
                string pasa   = string.Format(cadena, ruta.Substring(0, ruta.LastIndexOf("\\")));

                using (OleDbConnection connection = new OleDbConnection(pasa))
                    using (OleDbCommand command = connection.CreateCommand())
                    {
                        connection.Open();

                        string queryClaves = $"select clave from nominas_catalogos.nominew where {especial} group by clave order by clave";
                        List <Dictionary <string, object> > claves = globales.consulta(queryClaves);


                        query = $"create temp table t1 as select JPP,numjpp from nominas_catalogos.nominew where  tipopago = 'N' and {especial} group by jpp,numjpp; " +
                                " create temp table t2 as  select mma.rfc,mma.nombre,mma.jpp,mma.num,mma.sexo,mma.curp from nominas_catalogos.maestro mma inner join t1 on mma.jpp = t1.jpp and mma.num = t1.numjpp  " +
                                " where  mma.jpp <> 'PEA' AND mma.superviven = 'S' ORDER BY mma.jpp,mma.num; ";


                        string selectPart = string.Empty;
                        string leftJoin   = string.Empty;


                        foreach (Dictionary <string, object> item in claves)
                        {
                            int    clave = globales.convertInt(Convert.ToString(item["clave"]));
                            string queEs = clave > 68 ? "D" : "P";
                            selectPart += $", COALESCE(sum(nn{clave}.monto),0) as {queEs}{clave} ";
                            leftJoin   += $" left join nominas_catalogos.nominew nn{clave}  " +
                                          $" on nn{clave}.jpp = t2.jpp and nn{clave}.numjpp = t2.num and nn{clave}.clave = {clave} ";
                        }

                        query    += $" select t2.* {selectPart} from t2 {leftJoin} group by t2.rfc,t2.nombre,t2.jpp,t2.num,t2.sexo,t2.curp order by t2.jpp,t2.num ";
                        resultado = globales.consulta(query);

                        string tabla = @"CREATE TABLE {0} (CQNACVE   N( 6, 0), CQNAIND   N( 2, 0), PBPNUP    N( 6, 0), PBPNUE    N( 6, 0), SIRFC     C(13, 0)," +
                                       "SINOM     C(45, 0), SIDEP     C(20, 0), SICATG    C( 7, 0), SISX      C( 1, 0), TIP_EMP   N( 2, 0)," +
                                       " NUMFOLIO  N( 6, 0), UBICA     C( 1, 0), CVE       N( 3, 0), TIPOPAGO  N( 1, 0), PBPFIG    D( 8, 0)," +
                                       " PBPIPTO   D( 8, 0), PBPFNOMB  D( 8, 0), PBPSTATUS N( 2, 0), LICDES    D( 8, 0), LICHAS    D( 8, 0)," +
                                       "CMOTCVE   N( 3, 0), PBPHIJOS  N( 1, 0), GUADES    D( 8, 0), GUAHAS    D( 8, 0), CURP      C(21, 0)," +
                                       "AREAADS   C(70, 0), NOMBANCO  C(20, 0), NUMCUENTA C(12, 0), CLAVE_INTE C(20, 0), CESTNIV   N( 2, 0)," +
                                       "CESTGDO   N( 1, 0), QNIOS     N( 1, 0), PBPIMSS   C(11, 0), BGIMSS    N(12, 2), CUOPIMSS  N(13, 2)," +
                                       "CUOPRCV   N(13, 2), INCDES    D( 8, 0), INCHAS    D( 8, 0), CUOPINF   N(13, 2), CUOPFPEN  N(13, 2)," +
                                       "BGISPT    N(12, 2), PROFESION N( 4, 0), STATPAGO  C(180, 0), AGUIFDES  D( 8, 0), AGUIFHAS  D( 8, 0)," +
                                       "DAFDES    D( 8, 0), DAFHAS    D( 8, 0),{1})";

                        string PercepcionesDeducciones = "";
                        foreach (Dictionary <string, object> item in claves)
                        {
                            int clave = globales.convertInt(Convert.ToString(item["clave"]));
                            PercepcionesDeducciones += (clave < 69)?$"P{clave} N( 13, 2 )," :$"D{clave} N( 13, 2 ),";
                        }
                        PercepcionesDeducciones = PercepcionesDeducciones.Substring(0, PercepcionesDeducciones.Length - 1);

                        string nombre = ruta.Substring(ruta.LastIndexOf("\\") + 1);
                        nombre = nombre.Split('.')[0];
                        tabla  = string.Format(tabla, nombre, PercepcionesDeducciones);
                        command.CommandText = tabla;
                        command.ExecuteNonQuery();



                        foreach (Dictionary <string, object> item in resultado)
                        {
                            int    CQNACVE = Convert.ToInt32(txtclave.Text);
                            int    CQNAIND = Convert.ToInt32(txtnomina.Text);
                            int    PBPNUP  = 0;
                            int    PBPNUE  = 0;
                            string SIRFC   = Convert.ToString(item["rfc"]);

                            string SINOM   = Convert.ToString(item["nombre"]);
                            string SIDEP   = Convert.ToString(item["jpp"]) + Convert.ToString(item["num"]);
                            string SICATG  = "";
                            string SISX    = Convert.ToString(item["sexo"]);
                            int    TIP_EMP = 0;

                            string jpp = Convert.ToString(item["jpp"]);
                            if (jpp == "JUB")
                            {
                                TIP_EMP = 13;
                            }
                            else if (jpp == "PTA")
                            {
                                TIP_EMP = 14;
                            }
                            else if (jpp == "PDO")
                            {
                                TIP_EMP = 15;
                            }
                            else
                            {
                                TIP_EMP = 0;
                            }

                            int    NUMFOLIO = 0;
                            string UBICA    = "3";
                            int    CVE      = 470;
                            int    TIPOPAGO = cmb2.SelectedIndex;
                            string PBPFIG   = "";

                            string PBPIPTO   = string.Empty;
                            string PBPFNOMB  = string.Empty;
                            int    PBPSTATUS = 11;
                            string LICDES    = string.Empty;
                            string LICHAS    = string.Empty;

                            int    CMOTCVE  = 0;
                            int    PBPHIJOS = 0;
                            string GUADES   = string.Empty;
                            string GUAHAS   = string.Empty;
                            string CURP     = Convert.ToString(item["curp"]);

                            string AREAADS    = "";
                            string NOMBANCO   = "";
                            string NUMCUENTA  = "";
                            string CLAVE_INTE = "";
                            int    CESTNIV    = 0;

                            int    CESTGDO  = 0;
                            int    QNIOS    = 0;
                            string PBPIMSS  = "";
                            double BGIMSS   = 0;
                            double CUOPIMSS = 0;

                            double CUOPRCV  = 0;
                            string INCDES   = string.Empty;
                            string INCHAS   = string.Empty;
                            double CUOPINF  = 0;
                            double CUOPFPEN = 0;

                            double BGISPT    = 0;
                            int    PROFESION = 0;
                            string STATPAGO  = "";
                            string AGUIFDES  = string.Empty;
                            string AGUIFHAS  = string.Empty;

                            string DAFDES = string.Empty;
                            string DAFHAS = string.Empty;

                            string sentencia = "INSERT INTO {0}({1},{3},{5},{7},{9},{11},{13},{15},{17},{19} {21}) VALUES({2},{4},{6},{8},{10},{12},{14},{16},{18},{20} {22})";

                            string part1  = "CQNACVE, CQNAIND, PBPNUP, PBPNUE, SIRFC";
                            string part11 = $"{CQNACVE},{ CQNAIND},{ PBPNUP},{ PBPNUE},'{SIRFC}'";

                            string part2  = "SINOM,SIDEP,SICATG,SISX,TIP_EMP";
                            string part22 = $"'{SINOM}','{SIDEP}','{SICATG}','{SISX}',{TIP_EMP}";

                            string part3  = "NUMFOLIO,UBICA,CVE,TIPOPAGO, PBPFIG";
                            string part33 = $"{NUMFOLIO},'{UBICA}',{CVE},{TIPOPAGO},CTOD('{PBPFIG}')";

                            string part4  = "PBPIPTO,PBPFNOMB,PBPSTATUS,LICDES,LICHAS";
                            string part44 = $"CTOD('{PBPIPTO}'),CTOD('{PBPFNOMB}'),{PBPSTATUS},CTOD('{LICDES}'),CTOD('{LICHAS}')";

                            string part5  = "CMOTCVE,PBPHIJOS,GUADES,GUAHAS,CURP";
                            string part55 = $"{CMOTCVE},{PBPHIJOS},CTOD('{GUADES}'),CTOD('{GUAHAS}'),'{CURP}'";

                            string part6  = "AREAADS,NOMBANCO,NUMCUENTA,CLAVE_INTE,CESTNIV";
                            string part66 = $"'{AREAADS}','{NOMBANCO}','{NUMCUENTA}','{CLAVE_INTE}',{CESTNIV}";

                            string part7  = "CESTGDO,QNIOS,PBPIMSS,BGIMSS,CUOPIMSS";
                            string part77 = $"{CESTGDO},{QNIOS},'{PBPIMSS}',{BGIMSS},{CUOPIMSS}";

                            string part8  = "CUOPRCV,INCDES,INCHAS,CUOPINF,CUOPFPEN";
                            string part88 = $"{CUOPRCV},CTOD('{INCDES}'),CTOD('{INCHAS}'),{CUOPINF},{CUOPFPEN}";

                            string part9  = "BGISPT,PROFESION,STATPAGO,AGUIFDES,AGUIFHAS";
                            string part99 = $"{BGISPT},{PROFESION},'{STATPAGO}',CTOD('{AGUIFDES}'),CTOD('{AGUIFHAS}')";

                            string part10   = "DAFDES, DAFHAS";
                            string part1010 = $"CTOD('{DAFDES}'),CTOD('{DAFDES}')";

                            string columna      = "";
                            string valorColumna = "";
                            foreach (Dictionary <string, object> clav in claves)
                            {
                                int    clave  = globales.convertInt(Convert.ToString(clav["clave"]));
                                string costr  = clave > 68 ? "D" : "P";
                                string llave  = $"{costr}{clave}";
                                string llave2 = $"{costr.ToLower()}{clave}";
                                columna      += $",{llave}";
                                valorColumna += $" ,{item[llave2]} ";
                            }



                            sentencia = string.Format(sentencia, nombre, part1, part11, part2, part22, part3, part33, part4, part44, part5, part55,
                                                      part6, part66, part7, part77, part8, part88, part9, part99, part10, part1010, columna, valorColumna);
                            command.CommandText = sentencia;
                            command.ExecuteNonQuery();
                        }

                        connection.Close();
                    }

                globales.MessageBoxSuccess("Archivo .DBF generado exitosamente", "Archivo generado", globales.menuPrincipal);
            }
        }
Exemple #7
0
        private void reporteEstados()
        {
            if (rd1.Checked)
            {
                string tipoPrestamo = this.tipoPrestamo ? "QUIROGRAFARIOS" : "HIPOTECARIOS";
                string f1           = string.Format("{0}/{1}/{2}", r3f1.Split('-')[2], r3f1.Split('-')[1], r3f1.Split('-')[0]);
                string f2           = string.Format("{0}/{1}/{2}", r3f2.Split('-')[2], r3f2.Split('-')[1], r3f2.Split('-')[0]);
                string fechaActual  = string.Format("{0}/{1}/{2}", DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year);

                object[][] parametros = new object[2][];
                object[]   headers    = { "tipoPrestamo", "R3F2", "R3F1", "fechaActual", "total" };
                object[]   body       = { tipoPrestamo, f2, f1, fechaActual, this.arreglo.Length.ToString() };

                parametros[0] = headers;
                parametros[1] = body;

                globales.reportes("reporteSinPagos", "p_quirog", this.arreglo, "", false, parametros);
            }
            else
            {
                SaveFileDialog dialogoGuardar = new SaveFileDialog();
                dialogoGuardar.AddExtension = true;
                dialogoGuardar.DefaultExt   = ".dbf";
                if (dialogoGuardar.ShowDialog() == DialogResult.OK)
                {
                    string ruta = dialogoGuardar.FileName;

                    Stream ops = File.Open(ruta, FileMode.OpenOrCreate, FileAccess.ReadWrite);

                    DotNetDBF.DBFWriter escribir = new DotNetDBF.DBFWriter();
                    escribir.DataMemoLoc = ruta.Replace("dbf", "dbt");

                    DotNetDBF.DBFField c1  = new DotNetDBF.DBFField("FOLIO", DotNetDBF.NativeDbType.Numeric, 20, 2);
                    DotNetDBF.DBFField c2  = new DotNetDBF.DBFField("RFC", DotNetDBF.NativeDbType.Char, 100);
                    DotNetDBF.DBFField c3  = new DotNetDBF.DBFField("NOMBRE_EM", DotNetDBF.NativeDbType.Char, 100);
                    DotNetDBF.DBFField c4  = new DotNetDBF.DBFField("PROYECTO", DotNetDBF.NativeDbType.Char, 100);
                    DotNetDBF.DBFField c5  = new DotNetDBF.DBFField("IMPORTE", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c6  = new DotNetDBF.DBFField("UBIC_PAGAR", DotNetDBF.NativeDbType.Char, 10);
                    DotNetDBF.DBFField c7  = new DotNetDBF.DBFField("NUMDESC", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c8  = new DotNetDBF.DBFField("TOTDESC", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c9  = new DotNetDBF.DBFField("PAGADO", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c10 = new DotNetDBF.DBFField("ULTIMOP", DotNetDBF.NativeDbType.Char, 20);
                    DotNetDBF.DBFField c11 = new DotNetDBF.DBFField("TIPO_MOV", DotNetDBF.NativeDbType.Char, 10);
                    DotNetDBF.DBFField c12 = new DotNetDBF.DBFField("F_DESCUENT", DotNetDBF.NativeDbType.Char, 20);

                    DotNetDBF.DBFField[] campos = new DotNetDBF.DBFField[] { c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12 };
                    escribir.Fields = campos;

                    foreach (Dictionary <string, object> item in resultado)
                    {
                        List <object> record = new List <object> {
                            Convert.ToDouble(item["folio"]),
                            Convert.ToString(item["rfc"]),
                            Convert.ToString(item["nombre_em"]),
                            Convert.ToString(item["proyecto"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["importe"])))?0:Convert.ToDouble(item["importe"]),
                            Convert.ToString(item["ubic_pagare"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["numdesc"])))?0:Convert.ToDouble(item["numdesc"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["totdesc"])))?0:Convert.ToDouble(item["totdesc"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["pagado"])))?0:Convert.ToDouble(item["pagado"]),
                            Convert.ToString(item["ultimop"]),
                            Convert.ToString(item["tipo_mov"]),
                            Convert.ToString(item["f_descuento"]).Replace(" 12:00:00 a. m.", "")
                        };

                        escribir.AddRecord(record.ToArray());
                    }

                    escribir.Write(ops);
                    escribir.Close();
                    ops.Close();

                    MessageBox.Show("Archivo .DBF generado exitosamente", "Archivo generado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string   nombreDbf     = string.Empty;
            DateTime dFecha        = txtFecha.Value;
            string   qtipoRelacion = string.Empty;
            string   sFecha        = string.Format("{0}-{1}-{2}", dFecha.Year, dFecha.Month, dFecha.Day);

            string query = (this.esReporte) ? "select * from datos.solicitud_dependencias where t_prestamo = " : "select DISTINCT tipo_rel from datos.solicitud_dependencias where t_prestamo = ";

            if (rdQuiro.Checked)
            {
                query    += " 'Q' ";
                nombreDbf = "PQ_";
            }
            else
            {
                query    += " 'H' ";
                nombreDbf = "PH_";
            }

            string altas = string.Empty;

            if (rdAltas.Checked)
            {
                altas = "A";
            }
            else if (rdCambios.Checked)
            {
                altas = "C";
            }
            else
            {
                altas = "B";
            }


            if (chkAval.Checked && chkNormal.Checked)
            {
                query        += string.Format(" and (tipo_mov = '{0}N' OR tipo_mov = '{0}A') and f_descuento = '{1}'", altas, sFecha);
                qtipoRelacion = "SUSCRIPTOR Y AVAL";
                nombreDbf    += string.Format("{0}N_{0}A", altas);
            }
            else if (chkAval.Checked)
            {
                query        += string.Format(" and tipo_mov = '{0}A' and f_descuento = '{1}'", altas, sFecha);
                qtipoRelacion = "AVAL";
                nombreDbf    += string.Format("{0}A", altas);
            }
            else if (chkNormal.Checked)
            {
                query        += string.Format(" and tipo_mov = '{0}N' and f_descuento = '{1}'", altas, sFecha);
                qtipoRelacion = "SUSCRIPTOR";
                nombreDbf    += string.Format("{0}N", altas);
            }
            else
            {
                globales.MessageBoxExclamation("Error en selección", "Aviso!!", this);
                return;
            }
            query += "  order by tipo_rel asc";
            string queryGlobal = query;

            if (this.esReporte)
            {
                globales.MessageBoxInformation(string.Format("Seleccionando altas del {0} de sector central", sFecha), "Seleccionando", this);
            }
            List <Dictionary <string, object> > resultado = globales.consulta(query);

            if (globales.esReporte)
            {
                goto seccionReporte;
            }

            List <Dictionary <string, string> > listaDiskets = new List <Dictionary <string, string> >();

            foreach (Dictionary <string, object> item in resultado)
            {
                string tipoRelacion = Convert.ToString(item["tipo_rel"]);
                if (!string.IsNullOrWhiteSpace(tipoRelacion))
                {
                    query = string.Format("select * from catalogos.disket where cuenta = '{0}'", item["tipo_rel"]);
                    List <Dictionary <string, object> > tmpDisket = globales.consulta(query);
                    if (tmpDisket.Count > 0)
                    {
                        Dictionary <string, string> diccionario = new Dictionary <string, string>();
                        diccionario.Add("cuenta", Convert.ToString(tmpDisket[0]["cuenta"]));
                        diccionario.Add("descripcion", Convert.ToString(tmpDisket[0]["descripcion"]));
                        listaDiskets.Add(diccionario);
                    }
                }
            }

            frmTiporelacion tr = new frmTiporelacion();



            tr.setLista(listaDiskets, queryGlobal, dFecha, qtipoRelacion, altas, rdQuiro.Checked);
            globales.showModal(tr);
            return;

seccionReporte:

            query = "select * from catalogos.disket where status = 'C'";
            List <Dictionary <string, object> > disketTmp = globales.consulta(query);

            List <Dictionary <string, object> > auxtmp1 = new List <Dictionary <string, object> >();

            foreach (Dictionary <string, object> item in resultado)
            {
                foreach (Dictionary <string, object> item2 in disketTmp)
                {
                    if (Convert.ToString(item["tipo_rel"]) == Convert.ToString(item2["cuenta"]))
                    {
                        auxtmp1.Add(item);
                    }
                }
            }
            resultado = auxtmp1;
            auxtmp1   = null;
            SaveFileDialog dialogoGuardar = new SaveFileDialog();

            dialogoGuardar.AddExtension = true;
            dialogoGuardar.DefaultExt   = ".dbf";



            if (dialogoGuardar.ShowDialog() == DialogResult.OK)
            {
                string ruta = dialogoGuardar.FileName;

                Stream ops = File.Open(ruta, FileMode.OpenOrCreate, FileAccess.ReadWrite);

                DotNetDBF.DBFWriter escribir = new DotNetDBF.DBFWriter();
                escribir.DataMemoLoc = ruta.Replace("dbf", "dbt");

                DotNetDBF.DBFField c1 = new DotNetDBF.DBFField("Inrfc", DotNetDBF.NativeDbType.Char, 13);
                DotNetDBF.DBFField c2 = new DotNetDBF.DBFField("Innom", DotNetDBF.NativeDbType.Char, 30);
                DotNetDBF.DBFField c3 = new DotNetDBF.DBFField("Inpro", DotNetDBF.NativeDbType.Char, 11);
                DotNetDBF.DBFField c4 = new DotNetDBF.DBFField("Innomina", DotNetDBF.NativeDbType.Char, 7);
                DotNetDBF.DBFField c5 = new DotNetDBF.DBFField("Inimp", DotNetDBF.NativeDbType.Numeric, 8, 2);
                DotNetDBF.DBFField c6 = new DotNetDBF.DBFField("Infolio", DotNetDBF.NativeDbType.Numeric, 6, 0);
                DotNetDBF.DBFField c7 = new DotNetDBF.DBFField("Inpag", DotNetDBF.NativeDbType.Numeric, 3, 0);
                DotNetDBF.DBFField c8 = new DotNetDBF.DBFField("Intpag", DotNetDBF.NativeDbType.Numeric, 3, 0);
                DotNetDBF.DBFField c9 = new DotNetDBF.DBFField("Indact", DotNetDBF.NativeDbType.Numeric, 1, 0);

                DotNetDBF.DBFField[] campos = new DotNetDBF.DBFField[] { c1, c2, c3, c4, c5, c6, c7, c8, c9 };
                escribir.Fields = campos;

                foreach (Dictionary <string, object> item in resultado)
                {
                    string rfcAux = Convert.ToString(item["rfc"]).Trim();

                    if (rfcAux.Length <= 10)
                    {
                        query = $"select rfc from datos.empleados where rfc like '%{rfcAux}%'";
                        List <Dictionary <string, object> > resulAux = globales.consulta(query);
                        if (resulAux.Count != 0)
                        {
                            item["rfc"] = resulAux[0]["rfc"];
                        }
                    }

                    List <object> record = new List <object> {
                        item["rfc"],
                        item["nombre_em"],
                        item["proyecto"],
                        item["tipo_rel"],
                        item["imp_unit"],
                        item["folio"],
                        item["numdesc"],
                        item["totdesc"],
                        0
                    };

                    escribir.AddRecord(record.ToArray());
                }

                escribir.Write(ops);
                escribir.Close();
                ops.Close();

                globales.MessageBoxSuccess("Archivo .DBF generado exitosamente", "Archivo generado", this);
                globales.MessageBoxInformation(string.Format("El archivo generado ( {0}.DBF ) tiene {1} registros.", nombreDbf, resultado.Count), "Archivo generado", this);
            }
        }
Exemple #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            object[] obj = new object[lista.Count];

            int    contador = 0;
            double sy       = 0;

            foreach (Dictionary <string, object> item in this.lista)
            {
                double folio = Convert.ToDouble(item["folio"]);


                string rfc             = Convert.ToString(item["rfc"]);
                string nombre          = Convert.ToString(item["nombre_em"]);
                string f_emischeq      = string.IsNullOrWhiteSpace(Convert.ToString(item["f_emischeq"]))?"": string.Format("{0:d}", item["f_emischeq"]);
                string ubicPagare      = Convert.ToString(item["ubic_pagare"]);
                string proyecto        = Convert.ToString(item["proyecto"]);
                string numdesc         = Convert.ToString(item["numdesc"]);
                string totdesc         = Convert.ToString(item["totdesc"]);
                double importe         = (string.IsNullOrWhiteSpace(Convert.ToString(item["importe"]))) ? 0 : (Convert.ToDouble(item["importe"]));
                double imp_unit        = (string.IsNullOrWhiteSpace(Convert.ToString(item["imp_unit"]))) ? 0 : (Convert.ToDouble(item["imp_unit"]));;
                double pagado          = (string.IsNullOrWhiteSpace(Convert.ToString(item["pagado"]))) ? 0 : (Convert.ToDouble(item["pagado"]));
                double saldo           = (string.IsNullOrWhiteSpace(Convert.ToString(item["saldo"]))) ? 0 : (Convert.ToDouble(item["saldo"]));
                string cta             = Convert.ToString(item["cuenta"]);
                string cta_descripcion = Convert.ToString(item["descripcion_cta"]);
                string fechaUltimo     = string.IsNullOrWhiteSpace(Convert.ToString(item["ultimop"])) ? "" : string.Format("{0:d}", item["ultimop"]);
                string resultadoFinal  = string.Empty;
                if (!string.IsNullOrWhiteSpace(f_emischeq))
                {
                    DateTime fec1 = DateTime.Parse(f_emischeq);
                    DateTime fec2 = DateTime.Parse(this.fecha);

                    string c1   = string.Format("{0}-{1}-{2}", fec1.Year, fec1.Month, fec1.Day);
                    string c2   = string.Format("{0}-{1}-{2}", fec2.Year, fec2.Month, fec2.Day);
                    double Q    = 0;
                    int    quin = 0;
                    int    concilia;


                    for (int A1 = fec1.Year; A1 <= fec2.Year; A1++)
                    {
                        for (int M1 = 1; M1 <= 12; M1++)
                        {
                            quin = (M1 * 2) - 1;
                            DateTime ftemp = new DateTime(A1, M1, 8);
                            if (ftemp >= fec1 && ftemp <= fec2)
                            {
                                Q++;
                            }

                            quin++;

                            ftemp = new DateTime(A1, M1, 23);

                            if (ftemp >= fec1 && ftemp <= fec2)
                            {
                                Q++;
                            }
                        }
                    }

                    Q = 0;
                    while (true)
                    {
                        DateTime aux1 = new DateTime(fec1.Year, fec1.Month, 8);
                        if (aux1 < fec2)
                        {
                            Q++;
                        }
                        else
                        {
                            break;
                        }

                        aux1 = new DateTime(fec1.Year, fec1.Month, 23);
                        if (aux1 < fec2)
                        {
                            Q++;
                        }
                        else
                        {
                            break;
                        }

                        fec1 = fec1.AddMonths(1);
                    }

                    int Qtotales = Convert.ToInt32(Q);
                    int AA       = Convert.ToInt32((Qtotales) / 24);
                    int QAux     = Qtotales - (AA * 24);
                    int AM       = Convert.ToInt32((QAux / 2));
                    int AQ       = QAux - (AM * 2);

                    int A  = AA;
                    int M  = AM;
                    int q1 = AQ;


                    resultadoFinal = string.Format("A:{0}-M:{1}", A, M);
                }
                sy += saldo;
                object[] aux = { folio, rfc, nombre, ubicPagare, proyecto, numdesc + "/" + totdesc, importe, imp_unit, pagado, saldo, cta, cta_descripcion, resultadoFinal };
                obj[contador] = aux;
                contador++;
            }
            string opcion1 = (opcion) ? "QUIROGRAFARIOS" : "HIPOTECARIOS";
            string fecha   = this.fecha;

            string logo = globales.getImagen(globales.imagenesSispe.logoreportes);

            object[][] parametros = new object[2][];
            object[]   headers    = { "p1", "p2", "fecha", "logo" };
            object[]   body       = { opcion1, string.Format("{0:d}", DateTime.Parse(fecha)), string.Format("{0:d}", DateTime.Now), logo };
            parametros[0] = headers;
            parametros[1] = body;


            if (listBox1.SelectedIndex == 0)
            {
                globales.reportes("reporteRsaldopSaldosPrestamo", "reporteSinSaldo", obj, "", false, parametros);
            }
            else if (listBox1.SelectedIndex == 1)
            {
                globales.reportes("reporteSaldopResumenCuenta", "reporteSinSaldo", obj, "", false, parametros);
            }
            else if (listBox1.SelectedIndex == 2)
            {
                globales.reportes("reporteRSaldoPAlfabetico", "reporteSinSaldo", obj, "", false, parametros);
            }
            else if (listBox1.SelectedIndex == 3)
            {
                globales.reportes("reporteRSaldoPAlfabeticoSinSaldordlc", "reporteSinSaldo", obj, "", false, parametros);
            }
            else if (listBox1.SelectedIndex == 4)
            {
                globales.reportes("reporteRSaldoPFolio", "reporteSinSaldo", obj, "", false, parametros);
            }
            else
            {
                SaveFileDialog dialogoGuardar = new SaveFileDialog();
                dialogoGuardar.AddExtension = true;
                dialogoGuardar.DefaultExt   = ".dbf";
                if (dialogoGuardar.ShowDialog() == DialogResult.OK)
                {
                    string ruta = dialogoGuardar.FileName;

                    Stream ops = File.Open(ruta, FileMode.OpenOrCreate, FileAccess.ReadWrite);

                    DotNetDBF.DBFWriter escribir = new DotNetDBF.DBFWriter();
                    escribir.DataMemoLoc = ruta.Replace("dbf", "dbt");

                    DotNetDBF.DBFField c1  = new DotNetDBF.DBFField("FOLIO", DotNetDBF.NativeDbType.Numeric, 20, 2);
                    DotNetDBF.DBFField c2  = new DotNetDBF.DBFField("RFC", DotNetDBF.NativeDbType.Char, 100);
                    DotNetDBF.DBFField c3  = new DotNetDBF.DBFField("NOMBRE_EM", DotNetDBF.NativeDbType.Char, 100);
                    DotNetDBF.DBFField c4  = new DotNetDBF.DBFField("PROYECTO", DotNetDBF.NativeDbType.Char, 100);
                    DotNetDBF.DBFField c5  = new DotNetDBF.DBFField("IMP_UNIT", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c6  = new DotNetDBF.DBFField("F_PRIMDESC", DotNetDBF.NativeDbType.Char, 20);
                    DotNetDBF.DBFField c7  = new DotNetDBF.DBFField("IMPORTE", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c8  = new DotNetDBF.DBFField("UBIC_PAGAR", DotNetDBF.NativeDbType.Char, 80);
                    DotNetDBF.DBFField c9  = new DotNetDBF.DBFField("NUMDESC", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c10 = new DotNetDBF.DBFField("TOTDESC", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c11 = new DotNetDBF.DBFField("PAGADO", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c12 = new DotNetDBF.DBFField("FECHA", DotNetDBF.NativeDbType.Char, 20);
                    DotNetDBF.DBFField c13 = new DotNetDBF.DBFField("CTA", DotNetDBF.NativeDbType.Char, 20);
                    DotNetDBF.DBFField c14 = new DotNetDBF.DBFField("SALDO", DotNetDBF.NativeDbType.Numeric, 10, 2);

                    DotNetDBF.DBFField[] campos = new DotNetDBF.DBFField[] { c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14 };
                    escribir.Fields = campos;

                    foreach (Dictionary <string, object> item in this.lista)
                    {
                        List <object> record = new List <object> {
                            Convert.ToDouble(item["folio"]),
                            Convert.ToString(item["rfc"]),
                            Convert.ToString(item["nombre_em"]),
                            Convert.ToString(item["proyecto"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["imp_unit"])))?0:Convert.ToDouble(item["imp_unit"]),
                            Convert.ToString(item["f_primdesc"]).Replace(" 12:00:00 a. m.", ""),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["importe"])))?0:Convert.ToDouble(item["importe"]),
                            Convert.ToString(item["ubic_pagare"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["numdesc"])))?0:Convert.ToDouble(item["numdesc"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["totdesc"])))?0:Convert.ToDouble(item["totdesc"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["pagado"])))?0:Convert.ToDouble(item["pagado"]),
                            Convert.ToString(item["f_emischeq"]).Replace(" 12:00:00 a. m.", ""),
                            Convert.ToString(item["cuenta"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["saldo"])))?0:Convert.ToDouble(item["saldo"])
                        };

                        escribir.AddRecord(record.ToArray());
                    }

                    escribir.Write(ops);
                    escribir.Close();
                    ops.Close();

                    globales.MessageBoxSuccess("Archivo .DBF generado exitosamente", "Archivo generado", globales.menuPrincipal);
                }
            }

            this.Cursor = Cursors.Default;
        }
Exemple #10
0
        private void btngenerar_Click(object sender, EventArgs e)
        {
            string tipo_movimiento = string.Empty;

            if (chk_movimiento.Checked)
            {
                if (string.IsNullOrWhiteSpace(cmbmovimiento.Text))
                {
                    globales.MessageBoxExclamation("Se debe seleccionar algun movimiento para buscar en salgos", "Aviso", globales.menuPrincipal);
                    return;
                }
            }
            seleccionar s = new seleccionar();

            s.ShowDialog();
            if (!s.seleccionado)
            {
                return;
            }



            DateTime fecha1 = DateTime.Parse(fec1.Text);
            DateTime fecha2 = DateTime.Parse(fec2.Text);

            this.Cursor = Cursors.AppStarting;


            string c1 = string.Format("{0:yyyy-MM-dd}", fecha1);
            string c2 = string.Format("{0:yyyy-MM-dd}", fecha2);


            string query = string.Empty;

            if (!chk_movimiento.Checked)
            {
                query = "SELECT datos.saldos ('{0}','{1}')";
                query = string.Format(query, c1, c2);
            }
            else
            {
                tipo_movimiento = "MOVIMIENTO: " + cmbmovimiento.Text;
                query           = "SELECT datos.\"saldos_movimientos(date, date, varchar)\"('{0}','{1}', '{2}') ";
                query           = string.Format(query, c1, c2, cmbmovimiento.Text);
            }



            globales.consulta(query);

            string query2 = $"SELECT emp.rfc, emp.nombre_em, emp.proyecto, sal.saldo, emp.nap, sal.mes, sal.anio FROM ( datos.empleados emp  JOIN datos.r_saldos sal ON(( (emp.rfc) ::TEXT = (sal.rfc) ::TEXT))) WHERE( (sal.saldo<>(0) :: NUMERIC) AND(emp.pendiente = FALSE))  ORDER BY emp.nombre_em";

            List <Dictionary <string, object> > lista = globales.consulta(query2);

            if (!s.esDbf)
            {
                object[] aux2     = new object[lista.Count];
                int      contador = 0;
                foreach (Dictionary <string, object> item in lista)
                {
                    string nombre_em = string.Empty;
                    string rfc       = string.Empty;
                    string proyecto  = string.Empty;
                    string nap       = string.Empty;
                    double saldo     = 0;

                    try
                    {
                        nombre_em = Convert.ToString(item["nombre_em"]);
                        rfc       = Convert.ToString(item["rfc"]);
                        proyecto  = Convert.ToString(item["proyecto"]);
                        nap       = Convert.ToString(item["nap"]);
                        saldo     = Convert.ToDouble(item["saldo"]);
                    }
                    catch
                    {
                    }

                    object[] tt1 = { nombre_em, rfc, proyecto, nap, string.Format("{0:C}", saldo).Replace("$", "") };
                    aux2[contador] = tt1;
                    contador++;
                }

                this.Cursor = Cursors.Default;

                string logo = globales.getImagen(globales.imagenesSispe.logoreportes);

                object[]   parametros       = { "fech1", "fech2", "tiporeporte", "mov", "logo" };
                object[]   valor            = { this.fec1.Text, this.fec2.Text, "NORMALES", tipo_movimiento, logo };
                object[][] enviarParametros = new object[2][];

                enviarParametros[0] = parametros;
                enviarParametros[1] = valor;

                globales.reportes("frmreportsaldo", "rsaldos_aporta", aux2, "", false, enviarParametros);
            }
            else
            {
                //SaveFileDialog p = new SaveFileDialog();
                //p.AddExtension = true;
                //p.DefaultExt = ".dbf";
                //p.ShowDialog();
                //string rutaa = p.FileName;
                ////StreamWriter escribir = new StreamWriter(rutaa);
                ////escribir.Close();
                SaveFileDialog dialogoGuardar = new SaveFileDialog();
                dialogoGuardar.AddExtension = true;
                dialogoGuardar.DefaultExt   = ".dbf";
                if (dialogoGuardar.ShowDialog() == DialogResult.OK)
                {
                    string ruta = dialogoGuardar.FileName;

                    Stream ops = File.Open(ruta, FileMode.OpenOrCreate, FileAccess.ReadWrite);

                    DotNetDBF.DBFWriter escribir = new DotNetDBF.DBFWriter();
                    escribir.DataMemoLoc = ruta.Replace("dbf", "dbt");

                    DotNetDBF.DBFField a1 = new DotNetDBF.DBFField("RFC", DotNetDBF.NativeDbType.Char, 20);
                    DotNetDBF.DBFField a2 = new DotNetDBF.DBFField("NOMBRE", DotNetDBF.NativeDbType.Char, 100);
                    DotNetDBF.DBFField a3 = new DotNetDBF.DBFField("PROYECTO", DotNetDBF.NativeDbType.Char, 35);
                    DotNetDBF.DBFField a4 = new DotNetDBF.DBFField("SALDO", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField a5 = new DotNetDBF.DBFField("NAP", DotNetDBF.NativeDbType.Numeric, 10, 2);


                    DotNetDBF.DBFField[] campos = new DotNetDBF.DBFField[] { a1, a2, a3, a4, a5 };
                    escribir.Fields = campos;

                    foreach (Dictionary <string, object> item in lista)
                    {
                        List <object> record = new List <object> {
                            item["rfc"],
                            item["nombre_em"],
                            item["proyecto"],
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["saldo"])))?0:Convert.ToDouble(item["saldo"]),
                            string.IsNullOrWhiteSpace(Convert.ToString(item["nap"]))?0:Convert.ToDouble(item["nap"])
                        };

                        escribir.AddRecord(record.ToArray());
                    }

                    escribir.Write(ops);
                    escribir.Close();
                    ops.Close();

                    globales.MessageBoxSuccess("Archivo .DBF generado exitosamente", "Archivo generado", globales.menuPrincipal);
                }
            }

            this.Cursor = Cursors.Default;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            object[] obj = new object[lista.Count];

            int contador = 0;

            foreach (Dictionary <string, object> item in this.lista)
            {
                double folio           = Convert.ToDouble(item["folio"]);
                string rfc             = Convert.ToString(item["rfc"]);
                string nombre          = Convert.ToString(item["nombre_em"]);
                string ubicPagare      = Convert.ToString(item["ubic_pagare"]);
                string proyecto        = Convert.ToString(item["proyecto"]);
                string numdesc         = Convert.ToString(item["numdesc"]);
                string totdesc         = Convert.ToString(item["totdesc"]);
                double importe         = (string.IsNullOrWhiteSpace(Convert.ToString(item["importe"]))) ? 0 : Math.Round(Convert.ToDouble(item["importe"]), 2);
                double imp_unit        = (string.IsNullOrWhiteSpace(Convert.ToString(item["imp_unit"]))) ? 0 : Math.Round(Convert.ToDouble(item["imp_unit"]), 2);;
                double pagado          = (string.IsNullOrWhiteSpace(Convert.ToString(item["pagado"]))) ? 0 : Math.Round(Convert.ToDouble(item["pagado"]), 2);
                double saldo           = (string.IsNullOrWhiteSpace(Convert.ToString(item["saldo"]))) ? 0 : Math.Round(Convert.ToDouble(item["saldo"]), 2);
                string cta             = Convert.ToString(item["cta"]);
                string cta_descripcion = Convert.ToString(item["cta_descripcion"]);

                object[] aux = { folio, rfc, nombre, ubicPagare, proyecto, numdesc + "/" + totdesc, importe, imp_unit, pagado, saldo, cta, cta_descripcion };
                obj[contador] = aux;
                contador++;
            }
            string opcion1 = (opcion) ? "QUIROGRAFARIOS" : "HIPOTECARIOS";
            string fecha   = this.fecha;

            object[][] parametros = new object[2][];
            object[]   headers    = { "p1", "p2", "fecha" };
            object[]   body       = { opcion1, fecha, string.Format("{0}/{1}/{2}", DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year) };
            parametros[0] = headers;
            parametros[1] = body;


            if (listBox1.SelectedIndex == 0)
            {
                globales.reportes("reporteRsaldopSaldosPrestamo", "reporteSinSaldo", obj, "", false, parametros);
            }
            else if (listBox1.SelectedIndex == 1)
            {
                globales.reportes("reporteSaldopResumenCuenta", "reporteSinSaldo", obj, "", false, parametros);
            }
            else if (listBox1.SelectedIndex == 2)
            {
                globales.reportes("reporteRSaldoPAlfabetico", "reporteSinSaldo", obj, "", false, parametros);
            }
            else if (listBox1.SelectedIndex == 3)
            {
                globales.reportes("reporteRSaldoPAlfabeticoSinSaldordlc", "reporteSinSaldo", obj, "", false, parametros);
            }
            else if (listBox1.SelectedIndex == 4)
            {
                globales.reportes("reporteRSaldoPFolio", "reporteSinSaldo", obj, "", false, parametros);
            }
            else
            {
                SaveFileDialog dialogoGuardar = new SaveFileDialog();
                dialogoGuardar.AddExtension = true;
                dialogoGuardar.DefaultExt   = ".dbf";
                if (dialogoGuardar.ShowDialog() == DialogResult.OK)
                {
                    string ruta = dialogoGuardar.FileName;

                    Stream ops = File.Open(ruta, FileMode.OpenOrCreate, FileAccess.ReadWrite);

                    DotNetDBF.DBFWriter escribir = new DotNetDBF.DBFWriter();
                    escribir.DataMemoLoc = ruta.Replace("dbf", "dbt");

                    DotNetDBF.DBFField c1  = new DotNetDBF.DBFField("FOLIO", DotNetDBF.NativeDbType.Numeric, 20, 2);
                    DotNetDBF.DBFField c2  = new DotNetDBF.DBFField("RFC", DotNetDBF.NativeDbType.Char, 100);
                    DotNetDBF.DBFField c3  = new DotNetDBF.DBFField("NOMBRE_EM", DotNetDBF.NativeDbType.Char, 100);
                    DotNetDBF.DBFField c4  = new DotNetDBF.DBFField("PROYECTO", DotNetDBF.NativeDbType.Char, 100);
                    DotNetDBF.DBFField c5  = new DotNetDBF.DBFField("IMP_UNIT", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c6  = new DotNetDBF.DBFField("F_PRIMDESC", DotNetDBF.NativeDbType.Char, 20);
                    DotNetDBF.DBFField c7  = new DotNetDBF.DBFField("IMPORTE", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c8  = new DotNetDBF.DBFField("UBIC_PAGAR", DotNetDBF.NativeDbType.Char, 20);
                    DotNetDBF.DBFField c9  = new DotNetDBF.DBFField("NUMDESC", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c10 = new DotNetDBF.DBFField("TOTDESC", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c11 = new DotNetDBF.DBFField("PAGADO", DotNetDBF.NativeDbType.Numeric, 10, 2);
                    DotNetDBF.DBFField c12 = new DotNetDBF.DBFField("FECHA", DotNetDBF.NativeDbType.Char, 20);
                    DotNetDBF.DBFField c13 = new DotNetDBF.DBFField("CTA", DotNetDBF.NativeDbType.Char, 20);
                    DotNetDBF.DBFField c14 = new DotNetDBF.DBFField("SALDO", DotNetDBF.NativeDbType.Numeric, 10, 2);

                    DotNetDBF.DBFField[] campos = new DotNetDBF.DBFField[] { c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14 };
                    escribir.Fields = campos;

                    foreach (Dictionary <string, object> item in this.lista)
                    {
                        List <object> record = new List <object> {
                            Convert.ToDouble(item["folio"]),
                            Convert.ToString(item["rfc"]),
                            Convert.ToString(item["nombre_em"]),
                            Convert.ToString(item["proyecto"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["imp_unit"])))?0:Convert.ToDouble(item["imp_unit"]),
                            Convert.ToString(item["f_primdesc"]).Replace(" 12:00:00 a. m.", ""),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["importe"])))?0:Convert.ToDouble(item["importe"]),
                            Convert.ToString(item["ubic_pagare"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["numdesc"])))?0:Convert.ToDouble(item["numdesc"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["totdesc"])))?0:Convert.ToDouble(item["totdesc"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["pagado"])))?0:Convert.ToDouble(item["pagado"]),
                            Convert.ToString(item["fecha"]).Replace(" 12:00:00 a. m.", ""),
                            Convert.ToString(item["cta"]),
                            (string.IsNullOrWhiteSpace(Convert.ToString(item["saldo"])))?0:Convert.ToDouble(item["saldo"])
                        };

                        escribir.AddRecord(record.ToArray());
                    }

                    escribir.Write(ops);
                    escribir.Close();
                    ops.Close();

                    MessageBox.Show("Archivo .DBF generado exitosamente", "Archivo generado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }