예제 #1
0
 protected void btnAddTopic_Click(object sender, EventArgs e)
 {
     if (ReplyHelper.HasReplyKey(this.txtKeys.Text.Trim()))
     {
         this.ShowMsg("关键字重复!", false);
     }
     else
     {
         string str = string.Empty;
         if (this.fileUpload.HasFile)
         {
             try
             {
                 str = VShopHelper.UploadTopicImage(this.fileUpload.PostedFile);
             }
             catch
             {
                 this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false);
                 return;
             }
         }
         TopicInfo target = new TopicInfo {
             Title = this.txtTopicTitle.Text.Trim(),
             Keys = this.txtKeys.Text.Trim(),
             IconUrl = str,
             Content = this.fcContent.Text,
             AddedDate = DateTime.Now,
             IsRelease = true
         };
         ValidationResults results = Hishop.Components.Validation.Validation.Validate<TopicInfo>(target, new string[] { "ValTopicInfo" });
         string msg = string.Empty;
         if (results.IsValid)
         {
             int num;
             if (VShopHelper.Createtopic(target, out num) && (num > 0))
             {
                 base.Response.Redirect("SetTopicProducts.aspx?topicid=" + num);
             }
             else
             {
                 this.ShowMsg("添加专题错误", false);
             }
         }
         else
         {
             foreach (ValidationResult result in (IEnumerable<ValidationResult>) results)
             {
                 msg = msg + Formatter.FormatErrorMessage(result.Message);
             }
             this.ShowMsg(msg, false);
         }
     }
 }
예제 #2
0
 public int AddTopic(TopicInfo topicinfo)
 {
     int num;
     StringBuilder builder = new StringBuilder();
     builder.Append("insert into Vshop_Topics(Title,IconUrl,Content,AddedDate,IsRelease,DisplaySequence)");
     builder.Append(" values (@Title,@IconUrl,@Content,@AddedDate,@IsRelease,@DisplaySequence);");
     builder.Append(" select @@IDENTITY");
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString());
     this.database.AddInParameter(sqlStringCommand, "Title", DbType.String, topicinfo.Title);
     this.database.AddInParameter(sqlStringCommand, "IconUrl", DbType.String, topicinfo.IconUrl);
     this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, topicinfo.Content);
     this.database.AddInParameter(sqlStringCommand, "AddedDate", DbType.DateTime, topicinfo.AddedDate);
     this.database.AddInParameter(sqlStringCommand, "IsRelease", DbType.Boolean, topicinfo.IsRelease);
     this.database.AddInParameter(sqlStringCommand, "DisplaySequence", DbType.Int32, topicinfo.DisplaySequence);
     this.database.AddInParameter(sqlStringCommand, "Keys", DbType.String, topicinfo.Keys);
     int.TryParse(this.database.ExecuteScalar(sqlStringCommand).ToString(), out num);
     return num;
 }
예제 #3
0
 public static bool Createtopic(TopicInfo topic, out int id)
 {
     id = 0;
     if (null == topic)
     {
         return false;
     }
     Globals.EntityCoding(topic, true);
     id = new TopicDao().AddTopic(topic);
     ReplyInfo reply = new TextReplyInfo {
         Keys = topic.Keys,
         MatchType = MatchType.Equal,
         MessageType = MessageType.Text,
         ReplyType = ReplyType.Topic,
         ActivityId = id
     };
     return new ReplyDao().SaveReply(reply);
 }
예제 #4
0
 public static TopicInfo PopulateTopic(IDataReader reader)
 {
     TopicInfo info = new TopicInfo {
         TopicId = (int) reader["TopicId"],
         Title = (string) reader["Title"]
     };
     if (reader["IconUrl"] != DBNull.Value)
     {
         info.IconUrl = (string) reader["IconUrl"];
     }
     info.Content = (string) reader["Content"];
     info.AddedDate = (DateTime) reader["AddedDate"];
     info.IsRelease = (bool) reader["IsRelease"];
     return info;
 }
예제 #5
0
 public bool UpdateTopic(TopicInfo topic)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("update Vshop_Topics set ");
     builder.Append("Title=@Title,");
     builder.Append("IconUrl=@IconUrl,");
     builder.Append("Content=@Content,");
     builder.Append("AddedDate=@AddedDate,");
     builder.Append("DisplaySequence=@DisplaySequence,");
     builder.Append("IsRelease=@IsRelease");
     builder.Append(" where TopicId=@TopicId ");
     builder.Append(" UPDATE vshop_Reply SET Keys = @Keys WHERE  ActivityId = @TopicId  AND [ReplyType] = @ReplyType");
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString());
     this.database.AddInParameter(sqlStringCommand, "TopicId", DbType.Int32, topic.TopicId);
     this.database.AddInParameter(sqlStringCommand, "Title", DbType.String, topic.Title);
     this.database.AddInParameter(sqlStringCommand, "IconUrl", DbType.String, topic.IconUrl);
     this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, topic.Content);
     this.database.AddInParameter(sqlStringCommand, "AddedDate", DbType.DateTime, topic.AddedDate);
     this.database.AddInParameter(sqlStringCommand, "DisplaySequence", DbType.Int32, topic.DisplaySequence);
     this.database.AddInParameter(sqlStringCommand, "IsRelease", DbType.Boolean, topic.IsRelease);
     this.database.AddInParameter(sqlStringCommand, "Keys", DbType.String, topic.Keys);
     this.database.AddInParameter(sqlStringCommand, "ReplyType", DbType.Int32, 0x200);
     return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
예제 #6
0
 public static bool Updatetopic(TopicInfo topic)
 {
     if (null == topic)
     {
         return false;
     }
     Globals.EntityCoding(topic, true);
     return new TopicDao().UpdateTopic(topic);
 }