public _PERSONAL Buscar(int vcedper)
        {
            dbSQLConn.ConecDb_Abrir();
            _PERSONAL        usr = new _PERSONAL();
            NpgsqlDataReader Dr  = null;
            string           Sql = "SELECT " + Elementos + " FROM personal WHERE cedper = @cedper LIMIT 1";
            NpgsqlCommand    cmd = new NpgsqlCommand(Sql, dbSQLConn.Cnn);

            cmd.Parameters.AddWithValue("@cedper", vcedper);
            Dr = cmd.ExecuteReader();
            if (Dr.HasRows)
            {
                Dr.Read();
                usr = LLenar(Dr);
                Dr.Close();
                dbSQLConn.ConecDb_Close();
                return(usr);
            }
            else
            {
                Dr.Close();
                dbSQLConn.ConecDb_Close();
                return(BuscarPrimero());
            }
        }
 public Boolean Modificar(_PERSONAL clas)
 {
     if (Existe(clas.cedper))
     {
         dbSQLConn.ConecDb_Abrir();
         string Sql = "UPDATE personal SET cedper = @cedper, nomper = @nomper, apeper = @apeper, nacper = @nacper, fenper = @fenper, coddpt = @coddpt, codgco = @codgco, feiper = @feiper, feeper = @feeper, retper = @retper, staper = @staper "
                      + "WHERE cedper = @cedper";
         NpgsqlCommand cmd = new NpgsqlCommand(Sql, dbSQLConn.Cnn);
         cmd.Parameters.AddWithValue("@cedper", clas.cedper);
         cmd.Parameters.AddWithValue("@nomper", clas.nomper);
         cmd.Parameters.AddWithValue("@apeper", clas.apeper);
         cmd.Parameters.AddWithValue("@nacper", clas.nacper);
         cmd.Parameters.AddWithValue("@fenper", clas.fenper);
         cmd.Parameters.AddWithValue("@coddpt", clas.coddpt);
         cmd.Parameters.AddWithValue("@codgco", clas.codgco);
         cmd.Parameters.AddWithValue("@feiper", clas.feiper);
         cmd.Parameters.AddWithValue("@feeper", clas.feeper);
         cmd.Parameters.AddWithValue("@retper", clas.retper);
         cmd.Parameters.AddWithValue("@staper", clas.staper);
         int retVal = cmd.ExecuteNonQuery();
         dbSQLConn.ConecDb_Close();
         if (retVal == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
 public Boolean Nuevo(_PERSONAL clas)
 {
     if (!Existe(clas.cedper))
     {
         dbSQLConn.ConecDb_Abrir();
         string Sql = "INSERT INTO personal (cedper, nomper, apeper, nacper, fenper, coddpt, codgco, feiper, feeper, retper, staper) "
                      + "VALUES (@cedper, @nomper, @apeper, @nacper,  @fenper, @coddpt, @codgco, @feiper, @feeper, @retper, @staper)";
         NpgsqlCommand cmd = new NpgsqlCommand(Sql, dbSQLConn.Cnn);
         cmd.Parameters.AddWithValue("@cedper", clas.cedper);
         cmd.Parameters.AddWithValue("@nomper", clas.nomper);
         cmd.Parameters.AddWithValue("@apeper", clas.apeper);
         cmd.Parameters.AddWithValue("@nacper", clas.nacper);
         cmd.Parameters.AddWithValue("@fenper", clas.fenper);
         cmd.Parameters.AddWithValue("@coddpt", clas.coddpt);
         cmd.Parameters.AddWithValue("@codgco", clas.codgco);
         cmd.Parameters.AddWithValue("@feiper", clas.feiper);
         cmd.Parameters.AddWithValue("@feeper", clas.feeper);
         cmd.Parameters.AddWithValue("@retper", clas.retper);
         cmd.Parameters.AddWithValue("@staper", clas.staper);
         cmd.ExecuteNonQuery();
         dbSQLConn.ConecDb_Close();
         return(true);
     }
     else
     {
         return(false);
     }
 }
 private void Cmd_Cancelar_Click(object sender, EventArgs e)
 {
     Bloqueos();
     //Form activeChild = ActiveMdiChild;
     PER = FunPER.BuscarUltimo();
     Asignar();
     Lb_CodVac.Focus();
 }
 private void Llenar_Lb(int vCodigo)
 {
     PER            = FunPER.Buscar(vCodigo);
     Lb_NomPer.Text = PER.nomper;
     Lb_ApePer.Text = PER.apeper;
     Lb_CodDpt.Text = PER.coddpt.ToString().PadLeft(8, '0');;
     Lb_NomDpt.Text = FunDP.Sent_NomDpt(PER.coddpt);
     Lb_CodGru.Text = PER.codgco.ToString().PadLeft(8, '0');
     Lb_DesGco.Text = FunGCO.Sent_DesGco(PER.codgco);
     Lb_FeiPer.Text = PER.feiper.ToShortDateString();
 }
        private void Cmd_Buscar_Click(object sender, EventArgs e)
        {
            FormBUSQUEDAS f = new FormBUSQUEDAS();

            f.ListaPersonal();
            f.ShowDialog();
            if (f._CedPer != "")
            {
                PER = FunPER.Buscar(Convert.ToInt32(f._CedPer));
                Actualizar();
            }
        }
        //public Boolean FechaCumple(int vcedper)
        //{
        //    Utilitarios Util = new Utilitarios();
        //    dbSQLConn.ConecDb_Abrir();
        //    NpgsqlDataReader Dr = null;
        //    string Sql = "SELECT fenper FROM personal WHERE cedper = @cedper ORDER BY cedper ASC";
        //    NpgsqlCommand cmd = new NpgsqlCommand(Sql, dbSQLConn.Cnn);
        //    cmd.Parameters.AddWithValue("@cedper", vcedper);
        //    Dr = cmd.ExecuteReader();
        //    if (Dr.HasRows)
        //    {
        //        Dr.Read();
        //        if (Dr.GetDateTime(0).ToString("MMdd").CompareTo(Util.GetDate().ToString("MMdd")) <= 0)
        //        {
        //            Dr.Close();
        //            dbSQLConn.ConecDb_Close();
        //            return true;
        //        }
        //        else
        //        {
        //            Dr.Close();
        //            dbSQLConn.ConecDb_Close();
        //            return false;
        //        }
        //    }
        //    else
        //    {
        //        Dr.Close();
        //        dbSQLConn.ConecDb_Close();
        //        return false;
        //    }
        //}

        public _PERSONAL findById(int cedper)
        {
            dbSQLConn.ConecDb_Abrir();
            _PERSONAL        usr    = new _PERSONAL();
            NpgsqlDataReader Dr     = null;
            string           strSQL = $"SELECT {Elementos} FROM personal WHERE cedper = {cedper}";
            NpgsqlCommand    cmd    = new NpgsqlCommand(strSQL, dbSQLConn.Cnn);

            Dr = cmd.ExecuteReader();
            if (Dr.HasRows)
            {
                Dr.Read();
                usr = LLenar(Dr);
                Dr.Close();
                dbSQLConn.ConecDb_Close();
                return(usr);
            }
            Dr.Close();
            dbSQLConn.ConecDb_Close();
            return(null);
        }