예제 #1
0
        public static int Actualizar(Tasa pTasa)
        {
            int    retorno  = 0;
            string simporte = General.Convertir_a_real(pTasa.importe.ToString("N2"));

            string sql = "update tasas set descripcion='" + pTasa.descripcion.Trim() + "', importe='" + simporte +
                         "' where ejercicio=" + pTasa.ejercicio + " and codigo='" + pTasa.codigo + "'";

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

                retorno = comando.ExecuteNonQuery();
                comando.Connection.Close();

                return(retorno);
            }
        }
예제 #2
0
        public static int Actualizar(Cliente pCliente)
        {
            int    retorno = 0;
            string sql     = "update clientes set nombre='" + pCliente.Nombre + "', tipo_docu='" + pCliente.Tipo_docu + "', documento='" + pCliente.Documento + "', letra='" +
                             pCliente.Letra + "', direccion='" + pCliente.Direccion + "', pers_cont='" + pCliente.Pers_cont + "', email='" + pCliente.Email + "', telf1='" + pCliente.Telf1 + "', telf2='" +
                             pCliente.Telf2 + "', cpostal='" + pCliente.Cpostal + "', ciudad='" + pCliente.Ciudad + "', provin='" + pCliente.Provin + "', tipo_cte='" + pCliente.Tipo_cte +
                             "' where id_cliente=" + pCliente.Id_Cliente;

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

                retorno = comando.ExecuteNonQuery();
                comando.Connection.Close();

                return(retorno);
            }
        }
예제 #3
0
        public static int Agregar(Cliente pCliente)
        {
            int    retorno = 0;//+ pCliente.Id_Cliente +
            string sql     = "insert into clientes values((select max(id_cliente)from clientes)+1,'" + pCliente.Nombre + "','" + pCliente.Tipo_docu + "','" + pCliente.Documento + "','" +
                             pCliente.Letra + "','" + pCliente.Direccion + "','" + pCliente.Pers_cont + "','" + pCliente.Email + "','" + pCliente.Telf1 + "','" + pCliente.Telf2 + "','" +
                             pCliente.Cpostal + "','" + pCliente.Ciudad + "','" + pCliente.Provin + "','" + pCliente.Tipo_cte + "')";


            // Aquí lanzas el proceso de guardado a la bd etc...
            using (BDConexion.ObtenerConexion())
            {
                NpgsqlCommand comando = new NpgsqlCommand(sql, BDConexion.ObtenerConexion());
                // Incrementamos hasta un minuto para evitar que de error cualquier ejecución común.
                comando.CommandTimeout = 5 * 60;

                retorno = comando.ExecuteNonQuery();
            }

            return(retorno);
        }
예제 #4
0
        public static int Agregar(Tasa pTasa)
        {
            int    retorno  = 0;
            string simporte = General.Convertir_a_real(pTasa.importe.ToString("N2"));

            string sql = "insert into tasas values(" + pTasa.ejercicio + ",'" + pTasa.codigo.Trim() + "','" + pTasa.descripcion.Trim() + "','" + simporte + "')";


            // Aquí lanzas el proceso de guardado a la bd etc...
            using (BDConexion.ObtenerConexion())
            {
                NpgsqlCommand comando = new NpgsqlCommand(sql, BDConexion.ObtenerConexion());
                // Incrementamos hasta un minuto para evitar que de error cualquier ejecución común.
                comando.CommandTimeout = 5 * 60;

                retorno = comando.ExecuteNonQuery();
            }

            return(retorno);
        }
예제 #5
0
        public static int Calcular_id_cte()
        {
            int    max_id = 0;
            string sql    = "select max(id_cliente) from clientes";

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

                NpgsqlDataReader datos = comando.ExecuteReader();

                while (datos.Read())
                {
                    max_id = datos.GetInt32(0); //solo un reg.
                }

                comando.Connection.Close();
                return(max_id + 1);
            }
        }
예제 #6
0
        public static int Calcular_n_reg(char pdeleg)
        {
            int    max_n_reg = 0;
            string sql       = "select max(n_reg) from registros where delegacion='" + pdeleg + "'";

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

                NpgsqlDataReader datos = comando.ExecuteReader();

                while (datos.Read())
                {
                    max_n_reg = datos.GetInt32(0); //solo un reg.
                }

                comando.Connection.Close();
                return(max_n_reg + 1);
            }
        }
예제 #7
0
        public static List <Tasa> Buscar_ltasas(string pd_ej, string ph_ej, string pd_cod, string ph_cod)
        {
            string      sql      = "";
            List <Tasa> _l_tasas = new List <Tasa>();

            //SELECT * FROM clientes WHERE nombre ~* 'pUc';
            if (pd_ej == "0" & ph_ej == "9999" & pd_cod == "" & ph_cod == "ZZZZZ")
            {
                sql = "select * from tasas order by ejercicio desc,codigo";
            }
            else
            {
                sql = "select * from tasas where ejercicio between '" + pd_ej + "' and '" + ph_ej + "' and codigo between '" + pd_cod + "' and '" + ph_cod +
                      "' order by ejercicio desc,codigo";
            }


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

                NpgsqlDataReader datos = comando.ExecuteReader();

                while (datos.Read())
                {
                    Tasa pTasa = new Tasa();
                    pTasa.ejercicio   = datos.GetInt16(0);
                    pTasa.codigo      = datos.GetString(1);
                    pTasa.descripcion = datos.GetString(2);
                    pTasa.importe     = datos.GetDecimal(3);

                    _l_tasas.Add(pTasa);
                }

                comando.Connection.Close();
                return(_l_tasas);
            }
        }
예제 #8
0
        public static decimal Saca_imp_tasa(short pejercicio, string pcodigo)
        {
            decimal timp = 0;

            string sql = "select importe from tasas where ejercicio=" + pejercicio + " and codigo='" + pcodigo + "'";

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

                NpgsqlDataReader datos = comando.ExecuteReader();

                while (datos.Read())
                {
                    timp = datos.GetDecimal(0);  //solo un reg.
                }

                comando.Connection.Close();
                return(timp);
            }
        }
예제 #9
0
        public static int Existe_tasa(short pejercicio, string pcodigo)
        {
            int existe = 0;

            string sql = "select * from tasas where ejercicio=" + pejercicio + " and codigo='" + pcodigo + "'";

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

                NpgsqlDataReader datos = comando.ExecuteReader();

                while (datos.Read())
                {
                    // max_n_reg = datos.GetInt32(0); //solo un reg.
                    existe++;
                }

                comando.Connection.Close();
                return(existe);
            }
        }
예제 #10
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);
            }
        }
예제 #11
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);
            }
        }