Exemplo n.º 1
0
		public bool AddSpaceLink(SpaceLinkInfo spacelinks)
		{
			//try
			//{
			IDataParameter[] prams = 
				{
					DbHelper.MakeInParam("@linkid", (DbType)SqlDbType.Int, 4,spacelinks.LinkId),
					DbHelper.MakeInParam("@userid", (DbType)SqlDbType.Int, 4,spacelinks.UserId),
					DbHelper.MakeInParam("@linktitle", (DbType)SqlDbType.NVarChar, 50,spacelinks.LinkTitle),
					DbHelper.MakeInParam("@linkurl", (DbType)SqlDbType.VarChar,255,spacelinks.LinkUrl),
					DbHelper.MakeInParam("@description", (DbType)SqlDbType.NVarChar, 200,spacelinks.Description),
			};
			string sqlstring = String.Format("INSERT INTO [" + BaseConfigs.GetTablePrefix + "spacelinks] ( [userid], [linktitle], [linkurl], [description]) VALUES ( @userid, @linktitle, @linkurl,  @description)");

			DbHelper.ExecuteNonQuery(CommandType.Text, sqlstring, prams);

			return true;
			//}
			//catch (Exception ex)
			//{
			//    errormsg = Globals.TransferSqlErrorInfo(ex.Message);
			//    return false;
			//}

		}
Exemplo n.º 2
0
        protected override void ShowPage()
        {
            pagetitle = "用户控制面板";

            if (userid == -1)
            {
                AddErrLine("你尚未登录");
                return;
            }
            user = Users.GetUserInfo(userid);
            if (config.Enablespace != 1)
            {
                AddErrLine("个人空间功能已被关闭");
                return;
            }

            if (user.Spaceid <= 0)
            {
                AddErrLine("您尚未开通个人空间");
                return;
            }

            if (DNTRequest.IsPost())
            {
                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                string linktitle = Utils.HtmlEncode(DNTRequest.GetString("linktitle"));
                if ((linktitle.Length > 50) || (linktitle == ""))
                {
                    AddErrLine("链接标题不得超过50个字符且不能为空");
                    return;
                }

                string linkurl = Utils.HtmlEncode(DNTRequest.GetString("linkurl"));
                if ((linkurl.Length > 255) || (linkurl == ""))
                {
                    AddErrLine("链接地址不得超过255个字符且不能为空");
                    return;
                }

                if (DNTRequest.GetString("description").Length > 200)
                {
                    AddErrLine("链接描述不得超过200个字符");
                    return;
                }

                string errorinfo = "";
                SpaceLinkInfo __spacelinkinfo = new SpaceLinkInfo();
                __spacelinkinfo.UserId = userid;
                __spacelinkinfo.LinkTitle = linktitle;
                __spacelinkinfo.LinkUrl = linkurl;
                __spacelinkinfo.Description = Utils.HtmlEncode(DNTRequest.GetString("description"));

                Space.Data.DbProvider.GetInstance().AddSpaceLink(__spacelinkinfo);

                if (errorinfo == "")
                {
                    SetUrl("usercpspacelinklist.aspx");
                    SetMetaRefresh();
                    SetShowBackLink(true);
                    AddMsgLine("添加友情链接完毕");
                }
                else
                {
                    AddErrLine(errorinfo);
                    return;
                }
            }
        }
Exemplo n.º 3
0
		public static SpaceLinkInfo[] GetSpaceLinksInfo (DataTable dt)
		{
			if(dt == null || dt.Rows.Count == 0)
				return null;

			SpaceLinkInfo[] spacelinksinfoarray = new SpaceLinkInfo[dt.Rows.Count];
			for(int i = 0 ; i < dt.Rows.Count ; i++)
			{
				spacelinksinfoarray[i] = new SpaceLinkInfo();
				spacelinksinfoarray[i].LinkId = TypeConverter.ObjectToInt(dt.Rows[i]["linkid"]);
				spacelinksinfoarray[i].UserId = TypeConverter.ObjectToInt(dt.Rows[i]["userid"]);
				spacelinksinfoarray[i].LinkTitle = dt.Rows[i]["linktitle"].ToString();
				spacelinksinfoarray[i].Description = dt.Rows[i]["description"].ToString();
				spacelinksinfoarray[i].LinkUrl =dt.Rows[i]["linkurl"].ToString();
			}
			dt.Dispose();
			return spacelinksinfoarray;
		}
Exemplo n.º 4
0
		public static SpaceLinkInfo GetSpaceLinksInfo (IDataReader idatareader)
		{
			if(idatareader == null)
				return null;

			if(idatareader.Read())
			{		
				SpaceLinkInfo spacelinksinfo = new SpaceLinkInfo();
				spacelinksinfo.LinkId = TypeConverter.ObjectToInt(idatareader["linkid"]);
				spacelinksinfo.UserId = TypeConverter.ObjectToInt(idatareader["userid"]);
				spacelinksinfo.LinkTitle = idatareader["linktitle"].ToString();
				spacelinksinfo.Description = idatareader["description"].ToString();
				spacelinksinfo.LinkUrl = idatareader["linkurl"].ToString();

                idatareader.Close();
				return spacelinksinfo;
			}
			else
			{
                idatareader.Close();
				return null;
			}
		}
Exemplo n.º 5
0
        public bool AddSpaceLink(SpaceLinkInfo spacelinks)
        {
            DbParameter[] parms = 
				{
					DbHelper.MakeInParam("@linkid", (DbType)SqlDbType.Int, 4,spacelinks.LinkId),
					DbHelper.MakeInParam("@userid", (DbType)SqlDbType.Int, 4,spacelinks.UserId),
					DbHelper.MakeInParam("@linktitle", (DbType)SqlDbType.NVarChar, 50,spacelinks.LinkTitle),
					DbHelper.MakeInParam("@linkurl", (DbType)SqlDbType.VarChar,255,spacelinks.LinkUrl),
					DbHelper.MakeInParam("@description", (DbType)SqlDbType.NVarChar, 200,spacelinks.Description),
				};
            string commandText = String.Format("INSERT INTO [{0}spacelinks] ( [userid], [linktitle], [linkurl], [description]) VALUES ( @userid, @linktitle, @linkurl,  @description)", BaseConfigs.GetTablePrefix);

            DbHelper.ExecuteNonQuery(CommandType.Text, commandText, parms);

            return true;
        }
Exemplo n.º 6
0
        public bool SaveSpaceLink(SpaceLinkInfo spacelinks)
        {
            DbParameter[] parms = 
				{
					DbHelper.MakeInParam("@linkid", (DbType)SqlDbType.Int, 4,spacelinks.LinkId),
					DbHelper.MakeInParam("@linktitle", (DbType)SqlDbType.NVarChar, 50,spacelinks.LinkTitle),
					DbHelper.MakeInParam("@linkurl", (DbType)SqlDbType.VarChar,255,spacelinks.LinkUrl),
					DbHelper.MakeInParam("@description", (DbType)SqlDbType.NVarChar, 200,spacelinks.Description),
				};
            string commandText = String.Format("UPDATE [{0}spacelinks] SET  [linktitle] = @linktitle, [linkurl] = @linkurl, [description] = @description WHERE [linkid] = @linkid ", BaseConfigs.GetTablePrefix);

            DbHelper.ExecuteNonQuery(CommandType.Text, commandText, parms);

            return true;
        }