private void DisplaySelectedId(ServiceReference2.EmployeeServiceClient service, int id) { try { //uses the connection to the WCF host service to extract data from the database dgdEmployeeTable.ItemsSource = from employee in service.GetEmployee() where employee.Id == id select new { Id = employee.Id, Name = employee.Name, Gender = employee.Gender, Date = employee.Birthday.ToShortDateString() }; //Moves to the form field population method and hides the button DisableSaveChangesButton(); PopulateFormFields(); } catch (Exception error) { //stores an error message for further diagnostics string errmessage = error.Message; } finally { //code should go here } }
private void DisplayAllRecords(ServiceReference2.EmployeeServiceClient service) { try { //connects to the WCF host service to extract data from the database dgdEmployeeTable.ItemsSource = from employee in service.GetEmployee() select new { Id = employee.Id, Name = employee.Name, Gender = employee.Gender, Date = employee.Birthday.ToShortDateString(), //ExtensionData = employee.ExtensionData.GetType().Name, }; DisablesCancelButton(); } catch (Exception error) { //stores an error message for further diagnostics string errmessage = error.Message; } finally { //code should go here } }
private void PopulateFormFields() { //Populates all the form property fields for editing //checks the textbox for a value if (!string.IsNullOrWhiteSpace(tbxEmplyeeid.Text)) { //extracts the data for the selected id for modyfying ServiceReference2.Employees person = theservice.GetEmployee().FirstOrDefault(x => x.Id == int.Parse(tbxEmplyeeid.Text)); //sets the properties tbxName.Text = person.Name; tbxGender.Text = person.Gender; dpkDateOfBirth.Text = person.Birthday.ToShortDateString(); } }