Пример #1
0
        //constructor for the class
        public clsBookCollection()
        {
            //var for the index
            Int32 Index = 0;
            //var to store the record count
            Int32 RecordCount = 0;
            //object for data connection
            clsDataConnection DB = new clsDataConnection();

            //execute the stored procodure
            DB.Execute("sproc_BookTable_SelectAll");
            //get the count of records
            RecordCount = DB.Count;
            //while there are records to process
            while (Index < RecordCount)
            {
                //Create a blank Customer
                clsBook AnBook = new clsBook();
                AnBook.ISBN          = Convert.ToInt32(DB.DataTable.Rows[Index]["ISBN"]);
                AnBook.Title         = Convert.ToString(DB.DataTable.Rows[Index]["Title"]);
                AnBook.Author        = Convert.ToString(DB.DataTable.Rows[Index]["Author"]);
                AnBook.Publisher     = Convert.ToString(DB.DataTable.Rows[Index]["Publisher"]);
                AnBook.PublishedYear = Convert.ToInt32(DB.DataTable.Rows[Index]["PublishedYear"]);
                AnBook.FK_GenreID    = Convert.ToString(DB.DataTable.Rows[Index]["FK_GenreID"]);
                AnBook.EditionNo     = Convert.ToInt32(DB.DataTable.Rows[Index]["EditionNo"]);
                AnBook.ShelfNo       = Convert.ToString(DB.DataTable.Rows[Index]["ShelfNo"]);
                //add the records into a private data member
                mBookList.Add(AnBook);
                //point to the next record
                Index++;
            }
        }
Пример #2
0
        void PopulateArray(clsDataConnection DB)
        {
            //populates array list based on the data table in the parameter DB
            //var for the index
            Int32 Index = 0;
            //var to store the record count.
            Int32 RecordCount;

            //get the count of records
            RecordCount = DB.Count;
            //clear the private array lsit
            mBookList = new List <clsBook>();
            //while there are records to process
            while (Index < RecordCount)
            {
                clsBook AnBook = new clsBook();
                AnBook.ISBN          = Convert.ToInt32(DB.DataTable.Rows[Index]["ISBN"]);
                AnBook.Title         = Convert.ToString(DB.DataTable.Rows[Index]["Title"]);
                AnBook.Author        = Convert.ToString(DB.DataTable.Rows[Index]["Author"]);
                AnBook.Publisher     = Convert.ToString(DB.DataTable.Rows[Index]["Publisher"]);
                AnBook.PublishedYear = Convert.ToInt32(DB.DataTable.Rows[Index]["PublishedYear"]);
                AnBook.FK_GenreID    = Convert.ToString(DB.DataTable.Rows[Index]["FK_GenreID"]);
                AnBook.EditionNo     = Convert.ToInt32(DB.DataTable.Rows[Index]["EditionNo"]);
                AnBook.ShelfNo       = Convert.ToString(DB.DataTable.Rows[Index]["ShelfNo"]);
                //add the records into a private data member
                mBookList.Add(AnBook);
                //point to the next record
                Index++;
            }
        }