Пример #1
0
        //constructor for the class
        public clsCustomersCollection()
        {
            //create the items of test data
            clsCustomers TestItem = new clsCustomers();

            //set its properties
            TestItem.CustomerNo = 1;
            TestItem.FirstName  = "John";
            TestItem.LastName   = "Smith";
            TestItem.DOB        = DateTime.Now.Date.AddYears(-18);
            TestItem.Email      = "*****@*****.**";
            TestItem.PhoneNo    = "07865432345";
            TestItem.DateAdded  = DateTime.Now.Date;
            //add the time to the test list
            mCustomerList.Add(TestItem);
            //reinstialise the object for some new data
            TestItem = new clsCustomers();
            //set its properites
            TestItem.CustomerNo = 10;
            TestItem.FirstName  = "Sarah";
            TestItem.LastName   = "Green";
            TestItem.DOB        = DateTime.Now.Date.AddYears(-18);
            TestItem.Email      = "*****@*****.**";
            TestItem.PhoneNo    = "07867322345";
            TestItem.DateAdded  = DateTime.Now.Date;
            //add the item to the test list
            mCustomerList.Add(TestItem);
        }
Пример #2
0
        private 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
            mCustomerList = new List <clsCustomers>();
            //while there are records to process
            while (Index < RecordCount)
            {
                //create a blank address
                clsCustomers AnCustomer = new clsCustomers();
                //read in the fields from the current record
                AnCustomer.CustomerNo = Convert.ToInt32(DB.DataTable.Rows[Index]["CustomerNo"]);
                AnCustomer.FirstName  = Convert.ToString(DB.DataTable.Rows[Index]["FirstName"]);
                AnCustomer.Surname    = Convert.ToString(DB.DataTable.Rows[Index]["Surname"]);
                AnCustomer.Address1   = Convert.ToString(DB.DataTable.Rows[Index]["Address1"]);
                AnCustomer.Address2   = Convert.ToString(DB.DataTable.Rows[Index]["Address2"]);
                AnCustomer.Email      = Convert.ToString(DB.DataTable.Rows[Index]["Email"]);
                //add the record to the private data mamber
                mCustomerList.Add(AnCustomer);
                //point at the next record
                Index++;
            }
        }