/// <summary>
        /// open the Partner Edit screen for the supplier
        /// </summary>
        private void EditPartner(object sender, EventArgs e)
        {
            FPetraUtilsObject.WriteToStatusBar("Opening Partner in Partner Edit screen...");
            this.Cursor = Cursors.WaitCursor;

            try
            {
                TFrmPartnerEdit frm = new TFrmPartnerEdit(this);
                frm.SetParameters(TScreenMode.smEdit, FMainDS.AApSupplier[0].PartnerKey);
                frm.Show();
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Beispiel #2
0
        // display the partner edit screen, open to the Contact Log tab and display the contact log that has been selected in the grid
        private void ViewPartner(object Sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            // get data for contact log to display
            DataRow CurrentRow   = GetCurrentDataRow();
            Int64   PartnerKey   = Convert.ToInt64(CurrentRow["p_partner_key_n"]);
            string  ContactLogID = CurrentRow["p_contact_log_id_i"].ToString();

            TFrmPartnerEdit frm = new TFrmPartnerEdit(FPetraUtilsObject.GetForm());

            frm.SetParameters(TScreenMode.smEdit, PartnerKey, TPartnerEditTabPageEnum.petpContacts);
            frm.Show();
            frm.SelectContactLog(ContactLogID);

            this.Cursor = Cursors.Default;
        }
Beispiel #3
0
        /// <summary>
        /// Shows the Partner Edit screen for a new Partner.
        ///
        /// </summary>
        /// <returns>void</returns>
        public void ShowForExistingPartner(Form AParentForm)
        {
            TFrmPartnerEdit frmPEDS;

            // MessageBox.Show('From Thread: about to show PartnerEdit screen for existing Partner...');
            try
            {
                frmPEDS = new TFrmPartnerEdit(AParentForm);
                frmPEDS.SetParameters(FScreenMode,
                                      FPartnerKey,
                                      FSiteKeyForSelectingPartnerLocation,
                                      FLocationKeyForSelectingPartnerLocation,
                                      FShowTabPage);

                // MessageBox.Show('From Thread: now showing PartnerEdit screen!');
                frmPEDS.Show();
            }
            catch (Exception Exp)
            {
                MessageBox.Show("Exception in TThreadedOpenPartnerEditScreen.ShowForExistingPartner:" + Exp.ToString());
            }
        }
        /// <summary>
        /// button was pressed to edit other partner in relationship record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditOtherPartner(System.Object sender, EventArgs e)
        {
            long RelationPartnerKey;

            if (GetSelectedDetailRow() == null)
            {
                return;
            }

            // depending on the relation select other partner to be edited
            if (GetSelectedDetailRow().PartnerKey == ((PPartnerRow)FMainDS.PPartner.Rows[0]).PartnerKey)
            {
                RelationPartnerKey = GetSelectedDetailRow().RelationKey;
            }
            else
            {
                RelationPartnerKey = GetSelectedDetailRow().PartnerKey;
            }

            if (RelationPartnerKey == 0)
            {
                return;
            }

            this.Cursor = Cursors.WaitCursor;

            try
            {
                TFrmPartnerEdit frm = new TFrmPartnerEdit(FPetraUtilsObject.GetForm());

                frm.SetParameters(TScreenMode.smEdit, RelationPartnerKey);
                frm.Show();
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Beispiel #5
0
        private void FPetraUtilsObject_DataSaved_NewDonorWarning(object Sender, TDataSavedEventArgs e)
        {
            // if data successfully saved then look for new donors and warn the user
            if (e.Success && (FGiftDetailTable != null) && FNewDonorWarning)
            {
                // this list contains a list of all new donors that were entered onto form
                List <Int64> NewDonorsList = ucoTransactions.NewDonorsList;

                foreach (GiftBatchTDSAGiftDetailRow Row in FGiftDetailTable.Rows)
                {
                    // check changed data is either added or modified and that it is by a new donor
                    if (((Row.RowState == DataRowState.Added) || (Row.RowState == DataRowState.Modified)) &&
                        (!Row.IsDonorKeyNull() && NewDonorsList.Contains(Row.DonorKey)))
                    {
                        if (MessageBox.Show(string.Format(Catalog.GetString(
                                                              "{0} ({1}) is a new Donor.{2}Do you want to add subscriptions for them?{2}" +
                                                              "(Note: this message can be disabled in the 'File' menu by unselecting the 'New Donor Warning' item.)"),
                                                          Row.DonorName, Row.DonorKey, "\n\n"),
                                            Catalog.GetString("New Donor"), MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                            MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                        {
                            // Open the donor's Edit screen so subscriptions can be added
                            TFrmPartnerEdit frm = new TFrmPartnerEdit(FPetraUtilsObject.GetForm());

                            frm.SetParameters(TScreenMode.smEdit, Row.DonorKey, TPartnerEditTabPageEnum.petpSubscriptions);
                            frm.ShowDialog();
                        }

                        // ensures message is not displayed twice for one new donor with two gifts
                        NewDonorsList.Remove(Row.DonorKey);
                    }
                }

                ucoTransactions.NewDonorsList.Clear();
            }
        }
Beispiel #6
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;
                    }
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Opens the partner edit screen with the last partner worked on.
        /// Checks if the partner is merged.
        /// </summary>
        public static void OpenLastUsedPartnerEditScreenByContext(Form AParentForm, string AContext = null)
        {
            string ValidContexts;
            string Context;
            long   MergedPartnerKey = 0;
            long   LastPartnerKey;
            string NoPartnerAvailableStr = Catalog.GetString("You have not edited a Partner yet.");

            if (AContext != null)
            {
                ValidContexts = TUserDefaults.USERDEFAULT_LASTPARTNERMAILROOM + ";" + TUserDefaults.USERDEFAULT_LASTPERSONPERSONNEL + ";" +
                                TUserDefaults.USERDEFAULT_LASTUNITPERSONNEL + ";" + TUserDefaults.USERDEFAULT_LASTPERSONCONFERENCE + ";";

                if (!ValidContexts.Contains(AContext + ";"))
                {
                    throw new ArgumentException("AContext \"" + AContext + "\" is not a valid context. Valid contexts: " + ValidContexts);
                }
                else
                {
                    Context = AContext;
                }
            }
            else
            {
                Context = TUserDefaults.USERDEFAULT_LASTPARTNERMAILROOM;
            }

            LastPartnerKey = TUserDefaults.GetInt64Default(Context, 0);

            // we don't need to validate the partner key
            // because it's done in the mnuFile_Popup function.
            // If we don't have a valid partner key, this code can't be called from the file menu.

            // now that this function is called from the main menu, we need to check for LastPartnerKey != 0
            if (LastPartnerKey == 0)
            {
                if (Context == TUserDefaults.USERDEFAULT_LASTPERSONPERSONNEL)
                {
                    NoPartnerAvailableStr = Catalog.GetString("You have not yet worked with a Person in the Personnel Module.");
                }

                MessageBox.Show(Catalog.GetString(NoPartnerAvailableStr),
                                Catalog.GetString("No Last Partner"),
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                return;
            }

            if (MergedPartnerHandling(LastPartnerKey, out MergedPartnerKey, AParentForm))
            {
                // work with the merged partner
                LastPartnerKey = MergedPartnerKey;
            }
            else if (MergedPartnerKey > 0)
            {
                // The partner is merged but user cancelled the action
                return;
            }

            // Open the Partner Edit screen
            TFrmPartnerEdit frmPEDS;

            AParentForm.Cursor = Cursors.WaitCursor;

            frmPEDS = new TFrmPartnerEdit(AParentForm);

            if (Context == TUserDefaults.USERDEFAULT_LASTPERSONPERSONNEL)
            {
                frmPEDS.SetParameters(TScreenMode.smEdit, LastPartnerKey, TPartnerEditTabPageEnum.petpPersonnelIndividualData);
            }
            else
            {
                frmPEDS.SetParameters(TScreenMode.smEdit, LastPartnerKey);
            }

            frmPEDS.Show();

            AParentForm.Cursor = Cursors.Default;
        }
Beispiel #8
0
        private void EditPartner(System.Object sender, EventArgs e)
        {
            bool ServerCallSuccessful          = false;
            bool VerifyPartnerAtLocationResult = false;

            if (CountSelectedRows() > 1)
            {
                MessageBox.Show(Catalog.GetString("Please select only one partner record that you want to edit"),
                                Catalog.GetString("Edit Partner"),
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return;
            }

            ExtractTDSMExtractRow SelectedRow = GetSelectedDetailRow();

            // TODO: private partners
            // Check if partner is has "restricted" field set to be private and in that
            // case only let the owner access that partner.
            // Make use of SharedConstants.PARTNER_PRIVATE_USER while running the query.

            // Open Partner Edit Screen for selected partner
            if (SelectedRow != null)
            {
                bool CurrentAddress;
                bool MailingAddress;

                this.Cursor = Cursors.WaitCursor;

                try
                {
                    Ict.Common.DB.TServerBusyHelper.CoordinatedAutoRetryCall("Extract Maintenance/Edit Partner", ref ServerCallSuccessful,
                                                                             delegate
                    {
                        VerifyPartnerAtLocationResult = TRemote.MPartner.Partner.ServerLookups.WebConnectors.VerifyPartnerAtLocation(
                            SelectedRow.PartnerKey,
                            new TLocationPK(SelectedRow.SiteKey, SelectedRow.LocationKey),
                            out CurrentAddress,
                            out MailingAddress);

                        ServerCallSuccessful = true;
                    });

                    if (!ServerCallSuccessful)
                    {
                        // ServerCallRetries must be equal to MAX_RETRIES when we get here!
                        if (TServerBusyHelperGui.ShowServerBusyDialogWhenOpeningForm(Catalog.GetString("Partner Edit")) == DialogResult.Retry)
                        {
                            EditPartner(null, null);
                        }

                        return;
                    }

                    TFrmPartnerEdit frm = new TFrmPartnerEdit(FPetraUtilsObject.GetForm());

                    if (!VerifyPartnerAtLocationResult)
                    {
                        MessageBox.Show(Catalog.GetString("Cannot find the location that was stored for this partner." +
                                                          "\r\n" + "Will use any known location for this partner." +
                                                          "\r\n" + "\r\n" + "(Fix with 'Verify and Update Extract')"),
                                        Catalog.GetString("Edit Partner"),
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Warning);

                        frm.SetParameters(TScreenMode.smEdit,
                                          SelectedRow.PartnerKey);
                    }
                    else
                    {
                        frm.SetParameters(TScreenMode.smEdit,
                                          SelectedRow.PartnerKey,
                                          SelectedRow.SiteKey,
                                          SelectedRow.LocationKey);
                    }

                    frm.Show();
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }