Exemple #1
0
 public string ViewName(ViewElement view)
 {
     return (String.IsNullOrEmpty(view.GetObjectName()) ? ObjectName(this.View, view.Parent.Name) : view.GetObjectName());
 }
        private void AddSuborTabTrnLevel(ViewElement viewElement, Transaction trn, TransactionLevel subLevel)
        {
            TabElement tabElement = viewElement.AddTab(subLevel.Name);
            tabElement.Name = subLevel.Description;
            tabElement.Wcname = trn.Name + subLevel.Name + "WC";
            tabElement.Description = subLevel.Description;
            tabElement.Type = TabElement.TypeValue.Grid;
            tabElement.Page = TabElement.PageValue.Default;

            AddGridTabAttributes(tabElement, trn, subLevel, subLevel.Attributes);
        }
        private static bool CanRedirectToView(HPatternInstance instance, out ViewElement view)
        {
            // Do we have an appropriate view element?
            if (instance.Levels.Count > 0 &&
                instance.Levels[0].View != null &&
                CanRedirectTo(instance.Levels[0].View))
            {
                view = instance.Levels[0].View;
                return true;
            }

            view = null;
            return false;
        }
        private void AddSuborTabs(ViewElement tabsNode, Transaction trn, TransactionLevel fatherLvl)
        {
            // Tabs for each transaction level subordinated to the first one.
            List<Table> tablesInTrnLvls = new List<Table>();
            foreach (TransactionLevel suborLvl in fatherLvl.Levels)
            {
                AddSuborTabTrnLevel(tabsNode, trn, suborLvl);
                tablesInTrnLvls.Add(suborLvl.AssociatedTable);
            }

            // Tabs for other subordinated tables (by FK).
            foreach (TransactionLevelRelation relation in fatherLvl.GetSubordinations())
            {
                if (!fatherLvl.Levels.Contains(relation.RelatedLevel) &&
                    !tablesInTrnLvls.Contains(relation.RelatedTransaction.Structure.Root.AssociatedTable))
                {
                    string tabId = MakeTabUniqueId(fatherLvl, relation, tabsNode);
                    AddSuborTabTransaction(tabsNode, tabId, relation);
                }
            }
        }
        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;

            }
        }
 private void AddParameters(ViewElement viewElement, bool addMode, IList<TransactionAttribute> attris)
 {
     AddParameters(viewElement.Parameters, addMode, attris, new List<TransactionAttribute>());
 }
        private void AddParallelTabs(ViewElement viewElement, Transaction trn, TransactionLevel level)
        {
            foreach (Transaction parallel in level.AssociatedTable.AssociatedTransactions)
            {
                if (!parallel.Equals(trn))
                {
                    TabElement tabElement = viewElement.AddTab(parallel.Name);
                    tabElement.Name = parallel.Description;
                    tabElement.Wcname = trn.Name + parallel.Name;
                    tabElement.Type = TabElement.TypeValue.Tabular;

                    AddTrn(parallel, tabElement);
                    AddTabularTabAttributes(tabElement, parallel, parallel.Structure.Root);
                    AddActions(tabElement);
                }
            }
        }
        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;
        }
        private void AddTabularTab(ViewElement viewElement, Transaction trn, TransactionLevel level, string lvlName, string wcDescription, bool needActions)
        {
            string code = "General";

            TabElement tabElement = viewElement.AddTab(code);
            tabElement.Name = viewElement.Instance.Settings.Labels.GeneralTab;
            tabElement.Wcname = lvlName + "General";
            tabElement.Description = wcDescription + " Info";
            tabElement.Type = TabElement.TypeValue.Tabular;

            AddTabularTabAttributes(tabElement, trn, level);

            if (needActions)
                AddActions(tabElement);
        }
        private void AddTabs(Transaction trn, ViewElement viewNode, string lvlName, string lvlDescription, TransactionLevel level, bool needActions)
        {
            // General tab
            AddTabularTab(viewNode, trn, level, lvlName, lvlDescription, needActions);

            //viewNode.Instance.Settings.Template.TitleImage
            // Tabs for parallel transactions.
            if (viewNode.Instance.Settings.Template.TabsForParallelTransactions)
            {
                if (trn.Structure.Root == level && level.AssociatedTable.AssociatedTransactions.Count > 1)
                    AddParallelTabs(viewNode, trn, level);
            }

            // Tabs for subordinations.
            AddSuborTabs(viewNode, trn, level);
        }