Пример #1
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (!IsPostBack)
        {
            ifError = false;
            ViewState["SortOrder"]  = appFunctions.Enum_SortOrderBy.Asc;
            ViewState["SortColumn"] = "";

            btnAdd.Visible    = HasAdd;
            btnDelete.Visible = HasDelete;
            dgvGridView.Columns[0].Visible = HasDelete;
            dgvGridView.Columns[1].Visible = HasEdit;
            dgvGridView.Columns[5].Visible = HasEdit;

            if ((Session[appFunctions.Session.ShowMessage.ToString()] != null))
            {
                if (!string.IsNullOrEmpty(Session[appFunctions.Session.ShowMessage.ToString()].ToString()))
                {
                    DInfo.ShowMessage(Session[appFunctions.Session.ShowMessage.ToString()].ToString(), (Enums.MessageType)Session[appFunctions.Session.ShowMessageType.ToString()]);
                    Session[appFunctions.Session.ShowMessage.ToString()]     = "";
                    Session[appFunctions.Session.ShowMessageType.ToString()] = "";
                }
            }
            objCommon = new clsCommon();
            objCommon.FillRecordPerPage(ref ddlPerPage);
            if ((Request.QueryString.Get("ID") != null))
            {
                objEncrypt = new clsEncryption();
                try
                {
                    hdnPKID.Value = objEncrypt.Decrypt(Request.QueryString.Get("ID"), appFunctions.strKey);
                    intSiteMapId  = Convert.ToInt32(hdnPKID.Value);
                }
                catch (Exception ex)
                {
                    // noIdFoundRedirect("Employee.aspx");
                }

                objEncrypt = null;
                if ((Request.QueryString.Get("type") != null))
                {
                    if ((Request.QueryString.Get("type") == "mtype"))
                    {
                        hdnType.Value = "mtype";
                    }
                    else
                    {
                        hdnType.Value = "";
                    }
                }
                else
                {
                    hdnType.Value = "";
                }
            }
            if (intSiteMapId != -1)
            {
                DataTable dt = new DataTable();

                objEncrypt = new clsEncryption();
                dynamic objTempMenuItem = new tblMenuItem();
                if (hdnType.Value == "")
                {
                    dt             = objTempMenuItem.GetSiteMap(intSiteMapId);
                    strSiteMapData = dt.Rows[0][0].ToString();
                    dt             = objTempMenuItem.GetMenuType(intSiteMapId, false);
                }
                else
                {
                    dt = objTempMenuItem.GetMenuType(intSiteMapId, true);
                }

                String[] SplitSiteMapString = strSiteMapData.Split('/');

                strSiteMap = "<a href='MasterMenus.aspx'>Menu Items</a>";

                if (SplitSiteMapString.Length > 1)
                {
                    strSiteMap += " >  <a href=MenuItems.aspx?Id=" + objEncrypt.Encrypt(dt.Rows[0]["appMenuTypeId"].ToString(), appFunctions.strKey) + "&type=mtype>" + dt.Rows[0]["appMenuTypeName"].ToString() + "</a>";
                    //strSiteMap = "<a href='MenuItems.aspx'>Parent Tabs </a>";
                }
                else
                {
                    strSiteMap += " > " + dt.Rows[0]["appMenuTypeName"].ToString();
                }

                for (int i = 0; i <= SplitSiteMapString.Length - 2; i += 1)
                {
                    String[] SplittedItems = SplitSiteMapString.GetValue(i).ToString().Split(',');
                    if (i == SplitSiteMapString.Length - 2)
                    {
                        strSiteMap += " > " + SplittedItems.GetValue(0);
                    }
                    else
                    {
                        strSiteMap += " > <a href='MenuItems.aspx?Id=" + objEncrypt.Encrypt(SplittedItems.GetValue(1).ToString(), appFunctions.strKey) + "'> " + SplittedItems.GetValue(0) + "</a>";
                    }
                }

                litSiteMap.Text = strSiteMap;
            }

            LoadDataGrid(true, false);
            txtSearch.Focus();
            objCommon = null;
        }
    }
Пример #2
0
    public void GenerateAlias(int intId)
    {
        DataTable   dt;
        tblMenuType objMenuType = new tblMenuType();

        objMenuItem = new tblMenuItem();
        objEncrypt  = new clsEncryption();
        dt          = objMenuItem.GetSiteMap(intId);
        strSiteMap  = dt.Rows[0][0].ToString().Trim('/');
        if (hdnMenuTypeId.Value == "")
        {
            dt = objMenuItem.GetMenuType(intId, false);
        }
        else
        {
            dt = objMenuItem.GetMenuType(Convert.ToInt32(hdnMenuTypeId.Value), true);
        }
        string[] SplitSiteMapString = strSiteMap.Split('/');
        objMenuType.Where.AppMenuTypeId.Value = ddlMenuType.SelectedValue;
        objMenuType.Query.Load();
        strSiteMap = "<a href='MasterMenus.aspx'>Menu Items</a>";
        if (objMenuType.RowCount > 0)
        {
            strSiteMap += " >  <a href=MenuItems.aspx?Id=" + objEncrypt.Encrypt(dt.Rows[0]["appMenuTypeId"].ToString(), appFunctions.strKey) + "&type=mtype>" + dt.Rows[0]["appMenuTypeName"].ToString() + "</a>";
        }
        if (objMenuType.AppNoOfLevel > SplitSiteMapString.Length - 1)
        {
            for (int i = 0; i <= SplitSiteMapString.Length - 1; i++)
            {
                string[] SplittedItems = SplitSiteMapString[i].Split(',');
                aliasPrefix += SplittedItems[0] + "/";
                if (i == SplitSiteMapString.Length - 1)
                {
                    strSiteMap += " > " + SplittedItems[0];
                }
                else
                {
                    strSiteMap += "> <a href='MenuItems.aspx?Id=" + objEncrypt.Encrypt(SplittedItems[1].ToString(), appFunctions.strKey) + "'>" + SplittedItems[0].ToString() + "</a>";
                }
            }
            siteMapLiteral.Text = strSiteMap.ToString();
            if (aliasPrefix.Length > 0)
            {
                aliasPrefix = aliasPrefix.Substring(0, aliasPrefix.Length - 1);
                aliasPrefix = aliasPrefix.Substring(0, aliasPrefix.LastIndexOf("/") + 1);
            }
            hdnAliasPrefix.Value = aliasPrefix.Replace(" ", "-");
        }
        else
        {
            Session[appFunctions.Session.ShowMessage.ToString()]     = "You Can't Add Menu Item For This Level As Maximum No. Of Level Is " + objMenuType.AppNoOfLevel.ToString();
            Session[appFunctions.Session.ShowMessageType.ToString()] = Enums.MessageType.Error;

            if (Request.QueryString.Get("PID") != null)
            {
                Response.Redirect("MenuItems.aspx?Id=" + Request.QueryString.Get("PID"), true);
            }
            else if (Request.QueryString.Get("TID") != null)
            {
                Response.Redirect("MenuItems.aspx?Id=" + Request.QueryString.Get("TID") + "&type=mtype", true);
            }
            else if (hdnPKID.Value == "")
            {
                Response.Redirect("Dashboard.aspx");
            }
        }
        objMenuItem = null;
        objMenuType = null;
    }