예제 #1
0
        private void AddSuborTabTransaction(ViewElement viewElement, string tabId, TransactionLevelRelation relation)
        {
            // Do not include the attributes "known due to context" (for example, when browsing the client's invoices, drop ClientId, ClientName, and ClientAddress).
            BaseCollection<TransactionAttribute> attrisInTab = new BaseCollection<TransactionAttribute>(relation.RelatedTransaction.Structure.Root.Attributes);
            attrisInTab.RemoveAll(delegate(TransactionAttribute trnAtt) { return relation.ContainsRelatedAttribute(trnAtt.Attribute); });

            // This may leave us with nothing to add, actually...
            if (attrisInTab.Count > 0)
            {
                TabElement tabElement = viewElement.AddTab(tabId);
                tabElement.Name = (relation.GroupRelation != null ? relation.GroupRelation.Description : relation.RelatedTransaction.Description);
                tabElement.Wcname = relation.BaseTransaction.Name + tabId + "WC";
                tabElement.Description = (relation.GroupRelation != null ? relation.GroupRelation.Description : relation.RelatedTransaction.Description);
                tabElement.Type = TabElement.TypeValue.Grid;
                tabElement.Page = TabElement.PageValue.Default;

                // If the attribute names in the subordinated tab differ from those in the view, they
                // must be explicitly listed (for "trn level subordination", they are known to be equal).
                bool hasDifferentAttris = false;
                IList<Gx.Attribute> paramAttris = new List<Gx.Attribute>();
                foreach (AttributeRelation subordAttr in relation.KeyAttributes)
                {
                    paramAttris.Add(subordAttr.Related);
                    hasDifferentAttris = hasDifferentAttris || (subordAttr.Base != subordAttr.Related);
                }

                if (hasDifferentAttris)
                {
                    foreach (Gx.Attribute paramAttri in paramAttris)
                        AddParameter(tabElement.Parameters, paramAttri.Name, true);
                }

                AddTrn(relation.RelatedTransaction, tabElement);
                AddGridTabAttributes(tabElement, relation.RelatedTransaction, relation.RelatedTransaction.Structure.Root, attrisInTab);
                tabElement.Modes = new ModesElement();
                tabElement.Modes.InsertCondition = viewElement.Instance.Settings.StandardActions.Insert.Condition;
                tabElement.Modes.UpdateCondition = viewElement.Instance.Settings.StandardActions.Update.Condition;
                tabElement.Modes.DeleteCondition = viewElement.Instance.Settings.StandardActions.Delete.Condition;
                tabElement.Modes.DisplayCondition = viewElement.Instance.Settings.StandardActions.Display.Condition;
                tabElement.Modes.ExportCondition = viewElement.Instance.Settings.StandardActions.Export.Condition;

            }
        }
예제 #2
0
        private string MakeTabUniqueId(TransactionLevel level, TransactionLevelRelation subord, ViewElement viewElement)
        {
            // If a table is subordinated to the level's base table more than once, then it is indexed
            // (i.e. "Client1", "Client2", "Client3"). Otherwise the table name is used ("Client").
            int currentIndex = 0;
            bool addedIndex = false;
            string tabCode = subord.RelatedLevel.Name;

            while (viewElement.FindTab(tabCode) != null)
            {
                if (addedIndex)
                {
                    // Remove this index to try with next one.
                    Debug.Assert(tabCode.EndsWith(currentIndex.ToString()));
                    tabCode = tabCode.Substring(0, subord.RelatedLevel.Name.Length);
                }

                currentIndex++;
                tabCode = tabCode + currentIndex.ToString();
                addedIndex = true;
            }

            return tabCode;
        }