예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataGrid1.DataKeyField = "id";
            string menuid = DNTRequest.GetString("menuid");
            string mode   = DNTRequest.GetString("mode");

            if (mode != "")
            {
                if (mode == "del")
                {
                    Nav.Delete(Nav._.ID == DNTRequest.GetQueryInt("id", 0));
                    Response.Redirect(Request.Path + (DNTRequest.GetString("parentid") != "" ? "?parentid=" + DNTRequest.GetString("parentid") : ""), true);
                }
                else
                {
                    if (String.IsNullOrEmpty(DNTRequest.GetFormString("name").Trim()) ||
                        String.IsNullOrEmpty(DNTRequest.GetFormString("displayorder").Trim()) ||
                        DNTRequest.GetFormInt("displayorder", 0) > Int16.MaxValue)
                    {
                        this.RegisterStartupScript("", "<script type='text/javascript'>alert('名称或序号输入不合法。');window.location=window.location;</script>");
                        return;
                    }
                    if (menuid == "0")
                    {
                        Nav nav = new Nav();
                        nav.ParentID = DNTRequest.GetQueryInt("parentid", 0);
                        GetFromData(nav);
                        //Nav.Insert(nav);
                        nav.Insert();
                    }
                    else
                    {
                        Nav nav = new Nav();
                        nav = Nav.Find(Nav._.ID == DNTRequest.GetFormInt("menuid", 0));
                        GetFromData(nav);
                        Nav.Update(nav);
                    }
                    Response.Redirect(Request.RawUrl, true);
                }
            }
            else
            {
                BindDataGrid(DNTRequest.GetQueryInt("parentid", 0));
                if (String.IsNullOrEmpty(DNTRequest.GetString("parentid")))
                {
                    returnbutton.Visible = false;
                }
            }
        }