Example #1
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;
                }
            }
        }
        private void UpdateSubsystemLinkStatus(int ALedgerNumber, TTaskList ATaskList, XmlNode ATaskListNode)
        {
            bool       ServerCallSuccessful;
            ALedgerRow LedgerDR = null;

            if ((ATaskListNode != null) && (ATaskListNode.ParentNode != null) &&
                (ATaskListNode.ParentNode.Name == "Finance"))
            {
                try
                {
                    LedgerDR =
                        ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(
                             TCacheableFinanceTablesEnum.LedgerDetails, ALedgerNumber))[0];
                }
                catch (ECachedDataTableLoadingRetryGotCancelledException Exc)
                {
                    TLogging.Log("Loading of Cacheable DataTable 'LedgerDetails' failed; the CLIENT NEEDS TO BE RESTARTED!  " +
                                 "Details: " + Exc.ToString());

                    // RESTART CLIENT!
                    PetraClientShutdown.Shutdown.StopPetraClient(true, true, true, StrDataLoadingErrorMessage);
                }

                XmlNode TempNode = ATaskListNode.ParentNode.FirstChild;

                while (TempNode != null)
                {
                    ServerCallSuccessful = false;

                    Ict.Common.DB.TServerBusyHelper.CoordinatedAutoRetryCall("Finance Sub-system Activated inquiry", ref ServerCallSuccessful,
                                                                             delegate
                    {
                        if (TempNode.Name == "GiftProcessing")
                        {
                            ATaskList.EnableDisableTaskItem(TempNode,
                                                            TRemote.MFinance.Setup.WebConnectors.IsGiftProcessingSubsystemActivated(ALedgerNumber));
                        }
                        else if (TempNode.Name == "AccountsPayable")
                        {
                            ATaskList.EnableDisableTaskItem(TempNode,
                                                            TRemote.MFinance.Setup.WebConnectors.IsAccountsPayableSubsystemActivated(ALedgerNumber));
                        }

                        ServerCallSuccessful = true;
                    });

                    if (!ServerCallSuccessful)
                    {
                        TLogging.Log("Inquiring of Finance Subsystems' Activated States failed; the CLIENT NEEDS TO BE RESTARTED!");
                        TServerBusyHelperGui.ShowLoadingOfDataGotCancelledDialog();

                        // RESTART CLIENT!
                        PetraClientShutdown.Shutdown.StopPetraClient(true, true, true, StrDataLoadingErrorMessage);

                        // ALL-IMPORTANT EXIT statement: without this, a number of OpenPetra Clients might get
                        // started from within this while loop!!!
                        Environment.Exit(0);
                    }

                    TempNode = TempNode.NextSibling;
                } // while

                EnableDisableChildOption(ATaskList, "SuspenseAccounts", LedgerDR.SuspenseAccountFlag, ATaskListNode.ParentNode);
            } // if
        }