示例#1
0
    public static TMSSchoolSubCategory Get(System.Int64 sscSubCategoryId)
    {
        DataSet              ds;
        Database             db;
        string               sqlCommand;
        DbCommand            dbCommand;
        TMSSchoolSubCategory instance;


        instance = new TMSSchoolSubCategory();

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

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

        instance.MapFrom(ds.Tables[0].Rows[0]);
        return(instance);
    }
示例#2
0
    public static TMSSchoolSubCategory[] Search(System.Int64?sscSubCategoryId, System.Int64?sscCategoryId, System.String sscSubCategoryName, System.DateTime?sscDate, System.Int32?sscStatus)
    {
        DataSet   ds;
        Database  db;
        string    sqlCommand;
        DbCommand dbCommand;


        db         = DatabaseFactory.CreateDatabase();
        sqlCommand = "[dbo].gspTMSSchoolSubCategory_SEARCH";
        dbCommand  = db.GetStoredProcCommand(sqlCommand, sscSubCategoryId, sscCategoryId, sscSubCategoryName, sscDate, sscStatus);

        ds = db.ExecuteDataSet(dbCommand);
        ds.Tables[0].TableName = TABLE_NAME;
        return(TMSSchoolSubCategory.MapFrom(ds));
    }
示例#3
0
    public static TMSSchoolSubCategory[] MapFrom(DataSet ds)
    {
        List <TMSSchoolSubCategory> objects;


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

        // 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_SchoolSubCategory] in DataSet.");
        }

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

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

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

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

        // 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_SchoolSubCategory] in DataSet.");

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

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

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

        instance = new TMSSchoolSubCategory();

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

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

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