Esempio n. 1
0
        public override void OnWizardNext(object sender, WizardPageEventArgs e)
        {
            if (!IsValid())
            {
                e.Cancel = true;
                return;
            }
            else
            {
                ProgressDialog      dlgProgresss = new ProgressDialog();
                BrokerServiceClient client       = GetWizard().Tag as BrokerServiceClient;

                if (_Update && comboBoxRequestedId.Text != _OriginalRequestedProcedureId)
                {
                    DialogResult r = Messager.ShowQuestion(this, "You searched for a requested procedure but have changed some of the identifying information.  " +
                                                           "Would you like to update this requested procedure with the new information?\r\n\r\nClicking No will add a new requested procedure.",
                                                           MessageBoxButtons.YesNo);
                    _Update = r == DialogResult.Yes;
                }

                UpdateRequestedProcedure();
                dlgProgresss.Title       = _Update ? "Update Requested Procedure" : "Add Requested Procedure";
                dlgProgresss.Description = _Update ? "Updating..." : "Adding...";
                dlgProgresss.Action      = () =>
                {
                    if (_Update)
                    {
                        client.UpdateRequestedProcedure(_ImagingServiceRequest.AccessionNumber, _OriginalRequestedProcedureId, RequestedProcedure);
                    }

                    else
                    {
                        client.AddRequestedProcedure(_ImagingServiceRequest.AccessionNumber, RequestedProcedure);
                    }
                };

                if (dlgProgresss.ShowDialog(this) == DialogResult.Cancel)
                {
                    if (dlgProgresss.Exception != null)
                    {
                        e.Cancel = true;
                        Messager.ShowError(this, dlgProgresss.Exception);
                    }
                }
                else
                {
                    if (_Update)
                    {
                        int index = comboBoxRequestedId.Items.IndexOf(_OriginalRequestedProcedureId);

                        if (index != -1)
                        {
                            comboBoxRequestedId.Items.Remove(_OriginalRequestedProcedureId);
                        }
                    }
                    comboBoxRequestedId.Items.Add(RequestedProcedure.RequestedProcedureID);
                    comboBoxRequestedId.Text      = RequestedProcedure.RequestedProcedureID;
                    _OriginalRequestedProcedureId = RequestedProcedure.RequestedProcedureID;
                }
            }

            base.OnWizardNext(sender, e);
        }