public Form1()
        {
            InitializeComponent();

            Proxies.EmployeesQueryProxyStub q = new Proxies.EmployeesQueryProxyStub();
            q.Select(q.EmployeeID, q.FirstName, q.LastName, q.HireDate, q.BirthDate, (q.LastName + ", " + q.FirstName).As("Fullname"));

            coll = svc.Employees_QueryForCollection(q);

            this.dataGrid.DataSource = coll.Collection;
        }
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection selectedRows = dataGrid.SelectedRows;

            foreach (DataGridViewRow row in selectedRows)
            {
                EmployeesProxyStub emp = row.DataBoundItem as EmployeesProxyStub;
                emp.MarkAsDeleted();
            }

            coll = svc.Employees_SaveCollection(coll);
            this.dataGrid.DataSource = coll.Collection;
        }
        void Employees_QueryForCollectionCompleted(object sender, Employees_QueryForCollectionCompletedEventArgs e)
        {
            WorkingBar.Value = 100;
            Timer.Stop();

            if (e.Result != null)
            {
                employees = e.Result;
                EmployeesDataGrid.ItemsSource = employees.Collection;
            }
            else
            {
                EmployeesDataGrid.ItemsSource = null;
            }
        }
        void Employees_QueryForCollectionCompleted(object sender, Employees_QueryForCollectionCompletedEventArgs e)
        {
            WorkingBar.Value = 100;
            Timer.Stop();

            if (e.Result != null)
            {
                employees = e.Result;
                EmployeesDataGrid.ItemsSource = employees.Collection;
            }
            else
            {
                EmployeesDataGrid.ItemsSource = null;
            }
        }
        void Employees_SaveCollectionCompleted(object sender, Employees_SaveCollectionCompletedEventArgs e)
        {
            try
            {
                WorkingBar.Value = 100;
                Timer.Stop();

                RecordsAdded = 0;

                employees = e.Result;
                EmployeesDataGrid.ItemsSource = employees.Collection;
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.StackTrace);
            }
        }
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            if (employees == null)
            {
                employees = new EmployeesCollectionProxyStub();
                EmployeesDataGrid.ItemsSource = employees.Collection;
            }

            if (RecordsAdded++ < 5)
            {
                EmployeesProxyStub newEmp = new EmployeesProxyStub();
                newEmp.FirstName = "Scott";
                newEmp.LastName  = "Schecter";

                employees.Collection.Add(newEmp);
            }
        }
        private void buttonQuery_Click(object sender, EventArgs e)
        {
            Proxies.EmployeesQueryProxyStub q = new Proxies.EmployeesQueryProxyStub("emp");

            q.Select(q.EmployeeID, q.FirstName, q.LastName, q.HireDate, q.BirthDate, (q.LastName + ", " + q.FirstName).As("Fullname"));
            q.Where(q.LastName.Like("%" + txtLastName.Text + "%"));
            q.OrderBy(q.LastName.Ascending);

            coll = svc.Employees_QueryForCollection(Proxies.EmployeesQueryProxyStub.SerializeHelper.ToXml(q));

            if (coll == null)
            {
                coll = new EmployeesCollectionProxyStub();
            }

            this.dataGrid.DataSource = coll.Collection;
        }
 private void ClearButton_Click(object sender, RoutedEventArgs e)
 {
     SearchTextBox.Text            = "";
     employees                     = null;
     EmployeesDataGrid.ItemsSource = null;
 }
 private void ClearButton_Click(object sender, RoutedEventArgs e)
 {
     SearchTextBox.Text = "";
     employees = null;
     EmployeesDataGrid.ItemsSource = null;
 }
        void Employees_SaveCollectionCompleted(object sender, Employees_SaveCollectionCompletedEventArgs e)
        {
            try
            {
                WorkingBar.Value = 100;
                Timer.Stop();

                RecordsAdded = 0;

                employees = e.Result;
                EmployeesDataGrid.ItemsSource = employees.Collection;
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.StackTrace);
            }
        }
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            if (employees == null)
            {
                employees = new EmployeesCollectionProxyStub();
                EmployeesDataGrid.ItemsSource = employees.Collection;
            }

            if (RecordsAdded++ < 5)
            {
                EmployeesProxyStub newEmp = new EmployeesProxyStub();
                newEmp.FirstName = "Scott";
                newEmp.LastName = "Schecter";

                employees.Collection.Add(newEmp);
            }
        }
 private void buttonSave_Click(object sender, EventArgs e)
 {
     coll = svc.Employees_SaveCollection(coll);
     this.dataGrid.DataSource = coll.Collection;
 }