Example #1
0
        protected void cmdAddNew_Click(object sender, EventArgs e)
        {
            if ((txtCmd.Text != string.Empty) && (CmdDB.GetIDByCmd(txtCmd.Text) != 0))
            {
                lblUpdateStatus.Text = "<font color='red'> Đã tồn tại chức năng này! </font>";
                return;
            }
            CmdInfo info = new CmdInfo();

            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_ParentID = ConvertUtility.ToInt32(dropParent.SelectedValue);

            try
            {
                txtID.Text           = CmdDB.Insert(info).ToString();
                lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS;
            }
            catch (Exception ex)
            {
                string s = ex.Message;
                lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR;
            }
        }
Example #2
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 !";
        }
Example #3
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;
            }
        }