Ejemplo n.º 1
0
        //constructor for the class
        public clsProductCollection()
        {
            //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 procedure
            DB.Execute("sproc_tblProduct_SelectAll");
            PopulateArray(DB);
            //get the count of records
            RecordCount = DB.Count;
            //While there are records to process
            while (Index < RecordCount)
            {
                //create a blank address
                clsProduct AProduct = new clsProduct();
                //read in the fields from the current record
                AProduct.Out_Of_Stock = Convert.ToString(DB.DataTable.Rows[Index]["Active"]);
                AProduct.Product_ID   = Convert.ToInt32(DB.DataTable.Rows[Index]["Product_ID"]);
                AProduct.Title        = Convert.ToString(DB.DataTable.Rows[Index]["Title"]);
                AProduct.Description  = Convert.ToString(DB.DataTable.Rows[Index]["Description"]);
                AProduct.Unit_Price   = Convert.ToDouble(DB.DataTable.Rows[Index]["Unit_Price"]);
                AProduct.Release_Date = Convert.ToDateTime(DB.DataTable.Rows[Index]["Release_Date"]);
                AProduct.Platform     = Convert.ToString(DB.DataTable.Rows[Index]["Platform"]);
                AProduct.Genre        = Convert.ToString(DB.DataTable.Rows[Index]["Genre"]);
                //add the record to the private data member
                mProductList.Add(AProduct);
                //point at the next record
                Index++;
            }
        }
Ejemplo n.º 2
0
        void PopulateArray(clsDataConnection DB)
        {
            //POPULATES THE 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 list
            mProductList = new List <clsProduct>();
            //while there are records to process
            while (Index < RecordCount)
            {
                //create a blank address
                clsProduct AProduct = new clsProduct();
                //read in the fields from the current record
                AProduct.Out_Of_Stock = Convert.ToString(DB.DataTable.Rows[Index]["Active"]);
                AProduct.Product_ID   = Convert.ToInt32(DB.DataTable.Rows[Index]["Product_ID"]);
                AProduct.Title        = Convert.ToString(DB.DataTable.Rows[Index]["Title"]);
                AProduct.Description  = Convert.ToString(DB.DataTable.Rows[Index]["Description"]);
                AProduct.Unit_Price   = Convert.ToDouble(DB.DataTable.Rows[Index]["Unit_Price"]);
                AProduct.Release_Date = Convert.ToDateTime(DB.DataTable.Rows[Index]["Release_Date"]);
                AProduct.Platform     = Convert.ToString(DB.DataTable.Rows[Index]["Platform"]);
                AProduct.Genre        = Convert.ToString(DB.DataTable.Rows[Index]["Genre"]);
                //add the record to the private data member
                mProductList.Add(AProduct);
                //Point at the next record
                Index++;
            }
        }