Пример #1
0
 public Page1()
 {
     InitializeComponent();
     theservice = CreateEmployeeService();
     DisplayAllRecords(theservice);
     SetTheFocus();
 }
Пример #2
0
 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
     }
 }
Пример #3
0
        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
            }
        }
Пример #4
0
        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);
        }
Пример #5
0
 private void btnStartService_Click(object sender, RoutedEventArgs e)
 {
     theservice = CreateEmployeeService();
     DisplayAllRecords(theservice);
 }