public Page1() { InitializeComponent(); theservice = CreateEmployeeService(); DisplayAllRecords(theservice); SetTheFocus(); }
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 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 ServiceReference2.EmployeeServiceClient CreateEmployeeService() { //creates a client service to connect to the WCF host service ServiceReference2.EmployeeServiceClient service = new ServiceReference2.EmployeeServiceClient(); //returns to service to the caller return(service); }
private void btnStartService_Click(object sender, RoutedEventArgs e) { theservice = CreateEmployeeService(); DisplayAllRecords(theservice); }