private void GetFromData(NavInfo nav)
 {
     nav.Name = GetMaxlengthString(DNTRequest.GetFormString("name"),50);
     nav.Title = GetMaxlengthString(DNTRequest.GetFormString("title"), 255);
     nav.Url = GetMaxlengthString(DNTRequest.GetFormString("url"), 255);
     nav.Target = DNTRequest.GetFormInt("target", 0);
     nav.Available = DNTRequest.GetFormInt("available", 0);
     nav.Displayorder = DNTRequest.GetFormInt("displayorder", 0);
     nav.Level = DNTRequest.GetFormInt("level", 0);
 }
Example #2
0
 /// <summary>
 /// 得到自定义菜单不重复的PARENTID
 /// </summary>
 /// <returns></returns>
 public static List<NavInfo> GetNavigationHasSub()
 {
     List<NavInfo> info = new List<NavInfo>();
     IDataReader reader = DatabaseProvider.GetInstance().GetNavigationHasSub();
     while (reader.Read())
     {
         NavInfo m = new NavInfo();
         m.Parentid = TypeConverter.ObjectToInt(reader["parentid"], 0);
         info.Add(m);
     }
     reader.Close();
     return info;
 }
        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")
                {
                    Navs.DeleteNavigation(DNTRequest.GetQueryInt("id",0));
                    Response.Redirect(Request.Path + (DNTRequest.GetString("parentid") != "" ? "?parentid=" + DNTRequest.GetString("parentid") : ""),true);
                }
                else
                {
                    if (DNTRequest.GetFormString("name").Trim() == "" || 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")
                    {
                        NavInfo nav = new NavInfo();
                        nav.Parentid = DNTRequest.GetQueryInt("parentid",0);
                        GetFromData(nav);
                        Navs.InsertNavigation(nav);

                    }
                    else
                    {
                        NavInfo nav = new NavInfo();
                        nav.Id = DNTRequest.GetFormInt("menuid", 0);
                        GetFromData(nav);
                        Navs.UpdateNavigation(nav);
                    }
                    Response.Redirect(Request.RawUrl, true);
                }
            }
            else
            {
                BindDataGrid(DNTRequest.GetQueryInt("parentid",0));
                if(DNTRequest.GetString("parentid") == "")
                {
                    returnbutton.Visible = false;
                }
            }
        }
Example #4
0
 /// <summary>
 /// 得到自定义菜单信息
 /// </summary>
 /// <returns></returns>
 public static List<NavInfo> GetNavigation()
 {
     List<NavInfo> info = new List<NavInfo>();
     IDataReader reader = GetNavigation(false);
     while (reader.Read())
     {
         NavInfo m = new NavInfo();
         m.Id = TypeConverter.ObjectToInt(reader["id"], 0);
         m.Level = TypeConverter.ObjectToInt(reader["level"], 0);
         m.Name = reader["name"].ToString();
         m.Parentid = TypeConverter.ObjectToInt(reader["parentid"], 0);
         m.Target = TypeConverter.ObjectToInt(reader["target"], 0);
         m.Title = reader["title"].ToString();
         m.Type = TypeConverter.ObjectToInt(reader["type"], 0);
         m.Url = reader["url"].ToString();
         m.Available = TypeConverter.ObjectToInt(reader["available"], 0);
         m.Displayorder = TypeConverter.ObjectToInt(reader["displayorder"], 0);
         info.Add(m);
     }
     reader.Close();
     return info;
 }
Example #5
0
 public void UpdateNavigation(NavInfo nav)
 {
     DbParameter[] param = {
                                  DbHelper.MakeInParam("@name",(DbType)SqlDbType.NChar, 50, nav.Name),
                                  DbHelper.MakeInParam("@title",(DbType)SqlDbType.NChar, 255, nav.Title),
                                  DbHelper.MakeInParam("@url",(DbType)SqlDbType.Char, 255, nav.Url),
                                  DbHelper.MakeInParam("@target",(DbType)SqlDbType.TinyInt, 1, nav.Target),
                                  DbHelper.MakeInParam("@available",(DbType)SqlDbType.TinyInt,1,nav.Available),
                                  DbHelper.MakeInParam("@displayorder",(DbType)SqlDbType.SmallInt,2,nav.Displayorder),
                                  DbHelper.MakeInParam("@level",(DbType)SqlDbType.TinyInt,1,nav.Level),
                                  DbHelper.MakeInParam("@id",(DbType)SqlDbType.Int,4,nav.Id)
                                };
     string commandText = String.Format("UPDATE [{0}navs] set [name]=@name,[title]=@title,[url]=@url,[target]=@target,[available]=@available,[displayorder]=@displayorder,[level]=@level WHERE id=@id",
                                         BaseConfigs.GetTablePrefix);
     DbHelper.ExecuteNonQuery(CommandType.Text, commandText, param);
 }
Example #6
0
 public void InsertNavigation(NavInfo nav)
 {
     DbParameter[] param = {
                                  DbHelper.MakeInParam("@parentid",(DbType)SqlDbType.Int,4,nav.Parentid),
                                  DbHelper.MakeInParam("@name",(DbType)SqlDbType.NChar, 50, nav.Name),
                                  DbHelper.MakeInParam("@title",(DbType)SqlDbType.NChar, 255, nav.Title),
                                  DbHelper.MakeInParam("@url",(DbType)SqlDbType.Char, 255, nav.Url),
                                  DbHelper.MakeInParam("@target",(DbType)SqlDbType.TinyInt, 1, nav.Target),
                                  DbHelper.MakeInParam("@available",(DbType)SqlDbType.TinyInt,1,nav.Available),
                                  DbHelper.MakeInParam("@displayorder",(DbType)SqlDbType.SmallInt,2,nav.Displayorder),
                                  DbHelper.MakeInParam("@level",(DbType)SqlDbType.TinyInt,1,nav.Level)
                                };
     string commandText = String.Format("INSERT INTO [{0}navs] ([parentid],[name],[title],[url],[target],[type],[available],[displayorder],[level]) VALUES(@parentid,@name,@title,@url,@target,1,@available,@displayorder,@level)",
                                         BaseConfigs.GetTablePrefix);
     DbHelper.ExecuteNonQuery(CommandType.Text, commandText, param);
 }
Example #7
0
 /// <summary>
 /// 更新导航菜单
 /// </summary>
 /// <param name="nav">导航菜单类</param>
 public static void UpdateNavigation(NavInfo nav)
 {
     Data.Navs.UpdateNavigation(nav);
     ClearNavigation();
     InitNavigation();
 }
Example #8
0
 /// <summary>
 /// 添加导航菜单
 /// </summary>
 /// <param name="nav"></param>
 public static void InsertNavigation(NavInfo nav)
 {
     Data.Navs.InsertNavigation(nav);
     ClearNavigation();
     InitNavigation();
 }
Example #9
0
 /// <summary>
 /// 更新导航菜单
 /// </summary>
 /// <param name="nav">导航菜单类</param>
 public static void UpdateNavigation(NavInfo nav)
 {
     DatabaseProvider.GetInstance().UpdateNavigation(nav);
 }
Example #10
0
 /// <summary>
 /// 添加导航菜单
 /// </summary>
 /// <param name="nav">导航菜单类</param>
 public static void InsertNavigation(NavInfo nav)
 {
     DatabaseProvider.GetInstance().InsertNavigation(nav);
 }