private void btnAddTimePeriods_Click(object sender, EventArgs e) { CreateMainTable frmCreateMainTable = new CreateMainTable(); frmCreateMainTable.NewMainTable = VariableFacade.GetMainTableById(menuTextBox.Text); frmCreateMainTable.SetEditMode(); frmCreateMainTable.ShowDialog(); }
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; } } }