Beispiel #1
0
        public void getPersona(int ID)
        {
            string sqlSelect = "SELECT * FROM PERSONAS "
                               + " WHERE idPersonas ='" + ID + "'";

            Persistence.Database oDatos;
            oDatos = new Persistence.Database();
            oDatos.conectar();
            oDatos.Ejecutar_Consulta(sqlSelect);
            oDatos.Desconectar();
            this.Apellido         = oDatos.Tabla.Rows[0].ItemArray[1].ToString();
            this.Nombre           = oDatos.Tabla.Rows[0].ItemArray[2].ToString();
            this.NumeroDocumento  = int.Parse(oDatos.Tabla.Rows[0].ItemArray[4].ToString());
            this.idTiposDocumento = int.Parse(oDatos.Tabla.Rows[0].ItemArray[3].ToString());
            this.Activo           = bool.Parse(oDatos.Tabla.Rows[0].ItemArray[5].ToString());
            this.idRolesPersonas  = int.Parse(oDatos.Tabla.Rows[0].ItemArray[6].ToString());
            this.Dedos            = int.Parse(oDatos.Tabla.Rows[0].ItemArray[12].ToString());
            this.FechaAlta        = DateTime.Parse(oDatos.Tabla.Rows[0].ItemArray[13].ToString());
            if (oDatos.Tabla.Rows[0].ItemArray[14].ToString() != "")
            {
                this.FechaBaja = DateTime.Parse(oDatos.Tabla.Rows[0].ItemArray[14].ToString());
            }
            this.FechaNacimiento    = DateTime.Parse(oDatos.Tabla.Rows[0].ItemArray[15].ToString());
            this.Celular            = oDatos.Tabla.Rows[0].ItemArray[16].ToString();
            this.Masculino          = bool.Parse(oDatos.Tabla.Rows[0].ItemArray[17].ToString());
            this.Administrador      = bool.Parse(oDatos.Tabla.Rows[0].ItemArray[18].ToString());
            this.idNivelesSeguridad = int.Parse(oDatos.Tabla.Rows[0].ItemArray[19].ToString());
        }
Beispiel #2
0
        //private void btnLeerDispositivo_Click(object sender, EventArgs e)
        //{
        //    _Dispositivo.LeerLogIngresosExitosos();
        //   int ID = ((LogBioStar)_Dispositivo.Log[_Dispositivo.Log.Count - 1]).UsuarioID;

        //    persona _persona = new persona();
        //    _persona.getPersona(ID);
        //    string apellido = _persona.Apellido;
        //    edtNombreApellido.Text = _persona.Apellido + " " + _persona.Nombre;

        //    Persistence.Database oDatos;
        //    oDatos = new Persistence.Database();
        //    oDatos.conectar();
        //    oDatos.Ejecutar_Consulta("SELECT TipoDocumento FROM TiposDocumento WHERE idTiposDocumento = " + _persona.idTiposDocumento);
        //    edtTipoNumero.Text = oDatos.Tabla.Rows[0].ItemArray[0].ToString() + " N° " + _persona.NumeroDocumento.ToString();
        //    oDatos.Desconectar();
        //    oDatos = new Persistence.Database();
        //    oDatos.conectar();
        //    oDatos.Ejecutar_Consulta("SELECT RolPersona FROM RolesPersonas WHERE idRolesPersonas = " + _persona.idRolesPersonas);
        //    edtRol.Text = oDatos.Tabla.Rows[0].ItemArray[0].ToString();
        //    oDatos.Desconectar();
        //    _ingresos.idPersonas = ID;
        //    MemoryStream mem = _persona.ImagenPersonaPorId(_ingresos.idPersonas);
        //    PbxImagen.Image = Image.FromStream(mem);
        //}



        public void modificarIngreso(int idPersonas, int idIngresos)

        {
            persona _persona = new persona();

            _persona.getPersona(idPersonas);
            string apellido = _persona.Apellido;

            edtNombreApellido.Text = _persona.Apellido + " " + _persona.Nombre;

            Persistence.Database oDatos;
            oDatos = new Persistence.Database();
            oDatos.conectar();
            oDatos.Ejecutar_Consulta("SELECT TipoDocumento FROM TiposDocumento WHERE idTiposDocumento = " + _persona.idTiposDocumento);
            edtTipoNumero.Text = oDatos.Tabla.Rows[0].ItemArray[0].ToString() + " N° " + _persona.NumeroDocumento.ToString();
            oDatos.Desconectar();
            oDatos = new Persistence.Database();
            oDatos.conectar();
            oDatos.Ejecutar_Consulta("SELECT RolPersona FROM RolesPersonas WHERE idRolesPersonas = " + _persona.idRolesPersonas);
            edtRol.Text = oDatos.Tabla.Rows[0].ItemArray[0].ToString();
            oDatos.Desconectar();
            MemoryStream mem = _persona.ImagenPersonaPorId(idPersonas);

            PbxImagen.Image = Image.FromStream(mem);

            _ingresos.getIngreso(idIngresos);
            edtLote.Text           = _ingresos.Lote;
            edtTiempoPersonal.Text = _ingresos.TiempoPersonal.ToString();
            edtVehiculo.Text       = _ingresos.Vehiculo;
            edtPertenecias.Text    = _ingresos.Pertenencias;
        }
Beispiel #3
0
        public int Alta()
        {
            string huella1, huella2, fechaBaja;

            if (this.Dedo1Huella == null)
            {
                huella1 = "null";
            }
            else
            {
                huella1 = "'" + this.Dedo1Huella.ToString() + "'";
            }
            if (this.Dedo2Huella == null)
            {
                huella2 = "null";
            }
            else
            {
                huella2 = "'" + this.Dedo2Huella.ToString() + "'";
            }
            if (this.FechaBaja == null)
            {
                fechaBaja = "null";
            }
            else
            {
                fechaBaja = "'" + DateToSQL(this.FechaBaja) + "'";
            }
            string sqlsentencia = "INSERT INTO Personas"
                                  + "(nombre, imagen, apellido, idRolesPersonas, idTiposDocumento, FechaNacimiento, FechaBaja, FechaAlta, Celular, Dedo1Huella, Dedo2Huella, " +
                                  "Dedo1Checksum, Dedo2Checksum, Dedos, Activo, Masculino, Administrador, idNivelesSeguridad, NumeroDocumento) "
                                  + "values ("
                                  + " '" + this.Nombre + "',"
                                  + " @Imagen,"
                                  + " '" + this.Apellido + "',"
                                  + " '" + this.idRolesPersonas + "',"
                                  + " '" + this.idTiposDocumento + "',"
                                  + " '" + this.DateToSQL(FechaNacimiento) + "',"
                                  + " " + fechaBaja + ","
                                  + " '" + this.DateToSQL(FechaAlta) + "',"
                                  + " '" + this.Celular + "',"
                                  + " " + huella1 + ","
                                  + " " + huella2 + ","
                                  + " '" + this.Dedo1Checksum + "',"
                                  + " '" + this.Dedo2Checksum + "',"
                                  + " '" + this.Dedos + "',"
                                  + " '" + this.Activo + "',"
                                  + " '" + this.Masculino + "',"
                                  + " '" + this.Administrador + "',"
                                  + " '" + this.idNivelesSeguridad + "',"
                                  + " '" + this.NumeroDocumento + " ')";

            Persistence.Database oDatos = new Persistence.Database();
            oDatos.conectar();
            int ID = oDatos.Ejecutar_Sentencia_Imagen(sqlsentencia, this.Imagen);

            oDatos.Desconectar();
            return(ID);
        }
Beispiel #4
0
        public void Modificacion()
        {
            string huella1, huella2, fechaBaja;

            if (this.Dedo1Huella == null)
            {
                huella1 = "null";
            }
            else
            {
                huella1 = "'" + this.Dedo1Huella.ToString() + "'";
            }
            if (this.Dedo2Huella == null)
            {
                huella2 = "null";
            }
            else
            {
                huella2 = "'" + this.Dedo2Huella.ToString() + "'";
            }
            if (this.FechaBaja == null)
            {
                fechaBaja = "null";
            }
            else
            {
                fechaBaja = "'" + DateToSQL(this.FechaBaja) + "'";
            }
            string sqlsentencia = "UPDATE Personas SET "
                                  + "nombre = " + this.Nombre + ","
                                  + "imagen = @Imagen,"
                                  + "apellido = " + this.Apellido + ","
                                  + "idRolesPersonas = " + this.idRolesPersonas + ","
                                  + "idTiposDocumento = " + this.idTiposDocumento + ","
                                  + "FechaNacimiento = " + this.FechaNacimiento + ","
                                  + "FechaBaja = " + this.FechaBaja + ","
                                  + "FechaAlta = " + this.FechaAlta + ","
                                  + "Celular = " + this.Celular + ","
                                  + "Dedo1Huella = " + this.Dedo1Huella + ","
                                  + "Dedo2Huella = " + this.Dedo2Huella + ","
                                  + "Dedo1Checksum = " + this.Dedo1Checksum + ","
                                  + "Dedo2Checksum = " + this.Dedo2Checksum + ","
                                  + "Dedos = " + this.Dedos + ","
                                  + "Activo = " + this.Activo + ","
                                  + "Masculino = " + this.Masculino + ","
                                  + "Administrador = " + this.Administrador + ","
                                  + "idNivelesSeguridad = " + this.idNivelesSeguridad + ","
                                  + "NumeroDocumento = " + this.NumeroDocumento
                                  + " WHERE idPersonas = " + this.idPersonas;

            Persistence.Database oDatos = new Persistence.Database();
            oDatos.conectar();
            oDatos.Desconectar();
            oDatos.Ejecutar_Sentencia_Imagen(sqlsentencia, this.Imagen);
        }
Beispiel #5
0
        public MemoryStream ImagenPersonaPorId(int ID)
        {
            string sqlSelect = "SELECT imagen FROM PERSONAS "
                               + " WHERE idPersonas ='" + ID + "'";

            Persistence.Database oDatos;
            oDatos = new Persistence.Database();
            oDatos.conectar();
            return(oDatos.Ejecutar_Consulta_Imagen(sqlSelect));

            oDatos.Desconectar();
        }
Beispiel #6
0
        public DataTable buscarPersonaPorDocumento(persona _persona)
        {
            string sqlSelect = "SELECT Apellido, Nombre, TipoDocumento, RolPersona, idPersonas FROM qPersonas "
                               + " WHERE idTiposDocumento ='" + this.idTiposDocumento + "'"
                               + " and NumeroDocumento ='" + this.NumeroDocumento + "'";

            Persistence.Database oDatos;
            oDatos = new Persistence.Database();
            oDatos.conectar();
            oDatos.Ejecutar_Consulta(sqlSelect);
            return(oDatos.Tabla);

            oDatos.Desconectar();
        }
Beispiel #7
0
        public int Alta()
        {
            string fechaIngreso, fechaEgreso;

            if (this.FechaIngreso == null)
            {
                fechaIngreso = "null";
            }
            else
            {
                fechaIngreso = this.FechaIngreso.ToString();
            }
            if (this.FechaEgreso == null)
            {
                fechaEgreso = "null";
            }
            else
            {
                fechaEgreso = this.FechaEgreso.ToString();
            }
            string sqlsentencia = "INSERT INTO Ingresos"
                                  + "(activo, vehiculo, pertenencias, codigoTarjeta, tiempoExtendido, tiempoPersonal, idUbicacionesEgreso, idUbicacionesIngreso, fechaIngreso, fechaEgreso, Lote, idPersonas)"
                                  + "values ("
                                  + " '" + this.Activo + "',"
                                  + " '" + this.Vehiculo + "',"
                                  + " '" + this.Pertenencias + "',"
                                  + " '" + this.CodigoTarjeta + "',"
                                  + " '" + this.TiempoExtendido + "',"
                                  + " '" + this.TiempoPersonal + "',"
                                  + " '" + this.idUbicacionesEgreso + "',"
                                  + " '" + this.idUbicacionesIngreso + "',"
                                  + " " + Funciones.FechaASQL(this.FechaIngreso) + ","
                                  + " " + Funciones.FechaASQL(this.FechaEgreso) + ","
                                  + " '" + this.Lote + "',"
                                  + " '" + this.idPersonas + "')";

            Persistence.Database oDatos = new Persistence.Database();
            oDatos.conectar();
            int ID = oDatos.Ejecutar_Sentencia(sqlsentencia);

            oDatos.Desconectar();
            return(ID);
        }
Beispiel #8
0
        private void AgregarIngresos()
        {
            DispositivoBioStar Dispositivo = (DispositivoBioStar)_BioStar.Dispositivos[0];

            Dispositivo.LeerLogIngresosEgresosExitosos();

            Persistence.Database oDatos = new Persistence.Database();
            oDatos.conectar();
            oDatos.Ejecutar_Consulta("SELECT UltimaFechaLog FROM Configuracion");
            DateTime UltimoLog = new DateTime(1970, 1, 1);

            if (oDatos.Tabla.Rows.Count > 0)
            {
                UltimoLog = DateTime.Parse(oDatos.Tabla.Rows[0].ItemArray[0].ToString());
            }
            oDatos.Desconectar();


            DateTime UltimoLogNuevo = new DateTime(1970, 1, 1);

            oDatos.conectar();
            foreach (LogBioStar Registro in Dispositivo.Log)
            {
                if ((Registro.FechaHora > UltimoLog) && (Registro.EventoTNA == 0))
                {
                    oDatos.Ejecutar_Sentencia("INSERT INTO Ingresos (idPersonas, Activo, FechaIngreso, idUbicacionesIngreso, idUbicacionesEgreso) VALUES (" +
                                              Registro.UsuarioID + ", 'True', " + BioSoft.Funciones.FechaASQL(Registro.FechaHora) + "," + 1 + "," + 1 + ")");
                    if (Registro.FechaHora > UltimoLogNuevo)
                    {
                        UltimoLogNuevo = Registro.FechaHora;
                    }
                }
            }
            oDatos.Desconectar();


            if (UltimoLogNuevo.Year > 1970)
            {
                oDatos.conectar();
                oDatos.Ejecutar_Sentencia("UPDATE Configuracion SET UltimaFechaLog = " + BioSoft.Funciones.FechaASQL(UltimoLogNuevo));
                oDatos.Desconectar();
            }
        }
Beispiel #9
0
 public void Editar(BioSoft.DispositivoBioStar Dispositivo, int ID)
 {
     _Dispositivo = Dispositivo;
     Persistence.Database db = new Persistence.Database();
     db.conectar();
     System.IO.MemoryStream mem = db.Ejecutar_Consulta_Imagen("SELECT Imagen FROM Personas WHERE idPersonas = " + ID);
     PbxImage2.Image = Image.FromStream(mem);
     _Persona.getPersona(ID);
     edtApellido.Text = _Persona.Apellido;
     edtNombre.Text   = _Persona.Nombre;
     cmbTipoDocumento.SelectedValue = _Persona.idTiposDocumento;
     edtDocumento.Text      = _Persona.NumeroDocumento.ToString();
     edtCelular.Text        = _Persona.Celular;
     edtFechaAlta.Value     = _Persona.FechaAlta;
     chkNuncaExpira.Checked = false;
     if (_Persona.FechaAlta != null)
     {
         edtFechaBaja.Value = _Persona.FechaBaja;
     }
     edtFechaNacimiento.Value = _Persona.FechaNacimiento;
     if (_Persona.Masculino)
     {
         rbSexo1.Checked = true;
     }
     else
     {
         rbSexo2.Checked = true;
     }
     if (_Persona.Administrador)
     {
         rbAdministrador.Checked = true;
     }
     else
     {
         rbUsuario.Checked = true;
     }
     cmbNivelSeguridad.SelectedValue = _Persona.idNivelesSeguridad;
     cmbRolPersona.SelectedValue     = _Persona.idRolesPersonas;
 }
Beispiel #10
0
        public void getIngreso(int ID)
        {
            string sqlSelect = "SELECT * FROM Ingresos "
                               + " WHERE idIngresos ='" + ID + "'";

            Persistence.Database oDatos;
            oDatos = new Persistence.Database();
            oDatos.conectar();
            oDatos.Ejecutar_Consulta(sqlSelect);
            oDatos.Desconectar();
            this.idIngresos    = int.Parse(oDatos.Tabla.Rows[0].ItemArray[0].ToString());
            this.idPersonas    = int.Parse(oDatos.Tabla.Rows[0].ItemArray[1].ToString());
            this.CodigoTarjeta = (oDatos.Tabla.Rows[0].ItemArray[2].ToString());
            if (oDatos.Tabla.Rows[0].ItemArray[3].ToString() != "")
            {
                this.TiempoPersonal = int.Parse(oDatos.Tabla.Rows[0].ItemArray[3].ToString());
            }
            if (oDatos.Tabla.Rows[0].ItemArray[4].ToString() != "")
            {
                this.TiempoExtendido = int.Parse(oDatos.Tabla.Rows[0].ItemArray[4].ToString());
            }
            this.Activo = bool.Parse(oDatos.Tabla.Rows[0].ItemArray[5].ToString());
            if (oDatos.Tabla.Rows[0].ItemArray[6].ToString() != "")
            {
                this.FechaIngreso = DateTime.Parse(oDatos.Tabla.Rows[0].ItemArray[6].ToString());
            }
            this.idUbicacionesIngreso = int.Parse(oDatos.Tabla.Rows[0].ItemArray[7].ToString());
            if (oDatos.Tabla.Rows[0].ItemArray[8].ToString() != "")
            {
                this.idUbicacionesEgreso = int.Parse(oDatos.Tabla.Rows[0].ItemArray[8].ToString());
            }
            this.Pertenencias = (oDatos.Tabla.Rows[0].ItemArray[9].ToString());
            this.Vehiculo     = (oDatos.Tabla.Rows[0].ItemArray[10].ToString());
            this.Lote         = (oDatos.Tabla.Rows[0].ItemArray[12].ToString());
            if (oDatos.Tabla.Rows[0].ItemArray[13].ToString() != "")
            {
                this.FechaEgreso = DateTime.Parse(oDatos.Tabla.Rows[0].ItemArray[13].ToString());
            }
        }
Beispiel #11
0
        public void Modificacion()
        {
            string sqlsentencia = "UPDATE Ingresos SET "
                                  + "Activo = '" + this.Activo + "',"
                                  + "Vehiculo = '" + this.Vehiculo + "',"
                                  + "Pertenencias = '" + this.Pertenencias + "',"
                                  + "CodigoTarjeta = '" + this.CodigoTarjeta + "',"
                                  + "TiempoExtendido = '" + this.TiempoExtendido + "',"
                                  + "TiempoPersonal = '" + this.TiempoPersonal + "',"
                                  + "idUbicacionesEgreso = '" + this.idUbicacionesEgreso + "',"
                                  + "idUbicacionesIngreso =  '" + this.idUbicacionesIngreso + "',"
                                  + "fechaIngreso =  " + Funciones.FechaASQL(this.FechaIngreso) + ","
                                  + "fechaEgreso =  " + Funciones.FechaASQL(this.FechaEgreso) + ","
                                  + "Lote = '" + this.Lote + "',"
                                  + "idPersonas = '" + this.idPersonas + "'"
                                  + " WHERE idIngresos = " + this.idIngresos;

            Persistence.Database oDatos = new Persistence.Database();
            oDatos.conectar();
            oDatos.Ejecutar_Sentencia(sqlsentencia);
            oDatos.Desconectar();
        }