Exemplo n.º 1
0
        //constructor for the class
        public clsContractCollection()
        {
            //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_tblContract_SelectAll");
            //get the count of records
            RecordCount = DB.Count;
            //while there are records to process
            while (Index < RecordCount)
            {
                //create a blank Contract
                clsContract AnContract = new clsContract();
                //read in the field from the current record
                AnContract.ContractNo          = Convert.ToInt32(DB.DataTable.Rows[Index]["ContractNo"]);
                AnContract.CustomerNo          = Convert.ToInt32(DB.DataTable.Rows[Index]["CustomerNo"]);
                AnContract.ContractType        = Convert.ToString(DB.DataTable.Rows[Index]["ContractType"]);
                AnContract.PhoneID             = Convert.ToInt32(DB.DataTable.Rows[Index]["PhoneID"]);
                AnContract.StartDateOfContract = Convert.ToDateTime(DB.DataTable.Rows[Index]["StartDateOfContract"]);
                AnContract.EndDateOfContract   = Convert.ToDateTime(DB.DataTable.Rows[Index]["EndDateOfContract"]);

                //add the records into a private data member
                mContractList.Add(AnContract);
                //Point to the next record
                Index++;
            }
        }
Exemplo n.º 2
0
        private 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
            mContractList = new List <clsContract>();
            //while there are records to process
            while (Index < RecordCount)
            {
                //Create a blank Contract
                clsContract AnContract = new clsContract();
                AnContract.ContractNo          = Convert.ToInt32(DB.DataTable.Rows[Index]["ContractNo"]);
                AnContract.CustomerNo          = Convert.ToInt32(DB.DataTable.Rows[Index]["CustomerNo"]);
                AnContract.ContractType        = Convert.ToString(DB.DataTable.Rows[Index]["ContractType"]);
                AnContract.PhoneID             = Convert.ToInt32(DB.DataTable.Rows[Index]["PhoneID"]);
                AnContract.StartDateOfContract = Convert.ToDateTime(DB.DataTable.Rows[Index]["StartDateOfContract"]);
                AnContract.EndDateOfContract   = Convert.ToDateTime(DB.DataTable.Rows[Index]["EndDateOfContract"]);

                //add the records into a private data member
                mContractList.Add(AnContract);
                //point to the next record
                Index++;
            }
        }