Example #1
0
    public void Bind()
    {
        Cms.BLL.wx_info   wxinfo = new Cms.BLL.wx_info();
        Cms.Model.wx_info minfo  = new Cms.Model.wx_info();
        minfo = wxinfo.GetModel(1);

        hdid.Value = minfo.access_token;

        Cms.BLL.wx_menu   wm  = new Cms.BLL.wx_menu();
        Cms.Model.wx_menu wmd = new Cms.Model.wx_menu();
        DataTable         dt  = wm.GetList("pid=0").Tables[0];

        rmenu.DataSource = dt.DefaultView;
        rmenu.DataBind();


        dt = wm.GetList("pid=1").Tables[0];
        rmenu1.DataSource = dt.DefaultView;
        rmenu1.DataBind();

        dt = wm.GetList("pid=2").Tables[0];
        rmenu2.DataSource = dt.DefaultView;
        rmenu2.DataBind();

        dt = wm.GetList("pid=3").Tables[0];
        rmenu3.DataSource = dt.DefaultView;
        rmenu3.DataBind();
    }
Example #2
0
    public string setmenutype(string name)
    {
        Cms.BLL.wx_menu wx = new Cms.BLL.wx_menu();
        DataTable       dt = wx.GetList("name='" + name + "'").Tables[0];

        if (dt.Rows.Count > 0)
        {
            return(dt.Rows[0]["type"].ToString());
        }
        return("");
    }
Example #3
0
    public void bindlist(string id)
    {
        string sid = "";

        if (ListBox1.SelectedItem != null)
        {
            sid = ListBox1.SelectedItem.Value;
        }

        if (ListBox2.SelectedItem != null)
        {
            sid = ListBox2.SelectedItem.Value;
        }

        if (ListBox3.SelectedItem != null)
        {
            sid = ListBox3.SelectedItem.Value;
        }

        Cms.BLL.wx_menu   wm  = new Cms.BLL.wx_menu();
        Cms.Model.wx_menu wmd = new Cms.Model.wx_menu();
        DataTable         dt  = wm.GetList("pid=" + id).Tables[0];

        tbmenu1.Text = "";
        tbmenu2.Text = "";
        tbmenu3.Text = "";
        tbmenu4.Text = "";
        tbmenu5.Text = "";
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (i == 0)
            {
                tbmenu1.Text = dt.Rows[i]["name"].ToString();
            }
            if (i == 1)
            {
                tbmenu2.Text = dt.Rows[i]["name"].ToString();
            }
            if (i == 2)
            {
                tbmenu3.Text = dt.Rows[i]["name"].ToString();
            }
            if (i == 3)
            {
                tbmenu4.Text = dt.Rows[i]["name"].ToString();
            }
            if (i == 4)
            {
                tbmenu5.Text = dt.Rows[i]["name"].ToString();
            }
        }
    }
Example #4
0
    protected void ListBox3_TextChanged(object sender, EventArgs e)
    {
        PlaceHolder4.Visible = true;
        ListBox1.ClearSelection();
        ListBox2.ClearSelection();
        ddeven.Items.Clear();
        int value = int.Parse(ListBox3.SelectedItem.Value);

        if (value == 3)
        {
            bindlist(value.ToString());
            PlaceHolder1.Visible = true;
            PlaceHolder2.Visible = false;
            PlaceHolder3.Visible = false;
            ddeven.Items.Insert(0, new ListItem("显示二级菜单", "0"));
            ddeven.Items.Insert(1, new ListItem("点击事件", "click"));
            ddeven.Items.Insert(2, new ListItem("链接地址", "url"));
        }
        else
        {
            ddeven.Items.Insert(0, new ListItem("点击事件", "click"));
            ddeven.Items.Insert(1, new ListItem("链接地址", "url"));
            Cms.BLL.wx_menu wm = new Cms.BLL.wx_menu();

            DataTable dt = wm.GetList("id=" + value).Tables[0];
            if (dt.Rows.Count > 0)
            {
                DataRow dr   = dt.Rows[0];
                string  type = dr["type"].ToString();
                if (type == "click")
                {
                    ddeven.SelectedValue = "click";
                    PlaceHolder1.Visible = false;
                    PlaceHolder2.Visible = true;
                    PlaceHolder3.Visible = false;
                    tbkey.Text           = dr["keys"].ToString();
                    tinfo.Value          = dr["info"].ToString();
                    tcontent.Value       = dr["content"].ToString();
                }
                else
                {
                    ddeven.SelectedValue = "url";
                    PlaceHolder1.Visible = false;
                    PlaceHolder2.Visible = false;
                    PlaceHolder3.Visible = true;
                    tburl.Text           = dr["url"].ToString();
                }
            }
        }

        tbname.Text = ListBox3.SelectedItem.Text;
    }
Example #5
0
    protected void ddeven_SelectedIndexChanged(object sender, EventArgs e)
    {
        string sid = "";

        if (ListBox1.SelectedItem != null)
        {
            sid = ListBox1.SelectedItem.Value;
        }

        if (ListBox2.SelectedItem != null)
        {
            sid = ListBox2.SelectedItem.Value;
        }

        if (ListBox3.SelectedItem != null)
        {
            sid = ListBox3.SelectedItem.Value;
        }

        string value = ddeven.SelectedValue.ToString();

        if (value == "0")
        {
            PlaceHolder1.Visible = true;
            PlaceHolder2.Visible = false;
            PlaceHolder3.Visible = false;
        }
        if (value == "click")
        {
            Cms.BLL.wx_menu wm = new Cms.BLL.wx_menu();
            tbkey.Text           = wm.GetList("id=" + sid).Tables[0].Rows[0]["keys"].ToString();
            tinfo.Value          = wm.GetList("id=" + sid).Tables[0].Rows[0]["info"].ToString();
            tcontent.Value       = wm.GetList("id=" + sid).Tables[0].Rows[0]["content"].ToString();
            PlaceHolder1.Visible = false;
            PlaceHolder2.Visible = true;
            PlaceHolder3.Visible = false;
        }
        if (value == "url")
        {
            Cms.BLL.wx_menu wm = new Cms.BLL.wx_menu();
            tburl.Text           = wm.GetList("id=" + sid).Tables[0].Rows[0]["url"].ToString();
            PlaceHolder1.Visible = false;
            PlaceHolder2.Visible = false;
            PlaceHolder3.Visible = true;
        }
    }
Example #6
0
    public string setmenuvalue(string name, int type)
    {
        Cms.BLL.wx_menu wx = new Cms.BLL.wx_menu();
        DataTable       dt = wx.GetList("name='" + name + "'").Tables[0];

        if (dt.Rows.Count > 0)
        {
            if (type == 0)
            {
                return(dt.Rows[0]["keys"].ToString());
            }
            if (type == 1)
            {
                return(dt.Rows[0]["url"].ToString());
            }
            if (type == 2)
            {
                return(dt.Rows[0]["info"].ToString());
            }
        }
        return("");
    }
Example #7
0
    public string bindlist(string id)
    {
        string str = "";

        Cms.BLL.wx_menu   wm  = new Cms.BLL.wx_menu();
        Cms.Model.wx_menu wmd = new Cms.Model.wx_menu();
        DataTable         dt  = wm.GetList("pid=" + id).Tables[0];

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (i == 0)
            {
                str += dt.Rows[i]["name"].ToString() + ",";
            }
            if (i == 1)
            {
                str += dt.Rows[i]["name"].ToString() + ",";
            }
            if (i == 2)
            {
                str += dt.Rows[i]["name"].ToString() + ",";
            }
            if (i == 3)
            {
                str += dt.Rows[i]["name"].ToString() + ",";
            }
            if (i == 4)
            {
                str += dt.Rows[i]["name"].ToString() + ",";
            }
        }
        if (str.Length > 1)
        {
            str = str.Substring(0, str.Length - 1);
        }
        return(str);
    }
Example #8
0
    public string setmenu()
    {
        Cms.BLL.wx_menu   wm  = new Cms.BLL.wx_menu();
        Cms.Model.wx_menu wmd = new Cms.Model.wx_menu();
        DataTable         dt  = wm.GetList("pid=0").Tables[0];
        StringBuilder     sb  = new StringBuilder();
        int i = 1;
        int j = 1;

        sb.Append("{");
        sb.Append("\"button\":[");
        foreach (DataRow dr in dt.Rows)
        {
            int       id   = int.Parse(dr["id"].ToString());
            string    name = dr["name"].ToString();
            string    type = dr["type"].ToString();
            string    key  = dr["keys"].ToString();
            string    url  = dr["url"].ToString();
            DataTable dts  = wm.GetList("pid=" + id).Tables[0];

            if (dts.Rows.Count > 0)
            {
                i = 1;
                sb.Append("{");
                sb.Append("\"name\":\"" + name + "\",");
                sb.Append("\"sub_button\":[");
                foreach (DataRow dr2 in dts.Rows)
                {
                    int    id2   = int.Parse(dr2["id"].ToString());
                    string name2 = dr2["name"].ToString();
                    string type2 = dr2["type"].ToString();
                    string key2  = dr2["keys"].ToString();
                    string url2  = dr2["url"].ToString();
                    if (i != dts.Rows.Count)
                    {
                        sb.Append("{");
                        if (type2 == "click")
                        {
                            sb.Append("\"type\":\"click\",");
                            sb.Append("\"name\":\"" + name2 + "\",");
                            sb.Append("\"key\":\"" + key2 + "\"");
                        }
                        if (type2 == "view")
                        {
                            sb.Append("\"type\":\"view\",");
                            sb.Append("\"name\":\"" + name2 + "\",");
                            sb.Append("\"url\":\"" + url2 + "\"");
                        }
                        sb.Append("},");
                    }
                    else
                    {
                        sb.Append("{");
                        if (type2 == "click")
                        {
                            sb.Append("\"type\":\"click\",");
                            sb.Append("\"name\":\"" + name2 + "\",");
                            sb.Append("\"key\":\"" + key2 + "\"");
                        }
                        if (type2 == "view")
                        {
                            sb.Append("\"type\":\"view\",");
                            sb.Append("\"name\":\"" + name2 + "\",");
                            sb.Append("\"url\":\"" + url2 + "\"");
                        }
                        if (j != 3)
                        {
                            sb.Append("}]},");
                        }
                        else
                        {
                            sb.Append("}]}");
                        }
                    }

                    i++;
                }
            }
            else
            {
                if (j != dt.Rows.Count)
                {
                    sb.Append("{");
                    if (type == "click")
                    {
                        sb.Append("\"type\":\"click\",");
                        sb.Append("\"name\":\"" + name + "\",");
                        sb.Append("\"key\":\"" + key + "\"");
                    }
                    if (type == "view")
                    {
                        sb.Append("\"type\":\"view\",");
                        sb.Append("\"name\":\"" + name + "\",");
                        sb.Append("\"url\":\"" + url + "\"");
                    }
                    sb.Append("},");
                }
                else
                {
                    sb.Append("{");
                    if (type == "click")
                    {
                        sb.Append("\"type\":\"click\",");
                        sb.Append("\"name\":\"" + name + "\",");
                        sb.Append("\"key\":\"" + key + "\"");
                    }
                    if (type == "view")
                    {
                        sb.Append("\"type\":\"view\",");
                        sb.Append("\"name\":\"" + name + "\",");
                        sb.Append("\"url\":\"" + url + "\"");
                    }
                    sb.Append("}");
                }
            }


            j++;
        }
        sb.Append("]");
        sb.Append("}");
        return(sb.ToString());
    }
Example #9
0
    protected void btnsaves_Click(object sender, EventArgs e)
    {
        Cms.BLL.wx_menu   wm  = new Cms.BLL.wx_menu();
        Cms.Model.wx_menu wmd = new Cms.Model.wx_menu();
        string            sid = "";

        if (ListBox1.SelectedItem != null)
        {
            sid = ListBox1.SelectedItem.Value;
        }

        if (ListBox2.SelectedItem != null)
        {
            sid = ListBox2.SelectedItem.Value;
        }

        if (ListBox3.SelectedItem != null)
        {
            sid = ListBox3.SelectedItem.Value;
        }


        string seven = ddeven.SelectedValue.ToString();

        if (sid != null && sid != "")
        {
            wmd      = wm.GetModel(int.Parse(sid));
            wmd.name = tbname.Text;
            if (seven == "0")
            {
                string smuen1 = tbmenu1.Text.Trim();
                string smuen2 = tbmenu2.Text.Trim();
                string smuen3 = tbmenu3.Text.Trim();
                string smuen4 = tbmenu4.Text.Trim();
                string smuen5 = tbmenu5.Text.Trim();
                string smuen  = "";
                if (smuen1 != "")
                {
                    smuen += smuen1 + ",";
                }
                if (smuen1 != "")
                {
                    smuen += smuen2 + ",";
                }
                if (smuen1 != "")
                {
                    smuen += smuen3 + ",";
                }
                if (smuen1 != "")
                {
                    smuen += smuen4 + ",";
                }
                if (smuen1 != "")
                {
                    smuen += smuen5 + ",";
                }
                if (smuen != "")
                {
                    smuen = smuen.Substring(0, smuen.Length - 1);
                }
                DataTable dtt    = wm.GetList("pid=" + sid).Tables[0];
                string    strid  = "";
                string    strid2 = "";
                foreach (DataRow dr in dtt.Rows)
                {
                    string str = dr["name"].ToString();
                    if (smuen.IndexOf(str) > -1)
                    {
                        strid += str + ",";
                    }
                    else
                    {
                        strid2 += dr["id"].ToString() + ",";
                    }
                }
                if (strid2 != "")
                {
                    strid2 = strid2.Substring(0, strid2.Length - 1);
                    wm.DeleteList(strid2);
                }

                string[] s = smuen.Split(',');
                foreach (string ss in s)
                {
                    if (strid.IndexOf(ss) == -1)
                    {
                        Cms.Model.wx_menu wmds = new Cms.Model.wx_menu();
                        wmds.name = ss;
                        wmds.pid  = sid;
                        wmds.time = DateTime.Now;
                        wm.Add(wmds);
                    }
                }
            }
            if (seven == "click")
            {
                wmd.type = "click";
                string skey = tbkey.Text.Trim();
                if (wmd.keys != skey)
                {
                    DataTable dt = wm.GetList("keys='" + skey + "'").Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        //ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('key值不能重复!')</script>");
                        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('key值不能重复!');", true);
                        return;
                    }
                }
                wmd.keys = tbkey.Text.Trim();
                wmd.info = tinfo.Value.Trim();
            }
            if (seven == "url")
            {
                wmd.keys = "";
                wmd.type = "view";
                wmd.url  = tburl.Text.Trim();
            }
            if (wm.Update(wmd))
            {
                // ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('设置成功!')</script>");
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('设置成功!');", true);
            }
            else
            {
                // ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('设置失败!')</script>");
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('设置失败!');", true);
            }
        }
        else
        {
            string name = tbname.Text.Trim();
            if (name != "")
            {
                DataTable dtwx = wm.GetList("").Tables[0];
                if (dtwx.Rows.Count == 0 || dtwx.Rows.Count < 3)
                {
                    wmd.name = name;
                    wmd.pid  = "0";
                    wmd.time = DateTime.Now;
                    if (wm.Add(wmd) > 0)
                    {
                        //ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('设置成功!')</script>");
                        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('设置成功!');", true);
                    }
                    else
                    {
                        //ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('设置失败!')</script>");
                        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('设置失败!');", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('设置无效!');", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", "alert('设置无效!');", true);
            }
        }
    }
Example #10
0
    public void Bind()
    {
        // Response.Write(setmenu());
        Cms.BLL.wx_info   wx  = new Cms.BLL.wx_info();
        Cms.Model.wx_info mwx = new Cms.Model.wx_info();
        DataTable         dt  = wx.GetList("").Tables[0];

        if (dt.Rows.Count > 0)
        {
            mwx = wx.GetModel(1);
            if (mwx != null)
            {
                AppId.Text     = mwx.AppId;
                AppSecret.Text = mwx.AppSecret;
                hdid.Text      = mwx.access_token;
            }
            mwx = wx.GetModel(2);
            if (mwx != null)
            {
                tbid.Text   = mwx.AppId;
                tburls.Text = mwx.AppSecret;
            }
        }
        Cms.BLL.wx_menu   wm  = new Cms.BLL.wx_menu();
        Cms.Model.wx_menu wmd = new Cms.Model.wx_menu();
        dt = wm.GetList("pid=0").Tables[0];

        foreach (DataRow dr in dt.Rows)
        {
            int    id   = int.Parse(dr["id"].ToString());
            string name = dr["name"].ToString();
            int    pid  = int.Parse(dr["pid"].ToString());
            if (id == 1)
            {
                DataTable dts = wm.GetList("pid=" + id).Tables[0];


                ListBox1.DataSource     = dts.DefaultView;
                ListBox1.DataTextField  = "name";
                ListBox1.DataValueField = "id";
                ListBox1.DataBind();
                ListBox1.Items.Insert(0, new ListItem(name, id.ToString()));
            }
            if (id == 2)
            {
                DataTable dts = wm.GetList("pid=" + id).Tables[0];

                ListBox2.DataSource     = dts.DefaultView;
                ListBox2.DataTextField  = "name";
                ListBox2.DataValueField = "id";
                ListBox2.DataBind();
                ListBox2.Items.Insert(0, new ListItem(name, id.ToString()));
            }
            if (id == 3)
            {
                DataTable dts = wm.GetList("pid=" + id).Tables[0];

                ListBox3.DataSource     = dts.DefaultView;
                ListBox3.DataTextField  = "name";
                ListBox3.DataValueField = "id";
                ListBox3.DataBind();
                ListBox3.Items.Insert(0, new ListItem(name, id.ToString()));
            }
        }
    }