Exemple #1
0
    void DisplayEmployees()
    {
        //THE REDLINE UNDER MYCLASSLIBARY, APPRENLTY THAT IS OK TILL PAGE 38 AND IT SHOULD RIGHT NOW WORK  BUT DONT KNOW
        //creating an instance of the class employee collection
        MyClassLibrary.clsEmployeeCollection Employees = new MyClassLibrary.clsEmployeeCollection();
        //set the data source to the list of the counties in the collectiom

        //lstEmployees.DataSource = Employees.EmployeeList;
        //set the name of the primary filed
        lstEmp.DataValueField = "EmployeeNo";
        lstEmp.DataValueField = "EmployeeFirstName";
        //bind the data yo the list
        lstEmp.DataBind();
    }
        void Add()
        {
            //create an instance of the employee
            clsEmployeeCollection EmployeeGroup = new clsEmployeeCollection();
            //validate the data on the web form
            string Error = EmployeeGroup.ThisEmployee.Valid(txtEAFA.Text, txtEAEmployeeSurName.Text, txtEAEmployeeContactNo.Text, txtEAEmployeeEmail.Text);

            //if the data is ok then add it to the object
            if (Error == "")
            {
                //get the data entered by the user
                EmployeeGroup.ThisEmployee.EmployeeFirstName = txtEAFA.Text;
                EmployeeGroup.ThisEmployee.EmployeeSurName   = txtEAEmployeeSurName.Text;
                EmployeeGroup.ThisEmployee.EmployeeContactNo = txtEAEmployeeContactNo.Text;
                EmployeeGroup.ThisEmployee.EmployeeEmail     = txtEAEmployeeEmail.Text;

                EmployeeGroup.Add();
            }
            else
            {
                //REPOR AN ERROR
                lblEAError.Text = "There wwhere problems with the data entered" + Error;
            }
        }