Example #1
0
 public void connection_PropertyChanged(object sender, Xrm.ComponentModel.PropertyChangedEventArgs e)
 {
     if(e.PropertyName == "record1roleid")
     {
         Connection update = (Connection)sender;
         Connection connectionToUpdate = new Connection();
         connectionToUpdate.ConnectionId = new Guid(update.Id);
         connectionToUpdate.Record1RoleId = update.Record1RoleId;
         OrganizationServiceProxy.BeginUpdate(connectionToUpdate, delegate(object state)
         {
             try
             {
                 OrganizationServiceProxy.EndUpdate(state);
                 ErrorMessage.SetValue(null);
             }
             catch (Exception ex)
             {
                 ErrorMessage.SetValue(ex.Message);
             }
         });
     }
 }
Example #2
0
        public void SaveCommand()
        {
            bool isValid = ((IValidatedObservable)this).IsValid();
            if (!isValid)
            {
                ((IValidatedObservable)this).Errors.ShowAllMessages(true);
                return;
            }
            IsBusy.SetValue(true);

            Connection connection = new Connection();
            connection.Record1Id = Record1Id.GetValue();
            connection.Record2Id = Record2Id.GetValue();
            connection.Record1RoleId = Record1RoleId.GetValue();
            connection.Record2RoleId = Record2RoleId.GetValue();

            OrganizationServiceProxy.BeginCreate(connection, delegate(object State)
            {
                try
                {
                    ConnectionId.SetValue(OrganizationServiceProxy.EndCreate(State));
                    OnSaveComplete(null);
                    ((IValidatedObservable)this).Errors.ShowAllMessages(false);
                }
                catch (Exception ex)
                {
                    OnSaveComplete(ex.Message);
                }
                finally
                {
                    IsBusy.SetValue(false);
                    AddNewVisible.SetValue(false);
                }
            });
        }
Example #3
0
        public void SaveCommand()
        {
            if (!((IValidatedObservable)this).IsValid())
            {
                ((IValidatedObservable)(object)this).Errors.ShowAllMessages(true);
                return;
            }

            this.IsBusy.SetValue(true);
            this.AddNewVisible.SetValue(false);

            Connection connection = new Connection();
            connection.Record1Id = Record1Id.GetValue();
            connection.Record2Id = Record2Id.GetValue();
            connection.Record1RoleId = Record1RoleId.GetValue();
            connection.Record2RoleId = Record2RoleId.GetValue();

            OrganizationServiceProxy.BeginCreate(connection,delegate(object state)
            {
                try
                {
                    ConnectionId.SetValue(OrganizationServiceProxy.EndCreate(state));
                    OnSaveComplete(null);
                    Record1Id.SetValue(null);
                    Record1RoleId.SetValue(null);
                    ((IValidatedObservable)(object)this).Errors.ShowAllMessages(false);

                }
                catch (Exception ex)
                {
                    // Something went wrong - report it
                    OnSaveComplete(ex.Message);
                }
                finally
                {
                    this.IsBusy.SetValue(false);
                }

            });
        }