Exemplo n.º 1
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);
            }
        }
Exemplo n.º 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);
                    pCliente.cta_cble   = datos.GetString(14);
                }


                comando.Connection.Close();
                return(pCliente);
            }
        }
Exemplo n.º 3
0
        public static List <HRegistro> Buscar(char pt_deleg, int pn_reg, string pusu)
        {
            string           sql      = "";
            List <HRegistro> _l_hregs = new List <HRegistro>();

            //SELECT * FROM clientes WHERE nombre ~* 'pUc';
            sql = "select * from h_registros where 1=1";
            if (pt_deleg != ' ')
            {
                sql = sql.TrimEnd() + " and delegacion='" + pt_deleg + "'";
            }

            if (pn_reg != 0)
            {
                sql = sql.TrimEnd() + " and n_reg=" + pn_reg;
            }


            if (!string.IsNullOrWhiteSpace(pusu))
            {
                sql = sql.TrimEnd() + " and cod_usu ~* '" + pusu + "'";
            }

            sql = sql + " order by delegacion, n_reg, linea";

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

                NpgsqlDataReader datos = comando.ExecuteReader();

                while (datos.Read())
                {
                    HRegistro pHRegistro = new HRegistro();
                    pHRegistro.delegacion = datos.GetChar(0);
                    pHRegistro.n_reg      = datos.GetInt32(1);
                    pHRegistro.linea      = datos.GetInt16(2);
                    pHRegistro.fec_modif  = datos.GetDateTime(3);
                    pHRegistro.tipo_modif = datos.GetChar(4);
                    pHRegistro.cod_usu    = datos.GetString(5);

                    _l_hregs.Add(pHRegistro);
                }

                comando.Connection.Close();
                return(_l_hregs);
            }
        }
Exemplo n.º 4
0
        public static List <Cliente> Buscar_LCte(char pt_cte, int pd_cte, int ph_cte)
        {
            string         sql;
            List <Cliente> _lista = new List <Cliente>();

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

            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);
                    pCliente.cta_cble   = datos.GetString(14);


                    _lista.Add(pCliente);
                }

                comando.Connection.Close();
                return(_lista);
            }
        }
Exemplo n.º 5
0
 public OrdenMinado(NpgsqlDataReader rdr)
 {
     this.id   = rdr.GetInt32(0);
     this.name = rdr.GetString(1);
     this.size = rdr.GetInt16(2);
     if (rdr.IsDBNull(3))
     {
         robot = null;
     }
     else
     {
         this.robot = rdr.GetInt16(3);
     }
     this.posX        = rdr.GetInt16(4);
     this.posY        = rdr.GetInt16(5);
     this.posZ        = rdr.GetInt16(6);
     this.facing      = rdr.GetInt16(7);
     this.gpsX        = rdr.GetInt16(8);
     this.gpsY        = rdr.GetInt16(9);
     this.gpsZ        = rdr.GetInt16(10);
     this.numeroItems = rdr.GetInt32(11);
     this.dateAdd     = rdr.GetDateTime(12);
     this.dateUpd     = rdr.GetDateTime(13);
     if (rdr.IsDBNull(14))
     {
         this.dateInicio = null;
     }
     else
     {
         this.dateInicio = rdr.GetDateTime(14);
     }
     if (rdr.IsDBNull(15))
     {
         this.dateFin = null;
     }
     else
     {
         this.dateFin = rdr.GetDateTime(15);
     }
     this.descripcion    = rdr.GetString(16);
     this.estado         = rdr.GetChar(17);
     this.unidadRecarga  = rdr.GetChar(18);
     this.energiaRecarga = rdr.GetInt16(19);
     this.modoMinado     = rdr.GetChar(20);
     this.shutdown       = rdr.GetBoolean(21);
     this.notificacion   = rdr.GetBoolean(22);
     this.chestSide      = rdr.GetChar(23);
 }
Exemplo n.º 6
0
        //Metodos
        public List <MedicoDTO> VerRegistros(string condicion)
        {
            conn.Open();
            comm.Connection  = conn;
            comm.CommandText = "select * from " + condicion + ";";
            comm.ExecuteNonQuery();

            LeerFilas = comm.ExecuteReader();
            List <MedicoDTO> listaGenerica = new List <MedicoDTO>();

            while (LeerFilas.Read())
            {
                listaGenerica.Add(new MedicoDTO {
                    Nombre          = LeerFilas.GetString(0),
                    Apellido        = LeerFilas.GetString(1),
                    Cedula          = LeerFilas.GetString(2),
                    Especializacion = LeerFilas.GetString(3),
                    Horario         = LeerFilas.GetString(4),
                    Salario         = LeerFilas.GetFloat(5),
                    Sexo            = LeerFilas.GetChar(6),
                    Password        = LeerFilas.GetString(7)
                });
            }
            LeerFilas.Close();
            conn.Close();
            return(listaGenerica);
        }
Exemplo n.º 7
0
        public List <PacienteDTO> VerRegistros(string condicion)
        {
            conn.Open();
            comm.Connection  = conn;
            comm.CommandText = "select * from " + condicion + ";";
            comm.ExecuteNonQuery();

            LeerFilas = comm.ExecuteReader();
            List <PacienteDTO> listaGenerica = new List <PacienteDTO>();

            while (LeerFilas.Read())
            {
                listaGenerica.Add(new PacienteDTO {
                    Nombre        = LeerFilas.GetString(0),
                    Apellido      = LeerFilas.GetString(1),
                    Curp          = LeerFilas.GetString(2),
                    Nss           = LeerFilas.GetInt32(3),
                    Codigo_Postal = LeerFilas.GetInt32(4),
                    Sexo          = LeerFilas.GetChar(5),
                });
            }
            LeerFilas.Close();
            conn.Close();
            return(listaGenerica);
        }
Exemplo n.º 8
0
        public List <Responsavel> Consultar(string resp_nome, Aluno aluno)
        {
            List <Responsavel> lista     = new List <Responsavel>();
            string             stringSQL = "select ra.alu_pk, ra.resp_pk, p.pes_nome, r.resp_parentesco, r.resp_outroparentesco " +
                                           "from responsaveis_aluno ra " +
                                           "inner join pessoas p on p.pes_pk=ra.resp_pk " +
                                           "inner join responsaveis r on r.pes_pk=ra.resp_pk " +
                                           "where ra.alu_pk=20 and p.pes_nome ilike @nome";

            NpgsqlCommand cmdConsultar = new NpgsqlCommand(stringSQL, this.Conexao);

            this.Conexao.Open();
            cmdConsultar.Parameters.AddWithValue("@nome", "%" + resp_nome + "%");

            NpgsqlDataReader resultado = cmdConsultar.ExecuteReader();

            if (resultado.HasRows)
            {
                while (resultado.Read())
                {
                    Responsavel resp = new Responsavel();
                    resp.Id              = resultado.GetInt32(1);
                    resp.Nome            = resultado.GetString(2);
                    resp.Parentesco      = resultado.GetChar(3).ToString();
                    resp.OutroParentesco = resultado.GetString(4);

                    lista.Add(resp);
                }
            }
            resultado.Close();
            this.Conexao.Close();

            return(lista);
        }
Exemplo n.º 9
0
        public MedicoDTO ObtenerMedico(string cedula)
        {
            MedicoDTO medico = new MedicoDTO();

            conn.Open();
            comm.Connection  = conn;
            comm.CommandText = "select * from medico where cedula = '" + cedula + "';";
            comm.ExecuteNonQuery();
            LeerFilas = comm.ExecuteReader();
            if (LeerFilas.HasRows)
            {
                while (LeerFilas.Read())
                {
                    medico.Nombre          = LeerFilas.GetString(0);
                    medico.Apellido        = LeerFilas.GetString(1);
                    medico.Cedula          = LeerFilas.GetString(2);
                    medico.Especializacion = LeerFilas.GetString(3);
                    medico.Horario         = LeerFilas.GetString(4);
                    medico.Salario         = LeerFilas.GetFloat(5);
                    medico.Sexo            = LeerFilas.GetChar(6);
                    medico.Password        = LeerFilas.GetString(7);
                }
            }
            LeerFilas.Close();
            conn.Close();
            return(medico);
        }
Exemplo n.º 10
0
        //Metodos
        public PacienteDTO ObtenerPaciente(int nss)
        {
            PacienteDTO paciente = new PacienteDTO();

            conn.Open();
            comm.Connection  = conn;
            comm.CommandText = "select * from paciente where nss = " + nss + ";";
            comm.ExecuteNonQuery();
            LeerFilas = comm.ExecuteReader();
            if (LeerFilas.HasRows)
            {
                while (LeerFilas.Read())
                {
                    paciente.Nombre        = LeerFilas.GetString(0);
                    paciente.Apellido      = LeerFilas.GetString(1);
                    paciente.Curp          = LeerFilas.GetString(2);
                    paciente.Nss           = LeerFilas.GetInt32(3);
                    paciente.Codigo_Postal = LeerFilas.GetInt32(4);
                    paciente.Sexo          = LeerFilas.GetChar(5);
                }
            }
            LeerFilas.Close();
            conn.Close();
            return(paciente);
        }
Exemplo n.º 11
0
 public Drone(NpgsqlDataReader rdr)
 {
     this.id                      = rdr.GetInt16(0);
     this.name                    = rdr.GetString(1);
     this.uuid                    = rdr.GetGuid(2);
     this.tier                    = rdr.GetInt16(3);
     this.numeroSlots             = rdr.GetInt16(4);
     this.numeroStacks            = rdr.GetInt16(5);
     this.numeroItems             = rdr.GetInt16(6);
     this.estado                  = rdr.GetChar(7);
     this.totalEnergia            = rdr.GetInt16(8);
     this.energiaActual           = rdr.GetInt16(9);
     this.upgradeGenerador        = rdr.GetBoolean(10);
     this.itemsGenerador          = rdr.GetInt16(11);
     this.fechaConexion           = rdr.GetDateTime(12);
     this.fechaDesconexion        = rdr.GetDateTime(13);
     this.descripcion             = rdr.GetString(14);
     this.upgradeGps              = rdr.GetBoolean(15);
     this.posX                    = rdr.GetInt16(16);
     this.posY                    = rdr.GetInt16(17);
     this.posZ                    = rdr.GetInt16(18);
     this.complejidad             = rdr.GetInt16(19);
     this.dateAdd                 = rdr.GetDateTime(20);
     this.dateUpd                 = rdr.GetDateTime(21);
     this.off                     = rdr.GetBoolean(22);
     this.offsetPosX              = rdr.GetInt16(23);
     this.offsetPosY              = rdr.GetInt16(24);
     this.offsetPosZ              = rdr.GetInt16(25);
     this.notificacionConexion    = rdr.GetBoolean(26);
     this.notificacionDesconexion = rdr.GetBoolean(27);
     this.notificacionBateriaBaja = rdr.GetBoolean(28);
 }
Exemplo n.º 12
0
 /// <summary>
 /// Ya hay un constructor que tome 'NpgsqlDataReader', para el front-end, pero no necesitamos todos los campos para los enviar a los robots
 /// Este metodo construye solo con los campos necesarios para los robots
 /// </summary>
 /// <param name="rdr"></param>
 public void robotParse(NpgsqlDataReader rdr)
 {
     this.id             = rdr.GetInt32(0);
     this.size           = rdr.GetInt16(1);
     this.posX           = rdr.GetInt16(2);
     this.posY           = rdr.GetInt16(3);
     this.posZ           = rdr.GetInt16(4);
     this.facing         = rdr.GetInt16(5);
     this.gpsX           = rdr.GetInt16(6);
     this.gpsY           = rdr.GetInt16(7);
     this.gpsZ           = rdr.GetInt16(8);
     this.unidadRecarga  = rdr.GetChar(9);
     this.energiaRecarga = rdr.GetInt16(10);
     this.modoMinado     = rdr.GetChar(11);
     this.shutdown       = rdr.GetBoolean(12);
     this.chestSide      = rdr.GetChar(13);
 }
Exemplo n.º 13
0
 public AlmacenInventarioNotificacion(NpgsqlDataReader rdr)
 {
     this.idAlmacen  = rdr.GetInt16(0);
     this.id         = rdr.GetInt16(1);
     this.name       = rdr.GetString(2);
     this.idArticulo = rdr.GetInt16(3);
     this.modo       = rdr.GetChar(4);
     this.cantidad   = rdr.GetInt32(5);
 }
Exemplo n.º 14
0
        public List <Teacher> ReadAllTeachers()
        {
            conn = DAO.getConnection();
            Teacher        teacher  = new Teacher();
            List <Teacher> teachers = new List <Teacher>();
            String         email;
            String         password;
            String         name;
            String         lastName;
            DateTime       birthDate;
            String         phone;
            String         country;
            Char           status;

            try
            {
                conn = DAO.getConnection();
                NpgsqlTransaction tran    = conn.BeginTransaction();
                NpgsqlCommand     command = new NpgsqlCommand(DAOTeacherResource.ReadAllTeachersSP, conn);
                command.CommandType = CommandType.StoredProcedure;

                NpgsqlDataReader dr = command.ExecuteReader();
                try
                {
                    while (dr.Read())
                    {
                        email          = dr.GetString(0);
                        password       = dr.GetString(1);
                        name           = dr.GetString(2);
                        lastName       = dr.GetString(3);
                        birthDate      = dr.GetDateTime(4);
                        phone          = dr.GetString(5);
                        country        = dr.GetString(6);
                        status         = dr.GetChar(7);
                        teacher        = new Teacher(email, password, name, lastName, birthDate, phone, country);
                        teacher.Status = status;
                        teachers.Add(teacher);
                    }
                    dr.Close();
                    tran.Commit();
                    return(teachers);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            catch (NpgsqlException ex2)
            {
                throw ex2;
            }
            finally
            {
                conn.Close();
            }
        }
Exemplo n.º 15
0
 public MovimientoAlmacen(NpgsqlDataReader rdr)
 {
     this.almacen     = rdr.GetInt16(0);
     this.id          = rdr.GetInt64(1);
     this.articulo    = rdr.GetInt16(2);
     this.cantidad    = rdr.GetInt32(3);
     this.origen      = rdr.GetChar(4);
     this.dateAdd     = rdr.GetDateTime(5);
     this.descripcion = rdr.GetString(6);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Returns the column value as a nullable character.
 /// </summary>
 /// <param name="reader">The data reader.</param>
 /// <param name="ordinal">The zero-based column position.</param>
 /// <returns>The nullable column value.</returns>
 public static char?GetNullableChar(this NpgsqlDataReader reader, int ordinal)
 {
     if (reader[ordinal] == DBNull.Value)
     {
         return(null);
     }
     else
     {
         return(reader.GetChar(ordinal));
     }
 }
Exemplo n.º 17
0
 public Fabricacion(NpgsqlDataReader rdr)
 {
     this.id        = rdr.GetInt16(0);
     this.idAlmacen = rdr.GetInt16(1);
     this.name      = rdr.GetString(2);
     this.tipo      = rdr.GetChar(3);
     this.dateAdd   = rdr.GetDateTime(4);
     this.uuid      = rdr.GetGuid(5);
     this.off       = rdr.GetBoolean(6);
     this.cofreSide = rdr.GetInt16(7);
     this.hornoSide = rdr.GetInt16(8);
 }
Exemplo n.º 18
0
 public Generador(NpgsqlDataReader rdr)
 {
     this.redElectrica = rdr.GetInt16(0);
     this.id           = rdr.GetInt16(1);
     this.name         = rdr.GetString(2);
     this.uuid         = rdr.GetGuid(3);
     this.euTick       = rdr.GetInt32(4);
     this.activado     = rdr.GetBoolean(5);
     this.tipo         = rdr.GetChar(6);
     this.descripcion  = rdr.GetString(7);
     this.notificacion = rdr.GetBoolean(8);
 }
Exemplo n.º 19
0
        public Responsavel GetResponsavelById(int responsavel_id)
        {
            Responsavel resp      = null;
            string      stringSQL = "select p.pes_pk, p.pes_nome, p.pes_sexo, p.pes_rg, r.resp_cpf, " +
                                    "r.resp_estadocivil, r.resp_nomeconjuge, r.resp_profissao, r.resp_parentesco, " +
                                    "r.resp_outroparentesco, r.resp_enderecoaluno " +
                                    "from pessoas p " +
                                    "inner join responsaveis r on p.pes_pk = r.pes_pk " +
                                    "where p.pes_pk=@pessoa";

            NpgsqlCommand cmdConsultar = new NpgsqlCommand(stringSQL, this.Conexao);

            this.Conexao.Open();
            cmdConsultar.Parameters.AddWithValue("@pessoa", responsavel_id);

            NpgsqlDataReader resultado = cmdConsultar.ExecuteReader();

            if (resultado.HasRows)
            {
                resultado.Read();
                resp = new Responsavel();

                resp.Id   = resultado.GetInt32(0);
                resp.Nome = resultado.GetString(1);
                resp.Sexo = resultado.GetChar(2).ToString();
                resp.Rg   = resultado.GetString(3);

                resp.CPF                    = resultado.GetString(4);
                resp.EstadoCivil            = resultado.GetChar(5).ToString();
                resp.NomeConjuge            = resultado.GetString(6);
                resp.Profissao              = resultado.GetString(7);
                resp.Parentesco             = resultado.GetChar(8).ToString();
                resp.OutroParentesco        = resultado.GetString(9);
                resp.MoraMesmoEnderecoAluno = resultado.GetBoolean(10);
            }
            resultado.Close();
            this.Conexao.Close();

            return(resp);
        }
Exemplo n.º 20
0
 public Bateria(NpgsqlDataReader rdr)
 {
     this.id                 = rdr.GetInt16(0);
     this.redElectrica       = rdr.GetInt16(1);
     this.name               = rdr.GetString(2);
     this.uuid               = rdr.GetGuid(3);
     this.capacidadElectrica = rdr.GetInt64(4);
     this.cargaActual        = rdr.GetInt64(5);
     this.descripcion        = rdr.GetString(6);
     this.tipo               = rdr.GetChar(7);
     this.notificacion       = rdr.GetBoolean(8);
     this.cargaNotificacion  = rdr.GetInt64(9);
 }
Exemplo n.º 21
0
        public Funcionario GetFuncionarioById(int id)
        {
            Funcionario fun       = null;
            string      stringSQL = "select " +
                                    "p.pes_pk, p.pes_nome, p.pes_sexo, p.pes_datanascimento, p.pes_rg, p.pes_ativo, " +
                                    "f.fun_cpf, f.fun_email, f.fun_desligamento, f.fun_observacoes, f.fun_salario, " +
                                    "f.car_pk, f.fun_admissao, c.car_cargo " +
                                    "from pessoas p inner join funcionarios f on p.pes_pk = f.pes_pk " +
                                    "inner join cargos_funcionarios c on f.car_pk = c.car_pk " +
                                    "where f.pes_pk = @codigo";

            NpgsqlCommand cmdConsultar = new NpgsqlCommand(stringSQL, this.Conexao);

            this.Conexao.Open();
            cmdConsultar.Parameters.AddWithValue("@codigo", id);

            NpgsqlDataReader resultado = cmdConsultar.ExecuteReader();

            if (resultado.HasRows)
            {
                resultado.Read();
                fun = new Funcionario();

                fun.Id             = resultado.GetInt32(0);
                fun.Nome           = resultado.GetString(1);
                fun.Sexo           = resultado.GetChar(2).ToString();
                fun.DataNascimento = resultado.GetDateTime(3);
                fun.Rg             = resultado.GetString(4);
                fun.Ativo          = resultado.GetBoolean(5);

                fun.Cpf   = resultado.GetString(6);
                fun.Email = resultado.GetString(7);
                if (!resultado.IsDBNull(8))
                {
                    fun.Desligamento = resultado.GetDateTime(8);
                }
                fun.Observacoes = resultado.GetString(9);
                fun.Salario     = resultado.GetDecimal(10);
                fun.Admissao    = resultado.GetDateTime(12);

                CargoFuncionario c = new CargoFuncionario();
                c.Id    = resultado.GetInt32(11);
                c.Cargo = resultado.GetString(13);

                fun.Cargo = c;
            }
            resultado.Close();
            this.Conexao.Close();

            return(fun);
        }
Exemplo n.º 22
0
 public Almacen(NpgsqlDataReader rdr)
 {
     this.id             = rdr.GetInt16(0);
     this.name           = rdr.GetString(1);
     this.descripcion    = rdr.GetString(2);
     this.tipos          = rdr.GetInt16(3);
     this.items          = rdr.GetInt32(4);
     this.off            = rdr.GetBoolean(5);
     this.uuid           = rdr.GetGuid(6);
     this.dateAdd        = rdr.GetDateTime(7);
     this.dateLastUpdate = rdr.GetDateTime(8);
     this.stacks         = rdr.GetInt16(9);
     this.almacenamiento = rdr.GetChar(10);
     this.maximoStacks   = rdr.GetInt16(11);
     this.maximoTipos    = rdr.GetInt16(12);
     this.maximoItems    = rdr.GetInt32(13);
 }
Exemplo n.º 23
0
        public Aluno GetAlunoById(int id)
        {
            Aluno  alu       = null;
            string stringSQL = "select " +
                               "p.pes_pk, p.pes_nome, p.pes_datanascimento, p.pes_sexo, a.alu_localnascimento, " +
                               "a.est_pk, e.est_nome, e.est_sigla " +
                               "from alunos a " +
                               "inner join pessoas p on p.pes_pk = a.pes_pk " +
                               "inner join estados e on a.est_pk = e.est_pk " +
                               "where p.pes_pk = @codigo";

            NpgsqlCommand cmdConsultar = new NpgsqlCommand(stringSQL, this.Conexao);

            this.Conexao.Open();
            cmdConsultar.Parameters.AddWithValue("@codigo", id);

            NpgsqlDataReader resultado = cmdConsultar.ExecuteReader();

            if (resultado.HasRows)
            {
                resultado.Read();
                alu = new Aluno();

                alu.Id             = resultado.GetInt32(0);
                alu.Nome           = resultado.GetString(1);
                alu.DataNascimento = resultado.GetDateTime(2);
                alu.Sexo           = resultado.GetChar(3).ToString();
                alu.Municipio      = resultado.GetString(4);
                alu.Estado         = new Estado()
                {
                    Id    = resultado.GetInt32(5),
                    Nome  = resultado.GetString(6),
                    Sigla = resultado.GetString(7)
                };
            }

            resultado.Close();
            this.Conexao.Close();
            return(alu);
        }
Exemplo n.º 24
0
 public OrdenFabricacion(NpgsqlDataReader rdr)
 {
     this.id            = rdr.GetInt32(0);
     this.idAlmacen     = rdr.GetInt16(1);
     this.name          = rdr.GetString(2);
     this.idFabricacion = rdr.GetInt16(3);
     if (rdr.IsDBNull(4))
     {
         this.idCrafteo = null;
     }
     else
     {
         this.idCrafteo = rdr.GetInt16(4);
     }
     if (rdr.IsDBNull(5))
     {
         this.idSmelting = null;
     }
     else
     {
         this.idSmelting = rdr.GetInt16(5);
     }
     this.dateAdd = rdr.GetDateTime(6);
     if (rdr.IsDBNull(7))
     {
         this.dateFinalizado = null;
     }
     else
     {
         this.dateFinalizado = rdr.GetDateTime(7);
     }
     this.estado            = rdr.GetChar(8);
     this.cantidad          = rdr.GetInt32(9);
     this.cantidadFabricado = rdr.GetInt32(10);
     this.errorCode         = rdr.GetInt16(11);
 }
Exemplo n.º 25
0
 public char GetChar(int ordinal) => _Core.GetChar(ordinal);
 /// <summary>
 /// Get the value of a column as a char, given its zero-based ordinal.
 /// </summary>
 public char GetChar(int i) => _rdr.GetChar(i);
 /// <summary>
 /// Get the value of a column as a char, given its zero-based ordinal.
 /// </summary>
 /// <param name="i"></param>
 /// <returns></returns>
 public char GetChar(int i)
 {
     return(_rdr.GetChar(i));
 }
Exemplo n.º 28
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);
            }
        }
Exemplo n.º 29
0
        public Teacher ReadTeacher(Teacher teacher)
        {
            conn = DAO.getConnection();
            Teacher readTeacher = new Teacher();

            String   email;
            String   password;
            String   name;
            String   lastName;
            DateTime birthDate;
            String   phone;
            String   country;
            Char     status;

            try
            {
                conn = DAO.getConnection();
                NpgsqlTransaction tran      = conn.BeginTransaction();
                NpgsqlCommand     command   = new NpgsqlCommand(DAOTeacherResource.ReadTeacherSP, conn);
                NpgsqlParameter   parameter = new NpgsqlParameter();
                parameter.ParameterName = DAOTeacherResource.Email;
                parameter.NpgsqlDbType  = NpgsqlTypes.NpgsqlDbType.Varchar;
                parameter.Direction     = ParameterDirection.Input;
                parameter.Value         = teacher.Email;
                command.Parameters.Add(parameter);
                command.CommandType = CommandType.StoredProcedure;

                NpgsqlDataReader dr = command.ExecuteReader();
                try
                {
                    while (dr.Read())
                    {
                        email              = dr.GetString(0);
                        password           = dr.GetString(1);
                        name               = dr.GetString(2);
                        lastName           = dr.GetString(3);
                        birthDate          = dr.GetDateTime(4);
                        phone              = dr.GetString(5);
                        country            = dr.GetString(6);
                        status             = dr.GetChar(7);
                        readTeacher        = new Teacher(email, password, name, lastName, birthDate, phone, country);
                        readTeacher.Status = status;
                    }
                    dr.Close();
                    tran.Commit();
                    return(readTeacher);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            catch (NpgsqlException ex2)
            {
                throw ex2;
            }
            finally
            {
                conn.Close();
            }
        }
Exemplo n.º 30
0
        public List <Student> ReadAllStudentBySectionBetweenDates(DateTime initDate, DateTime endDate, Section section)
        {
            conn = DAO.getConnection();
            Student        readStudent = new Student();
            List <Student> students    = new List <Student>();
            String         email;
            String         password;
            String         name;
            String         lastName;
            DateTime       birthDate;
            String         phone;
            String         country;
            int            gradeId;
            String         gradeName;
            Char           status;

            try
            {
                conn = DAO.getConnection();
                NpgsqlTransaction tran        = conn.BeginTransaction();
                NpgsqlCommand     command     = new NpgsqlCommand(DAOReportResource.ReadStudentsBySectionPeriodSP, conn);
                NpgsqlParameter   parameter   = new NpgsqlParameter();
                NpgsqlParameter   parameter_2 = new NpgsqlParameter();
                NpgsqlParameter   parameter_3 = new NpgsqlParameter();

                parameter.ParameterName = DAOReportResource.IniDate;
                parameter.NpgsqlDbType  = NpgsqlTypes.NpgsqlDbType.Date;
                parameter.Direction     = ParameterDirection.Input;
                parameter.Value         = initDate;
                command.Parameters.Add(parameter);


                parameter_2.ParameterName = DAOReportResource.EndDate;
                parameter_2.NpgsqlDbType  = NpgsqlTypes.NpgsqlDbType.Date;
                parameter_2.Direction     = ParameterDirection.Input;
                parameter_2.Value         = endDate;
                command.Parameters.Add(parameter_2);


                parameter_3.ParameterName = DAOReportResource.Id;
                parameter_3.NpgsqlDbType  = NpgsqlTypes.NpgsqlDbType.Integer;
                parameter_3.Direction     = ParameterDirection.Input;
                parameter_3.Value         = section.Id;
                command.Parameters.Add(parameter_3);

                command.CommandType = CommandType.StoredProcedure;

                NpgsqlDataReader dr = command.ExecuteReader();
                try
                {
                    while (dr.Read())
                    {
                        email     = dr.GetString(0);
                        password  = dr.GetString(1);
                        name      = dr.GetString(2);
                        lastName  = dr.GetString(3);
                        birthDate = dr.GetDateTime(4);
                        phone     = dr.GetString(5);
                        country   = dr.GetString(6);
                        status    = dr.GetChar(7);
                        //gradeId = dr.GetInt32(8);
                        //gradeName = dr.GetString(9);
                        Grade grade = new Grade();
                        readStudent        = new Student(email, password, name, lastName, birthDate, phone, country, grade);
                        readStudent.Status = status;
                        students.Add(readStudent);
                    }
                    dr.Close();
                    tran.Commit();
                    return(students);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            catch (NpgsqlException ex2)
            {
                throw ex2;
            }
            finally
            {
                conn.Close();
            }
        }