Пример #1
0
        public static int Actualizar(Registro pRegistro)
        {
            int retorno = 0;
            //coversion de los decimales
            string sbase_imp = General.Convertir_a_real(pRegistro.base_imp.ToString("0.00"));
            string stasa     = General.Convertir_a_real(pRegistro.tasa.ToString("0.00"));
            string sdcho_col = General.Convertir_a_real(pRegistro.dcho_col.ToString("0.00"));

            //+  + pRegistro.tasa pRegistro.tasa_tl
            string sql = "update registros set fec_ent='" + pRegistro.fec_ent + "', id_cte=" + pRegistro.id_cte + ", id_titular=" + pRegistro.id_titular + ", seccion_int='" + pRegistro.seccion_int +
                         "', seccion='" + pRegistro.seccion + "', t_tramite='" + pRegistro.t_tramite + "', matricula='" + pRegistro.matricula + "', estado='" + pRegistro.estado + "', factura='" + pRegistro.factura +
                         "', fec_fra='" + pRegistro.fec_fra + "', observacion='" + pRegistro.observacion + "', base_imp='" + sbase_imp + "', p_iva='" + pRegistro.p_iva + "', tasa='" + stasa +
                         "', exp_tl='" + pRegistro.exp_tl + "', fec_pre_exp='" + pRegistro.fec_pre_exp + "', tasa_tl='" + pRegistro.tasa_tl + "', tipo_tl='" + pRegistro.tipo_tl + "', cambio_serv='" + pRegistro.cambio_serv +
                         "', bate_ant='" + pRegistro.bate_ant + "', nif='" + pRegistro.nif + "', dcho_col='" + sdcho_col + "', t_cte_fra='" + pRegistro.t_cte_fra +
                         "' where delegacion='" + pRegistro.delegacion + "' and n_reg=" + pRegistro.n_reg;

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

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

                return(retorno);
            }
        }
Пример #2
0
        //Se utiliza ene el form de busq.
        public static Cliente ObtenerCliente(int pcod_cte)
        {
            Cliente pCliente = new Cliente();
            string  sql      = "select * from clientes where id_cliente=" + pcod_cte;

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

                while (datos.Read())
                {
                    pCliente.Id_Cliente = datos.GetInt32(0);
                    pCliente.Nombre     = datos.GetString(1);
                    pCliente.Tipo_docu  = datos.GetString(2);
                    pCliente.Documento  = datos.GetString(3);
                    pCliente.Letra      = datos.GetChar(4);
                    pCliente.Direccion  = datos.GetString(5);
                    pCliente.Pers_cont  = datos.GetString(6);
                    pCliente.Email      = datos.GetString(7);
                    pCliente.Telf1      = datos.GetString(8);
                    pCliente.Telf2      = datos.GetString(9);
                    pCliente.Cpostal    = datos.GetString(10);
                    pCliente.Ciudad     = datos.GetString(11);
                    pCliente.Provin     = datos.GetString(12);
                    pCliente.Tipo_cte   = datos.GetChar(13);
                }


                comando.Connection.Close();
                return(pCliente);
            }
        }
Пример #3
0
        public static int Existe_tasa_rg(short pejercicio, string pcodigo)
        {
            string sql;

            int existe = 0;

            sql = "select * from registros where extract(year from fec_fra)='" + pejercicio + "' and (t_tasa='" + pcodigo +
                  "' or t_tasa2='" + pcodigo + "' or t_tasa3='" + pcodigo + "' or t_tasa4='" + pcodigo + "')";

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

                NpgsqlDataReader datos = comando.ExecuteReader();

                while (datos.Read())
                {
                    // si existe > 0, si hay tasas en rgs.
                    existe++;
                }

                comando.Connection.Close();
                return(existe);
            }
        }
Пример #4
0
        public static int Existe_factura(int pn_fra) //,int pn_reg, char p_deleg
        {
            int existe = 0;
            //busco la fra. en todas las filas menos en la actual.(antes)
            //string sql = "select * from registros where factura <> (select factura from registros where delegacion ='" + p_deleg + "' and n_reg ='" + pn_reg + "') and factura=" + pn_fra;

            //la actual ya no entra aqui, luego solo busco la nueva si exite
            string sql = "select * from registros where factura=" + pn_fra;

            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);
            }
        }
Пример #5
0
        public static int Agregar(Registro pRegistro)
        {
            int retorno = 0;
            //coversion de los decimales
            string sbase_imp = General.Convertir_a_real(pRegistro.base_imp.ToString("N2"));
            string stasa     = General.Convertir_a_real(pRegistro.tasa.ToString("N2"));
            //string stasa_tl = General.Convertir_a_real(pRegistro.tasa_tl.ToString("N2"));

            string sql = "insert into registros values('" + pRegistro.delegacion + "'," + pRegistro.n_reg + ",'" + pRegistro.fec_ent + "'," + pRegistro.id_cte + "," +
                         pRegistro.id_titular + ",'" + pRegistro.seccion_int + "','" + pRegistro.seccion + "','" + pRegistro.t_tramite + "','" + pRegistro.matricula + "','" + pRegistro.estado + "'," +
                         pRegistro.factura + ",'" + pRegistro.fec_fra + "','" + pRegistro.observacion + "','" + sbase_imp + "','" + pRegistro.p_iva +
                         "','" + stasa + "','" + pRegistro.exp_tl + "','" + pRegistro.fec_pre_exp + "','" + pRegistro.tasa_tl + "','" + pRegistro.tipo_tl + "','" + pRegistro.cambio_serv +
                         "','" + pRegistro.bate_ant + "','" + pRegistro.nif + "','" + pRegistro.dcho_col + "','" + pRegistro.t_cte_fra + "')";


            // 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);
        }
Пример #6
0
        public static int Existe_cte_rg(int pid_cte, char pt_cte) //,int pn_reg, char p_deleg
        {
            string sql;

            int existe = 0;

            if (pt_cte == 'C')
            {
                sql = "select * from registros where id_cte=" + pid_cte;
            }
            else
            {
                sql = "select * from registros where id_titular=" + pid_cte;
            }

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

                NpgsqlDataReader datos = comando.ExecuteReader();

                while (datos.Read())
                {
                    // si existe > 0, si hay ctes.
                    existe++;
                }

                comando.Connection.Close();
                return(existe);
            }
        }
Пример #7
0
        public static int Actualizar(Registro pRegistro)
        {
            int retorno = 0;
            //coversion de los decimales
            string shonorarios = General.Convertir_a_real(pRegistro.honorarios.ToString("0.00"));
            string stasa       = General.Convertir_a_real(pRegistro.tasa.ToString("0.00"));
            string sdcho_col   = General.Convertir_a_real(pRegistro.dcho_col.ToString("0.00"));
            string simpor1     = General.Convertir_a_real(pRegistro.impor1.ToString("0.00"));
            string simpor2     = General.Convertir_a_real(pRegistro.impor2.ToString("0.00"));

            //+  + pRegistro.tasa pRegistro.tasa_tl
            string sql = "update registros set fec_ent='" + pRegistro.fec_ent + "', id_cte=" + pRegistro.id_cte + ", id_titular=" + pRegistro.id_titular + ", seccion_int='" + pRegistro.seccion_int +
                         "', seccion='" + pRegistro.seccion + "', t_tramite='" + pRegistro.t_tramite + "', matricula='" + pRegistro.matricula + "', estado='" + pRegistro.estado + "', factura='" + pRegistro.factura +
                         "', fec_fra='" + pRegistro.fec_fra + "', observacion='" + pRegistro.observacion + "', honorarios='" + shonorarios + "', p_iva='" + pRegistro.p_iva + "', tasa='" + stasa +
                         "', exp_tl='" + pRegistro.exp_tl + "', fec_pre_exp='" + pRegistro.fec_pre_exp + "', et_tasa='" + pRegistro.et_tasa + "', t_tasa='" + pRegistro.t_tasa + "', cambio_serv='" + pRegistro.cambio_serv +
                         "', bate_ant='" + pRegistro.bate_ant + "', nif='" + pRegistro.nif + "', dcho_col='" + sdcho_col + "', t_cte_fra='" + pRegistro.t_cte_fra + "', et_tasa2='" + pRegistro.et_tasa2 + "', t_tasa2='" + pRegistro.t_tasa2 +
                         "', et_tasa3='" + pRegistro.et_tasa3 + "', t_tasa3='" + pRegistro.t_tasa3 + "', et_tasa4='" + pRegistro.et_tasa4 + "', t_tasa4='" + pRegistro.t_tasa4 + "', descripcion='" + pRegistro.descripcion +
                         "', ruta_pdf='" + pRegistro.ruta_pdf + "', vehiculo='" + pRegistro.vehiculo + "', descrip1='" + pRegistro.descrip1 + "', impor1='" + simpor1 + "', iva1_sn='" + pRegistro.iva1_sn +
                         "', descrip2='" + pRegistro.descrip2 + "', impor2='" + simpor2 + "', iva2_sn='" + pRegistro.iva2_sn +
                         "' where delegacion='" + pRegistro.delegacion + "' and n_reg=" + pRegistro.n_reg;

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

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

                return(retorno);
            }
        }
Пример #8
0
        //Se utiliza ene el form de busq.
        public static Registro ObtenerReg(char pdeleg, int pn_reg)
        {
            Registro pRegistro = new Registro();
            string   sql       = "select * from registros where delegacion='" + pdeleg + "' and n_reg=" + pn_reg;

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

                while (datos.Read())
                {
                    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); //(float)datos.GetDecimal(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);
                }


                comando.Connection.Close();
                return(pRegistro);
            }
        }
Пример #9
0
        public static int Agregar(Registro pRegistro)
        {
            int retorno = 0;
            //coversion de los decimales
            string shonorarios = General.Convertir_a_real(pRegistro.honorarios.ToString("N2"));
            string stasa       = General.Convertir_a_real(pRegistro.tasa.ToString("N2"));
            string sdcho_col   = General.Convertir_a_real(pRegistro.dcho_col.ToString("0.00"));
            string simpor1     = General.Convertir_a_real(pRegistro.impor1.ToString("0.00"));
            string simpor2     = General.Convertir_a_real(pRegistro.impor2.ToString("0.00"));

            string sql = "insert into registros values('" + pRegistro.delegacion + "',(select max(n_reg) from registros where delegacion='" + pRegistro.delegacion + "')+1,'" + pRegistro.fec_ent + "'," + pRegistro.id_cte + "," +
                         pRegistro.id_titular + ",'" + pRegistro.seccion_int + "','" + pRegistro.seccion + "','" + pRegistro.t_tramite + "','" + pRegistro.matricula + "','" + pRegistro.estado + "'," +
                         pRegistro.factura + ",'" + pRegistro.fec_fra + "','" + pRegistro.observacion + "','" + shonorarios + "','" + pRegistro.p_iva +
                         "','" + stasa + "','" + pRegistro.exp_tl + "','" + pRegistro.fec_pre_exp + "','" + pRegistro.et_tasa + "','" + pRegistro.t_tasa + "','" + pRegistro.cambio_serv +
                         "','" + pRegistro.bate_ant + "','" + pRegistro.nif + "','" + sdcho_col + "','" + pRegistro.t_cte_fra + "','" + pRegistro.et_tasa2 + "','" + pRegistro.t_tasa2 +
                         "','" + pRegistro.et_tasa3 + "','" + pRegistro.t_tasa3 + "','" + pRegistro.et_tasa4 + "','" + pRegistro.t_tasa4 + "','" + pRegistro.descripcion + "','" + pRegistro.ruta_pdf +
                         "','" + pRegistro.vehiculo + "','" + pRegistro.descrip1 + "','" + simpor1 + "','" + pRegistro.iva1_sn + "','" + pRegistro.descrip2 + "','" + simpor2 + "','" + pRegistro.iva2_sn + "')";


            // 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);
        }
Пример #10
0
        public static List <Tasa> Buscar(string pejercicio, string pcodigo, string pdescri, string pimporte)
        {
            string      sql      = "";
            List <Tasa> _l_tasas = new List <Tasa>();

            //SELECT * FROM clientes WHERE nombre ~* 'pUc';
            if (string.IsNullOrWhiteSpace(pejercicio) & string.IsNullOrWhiteSpace(pcodigo) & string.IsNullOrWhiteSpace(pdescri) & string.IsNullOrWhiteSpace(pimporte))
            {
                sql = "select * from tasas order by ejercicio desc,codigo";
            }
            else
            {
                if (string.IsNullOrWhiteSpace(pejercicio) & string.IsNullOrWhiteSpace(pimporte))
                {
                    sql = "select * from tasas where codigo ~* '" + pcodigo + "' and descripcion ~* '" + pdescri + "' order by ejercicio desc,codigo";
                }
                else
                if (pejercicio != "")
                {
                    sql = "select * from tasas where ejercicio ='" + pejercicio + "' and codigo ~* '" + pcodigo + "' and descripcion ~* '" + pdescri + "' order by ejercicio desc,codigo";
                }
                else
                {
                    sql = "select * from tasas where importe ='" + pimporte + "' and codigo ~* '" + pcodigo + "' and descripcion ~* '" + pdescri + "' 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);
            }
        }
Пример #11
0
        public static string Calcular_nom_cte(string pid_cte, char pt_cte)
        {
            if (string.IsNullOrWhiteSpace(pid_cte.Trim()))
            {
                return(pid_cte = " ");
            }
            else
            {
                int    existe = 0;
                string sql;
                int    iid_cte = Convert.ToInt32(pid_cte);

                //si iid_cte = 0 -> cte comodin: pt_cte(C,T)
                if (iid_cte == 0)
                {
                    sql = "select nombre from clientes where id_cliente=" + iid_cte;
                }
                else
                {
                    sql = "select nombre from clientes where id_cliente=" + iid_cte + " and tipo_cte='" + pt_cte + "'";
                }

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

                    NpgsqlDataReader datos = comando.ExecuteReader();

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

                    comando.Connection.Close();

                    if (existe > 0)
                    {
                        return(pid_cte);
                    }
                    else //no existe cte.
                    {
                        MessageBox.Show("Debe dar de alta ese código de cliente.", "El Código de Cliente no existe", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(" ");
                    }
                }
            }
        }
Пример #12
0
        public static int Eliminar(short pejercicio, string pcodigo)
        {
            int    retorno = 0;
            string sql     = "delete from tasas where ejercicio=" + pejercicio + " and codigo='" + pcodigo + "'";

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

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

                return(retorno);
            }
        }
Пример #13
0
        public static int Eliminar(char pdeleg, int pn_reg)
        {
            int    retorno = 0;
            string sql     = "delete from registros where delegacion='" + pdeleg + "' and n_reg=" + pn_reg;

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

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

                return(retorno);
            }
        }
Пример #14
0
        public static int Eliminar(int pId)
        {
            int    retorno = 0;
            string sql     = "delete from clientes where id_cliente=" + pId;

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

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

                return(retorno);
            }
        }
Пример #15
0
        public static List <Cliente> Buscar(string pnombre, string pdocu, char pt_cte)
        {
            string         sql;
            List <Cliente> _lista = new List <Cliente>();

            //SELECT * FROM clientes WHERE nombre ~* 'pUc';
            if (pnombre == "" & pdocu == "" & pt_cte == ' ') //consulta todos los ctes.
            {
                sql = "select * from clientes order by id_cliente";
            }
            else
            {
                sql = "select * from clientes where nombre ~* '" + pnombre + "' and documento ~* '" + pdocu + "' and tipo_cte='" + pt_cte + "'";
            }

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

                while (datos.Read())
                {
                    Cliente pCliente = new Cliente();
                    pCliente.Id_Cliente = datos.GetInt32(0);
                    pCliente.Nombre     = datos.GetString(1);
                    pCliente.Tipo_docu  = datos.GetString(2);
                    pCliente.Documento  = datos.GetString(3);
                    pCliente.Letra      = datos.GetChar(4);
                    pCliente.Direccion  = datos.GetString(5);
                    pCliente.Pers_cont  = datos.GetString(6);
                    pCliente.Email      = datos.GetString(7);
                    pCliente.Telf1      = datos.GetString(8);
                    pCliente.Telf2      = datos.GetString(9);
                    pCliente.Cpostal    = datos.GetString(10);
                    pCliente.Ciudad     = datos.GetString(11);
                    pCliente.Provin     = datos.GetString(12);
                    pCliente.Tipo_cte   = datos.GetChar(13);


                    _lista.Add(pCliente);
                }

                comando.Connection.Close();
                return(_lista);
            }
        }
Пример #16
0
        public static int Eliminar(int pId, char pt_cte)
        {
            int retorno = 0;

            if (Existe_cte_rg(pId, pt_cte) == 0) //Si = 0, no hay ctes en regs.
            {
                string sql = "delete from clientes where id_cliente=" + pId;
                using (BDConexion.ObtenerConexion())
                {
                    NpgsqlCommand comando = new NpgsqlCommand(sql, BDConexion.ObtenerConexion());
                    comando.CommandTimeout = 5 * 60;

                    retorno = comando.ExecuteNonQuery();
                    comando.Connection.Close();
                }
            }
            return(retorno);
        }
Пример #17
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);
            }
        }
Пример #18
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);
            }
        }
Пример #19
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);
        }
Пример #20
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);
        }
Пример #21
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);
            }
        }
Пример #22
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);
            }
        }
Пример #23
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);
            }
        }
Пример #24
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);
            }
        }
Пример #25
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);
            }
        }
Пример #26
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);
            }
        }
Пример #27
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);
            }
        }