Esempio n. 1
0
 public static SystemModule GetSystemModuleAsObject(DataTable dt)
 {
     foreach (DataRow row in dt.Rows)
     {
         try
         {
             SystemModule o = new SystemModule();
             o.Id     = Helper.ConvertToInt(row["ID"]);
             o.Name   = row["NAME"].ToString();
             o.Code   = row["CODE"].ToString();
             o.IsUsed = Helper.ConvertToBoolean(row["IS_USED"]);
             o.Notes  = row["NOTES"].ToString();
             return(o);
         }
         catch (Exception ex)
         {
             Log.InsertEntity("SystemModule", "GetSystemModuleAsObject", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
             throw ex;
         }
     }
     return(null);
 }
Esempio n. 2
0
 public static int Update(SystemModule o)
 {
     try
     {
         string query = @"UPDATE ""SYSTEM_MODULE"" SET ""ID"" = @Id, ""NAME"" = @Name, ""CODE"" = @Code, ""IS_USED"" = @IsUsed, ""NOTES"" = @Notes WHERE ""ID"" = @Id ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@Name", DbType.String)
             {
                 Value = o.Name
             },
             new NpgsqlParameter("@Code", DbType.String)
             {
                 Value = o.Code
             },
             new NpgsqlParameter("@IsUsed", DbType.Boolean)
             {
                 Value = (object)o.IsUsed ?? DBNull.Value
             },
             new NpgsqlParameter("@Notes", DbType.String)
             {
                 Value = (object)o.Notes ?? DBNull.Value
             },
             new NpgsqlParameter("@Id", DbType.Int32)
             {
                 Value = o.Id
             }
         };
         int rowAffected = DBManager.ExecuteNonQueryCommand(query, CommandType.Text, parameters);
         AuditTable.InsertEntity("SystemModule", o.Id.ToString(), 2, DateTime.Now, 1);
         return(rowAffected);
     }
     catch (Exception ex)
     {
         Log.InsertEntity("SystemModule", "Update", 2, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }