private void UpdatePublicationCost()
        {
            DataRow[] PublicationCostRows = null;

            /* if the Subscription is free, the cost is always 0! */
            if (this.chkPSubscriptionGratisSubscription.Checked)
            {
                SetupPublicationCost(0, "");
            }
            else
            {
                /* If any Publications */
                if (FSubscriptionDR != null)
                {
                    PublicationCostRows = FPublicationCostDT.Select(
                        PPublicationTable.GetPublicationCodeDBName() + " = '" + this.cmbPSubscriptionPublicationCode.GetSelectedString() + "'");

                    /* if the Subscription has a cost, set it, else set the cost to 0. */
                    if (PublicationCostRows.Length > 0)
                    {
                        SetupPublicationCost((decimal)((PPublicationCostRow)PublicationCostRows[0]).PublicationCost,
                                             ((PPublicationCostRow)PublicationCostRows[0]).CurrencyCode);
                    }
                    else
                    {
                        SetupPublicationCost(0, "");
                    }
                }
                else
                {
                    this.btnEditIssues.Enabled = false;
                }
            }
        }
Exemplo n.º 2
0
        private void InitializeManualCode()
        {
            string CheckedMember = "CHECKED";
            string DisplayMember = PPublicationTable.GetPublicationDescriptionDBName();
            string ValueMember   = PPublicationTable.GetPublicationCodeDBName();

            DataTable Table = TDataCache.TMPartner.GetCacheableSubscriptionsTable(TCacheableSubscriptionsTablesEnum.PublicationList);
            DataView  view  = new DataView(Table);

            // TODO view.RowFilter = only active publications?
            view.Sort = ValueMember;

            DataTable NewTable = view.ToTable(true, new string[] { ValueMember, DisplayMember });

            NewTable.Columns.Add(new DataColumn(CheckedMember, typeof(bool)));

            clbIncludePublication.SpecialKeys =
                ((SourceGrid.GridSpecialKeys)((((((SourceGrid.GridSpecialKeys.Arrows |
                                                   SourceGrid.GridSpecialKeys.PageDownUp) |
                                                  SourceGrid.GridSpecialKeys.Enter) |
                                                 SourceGrid.GridSpecialKeys.Escape) |
                                                SourceGrid.GridSpecialKeys.Control) | SourceGrid.GridSpecialKeys.Shift)));

            //clbIncludePublication.SelectionMode = SourceGrid.GridSelectionMode.Row;
            clbIncludePublication.Columns.Clear();
            clbIncludePublication.AddCheckBoxColumn("", NewTable.Columns[CheckedMember], 17, false);
            clbIncludePublication.AddTextColumn(Catalog.GetString("Publication Code"), NewTable.Columns[ValueMember]);
            clbIncludePublication.AddTextColumn(Catalog.GetString("Publication Description"), NewTable.Columns[DisplayMember]);
            clbIncludePublication.DataBindGrid(NewTable, ValueMember, CheckedMember, ValueMember, false, true, false);

            dtpDateOfSendingCopy.Date = DateTime.Now;

            ActiveSubscriptionsBoxChanged(null, null);
        }
        private void NewRowManual(ref PPublicationCostRow ARow)
        {
            // Deal with primary key.  It is combination of a code and a effective date
            // Start by finding a code that does not have today's date
            Type DataTableType;

            // Load Data
            PPublicationTable allPublications = new PPublicationTable();
            DataTable         CacheDT         = TDataCache.GetCacheableDataTableFromCache("PublicationList", String.Empty, null, out DataTableType);

            allPublications.Merge(CacheDT);

            bool bFound = false;

            for (int i = 0; i < allPublications.Rows.Count; i++)
            {
                string tryCode = allPublications.Rows[i][0].ToString();

                if (FMainDS.PPublicationCost.Rows.Find(new object[] { tryCode, DateTime.Today }) == null)
                {
                    ARow.PublicationCode = tryCode;
                    bFound = true;
                    break;
                }
            }

            if (!bFound)
            {
                // use the first Publication and the first unused date
                string tryCode = allPublications.Rows[0][0].ToString();

                for (int i = 1;; i++)
                {
                    DateTime tryDate = DateTime.Today.AddDays(i);

                    if (FMainDS.PPublicationCost.Rows.Find(new object[] { tryCode, tryDate }) == null)
                    {
                        ARow.PublicationCode = tryCode;
                        ARow.DateEffective   = tryDate;
                        break;
                    }
                }
            }

            if (FPreviouslySelectedDetailRow == null)
            {
                ARow.CurrencyCode = FLedgerBaseCurrency;
            }
            else
            {
                ARow.CurrencyCode = FPreviouslySelectedDetailRow.CurrencyCode;
            }
        }
        private void NewRowManual(ref PPublicationCostRow ARow)
        {
            // Deal with primary key.  It is combination of a code and a effective date
            // Start by finding a code that does not have today's date
            Type DataTableType;

            // Load Data
            PPublicationTable allPublications = new PPublicationTable();
            DataTable CacheDT = TDataCache.GetCacheableDataTableFromCache("PublicationList", String.Empty, null, out DataTableType);

            allPublications.Merge(CacheDT);

            bool bFound = false;

            for (int i = 0; i < allPublications.Rows.Count; i++)
            {
                string tryCode = allPublications.Rows[i][0].ToString();

                if (FMainDS.PPublicationCost.Rows.Find(new object[] { tryCode, DateTime.Today }) == null)
                {
                    ARow.PublicationCode = tryCode;
                    bFound = true;
                    break;
                }
            }

            if (!bFound)
            {
                // use the first Publication and the first unused date
                string tryCode = allPublications.Rows[0][0].ToString();

                for (int i = 1;; i++)
                {
                    DateTime tryDate = DateTime.Today.AddDays(i);

                    if (FMainDS.PPublicationCost.Rows.Find(new object[] { tryCode, tryDate }) == null)
                    {
                        ARow.PublicationCode = tryCode;
                        ARow.DateEffective = tryDate;
                        break;
                    }
                }
            }

            if (FPreviouslySelectedDetailRow == null)
            {
                ARow.CurrencyCode = FLedgerBaseCurrency;
            }
            else
            {
                ARow.CurrencyCode = FPreviouslySelectedDetailRow.CurrencyCode;
            }
        }
        private DataTable GetPublicationInfoListTable(TDBTransaction AReadTransaction, string ATableName)
        {
            DataColumn ValidityColumn;
            DataTable  TmpTable    = PPublicationAccess.LoadAll(AReadTransaction);
            string     ValidText   = "";
            string     InvalidText = Catalog.GetString("Invalid");

            // add column to display the other partner key depending on direction of relationship
            ValidityColumn            = new DataColumn();
            ValidityColumn.DataType   = System.Type.GetType("System.String");
            ValidityColumn.ColumnName = MPartnerConstants.PUBLICATION_VALID_TEXT_COLUMNNAME;
            ValidityColumn.Expression = "IIF(" + PPublicationTable.GetValidPublicationDBName() +
                                        ",'" + ValidText + "','" + InvalidText + "')";
            TmpTable.Columns.Add(ValidityColumn);

            return(TmpTable);
        }
        private void InitializePublicationCodeList()
        {
            string CheckedMember = "CHECKED";
            string ValueMember   = PPublicationTable.GetPublicationCodeDBName();
            string DisplayMember = PPublicationTable.GetPublicationDescriptionDBName();

            DataTable Publications     = TDataCache.TMPartner.GetCacheableSubscriptionsTable(TCacheableSubscriptionsTablesEnum.PublicationList);
            DataView  PublicationsView = new DataView(Publications);

            PublicationsView.Sort = ValueMember;

            DataTable PublicationsTable = PublicationsView.ToTable(true, new string[] { ValueMember, DisplayMember });

            PublicationsTable.Columns.Add(new DataColumn(CheckedMember, typeof(bool)));

            clbPublicationCode.SpecialKeys =
                ((SourceGrid.GridSpecialKeys)((((((SourceGrid.GridSpecialKeys.Arrows |
                                                   SourceGrid.GridSpecialKeys.PageDownUp) |
                                                  SourceGrid.GridSpecialKeys.Enter) |
                                                 SourceGrid.GridSpecialKeys.Escape) |
                                                SourceGrid.GridSpecialKeys.Control) | SourceGrid.GridSpecialKeys.Shift)));

            clbPublicationCode.Columns.Clear();
            clbPublicationCode.AddCheckBoxColumn("", PublicationsTable.Columns[CheckedMember], 17, false);
            clbPublicationCode.AddTextColumn(Catalog.GetString("Group Code"), PublicationsTable.Columns[ValueMember]);
            clbPublicationCode.AddTextColumn(Catalog.GetString("Description"), PublicationsTable.Columns[DisplayMember]);
            clbPublicationCode.DataBindGrid(PublicationsTable,
                                            ValueMember,
                                            CheckedMember,
                                            ValueMember,
                                            false,
                                            true,
                                            false);

            clbPublicationCode.AutoResizeGrid();
            clbPublicationCode.AutoStretchColumnsToFitWidth = true;
            clbPublicationCode.SetCheckedStringList("");
        }
Exemplo n.º 7
0
        public void TestDeleteFamily()
        {
            DataSet ResponseDS = new PartnerEditTDS();
            TVerificationResultCollection VerificationResult;
            String               TextMessage;
            Boolean              CanDeletePartner;
            PPartnerRow          FamilyPartnerRow;
            PFamilyRow           FamilyRow;
            PPersonRow           PersonRow;
            TSubmitChangesResult result;
            Int64 PartnerKey;

            TPartnerEditUIConnector connector = new TPartnerEditUIConnector();

            PartnerEditTDS MainDS = new PartnerEditTDS();

            FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            result           = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "Create family record");

            // check if Family partner can be deleted (still needs to be possible at this point)
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(FamilyPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(CanDeletePartner);

            // add a person to the family which means the family is not allowed to be deleted any longer
            FamilyRow = (PFamilyRow)MainDS.PFamily.Rows[0];
            FamilyRow.FamilyMembers = true;
            TCreateTestPartnerData.CreateNewLocation(FamilyPartnerRow.PartnerKey, MainDS);
            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create new location");

            PartnerEditTDS PersonDS = new PartnerEditTDS();

            PersonRow = TCreateTestPartnerData.CreateNewPerson(PersonDS, FamilyPartnerRow.PartnerKey,
                                                               MainDS.PLocation[0].LocationKey, "Adam", "Mr", 0);
            PersonRow.FamilyKey = FamilyPartnerRow.PartnerKey;
            result = connector.SubmitChanges(ref PersonDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create person record");

            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(FamilyPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);


            // create new family and create subscription given as gift from this family: not allowed to be deleted
            FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            PPublicationTable PublicationTable = PPublicationAccess.LoadByPrimaryKey("TESTPUBLICATION", DBAccess.GDBAccessObj.Transaction);

            if (PublicationTable.Count == 0)
            {
                // first check if frequency "Annual" exists and if not then create it
                if (!AFrequencyAccess.Exists("Annual", DBAccess.GDBAccessObj.Transaction))
                {
                    // set up details (e.g. bank account) for this Bank so deletion is not allowed
                    AFrequencyTable FrequencyTable = new AFrequencyTable();
                    AFrequencyRow   FrequencyRow   = FrequencyTable.NewRowTyped();
                    FrequencyRow.FrequencyCode        = "Annual";
                    FrequencyRow.FrequencyDescription = "Annual Frequency";
                    FrequencyTable.Rows.Add(FrequencyRow);

                    AFrequencyAccess.SubmitChanges(FrequencyTable, DBAccess.GDBAccessObj.Transaction);
                }

                // now add the publication "TESTPUBLICATION"
                PPublicationRow PublicationRow = PublicationTable.NewRowTyped();
                PublicationRow.PublicationCode = "TESTPUBLICATION";
                PublicationRow.FrequencyCode   = "Annual";
                PublicationTable.Rows.Add(PublicationRow);

                PPublicationAccess.SubmitChanges(PublicationTable, DBAccess.GDBAccessObj.Transaction);
            }

            // make sure that "reason subscription given" exists
            if (!PReasonSubscriptionGivenAccess.Exists("FREE", DBAccess.GDBAccessObj.Transaction))
            {
                // set up details (e.g. bank account) for this Bank so deletion is not allowed
                PReasonSubscriptionGivenTable ReasonTable = new PReasonSubscriptionGivenTable();
                PReasonSubscriptionGivenRow   ReasonRow   = ReasonTable.NewRowTyped();
                ReasonRow.Code        = "FREE";
                ReasonRow.Description = "Free Subscription";
                ReasonTable.Rows.Add(ReasonRow);

                PReasonSubscriptionGivenAccess.SubmitChanges(ReasonTable, DBAccess.GDBAccessObj.Transaction);
            }

            // now add the publication "TESTPUBLICATION" to the first family record and indicate it was a gift from newly created family record
            PSubscriptionRow SubscriptionRow = MainDS.PSubscription.NewRowTyped();

            SubscriptionRow.PublicationCode     = "TESTPUBLICATION";
            SubscriptionRow.PartnerKey          = FamilyRow.PartnerKey;        // link subscription with original family
            SubscriptionRow.GiftFromKey         = FamilyPartnerRow.PartnerKey; // indicate that subscription is a gift from newly created family
            SubscriptionRow.ReasonSubsGivenCode = "FREE";
            MainDS.PSubscription.Rows.Add(SubscriptionRow);

            result = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "add publication to family record");

            // this should now not be allowed since partner record has a subscription linked to it
            CanDeletePartner = TPartnerWebConnector.CanPartnerBeDeleted(FamilyPartnerRow.PartnerKey, out TextMessage);

            if (TextMessage.Length > 0)
            {
                TLogging.Log(TextMessage);
            }

            Assert.IsTrue(!CanDeletePartner);

            // now test actual deletion of Family partner
            FamilyPartnerRow = TCreateTestPartnerData.CreateNewFamilyPartner(MainDS);
            PartnerKey       = FamilyPartnerRow.PartnerKey;
            result           = connector.SubmitChanges(ref MainDS, ref ResponseDS, out VerificationResult);
            Assert.AreEqual(TSubmitChangesResult.scrOK, result, "create family record");

            // check if Family record is being deleted
            Assert.IsTrue(TPartnerWebConnector.DeletePartner(PartnerKey, out VerificationResult));

            // check that Family record is really deleted
            Assert.IsTrue(!TPartnerServerLookups.VerifyPartner(PartnerKey));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Initializes the SubscriptionCounter. Adds for each found subscription a
        /// key pair value where the key is the supscription code and the value is 0.
        /// </summary>
        /// <param name="SubscriptionCounter">The SubscriptionCounter to initialize</param>
        private void InitSubscriptionCounter(ref Dictionary <String, int>SubscriptionCounter)
        {
            PPublicationTable PublicationTable = new PPublicationTable();

            PublicationTable = PPublicationAccess.LoadAll(situation.GetDatabaseConnection().Transaction);

            foreach (PPublicationRow row in PublicationTable.Rows)
            {
                SubscriptionCounter.Add(row.PublicationCode, 0);
            }
        }