/// <summary>
 /// 绑定第一级目录
 /// </summary>
 private void BindFirstLevels()
 {
     IList<Owen.Model.Model_Resource> list = new Owen.BLL.BLL_Resource().GetEntities(string.Format(" Levels = 1 "));
     ddlResourceName.DataTextField = "ResourceName";
     ddlResourceName.DataValueField = "resourceId";
     ddlResourceName.DataSource = list;
     ddlResourceName.DataBind();
     ddlResourceName.Items.Insert(0, new ListItem("--请选择--", ""));
 }
示例#2
0
    /// <summary>
    /// 绑定子菜单事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void LeftMenu_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Model_UserInfo modelUser = new Owen.BLL.BLL_UserInfo().GetEntity(userID);
        if (modelUser.UserType == 1)
        {
            Model_Resource modelResource = (Model_Resource)e.Item.DataItem;

            string strWhere = string.Format(" Levels = 2 and  ParentID ={0}", modelResource.ResourceID);
            IList<Model_Resource> list2 = new Owen.BLL.BLL_Resource().GetEntities(strWhere);

            if (list2.Count > 0)
            {
                Repeater LeftSubID = (Repeater)e.Item.FindControl("LeftMenu_Sub");
                LeftSubID.DataSource = list2;
                LeftSubID.DataBind();
            }
            else
            {
                e.Item.Visible = false;
            }
        }
        else
        {
            DataRowView dv = (DataRowView)e.Item.DataItem;
            DataTable table = new Owen.BLL.BLL_RolesAuthorize().QueryLinks(modelUser.UserID, 2, Convert.ToInt32(dv.Row["ResourceID"]));
            foreach (DataRow r in table.Rows)
            {

                System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"^.*\?.+=.+$");
                if (reg.IsMatch(r["Links"].ToString()))
                    r["Links"] = r["Links"].ToString().Trim() + "&" + Owen.Common.Constant.ResourceID + "=" + r["ResourceID"].ToString();
                else
                    r["Links"] = r["Links"].ToString().Trim() + "?" + Owen.Common.Constant.ResourceID + "=" + r["ResourceID"].ToString();
            }

            if (table.Rows.Count > 0)
            {
                Repeater LeftSubID = (Repeater)e.Item.FindControl("LeftMenu_Sub");
                LeftSubID.DataSource = table;
                LeftSubID.DataBind();
            }
            else
            {
                e.Item.Visible = false;
            }
        }
    }
示例#3
0
 /// <summary>
 /// 绑定主菜单
 /// </summary>
 private void BindMenu()
 {
     Model_UserInfo modelUser = new Owen.BLL.BLL_UserInfo().GetEntity(userID);
     //超级用户
     if (modelUser.UserType == 1)
     {
         string sqlWhere = " Levels = 1 ";
         IList<Model_Resource> list = new Owen.BLL.BLL_Resource().GetEntities(sqlWhere);
         LeftMenu.DataSource = list;
         LeftMenu.DataBind();
     }
     else
     {
         DataTable table = new Owen.BLL.BLL_RolesAuthorize().QueryLinks(modelUser.UserID, 1, 0);
         LeftMenu.DataSource = table;
         LeftMenu.DataBind();
     }
 }
    /// <summary>
    /// 初始加载
    /// </summary>
    private void OnStart()
    {
        Owen.Model.Model_Resource model = new Owen.BLL.BLL_Resource().GetEntity(resourceId);

        if (model == null) return;

        this.txtResourceName.Text = model.ResourceName;
        this.txtResourceTitles.Text = model.ResourceTitles;
        this.ddlResLevels.SelectedValue = model.Levels.ToString();
        this.txtLinks.Text = model.Links;

        this.txtRemark.Value = model.Remark;

        if (model.ParentID != 0)
        {
            this.ddlResourceName.SelectedValue = model.ParentID.ToString();
        }

        SelectingOperate();
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Owen.Model.Model_Resource modelResource =
                            new Owen.BLL.BLL_Resource().GetEntity(resourceId);

        if (modelResource == null)
            modelResource = new Owen.Model.Model_Resource();

        if (String.IsNullOrEmpty(txtResourceName.Text))
        {
            JSHelper.Alert(this, "请输入资源名称!");
            return;
        }
        if ((action.Equals("add")) && new Owen.BLL.BLL_Resource().Exists(txtResourceName.Text))
        {
            JSHelper.Alert(this, "资源名已存在!");
            return;
        }
        if ((action.Equals("edit")) && new Owen.BLL.BLL_Resource().Exists(txtResourceName.Text, resourceId))
        {
            JSHelper.Alert(this, "资源名已存在!");
            return;
        }
        if (this.ddlResLevels.SelectedValue.Equals("2") && String.IsNullOrEmpty(txtLinks.Text))
        {
            JSHelper.Alert(this, "请输入资源链接地址!");
            return;
        }
        //如果是1级
        if (ddlResLevels.SelectedValue.Equals("1"))
        {
            if (!String.IsNullOrEmpty(ddlResourceName.SelectedValue))
            {
                JSHelper.Alert(this, "添加一级资源,请不要选择一级目录!");
                return;
            }
        }
        //如果是2级,则有父节点
        if (ddlResLevels.SelectedValue.Equals("2"))
        {
            if (!String.IsNullOrEmpty(ddlResourceName.SelectedValue))
            {
                int p = 0;
                int.TryParse(ddlResourceName.SelectedValue, out p);
                if (p != 0)
                    modelResource.ParentID = p;
            }
            else
            {
                JSHelper.Alert(this, "请选择一级目录!");
                return;
            }
        }
        modelResource.ResourceName = txtResourceName.Text;
        modelResource.ResourceTitles = txtResourceTitles.Text;
        modelResource.Levels = Convert.ToInt32(ddlResLevels.SelectedValue);
        modelResource.Links = txtLinks.Text;
        modelResource.Remark = txtRemark.Value;
        modelResource.Sort = 0;

        switch (action)
        {
            case "add":
                new Owen.BLL.BLL_Resource().Insert(modelResource, cblOperate);
                JSHelper.Alert(this, "保存成功!", "ResourceList.aspx");
                break;
            case "edit":
                new Owen.BLL.BLL_Resource().Update(modelResource, cblOperate);
                JSHelper.Alert(this, "保存成功!", "ResourceList.aspx");
                break;
        }

    }