Esempio n. 1
0
        private void GetPath()
        {
            path = "|";
            ArrayList titleArr = new ArrayList();

            if (cmd != string.Empty)
            {
                CmdInfo curCmd = CmdDB.GetInfoByCmd(cmd);
                while (curCmd != null)
                {
                    path += curCmd.Cmd_ID + "|";
                    titleArr.Add(curCmd.Cmd_Name);
                    curCmd = CmdDB.GetInfo(curCmd.Cmd_ParentID);
                }
            }

            string pageTitle = AppEnv.WebTitle + " - ";

            titleArr.Reverse();
            foreach (string item in titleArr)
            {
                pageTitle += item + " - ";
            }
            if (pageTitle.IndexOf(" - ") > 0)
            {
                pageTitle = pageTitle.Substring(0, pageTitle.Length - 2);
            }

            AdminPage page = (AdminPage)Page;

            page.Title = UnicodeUtility.UnicodeToKoDau(pageTitle);
        }
Esempio n. 2
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            CmdDB.FillToListBox(dropParent.Items);
            dropParent.Items.Insert(0, new ListItem("Root", "0"));

            if (txtID.Text != string.Empty)
            {
                CmdInfo info = CmdDB.GetInfo(ConvertUtility.ToInt32(txtID.Text));
                if (info != null)
                {
                    dropParent.SelectedIndex = -1;
                    MiscUtility.SetSelected(dropParent.Items, info.Cmd_ParentID.ToString());
                }
            }

            nodePath = "|";
            TreeViewNode focusNode = tvwCmds.SelectedNode;

            if (focusNode != null)
            {
                while (true)
                {
                    if (focusNode.ParentNode == null)
                    {
                        break;
                    }
                    else
                    {
                        focusNode = focusNode.ParentNode;
                        nodePath += focusNode.ID + "|";
                    }
                }
            }

            tvwCmds.Nodes.Clear();
            TreeViewNode topRoot = new TreeViewNode();

            topRoot.Text = "Root";
            topRoot.ID   = "0";
            tvwCmds.Nodes.Add(topRoot);

            DataTable dtRoot = CmdDB.GetByParentID(0);

            foreach (DataRow row in dtRoot.Rows)
            {
                TreeViewNode rootNode = new TreeViewNode();
                rootNode.Text = row["Cmd_Name"].ToString();
                rootNode.ID   = row["Cmd_ID"].ToString();

                if (nodePath.IndexOf("|" + rootNode.ID + "|") >= 0)
                {
                    rootNode.Expanded = true;
                }
                tvwCmds.Nodes.Add(rootNode);
                LoadCmdItem(rootNode);
            }
        }
Esempio n. 3
0
        private void LoadControls()
        {
            string cmd = ConvertUtility.ToString(Request.QueryString["cmd"]);

            if (cmd == string.Empty)
            {
                placeControls.Controls.Add(LoadControl(AppEnv.ADMIN_PATH + "/UserControls/Core/WelCome.ascx"));
                return;
            }

            if ((cmd == "management") && (CurrentAdminInfo.User_Email == AppEnv.ADMIN_EMAIL))
            {
                placeControls.Controls.Add(LoadControl(AppEnv.ADMIN_PATH + "/UserControls/Core/CmdManager.ascx"));
                return;
            }
            if (cmd == "accessdeny")
            {
                placeControls.Controls.Add(LoadControl(AppEnv.ADMIN_PATH + "/UserControls/Core/AccessDeny.ascx"));
                return;
            }

            CmdInfo info = CmdDB.GetInfo(CmdDB.GetIDByCmd(cmd));

            if (info == null || !info.Cmd_Enable)
            {
                Response.Redirect(AppEnv.ADMIN_ACCESSDENY);
            }

            lblCommandName.Text = info.Cmd_Name;
            if ((!CurrentAdminInfo.User_SuperAdmin) && (!CmdRoleDB.CheckRole(CurrentAdminInfo.User_ID, info.Cmd_ID)))
            {
                Response.Redirect(AppEnv.ADMIN_ACCESSDENY);
            }

            string modulePath = AppEnv.ADMIN_PATH + info.Cmd_Path;

            //modulePath.Replace("//", "/");

            if (File.Exists(Server.MapPath(modulePath)))
            {
                placeControls.Controls.Add(LoadControl(modulePath));
                return;
            }

            modulePath = AppEnv.MODULE_PATH + info.Cmd_Path;

            ////modulePath.Replace("//", "/");

            //Response.Write(modulePath);
            //Response.End();

            if (File.Exists(Server.MapPath(modulePath)))
            {
                placeControls.Controls.Add(LoadControl(modulePath));
                return;
            }
            lblErrorMessage.Text = " Không tìm thấy module, kiểm tra lại đường dẫn !";
        }
Esempio n. 4
0
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            CmdInfo info = CmdDB.GetInfo(ConvertUtility.ToInt32(txtID.Text));

            if (info == null)
            {
                return;
            }

            int cmdID = CmdDB.GetIDByCmd(txtCmd.Text);

            if ((txtCmd.Text != string.Empty) && (cmdID != 0) && (cmdID != info.Cmd_ID))
            {
                lblUpdateStatus.Text = "<font color='red'> Đã tồn tại chức năng này! </font>";
                return;
            }

            info.Cmd_Name   = txtName.Text.Trim();
            info.Cmd_Value  = txtCmd.Text.Trim();
            info.Cmd_Params = txtParams.Text.Trim();
            info.Cmd_Url    = txtUrl.Text.Trim();
            info.Cmd_Path   = txtPath.Text.Trim();

            info.Cmd_Enable  = chkEnable.Checked;
            info.Cmd_Visible = chkVisble.Checked;

            info.Cmd_Index    = ConvertUtility.ToInt32(dropIndex.SelectedValue);
            info.Cmd_ParentID = ConvertUtility.ToInt32(dropParent.SelectedValue);

            if (info.Cmd_ID == info.Cmd_ParentID)
            {
                lblUpdateStatus.Text = "<font color='red'> Trùng mục cha, chọn mục cha khác! </font>";
                return;
            }
            try
            {
                CmdDB.Update(info);
                lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS;
            }
            catch (Exception eex)
            {
                string t = eex.Message;
                lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR;
            }
        }
Esempio n. 5
0
        protected void tvwCmds_NodeSelected(object sender, TreeViewNodeEventArgs e)
        {
            int     curID = ConvertUtility.ToInt32(e.Node.ID);
            CmdInfo info  = CmdDB.GetInfo(curID);

            if (info == null)
            {
                cmdEmpty_Click(null, null);
                return;
            }

            txtID.Text     = info.Cmd_ID.ToString();
            txtName.Text   = info.Cmd_Name;
            txtCmd.Text    = info.Cmd_Value;
            txtParams.Text = info.Cmd_Params;
            txtPath.Text   = info.Cmd_Path;
            txtUrl.Text    = info.Cmd_Url;

            int maxIndex = CmdDB.GetChildCount(info.Cmd_ParentID);

            MiscUtility.FillIndex(dropIndex, maxIndex, info.Cmd_Index);
            chkEnable.Checked = info.Cmd_Enable;
            chkVisble.Checked = info.Cmd_Visible;
        }