private void OpenPartnerFindForLocation()
        {
            TPartnerFindScreen frmPF;
            TLocationPK LocationPK;

            this.Cursor = Cursors.WaitCursor;
            LocationPK = FLogic.DetermineCurrentLocationPK();
            frmPF = new TPartnerFindScreen(FPetraUtilsObject.GetForm());
            frmPF.SetParameters(true, LocationPK.LocationKey);
            frmPF.Show();
            this.Cursor = Cursors.Default;
        }
示例#2
0
        /// <summary>
        /// Opens the Partner Find screen (or activates it in case a non-modal instance was already open and
        /// ARestrictToPartnerClasses is null). If ARestrictToPartnerClasses isn't null then the screen is opened modally.
        /// </summary>
        /// <remarks>
        /// For NUnit tests that just try to open the Partner Find screen but which don't instantiate a Main Form
        /// we need to ignore the <paramref name="AParentForm" /> Argument as it will be null in those cases!
        /// </remarks>
        /// <returns>void</returns>
        public static void FindPartnerOfClass(Form AParentForm,
            string ARestrictToPartnerClasses = null,
            TPartnerEditTabPageEnum APreferredInitialTabPage = TPartnerEditTabPageEnum.petpAddresses)
        {
            if (ARestrictToPartnerClasses == null)
            {
                // No Cursor change if run from within NUnit Test without Main Form instance...
                if (AParentForm != null)
                {
                    AParentForm.Cursor = Cursors.WaitCursor;
                }

                TPartnerFindScreen PartnerFindForm = new TPartnerFindScreen(AParentForm);
                PartnerFindForm.SetParameters(false, -1);
                PartnerFindForm.Show();

                // No Cursor change if run from within NUnit Test without Main Form instance...
                if (AParentForm != null)
                {
                    AParentForm.Cursor = Cursors.Default;
                }
            }
            else
            {
                long PartnerKey;
                string ShortName;
                TPartnerClass? PartnerClass;
                TLocationPK LocationPK;

                if (TPartnerFindScreenManager.OpenModalForm(ARestrictToPartnerClasses, out PartnerKey, out ShortName, out PartnerClass,
                        out LocationPK, AParentForm))
                {
                    // Open the Partner Edit screen
                    TFrmPartnerEdit PartnerEditForm;

                    // No Cursor change if run from within NUnit Test without Main Form instance...
                    if (AParentForm != null)
                    {
                        AParentForm.Cursor = Cursors.WaitCursor;
                    }

                    PartnerEditForm = new TFrmPartnerEdit(AParentForm);

                    if (APreferredInitialTabPage == TPartnerEditTabPageEnum.petpAddresses)
                    {
                        PartnerEditForm.SetParameters(TScreenMode.smEdit, PartnerKey, LocationPK.SiteKey, LocationPK.LocationKey);
                    }
                    else
                    {
                        PartnerEditForm.SetParameters(TScreenMode.smEdit, PartnerKey, APreferredInitialTabPage);
                    }

                    PartnerEditForm.Show();

                    if (ARestrictToPartnerClasses.Split(new Char[] { (',') })[0] == "PERSON")
                    {
                        TUserDefaults.SetDefault(TUserDefaults.USERDEFAULT_LASTPERSONPERSONNEL, PartnerKey);
                    }
                    else
                    {
                        TUserDefaults.SetDefault(TUserDefaults.USERDEFAULT_LASTPARTNERMAILROOM, PartnerKey);
                    }

                    // No Cursor change if run from within NUnit Test without Main Form instance...
                    if (AParentForm != null)
                    {
                        AParentForm.Cursor = Cursors.Default;
                    }
                }
            }
        }
        /// <summary>
        /// Manages the opening of a new/showing of an existing Instance of the Partner Find Screen.
        /// </summary>
        /// <remarks>A call to this Method will create a new Instance of the Partner Find Screen
        /// if there was no running Instance, otherwise it will just activate any Instance of
        /// the Partner Find Screen if finds.</remarks>
        /// <param name="AFormWasAlreadyOpened">False if a new Partner Find Screen was opened,
        /// false if an existing Instance of the Partner Find Screen was activated.</param>
        /// <param name="AParentForm"></param>
        /// <returns>An Instance of the Partner Find Screen (either newly created or
        /// just activated).</returns>
        public static Form OpenNewOrExistingForm(out bool AFormWasAlreadyOpened, Form AParentForm)
        {
            Form OpenFindScreen;
            Form NewFindScreen;

            AFormWasAlreadyOpened = false;

            OpenFindScreen = TFormsList.GFormsList[typeof(TPartnerFindScreen).FullName];

            if (OpenFindScreen != null)
            {
                OpenFindScreen.BringToFront();

                AFormWasAlreadyOpened = true;

                return OpenFindScreen;
            }
            else
            {
                NewFindScreen = new TPartnerFindScreen(AParentForm);
                NewFindScreen.Show();
                return NewFindScreen;
            }
        }