Esempio n. 1
0
        private void btnAddTable_Click(object sender, EventArgs e)
        {
            PxMenuSelection selectedMenu = (PxMenuSelection)tvMenuSelection.SelectedNode.Tag;
            int levelNo;
            int.TryParse(selectedMenu.LevelNo, out levelNo);
            if (levelNo < 5)
            {
                CreateMainTable frmCreateDialog = new CreateMainTable();

                frmCreateDialog.NewMainTable.Theme = selectedMenu.GetTheme(selectedMenu);
                if (selectedMenu.GetTheme(selectedMenu) == null)
                {
                    MessageBox.Show("Can not insert a table in this node", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                frmCreateDialog.SetTheme(frmCreateDialog.NewMainTable.Theme);

                if (frmCreateDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    PxMenuSelection newMenuSelection = new PxMenuSelection();
                    newMenuSelection.Parent = selectedMenu;
                    newMenuSelection.LevelNo = "5";
                    newMenuSelection.PresText = frmCreateDialog.NewMainTable.PresText;
                    newMenuSelection.PresTextEnglish = frmCreateDialog.NewMainTable.TableTitleEnglish;
                    newMenuSelection.Menu = frmCreateDialog.NewMainTable.TableId;
                    newMenuSelection.Presentation = "A";
                    newMenuSelection.PresentationEnglish = "A";

                    string message = "";

                    if (!newMenuSelection.Validate(ref message))
                    {
                        MessageBox.Show(message, "Create Menu Selection", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                        return;
                    }

                    if (!VariableFacade.Save(newMenuSelection, ref message))
                    {
                        MessageBox.Show(message, "Create Menu Selection", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                        return;
                    }

                    selectedMenu.Childrens.Add(newMenuSelection);
                    TreeNode newTheme = new TreeNode();
                    newTheme.Name = newMenuSelection.Menu;
                    newTheme.Text = newMenuSelection.PresText;
                    newTheme.Tag = newMenuSelection;

                    tvMenuSelection.SelectedNode.Nodes.Add(newTheme);
                    tvMenuSelection.SelectedNode = newTheme;
                }
            }
        }
Esempio n. 2
0
        public string GetTheme(PxMenuSelection node)
        {
            if (node == null)
            {
                return(null);
            }
            if (node.Parent != null)
            {
                if (String.Compare(node.Parent.Menu, "START", true) == 0)
                {
                    return(node.Menu);
                }
                return(GetTheme(node.Parent));
            }

            return(null);
        }
        public static bool UpdateMenuSelection(PxMenuSelection selection)
        {
            try
            {
                PxMetaModel.PcAxisMetabaseEntities context = new PxMetaModel.PcAxisMetabaseEntities();

                var selectedMenu = from sm in context.MenuSelections
                                   where sm.Menu == selection.Parent.Menu && sm.Selection == selection.Menu
                                   select sm;
                PxMetaModel.MenuSelection ms = selectedMenu.First();
                ms.PresText = selection.PresText;
                ms.PresTextS = selection.PresTextS;
                ms.Presentation = selection.Presentation;
                ms.Description = selection.Description;
                ms.SortCode = selection.SortCode;
                ms.UserId = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                ms.LogDate = DateTime.Now;

                var selectedMenuEng = from sm in context.MenuSelection_Eng
                                      where sm.Menu == selection.Parent.Menu && sm.Selection == selection.Menu
                                      select sm;
                PxMetaModel.MenuSelection_Eng msEng = selectedMenuEng.First();
                msEng.PresText = selection.PresTextEnglish;
                msEng.PresTextS = selection.PresTextSEnglish;
                msEng.Presentation = selection.PresentationEnglish;
                msEng.Description = selection.DescriptionEnglish;
                msEng.SortCode = selection.SortCodeEnglish;
                msEng.UserId = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                msEng.LogDate = DateTime.Now;
                context.SaveChanges();
                selection.MarkAsOld();
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
        public static void LoadChildren(PxMenuSelection parent)
        {
            PxMetaModel.PcAxisMetabaseEntities context = new PxMetaModel.PcAxisMetabaseEntities();

            var mythemes = (from theme in context.MenuSelections
                            where theme.Menu == parent.Menu
                            orderby theme.SortCode
                            select new PxMenuSelection()
                            {
                                Menu = theme.Selection,
                                PresText = theme.PresText,
                                LevelNo = theme.LevelNo,
                                Description = theme.Description,
                                Presentation = theme.Presentation,
                                PresTextS = theme.PresTextS,
                                SortCode = theme.SortCode,
                                PresTextEnglish = theme.MenuSelection_Eng.PresText,
                                PresTextSEnglish = theme.MenuSelection_Eng.PresTextS,
                                DescriptionEnglish = theme.MenuSelection_Eng.Description,
                                PresentationEnglish = theme.MenuSelection_Eng.Presentation,
                                SortCodeEnglish = theme.MenuSelection_Eng.SortCode
                            });
            foreach (var item in mythemes)
            {
                item.Parent = parent;
                parent.Childrens.Add(item);
            }
        }
        public static PxMenuSelection GetMenuStart()
        {
            PxMetaModel.PcAxisMetabaseEntities context = new PxMetaModel.PcAxisMetabaseEntities();

            var mythemes = new PxMenuSelection() { Menu = "Start", PresText = "Start", LevelNo = "0", Description = "Start", Presentation = "A", PresTextS = "Start", SortCode = "A" };
            return mythemes;
        }
        public string GetTheme(PxMenuSelection node)
        {
            if (node == null)
            {
                return null;
            }
            if (node.Parent != null)
            {
                    if (String.Compare(node.Parent.Menu, "START", true) == 0)
                    {
                        return node.Menu;
                    }
                    return GetTheme(node.Parent);
            }

            return null;
        }
 public CreateMenuSelectionDialog()
 {
     InitializeComponent();
     NewMenuSelection = new Model.PxMenuSelection();
 }