Esempio n. 1
0
        public static void closeChildren(main_page mainPage)
        {
            foreach (Form child in mainPage.MdiChildren)
            {
                child.Close();
                child.Dispose();
            }
            selected_id = 0;
            File.WriteAllText(GF.path, String.Empty);

            //resetPagingState();
        }
Esempio n. 2
0
        public static void initPage(Form childPage, main_page mainPage)
        {
            GF.closeChildren(mainPage);
            GF.showLoading(mainPage);

            GF.doDebug("========== MAIN FORM :: " + childPage.Name + " ==========");
            GF.selected_id = 0;

            childPage.MdiParent = mainPage;
            if (childPage.Name.IndexOf("report_") != -1)
            {
                childPage.Dock = DockStyle.Fill;
            }
            else
            {
                childPage.Size          = childPage.MdiParent.ClientSize;
                childPage.StartPosition = FormStartPosition.Manual;
            }
            childPage.WindowState = FormWindowState.Maximized;

            GF.addKeyUp(childPage);

            childPage.Load += (s, e) =>
            {
                //((Form)s).Visible = true;
            };
            childPage.LocationChanged += (s, e) =>
            {
                if (childPage.Left != 0)
                {
                    childPage.Left = -5;
                }
                if (childPage.Top != 0)
                {
                    childPage.Top = 0;
                }
            };
            if (!childPage.IsDisposed)
            {
                childPage.Show();
            }

            GF.closeLoading();
        }
Esempio n. 3
0
        public static void setMenu(main_page mainPage, String username, String user_id)
        {
            String[,] auth;

            //GET USER AUTH
            using (DataTable authDT = DB.getS("SELECT ISNULL(MENU_ID, -1) MENU_ID, ISNULL(SUB_MENU_ID, -1) SUB_MENU_ID, ISNULL(SUB_MENU2_ID, -1) SUB_MENU2_ID FROM USERS_AUTH WHERE user_id = " + user_id, null, "CHECK AUTH FOR USER_ID[" + user_id + "]", false))
            {
                if (authDT.Rows.Count == 0 && username != "admin")
                {
                    return;
                }
                auth = new String[authDT.Rows.Count, 3];
                int index = 0;
                foreach (DataRow authRow in authDT.Rows)
                {
                    auth[index, 0] = authRow["MENU_ID"].ToString();
                    auth[index, 1] = authRow["SUB_MENU_ID"].ToString();
                    auth[index, 2] = authRow["SUB_MENU2_ID"].ToString();
                    index++;
                }
            }

            /*for (int arrayIndex = 0; arrayIndex < auth.GetLength(0); arrayIndex++)
             * {
             *  GF.doDebug("[ " + arrayIndex + " ] >>> " + auth[arrayIndex, 0] + " , " + auth[arrayIndex, 1] + " , " + auth[arrayIndex, 2]);
             * }*/

            //MAIN MENU
            foreach (ToolStripMenuItem menu in mainPage.MainMenuStrip.Items)
            {
                menu.Visible = false;

                if (menu.Tag.ToString() == String.Empty)
                {
                    menu.Visible = false;
                }
                else if (menu.Tag.ToString() == "SKIP" || username == "admin" || AUTH.mainMenuAuth(auth, menu.Tag.ToString()))
                {
                    menu.Visible = true;
                    bool foundBefore = false;
                    bool foundLater  = false;
                    bool foundSep    = false;

                    //SUB MENU LEVEL 1
                    foreach (Object sub1Item in menu.DropDown.Items)
                    {
                        if (((ToolStripItem)sub1Item).Name.IndexOf("toolStripSeparator") != -1)
                        {
                            foundSep = true;
                        }
                        else
                        {
                            ((ToolStripItem)sub1Item).Visible = false;
                            if (((ToolStripItem)sub1Item).Tag.ToString() == String.Empty)
                            {
                                ((ToolStripItem)sub1Item).Visible = false;
                            }
                            else if (username == "admin" || AUTH.subMenuAuth(auth, menu.Tag.ToString(), ((ToolStripItem)sub1Item).Tag.ToString()))
                            {
                                if (((ToolStripItem)sub1Item).Tag.ToString() != "SKIP")
                                {
                                    ((ToolStripItem)sub1Item).Visible = true;
                                }
                                if (!foundSep)
                                {
                                    foundBefore = true;
                                }
                                else
                                {
                                    foundLater = true;
                                }

                                if (sub1Item.GetType().Equals(typeof(ToolStripMenuItem)))
                                //if we get the desired object type.
                                {
                                    ToolStripMenuItem sub2 = (ToolStripMenuItem)sub1Item;
                                    // cast to ToolStripMenuItem

                                    if (sub2.HasDropDownItems) // if subMenu has children
                                    {
                                        // SUB MENU LEVEL 2
                                        bool subFoundBefore = false;
                                        bool subFoundLater  = false;
                                        bool subFoundSep    = false;
                                        foreach (Object sub2Item in sub2.DropDown.Items)
                                        {
                                            if (((ToolStripItem)sub2Item).Name.IndexOf("toolStripSeparator") != -1)
                                            {
                                                subFoundSep = true;
                                            }
                                            else
                                            {
                                                //GF.doDebug("[ " + ((ToolStripItem)sub1Item).Text + " ] >>> " + ((ToolStripItem)sub2Item).Text);
                                                if (((ToolStripItem)sub1Item).Tag.ToString() == String.Empty)
                                                {
                                                    ((ToolStripItem)sub1Item).Visible = false;
                                                }
                                                else if (((ToolStripItem)sub2Item).Tag == null)
                                                {
                                                    ((ToolStripItem)sub2Item).Visible = true;
                                                }
                                                else
                                                {
                                                    ((ToolStripItem)sub2Item).Visible = false;
                                                    if (username == "admin" || AUTH.sub2MenuAuth(auth, menu.Tag.ToString(), ((ToolStripItem)sub1Item).Tag.ToString(), ((ToolStripItem)sub2Item).Tag.ToString()))
                                                    {
                                                        if (((ToolStripItem)sub2Item).Tag.ToString() != "SKIP")
                                                        {
                                                            ((ToolStripItem)sub2Item).Visible = true;
                                                        }
                                                        if (!subFoundSep)
                                                        {
                                                            subFoundBefore = true;
                                                        }
                                                        else
                                                        {
                                                            subFoundLater = true;
                                                        }
                                                    }
                                                }
                                            }
                                        }

                                        foreach (ToolStripItem sub2Item in sub2.DropDown.Items)
                                        {
                                            if (sub2Item.GetType() == typeof(ToolStripSeparator))
                                            {
                                                if (subFoundBefore && subFoundLater)
                                                {
                                                    sub2Item.Visible = true;
                                                }
                                                else
                                                {
                                                    sub2Item.Visible = false;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    foreach (ToolStripItem sub1 in menu.DropDown.Items)
                    {
                        if (sub1.GetType() == typeof(ToolStripSeparator))
                        {
                            if (foundBefore && foundLater)
                            {
                                sub1.Visible = true;
                            }
                            else
                            {
                                sub1.Visible = false;
                            }
                        }
                    }
                }
            }
        }