Exemplo n.º 1
0
        protected override void Save()
        {
            try
            {
                base.CheckBusyAskCancel();
                formBusyIndicator.IsBusy = true;

                PartyService.Person person = (PartyService.Person)DataContext;
                person.FirstName   = firstNameTextBox.Text.Trim();
                person.LastName    = lastNameTextBox.Text.Trim();
                person.DateOfBirth = (DateTime)dateOfBirthPicker.SelectedDate;

                string action = "person";
                if (person.Id > 0)
                {
                    action += string.Format("/{0}", person.Id);
                }

                this.webClient =
                    app.ServicePost <PartyService.Person>(action, SaveEventHandler, person);
            }
            catch (Exception ex)
            {
                formBusyIndicator.IsBusy = false;
                app.ShowError(ex.Message);
            }
        }
Exemplo n.º 2
0
 private void NewPerson()
 {
     try
     {
         formBusyIndicator.IsBusy = true;
         PartyService.Person person     = new PartyService.Person();
         PersonForm          personForm = new PersonForm();
         personForm.DataContext = person;
         SetContent(personForm);
     }
     catch (Exception ex)
     {
         app.ShowError(ex.Message);
     }
     finally
     {
         formBusyIndicator.IsBusy = false;
     }
 }
Exemplo n.º 3
0
        void PartyLoadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            try
            {
                CheckForErrors(e);

                string returnTypeName = app.GetBusinessObjectType(e.Result);

                switch (returnTypeName)
                {
                case "Business":
                    PartyService.Business bus          = app.LoadBusinessObject <PartyService.Business>(e.Result);
                    BusinessForm          businessForm = new BusinessForm();
                    businessForm.DataContext = bus;
                    SetContent(businessForm);
                    break;

                case "Person":
                    PartyService.Person per        = app.LoadBusinessObject <PartyService.Person>(e.Result);
                    PersonForm          personForm = new PersonForm();
                    personForm.DataContext = per;
                    SetContent(personForm);
                    break;

                case "Error":
                    PartyService.Error err = app.LoadBusinessObject <PartyService.Error>(e.Result);
                    throw (new Exception(err.Message));

                default:
                    throw (new Exception("Unrecognised object type in server response"));
                }
            }
            catch (Exception ex)
            {
                app.ShowError(ex.Message);
            }
            finally
            {
                formBusyIndicator.IsBusy = false;
            }
        }
 private void NewPerson()
 {
     try
     {
         formBusyIndicator.IsBusy = true;
         PartyService.Person person = new PartyService.Person();
         PersonForm personForm = new PersonForm();
         personForm.DataContext = person;
         SetContent(personForm);
     }
     catch (Exception ex)
     {
         app.ShowError(ex.Message);
     }
     finally
     {
         formBusyIndicator.IsBusy = false;
     }
 }