コード例 #1
0
        /// <summary>
        /// 添加二级信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddTwo_Click(object sender, EventArgs e)
        {
            string pid = this.ddlOne.SelectedValue;

            if (pid == "0")
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('请选择一级分类!');", true);
                return;
            }
            string twoName = this.txtTwo.Text.Trim();

            if (twoName.Length == 0)
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('二级分类名称不能为空!');", true);
                return;
            }
            OALevel item = new OALevel();

            item.levelName = twoName;
            item.isParent  = 0;
            item.url       = txtURL.Text.Trim();
            OALevel parentItem = OALevelService.GetModel(Convert.ToInt32(pid));

            if (parentItem != null)
            {
                item.parentLevelNo = parentItem.levelNO;
            }
            else
            {
                item.parentLevelNo = 0;
            }
            item.levelNO = OALevelService.GetMaxLevelNo(item.parentLevelNo);
            item.status  = 0;
            item.remark  = "";
            int num = OALevelService.Add(item);

            if (num > 0)
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('添加成功!');", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('添加失败!');", true);
            }
            GetTwo(pid);
        }
コード例 #2
0
        /// <summary>
        /// 一级权限菜单信息加载
        /// </summary>
        /// <returns></returns>
        private void GetTwo(string pid)
        {
            StringBuilder sb = new StringBuilder();

            if (pid != "0")
            {
                OALevel item = OALevelService.GetModel(Convert.ToInt32(pid));
                if (item != null)
                {
                    DataSet ds = OALevelService.GetList("parentLevelNo = " + item.levelNO);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            sb.Append("<label class=\"preview\"><input type=\"radio\" id='city" + dr["id"] + "' name='city' onclick=\"getTwoInfo(" + dr["id"] + ",'" + dr["levelName"] + "',this,'" + dr["url"] + "');\" />" + dr["levelName"] + "</label>");
                        }
                    }
                }
            }
            ViewState["twoInfo"] = sb.ToString();
        }