Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.UrlReferrer != null)
            {
                ViewState["url"] = Request.UrlReferrer.ToString();
            }
            else
            {
                ViewState["url"] = "MenuList1.aspx";
            }
            if (Request.QueryString["sid"] != "" && Request.QueryString["sid"] != null)
            {
                int sid = Convert.ToInt32(Request.QueryString["sid"].ToString());
                model = bll.GetModel(sid);
                if (model.SCheck == 1)
                {
                    model.SCheck = 0;
                }
                else
                {
                    model.SCheck = 1;
                }

                bll.Update(model);
                Response.Redirect(ViewState["url"].ToString());
            }
        }
    }
Exemplo n.º 2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        int sid = Convert.ToInt32(Request.QueryString["sid"].ToString());

        model       = bll.GetModel(sid);
        model.SName = txtMuneName.Text.Trim();
        model.Surl  = txtUrlAdd.Text.Trim();
        try
        {
            model.Sorder = int.Parse(txtOrder.Text.Trim());
        }
        catch (Exception)
        {
            Response.Write("<script>alert('请输入数字')</script>");
            return;
        }

        model.Starget = DropDownList1.SelectedValue.Trim();
        if (bll.Update(model))
        {
            Response.Write("<script>alert('更新成功');location.href='" + ViewState["returnUrl"].ToString() + "';</script>");
            //Response.Redirect(ViewState["returnUrl"].ToString());
        }
        else
        {
            Response.Write("<script>alert('更新失败');location.href='" + ViewState["returnUrl"].ToString() + "';</script>");
        }
    }
Exemplo n.º 3
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int sid   = int.Parse(e.CommandArgument.ToString());
        int check = 0;

        switch (e.CommandName) //壮态

        {
        case "check":
            model = bll.GetModel(sid);
            if (model.SCheck == 0)
            {
                check = 1;
            }
            else
            {
                check = 0;
            }
            model.SCheck = check;
            bll.Update(model);
            databind(ViewState["order"].ToString());
            break;

        case "xiaji":    //添加一下级菜单
            Response.Redirect("MenuList2.aspx?sid=" + sid);
            break;

        case "modefiy":     //修改
            Response.Redirect("ModefiyMenu.aspx?sid=" + sid + "&ji=1");
            break;

        case "Del":    //删除
            bll.Delete(sid);
            databind(ViewState["order"].ToString());
            break;

        default:
            break;
        }
    }
Exemplo n.º 4
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        model.SName   = txtMuneName.Text.Trim();
        model.Surl    = txtUrlAdd.Text.Trim();
        model.Starget = DropDownList1.SelectedValue;
        model.SDate   = DateTime.Now;
        model.SCheck  = 1;
        model.Sorder  = 0;
        model.SCode   = "";
        if (ViewState["code"] != null)
        {
            model.SParentCode = Convert.ToInt32(ViewState["code"].ToString());
            if (model.SParentCode == 0) //一级节点
            {
                a = true;
            }
            else
            {
                model.Sparentsid = Convert.ToInt32(ViewState["code"].ToString());
            }

            // ViewState["code"] = null;
        }
        else
        {
            model.SParentCode = 0;
            a = true;
        }

        if (Request.QueryString["ji"] != null)
        {
            model.SisActive = Convert.ToInt32(Request.QueryString["ji"].ToString());
        }
        else
        {
            model.SisActive = 1;
        }
        int result = bll.Add(model);

        if (result > 0)
        {
            model.SCode = "M" + result;//改变model.SCode值
            model.sid   = result;
            if (a)
            {
                model.Sparentsid = result; //添加一级菜单
            }
            if (bll.Update(model))
            {
                Response.Write("<script>alert('添加成功');location.href='" + ViewState["returnUrl"].ToString() + "';</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败');location.href='" + ViewState["returnUrl"].ToString() + "';</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('添加失败');location.href='" + ViewState["returnUrl"].ToString() + "';</script>");
        }
    }