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

                //
                // See if the user wants to update are add.  The user will only be asked if the originally did a search but
                // changed one of the patient ids.
                //
                if (_Update && (comboBoxPatientId.Text != _OriginalPatientId))
                {
                    DialogResult r = Messager.ShowQuestion(this, "You searched for a patient but have changed some of the identifying information.  " +
                                                           "Would you like to update this patient with the new information? \r\n\r\nClicking No will add a new patient.",
                                                           MessageBoxButtons.YesNo);
                    _Update = r == DialogResult.Yes;
                }

                UpdatePatient();
                dlgProgresss.Title       = _Update ? "Update patient" : "Add Patient";
                dlgProgresss.Description = _Update ? "Updating..." : "Adding...";
                dlgProgresss.Action      = () =>
                {
                    if (_Update)
                    {
                        client.UpdatePatient(_OriginalPatientId, _OriginalIssuerOfPatientId, _Patient);
                    }
                    else
                    {
                        client.AddPatient(_Patient);
                    }
                };

                if (dlgProgresss.ShowDialog(this) == DialogResult.Cancel)
                {
                    if (dlgProgresss.Exception != null)
                    {
                        e.Cancel = true;
                        Messager.ShowError(this, dlgProgresss.Exception);
                    }
                }
                else
                {
                    if (_Update)
                    {
                        UpdatePatient(_OriginalPatientId, _OriginalIssuerOfPatientId, _Patient.PatientID, _Patient.IssuerOfPatientID);
                    }
                    else
                    {
                        comboBoxPatientId.Items.Add(new PatientKey()
                        {
                            PatientId = _Patient.PatientID, IssurerOfPatientId = _Patient.IssuerOfPatientID
                        });
                    }

                    comboBoxPatientId.Text = _Patient.PatientID;
                    if (_Patient != null)
                    {
                        _OriginalPatientId         = _Patient.PatientID;
                        _OriginalIssuerOfPatientId = _Patient.IssuerOfPatientID;
                    }
                    else
                    {
                        e.Cancel = true;
                        ParentWizard.Reset();
                    }
                }
            }

            base.OnWizardNext(sender, e);
        }