Exemple #1
0
        public static List <Registro> Buscar(char pt_deleg, int pn_reg, int pfra, char pt_cte, string pn_cte, string pexp, string pmatri, string pvehi)
        {
            string          sql;
            List <Registro> _lista = new List <Registro>();

            if (pt_deleg == ' ' & pn_reg == 0 & pfra == 0 & pt_cte == ' ' & pn_cte == " " & pexp == " " & pmatri == " " & pvehi == " ") //consulta todos los registros. (Mregistros)
            {
                sql = "select * from registros order by delegacion, n_reg";
            }
            else //opciones del buscador de registros
            {
                if (pt_deleg != ' ' & pn_reg != 0) //consulta el n_reg de su deleg.
                //sql = "select delegacion, n_reg, fec_ent, id_cte, factura, fec_fra, exp_tl, fec_pre_exp from registros where delegacion='" + pt_deleg + "' and n_reg=" + pn_reg;
                {
                    sql = "select * from registros where delegacion='" + pt_deleg + "' and n_reg=" + pn_reg;
                }
                else
                {
                    if (pfra != 0)// consulta n_fra
                    {
                        sql = "select * from registros where factura=" + pfra;
                    }
                    else
                    {
                        if (pt_cte != ' ' & pn_cte != " ")// t_cte y nombre
                        {
                            if (pt_cte == 'C')
                            {
                                sql = "select * from registros where registros.id_cte = (select id_cliente from clientes where tipo_cte ='C' and nombre ~* '" + pn_cte + "')";
                            }
                            else
                            {
                                sql = "select * from registros where registros.id_titular = (select id_cliente from clientes where tipo_cte ='T' and nombre ~* '" + pn_cte + "')";
                            }
                            //sql = "select delegacion, n_reg, fec_ent, id_cte,nombre,factura, fec_fra, exp_tl, fec_pre_exp from registros, clientes " +
                            //"where registros.id_titular = clientes.id_cliente and clientes.tipo_cte ='T' and nombre like '%" + pn_cte + "%'";
                        }
                        else
                        {
                            if (pmatri != " " | pvehi != " ")// matricula or vehiculo
                            {
                                sql = "select * from registros where matricula ~* '" + pmatri + "' and vehiculo ~* '" + pvehi + "'";
                            }
                            else //x n_exp.
                            {
                                sql = "select * from registros where exp_tl ~* '" + pexp + "'";
                            }
                        }
                    }
                }
            }

            using (BDConexion.ObtenerConexion())
            {
                NpgsqlCommand comando = new NpgsqlCommand(sql, BDConexion.ObtenerConexion());
                comando.CommandTimeout = 5 * 60;
                NpgsqlDataReader datos = comando.ExecuteReader();


                while (datos.Read())
                {
                    Registro pRegistro = new Registro();
                    pRegistro.delegacion  = datos.GetChar(0);
                    pRegistro.n_reg       = datos.GetInt32(1);
                    pRegistro.fec_ent     = datos.GetDateTime(2);
                    pRegistro.id_cte      = datos.GetInt32(3);
                    pRegistro.id_titular  = datos.GetInt32(4);
                    pRegistro.seccion_int = datos.GetString(5);
                    pRegistro.seccion     = datos.GetString(6);
                    pRegistro.t_tramite   = datos.GetString(7);
                    pRegistro.matricula   = datos.GetString(8);
                    pRegistro.estado      = datos.GetString(9);
                    pRegistro.factura     = datos.GetInt32(10);
                    pRegistro.fec_fra     = datos.GetDateTime(11);
                    pRegistro.observacion = datos.GetString(12);
                    pRegistro.honorarios  = datos.GetDecimal(13);
                    pRegistro.p_iva       = datos.GetInt16(14);
                    pRegistro.tasa        = datos.GetDecimal(15);
                    pRegistro.exp_tl      = datos.GetString(16);
                    pRegistro.fec_pre_exp = datos.GetDateTime(17);
                    pRegistro.et_tasa     = datos.GetInt64(18);
                    pRegistro.t_tasa      = datos.GetString(19);
                    pRegistro.cambio_serv = datos.GetString(20);
                    pRegistro.bate_ant    = datos.GetString(21);
                    pRegistro.nif         = datos.GetString(22);
                    pRegistro.dcho_col    = datos.GetDecimal(23);
                    pRegistro.t_cte_fra   = datos.GetChar(24);
                    pRegistro.et_tasa2    = datos.GetInt64(25);
                    pRegistro.t_tasa2     = datos.GetString(26);
                    pRegistro.et_tasa3    = datos.GetInt64(27);
                    pRegistro.t_tasa3     = datos.GetString(28);
                    pRegistro.et_tasa4    = datos.GetInt64(29);
                    pRegistro.t_tasa4     = datos.GetString(30);
                    pRegistro.descripcion = datos.GetString(31);
                    pRegistro.ruta_pdf    = datos.GetString(32);
                    pRegistro.vehiculo    = datos.GetString(33);
                    pRegistro.descrip1    = datos.GetString(34);
                    pRegistro.impor1      = datos.GetDecimal(35);
                    pRegistro.iva1_sn     = datos.GetBoolean(36);
                    pRegistro.descrip2    = datos.GetString(37);
                    pRegistro.impor2      = datos.GetDecimal(38);
                    pRegistro.iva2_sn     = datos.GetBoolean(39);
                    _lista.Add(pRegistro);
                }

                comando.Connection.Close();
                return(_lista);
            }
        }
Exemple #2
0
        public static List <Registro> Buscar_lreg(char pt_deleg, int pd_n_rg, int ph_n_rg, char pt_cte, int pd_cte, int ph_cte) //int pfra, string pn_cte, string pexp)
        {
            string          sql    = "";
            List <Registro> _lista = new List <Registro>();

            if (pt_deleg == ' ' & pd_n_rg == 0 & ph_n_rg == 999999 & pt_cte == ' ' & pd_cte == 0 & ph_cte == 999999) //consulta todos los registros. (Mregistros)
            {
                sql = "select * from registros order by delegacion, n_reg";
            }
            else //opciones del buscador de registros
            {
                if (pt_deleg != ' ') //consulta el n_reg de su deleg.
                //sql = "select delegacion, n_reg, fec_ent, id_cte, factura, fec_fra, exp_tl, fec_pre_exp from registros where delegacion='" + pt_deleg + "' and n_reg=" + pn_reg;
                {
                    sql = "select * from registros where delegacion='" + pt_deleg + "' and n_reg between " + pd_n_rg + " and " + ph_n_rg + " order by delegacion, n_reg";
                }
                else
                {
                    if (pt_cte != ' ')    // t_cte y nombre
                    {
                        if (pt_cte == 'C')
                        {
                            sql = "select * from registros where registros.id_cte between " + pd_cte + " and " + ph_cte;     //(select id_cliente from clientes where tipo_cte ='C' and nombre like '%" + pn_cte + "%')";
                        }
                        else
                        {
                            sql = "select * from registros where registros.id_titular between " + pd_cte + " and " + ph_cte;    //(select id_cliente from clientes where tipo_cte ='T' and nombre like '%" + pn_cte + "%')";
                        }
                        //sql = "select delegacion, n_reg, fec_ent, id_cte,nombre,factura, fec_fra, exp_tl, fec_pre_exp from registros, clientes " +
                        //"where registros.id_titular = clientes.id_cliente and clientes.tipo_cte ='T' and nombre like '%" + pn_cte + "%'";
                    }
                    //else //x n_exp.
                    //  sql = "select * from registros where exp_tl like '%" + pexp + "%'";

                    /*
                     * if (pfra != 0)// consulta n_fra
                     *  sql = "select * from registros where factura=" + pfra;
                     * else
                     * {
                     *  }
                     */
                }
            }

            using (BDConexion.ObtenerConexion())
            {
                NpgsqlCommand comando = new NpgsqlCommand(sql, BDConexion.ObtenerConexion());
                comando.CommandTimeout = 5 * 60;
                NpgsqlDataReader datos = comando.ExecuteReader();


                while (datos.Read())
                {
                    Registro pRegistro = new Registro();
                    pRegistro.delegacion  = datos.GetChar(0);
                    pRegistro.n_reg       = datos.GetInt32(1);
                    pRegistro.fec_ent     = datos.GetDateTime(2);
                    pRegistro.id_cte      = datos.GetInt32(3);
                    pRegistro.id_titular  = datos.GetInt32(4);
                    pRegistro.seccion_int = datos.GetString(5);
                    pRegistro.seccion     = datos.GetString(6);
                    pRegistro.t_tramite   = datos.GetString(7);
                    pRegistro.matricula   = datos.GetString(8);
                    pRegistro.estado      = datos.GetString(9);
                    pRegistro.factura     = datos.GetInt32(10);
                    pRegistro.fec_fra     = datos.GetDateTime(11);
                    pRegistro.observacion = datos.GetString(12);
                    pRegistro.honorarios  = datos.GetDecimal(13);
                    pRegistro.p_iva       = datos.GetInt16(14);
                    pRegistro.tasa        = datos.GetDecimal(15);
                    pRegistro.exp_tl      = datos.GetString(16);
                    pRegistro.fec_pre_exp = datos.GetDateTime(17);
                    pRegistro.et_tasa     = datos.GetInt64(18);
                    pRegistro.t_tasa      = datos.GetString(19);
                    pRegistro.cambio_serv = datos.GetString(20);
                    pRegistro.bate_ant    = datos.GetString(21);
                    pRegistro.nif         = datos.GetString(22);
                    pRegistro.dcho_col    = datos.GetDecimal(23);
                    pRegistro.t_cte_fra   = datos.GetChar(24);
                    pRegistro.et_tasa2    = datos.GetInt64(25);
                    pRegistro.t_tasa2     = datos.GetString(26);
                    pRegistro.et_tasa3    = datos.GetInt64(27);
                    pRegistro.t_tasa3     = datos.GetString(28);
                    pRegistro.et_tasa4    = datos.GetInt64(29);
                    pRegistro.t_tasa4     = datos.GetString(30);
                    pRegistro.descripcion = datos.GetString(31);
                    pRegistro.ruta_pdf    = datos.GetString(32);
                    pRegistro.vehiculo    = datos.GetString(33);

                    _lista.Add(pRegistro);
                }

                comando.Connection.Close();
                return(_lista);
            }
        }