Ejemplo n.º 1
0
    public static TMSEmailConfig Get(System.Int32 econfigId)
    {
        DataSet        ds;
        Database       db;
        string         sqlCommand;
        DbCommand      dbCommand;
        TMSEmailConfig instance;


        instance = new TMSEmailConfig();

        db         = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspTMSEmailConfig_SELECT";
        dbCommand  = db.GetStoredProcCommand(sqlCommand, econfigId);

        // Get results.
        ds = db.ExecuteDataSet(dbCommand);
        // Verification.
        if (ds == null || ds.Tables[0].Rows.Count == 0)
        {
            throw new ApplicationException("Could not get TMSEmailConfig ID:" + econfigId.ToString() + " from Database.");
        }
        // Return results.
        ds.Tables[0].TableName = TABLE_NAME;

        instance.MapFrom(ds.Tables[0].Rows[0]);
        return(instance);
    }
Ejemplo n.º 2
0
    public static TMSEmailConfig[] Search(System.Int32?econfigId, System.String econfigHost, System.String econfigUserName, System.String econfigPassword)
    {
        DataSet   ds;
        Database  db;
        string    sqlCommand;
        DbCommand dbCommand;


        db         = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspTMSEmailConfig_SEARCH";
        dbCommand  = db.GetStoredProcCommand(sqlCommand, econfigId, econfigHost, econfigUserName, econfigPassword);

        ds = db.ExecuteDataSet(dbCommand);
        ds.Tables[0].TableName = TABLE_NAME;
        return(TMSEmailConfig.MapFrom(ds));
    }
Ejemplo n.º 3
0
    public static TMSEmailConfig[] MapFrom(DataSet ds)
    {
        List <TMSEmailConfig> objects;


        // Initialise Collection.
        objects = new List <TMSEmailConfig>();

        // Validation.
        if (ds == null)
        {
            throw new ApplicationException("Cannot map to dataset null.");
        }
        else if (ds.Tables[TABLE_NAME].Rows.Count == 0)
        {
            return(objects.ToArray());
        }

        if (ds.Tables[TABLE_NAME] == null)
        {
            throw new ApplicationException("Cannot find table [dbo].[TMS_EmailConfig] in DataSet.");
        }

        if (ds.Tables[TABLE_NAME].Rows.Count < 1)
        {
            throw new ApplicationException("Table [dbo].[TMS_EmailConfig] is empty.");
        }

        // Map DataSet to Instance.
        foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows)
        {
            TMSEmailConfig instance = new TMSEmailConfig();
            instance.MapFrom(dr);
            objects.Add(instance);
        }

        // Return collection.
        return(objects.ToArray());
    }
    public static TMSEmailConfig[] MapFrom(DataSet ds)
    {
        List<TMSEmailConfig> objects;

        // Initialise Collection.
        objects = new List<TMSEmailConfig>();

        // Validation.
        if (ds == null)
        throw new ApplicationException("Cannot map to dataset null.");
        else if (ds.Tables[TABLE_NAME].Rows.Count == 0)
        return objects.ToArray();

        if (ds.Tables[TABLE_NAME] == null)
        throw new ApplicationException("Cannot find table [dbo].[TMS_EmailConfig] in DataSet.");

        if (ds.Tables[TABLE_NAME].Rows.Count < 1)
        throw new ApplicationException("Table [dbo].[TMS_EmailConfig] is empty.");

        // Map DataSet to Instance.
        foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows)
        {
            TMSEmailConfig instance = new TMSEmailConfig();
            instance.MapFrom(dr);
            objects.Add(instance);
        }

        // Return collection.
        return objects.ToArray();
    }
    public static TMSEmailConfig Get(System.Int32 econfigId)
    {
        DataSet ds;
        Database db;
        string sqlCommand;
        DbCommand dbCommand;
        TMSEmailConfig instance;

        instance = new TMSEmailConfig();

        db = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspTMSEmailConfig_SELECT";
        dbCommand = db.GetStoredProcCommand(sqlCommand, econfigId);

        // Get results.
        ds = db.ExecuteDataSet(dbCommand);
        // Verification.
        if (ds == null || ds.Tables[0].Rows.Count == 0) throw new ApplicationException("Could not get TMSEmailConfig ID:" + econfigId.ToString()+ " from Database.");
        // Return results.
        ds.Tables[0].TableName = TABLE_NAME;

        instance.MapFrom( ds.Tables[0].Rows[0] );
        return instance;
    }