public int SaveActivity(Hidistro.Entities.VShop.ActivityInfo activity) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("INSERT INTO vshop_Activity(").Append("Name,Description,StartDate,EndDate,CloseRemark,Keys").Append(",MaxValue,PicUrl,Item1,Item2,Item3,Item4,Item5)").Append(" VALUES (").Append("@Name,@Description,@StartDate,@EndDate,@CloseRemark,@Keys").Append(",@MaxValue,@PicUrl,@Item1,@Item2,@Item3,@Item4,@Item5)").Append(";select @@IDENTITY"); System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand(stringBuilder.ToString()); this.database.AddInParameter(sqlStringCommand, "Name", System.Data.DbType.String, activity.Name); this.database.AddInParameter(sqlStringCommand, "Description", System.Data.DbType.String, activity.Description); this.database.AddInParameter(sqlStringCommand, "StartDate", System.Data.DbType.DateTime, activity.StartDate); this.database.AddInParameter(sqlStringCommand, "EndDate", System.Data.DbType.DateTime, activity.EndDate); this.database.AddInParameter(sqlStringCommand, "CloseRemark", System.Data.DbType.String, activity.CloseRemark); this.database.AddInParameter(sqlStringCommand, "Keys", System.Data.DbType.String, activity.Keys); this.database.AddInParameter(sqlStringCommand, "MaxValue", System.Data.DbType.Int32, activity.MaxValue); this.database.AddInParameter(sqlStringCommand, "PicUrl", System.Data.DbType.String, activity.PicUrl); this.database.AddInParameter(sqlStringCommand, "Item1", System.Data.DbType.String, activity.Item1); this.database.AddInParameter(sqlStringCommand, "Item2", System.Data.DbType.String, activity.Item2); this.database.AddInParameter(sqlStringCommand, "Item3", System.Data.DbType.String, activity.Item3); this.database.AddInParameter(sqlStringCommand, "Item4", System.Data.DbType.String, activity.Item4); this.database.AddInParameter(sqlStringCommand, "Item5", System.Data.DbType.String, activity.Item5); object obj = this.database.ExecuteScalar(sqlStringCommand); int result; int.TryParse(obj.ToString(), out result); return(result); }
private void btnAddActivity_Click(object sender, EventArgs e) { if (ReplyHelper.HasReplyKey(this.txtKeys.Text.Trim())) { this.ShowMsg("关键字重复!", false); } else { int result = 0; if (!this.txtStartDate.SelectedDate.HasValue) { this.ShowMsg("请选择开始日期!", false); } else if (!this.txtEndDate.SelectedDate.HasValue) { this.ShowMsg("请选择结束日期!", false); } else if (this.txtStartDate.SelectedDate.Value.CompareTo(this.txtEndDate.SelectedDate.Value) >= 0) { this.ShowMsg("开始日期不能晚于结束日期!", false); } else if ((this.txtMaxValue.Text != "") && !int.TryParse(this.txtMaxValue.Text, out result)) { this.ShowMsg("人数上限格式错误!", false); } else { ActivityInfo activity = new ActivityInfo { CloseRemark = this.txtCloseRemark.Text.Trim(), Description = this.txtDescription.Text.Trim(), EndDate = this.txtEndDate.SelectedDate.Value.AddMinutes(59.0).AddSeconds(59.0), Item1 = this.txtItem1.Text.Trim(), Item2 = this.txtItem2.Text.Trim(), Item3 = this.txtItem3.Text.Trim(), Item4 = this.txtItem4.Text.Trim(), Item5 = this.txtItem5.Text.Trim(), Keys = this.txtKeys.Text.Trim(), MaxValue = result, Name = this.txtName.Text.Trim(), PicUrl = this.uploader1.UploadedImageUrl, StartDate = this.txtStartDate.SelectedDate.Value }; if (VShopHelper.SaveActivity(activity)) { base.Response.Redirect("ManageActivity.aspx"); } else { this.ShowMsg("添加失败", false); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!base.IsPostBack) { int urlIntParam = base.GetUrlIntParam("id"); ActivityInfo activity = VShopHelper.GetActivity(urlIntParam); if (activity != null) { this._act = activity; this.rpt.DataSource = VShopHelper.GetActivitySignUpById(urlIntParam); this.rpt.DataBind(); } } }
public bool UpdateActivity(ActivityInfo activity) { StringBuilder builder = new StringBuilder(); builder.Append("UPDATE vshop_Activity SET ").Append("Name=@Name,").Append("Description=@Description,").Append("StartDate=@StartDate,").Append("EndDate=@EndDate,").Append("CloseRemark=@CloseRemark,").Append("Keys=@Keys,").Append("MaxValue=@MaxValue,").Append("PicUrl=@PicUrl,").Append("Item1=@Item1,").Append("Item2=@Item2,").Append("Item3=@Item3,").Append("Item4=@Item4,").Append("Item5=@Item5").Append(" WHERE ActivityId=@ActivityId").Append(";UPDATE vshop_Reply SET Keys = @Keys WHERE ActivityId = @ActivityId AND [ReplyType] = @ReplyType"); DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString()); this.database.AddInParameter(sqlStringCommand, "Name", DbType.String, activity.Name); this.database.AddInParameter(sqlStringCommand, "Description", DbType.String, activity.Description); this.database.AddInParameter(sqlStringCommand, "StartDate", DbType.DateTime, activity.StartDate); this.database.AddInParameter(sqlStringCommand, "EndDate", DbType.DateTime, activity.EndDate); this.database.AddInParameter(sqlStringCommand, "CloseRemark", DbType.String, activity.CloseRemark); this.database.AddInParameter(sqlStringCommand, "Keys", DbType.String, activity.Keys); this.database.AddInParameter(sqlStringCommand, "MaxValue", DbType.Int32, activity.MaxValue); this.database.AddInParameter(sqlStringCommand, "PicUrl", DbType.String, activity.PicUrl); this.database.AddInParameter(sqlStringCommand, "Item1", DbType.String, activity.Item1); this.database.AddInParameter(sqlStringCommand, "Item2", DbType.String, activity.Item2); this.database.AddInParameter(sqlStringCommand, "Item3", DbType.String, activity.Item3); this.database.AddInParameter(sqlStringCommand, "Item4", DbType.String, activity.Item4); this.database.AddInParameter(sqlStringCommand, "Item5", DbType.String, activity.Item5); this.database.AddInParameter(sqlStringCommand, "ActivityId", DbType.Int32, activity.ActivityId); this.database.AddInParameter(sqlStringCommand, "ReplyType", DbType.Int32, 0x100); return (this.database.ExecuteNonQuery(sqlStringCommand) > 0); }
public int SaveActivity(ActivityInfo activity) { int num; StringBuilder builder = new StringBuilder(); builder.Append("INSERT INTO vshop_Activity(").Append("Name,Description,StartDate,EndDate,CloseRemark,Keys").Append(",MaxValue,PicUrl,Item1,Item2,Item3,Item4,Item5)").Append(" VALUES (").Append("@Name,@Description,@StartDate,@EndDate,@CloseRemark,@Keys").Append(",@MaxValue,@PicUrl,@Item1,@Item2,@Item3,@Item4,@Item5)").Append(";select @@IDENTITY"); DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString()); this.database.AddInParameter(sqlStringCommand, "Name", DbType.String, activity.Name); this.database.AddInParameter(sqlStringCommand, "Description", DbType.String, activity.Description); this.database.AddInParameter(sqlStringCommand, "StartDate", DbType.DateTime, activity.StartDate); this.database.AddInParameter(sqlStringCommand, "EndDate", DbType.DateTime, activity.EndDate); this.database.AddInParameter(sqlStringCommand, "CloseRemark", DbType.String, activity.CloseRemark); this.database.AddInParameter(sqlStringCommand, "Keys", DbType.String, activity.Keys); this.database.AddInParameter(sqlStringCommand, "MaxValue", DbType.Int32, activity.MaxValue); this.database.AddInParameter(sqlStringCommand, "PicUrl", DbType.String, activity.PicUrl); this.database.AddInParameter(sqlStringCommand, "Item1", DbType.String, activity.Item1); this.database.AddInParameter(sqlStringCommand, "Item2", DbType.String, activity.Item2); this.database.AddInParameter(sqlStringCommand, "Item3", DbType.String, activity.Item3); this.database.AddInParameter(sqlStringCommand, "Item4", DbType.String, activity.Item4); this.database.AddInParameter(sqlStringCommand, "Item5", DbType.String, activity.Item5); int.TryParse(this.database.ExecuteScalar(sqlStringCommand).ToString(), out num); return num; }
public static bool UpdateActivity(ActivityInfo activity) { return new ActivityDao().UpdateActivity(activity); }
public static bool SaveActivity(ActivityInfo activity) { int num = new ActivityDao().SaveActivity(activity); ReplyInfo reply = new TextReplyInfo { Keys = activity.Keys, MatchType = MatchType.Equal, MessageType = MessageType.Text, ReplyType = ReplyType.SignUp, ActivityId = num }; return new ReplyDao().SaveReply(reply); }