示例#1
0
    //function for updating records
    void Update()
    {
        //create an instance of the staff
        PhoneClasses.clsStaffCollection StaffSystem = new PhoneClasses.clsStaffCollection();
        //validate the data on the web form
        String Error = StaffSystem.ThisStaff.Valid(txtCounty.Text, txtStreet.Text, txtPostcode.Text, txtDOB.Text, txtFirstName.Text, txtLastName.Text, txtGender.Text, txtTelephone.Text);

        //if the data is ok then add it to the object
        if (Error == "")
        {
            //find the record to update
            StaffSystem.ThisStaff.Find(StaffID);
            //get the data entered by the user
            StaffSystem.ThisStaff.County      = txtCounty.Text;
            StaffSystem.ThisStaff.FirstName   = txtFirstName.Text;
            StaffSystem.ThisStaff.LastName    = txtLastName.Text;
            StaffSystem.ThisStaff.Gender      = txtGender.Text;
            StaffSystem.ThisStaff.DateOfBirth = txtDOB.Text;
            StaffSystem.ThisStaff.Street      = txtStreet.Text;
            StaffSystem.ThisStaff.PostCode    = txtPostcode.Text;
            StaffSystem.ThisStaff.Telephone   = Convert.ToInt32(txtTelephone.Text);
            StaffSystem.ThisStaff.Active      = Active.Checked;
            //update the record
            StaffSystem.Update();
            //all done so redirect back to the main page
            Response.Redirect("DefaultStaff.aspx");
        }
        else
        {
            //report an error
            lblError.Text = "There were problems with data entered" + Error;
        }
    }
示例#2
0
 void DisplayPostCode()
 {
     //create an instance of the county collection
     PhoneClasses.clsStaffCollection Staff = new PhoneClasses.clsStaffCollection();
     //set the data source to the list of counties in the collection
     lstStaff.DataSource = Staff.StaffList;
     //set the name of the primary key
     lstStaff.DataValueField = "StaffID";
     //set the data field to display
     lstStaff.DataTextField = "PostCode";
     //bind the data to the list
     lstStaff.DataBind();
 }