void Update() { //create an instance of the address book ShoeClasses.clsStaffCollection StaffSystem = new ShoeClasses.clsStaffCollection(); //validate the data on the web form String Error = StaffSystem.ThisStaff.Valid(txtEnrolmentDate.Text, txtDepartment.Text, txtJobTitle.Text, txtName.Text, txtExtension.Text, txtPhoneNo.Text, txtHomeAddress.Text, txtPostcode.Text, txtCity.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.EnrolmentDate = Convert.ToDateTime(txtEnrolmentDate.Text); StaffSystem.ThisStaff.Department = txtDepartment.Text; StaffSystem.ThisStaff.JobTitle = txtJobTitle.Text; StaffSystem.ThisStaff.Name = txtName.Text; StaffSystem.ThisStaff.Extension = txtExtension.Text; StaffSystem.ThisStaff.PhoneNo = txtPhoneNo.Text; StaffSystem.ThisStaff.HomeAddress = txtHomeAddress.Text; StaffSystem.ThisStaff.Postcode = txtPostcode.Text; StaffSystem.ThisStaff.City = txtCity.Text; StaffSystem.ThisStaff.Available = chkAvailable.Checked; //update the record StaffSystem.Update(); //all done so redirect back to the main page Response.Redirect("Default.aspx"); } else { //report an error lblError.Text = "There were problems with the data entered " + Error; } }
void DisplayNames() { ShoeClasses.clsStaffCollection Staff = new ShoeClasses.clsStaffCollection(); lstStaffList.DataSource = Staff.StaffList; lstStaffList.DataValueField = "staffid"; lstStaffList.DataTextField = "name"; lstStaffList.DataBind(); }
void DisplayStaff() { //create an instance of the Staff Collection ShoeClasses.clsStaffCollection Staff = new ShoeClasses.clsStaffCollection(); //set the data source to the list of staff 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(); }