Example #1
0
 public static TAdministrador GetAdministradorFromDr(SqlCeDataReader dr)
 {
     TAdministrador adm = new TAdministrador();
     adm.administradorId = dr.GetInt32(0);
     adm.nombre = dr.GetString(1);
     adm.login = dr.GetString(2);
     adm.password = dr.GetString(3);
     adm.email = dr.GetString(4);
     adm.nivel = dr.GetInt32(5);
     return adm;
 }
Example #2
0
 public async Task<string> SetAdministrador(string db, string pass, TAdministrador adm)
 {
     string res = "OK";
     if (adm == null)
     {
         return "ERROR: No se ha paso un objeto";
     }
     else
     {
         try
         {
             SqlCeConnection conn = CntFCN50.TOpen(db, pass);
             CntFCN50.SetAdministrador(adm, conn);
             CntFCN50.TClose(conn);
             return "OK";
         }
         catch (Exception ex)
         {
             return String.Format("ERROR: {0}", ex.Message);
         }
     }
 }
Example #3
0
 public static void SetAdministrador(TAdministrador adm, SqlCeConnection conn)
 {
     if (adm == null) return;
     // comprobamos si existe el registro
     TAdministrador administrador = GetTAdministrador(adm.administradorId, conn);
     string sql = "";
     if (administrador != null)
     {
         sql = @"UPDATE administradores SET nombre = '{1}', login = '******', password = '******', email = '{4}', nivel = {5}
                 WHERE administradorId = {0}";
     }
     else
     {
         sql = @"INSERT INTO administradores (administradorId, nombre, login, password, email, nivel)
                 VALUES({0},'{1}','{2}','{3}','{4}', {5})";
     }
     sql = String.Format(sql, adm.administradorId,adm.nombre, adm.login, adm.password, adm.email, adm.nivel);
     using (SqlCeCommand cmd = conn.CreateCommand())
     {
         cmd.CommandText = sql;
         int nrec = cmd.ExecuteNonQuery();
     }
 }