public static int CreateVote(VoteInfo vote) { int num = 0; VoteDao dao = new VoteDao(); long num2 = dao.CreateVote(vote); if (num2 > 0L) { ReplyInfo reply = new TextReplyInfo { Keys = vote.Keys, MatchType = MatchType.Equal, ReplyType = ReplyType.Vote, ActivityId = Convert.ToInt32(num2) }; new ReplyDao().SaveReply(reply); num = 1; if (vote.VoteItems == null) { return num; } foreach (VoteItemInfo info2 in vote.VoteItems) { info2.VoteId = num2; info2.ItemCount = 0; num += dao.CreateVoteItem(info2, null); } } return num; }
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); }
private void btnSubmit_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtKeys.Text) && ReplyHelper.HasReplyKey(this.txtKeys.Text.Trim())) { this.ShowMsg("关键字重复!", false); } else { TextReplyInfo info; info = info = new TextReplyInfo(); info.IsDisable = !this.radDisable.SelectedValue; if (this.chkKeys.Checked && !string.IsNullOrWhiteSpace(this.txtKeys.Text)) { info.Keys = this.txtKeys.Text.Trim(); } info.Text = this.fcContent.Text.Trim(); info.MatchType = this.radMatch.SelectedValue ? MatchType.Like : MatchType.Equal; if (this.chkKeys.Checked) { info.ReplyType |= ReplyType.Keys; } if (this.chkSub.Checked) { info.ReplyType |= ReplyType.Subscribe; } if (this.chkNo.Checked) { info.ReplyType |= ReplyType.NoMatch; } if (info.ReplyType == ReplyType.None) { this.ShowMsg("请选择回复类型", false); } else if (ReplyHelper.SaveReply(info)) { this.ShowMsg("添加成功", true); } else { this.ShowMsg("添加失败", false); } } }
private bool UpdateTextReply(TextReplyInfo reply) { StringBuilder builder = new StringBuilder(); builder.Append("update vshop_Reply set "); builder.Append("Keys=@Keys,"); builder.Append("MatchType=@MatchType,"); builder.Append("ReplyType=@ReplyType,"); builder.Append("MessageType=@MessageType,"); builder.Append("IsDisable=@IsDisable,"); builder.Append("LastEditDate=@LastEditDate,"); builder.Append("LastEditor=@LastEditor,"); builder.Append("Content=@Content,"); builder.Append("Type=@Type,"); builder.Append("ActivityId=@ActivityId"); builder.Append(" where ReplyId=@ReplyId"); DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString()); this.database.AddInParameter(sqlStringCommand, "Keys", DbType.String, reply.Keys); this.database.AddInParameter(sqlStringCommand, "MatchType", DbType.Int32, (int) reply.MatchType); this.database.AddInParameter(sqlStringCommand, "ReplyType", DbType.Int32, (int) reply.ReplyType); this.database.AddInParameter(sqlStringCommand, "MessageType", DbType.Int32, (int) reply.MessageType); this.database.AddInParameter(sqlStringCommand, "IsDisable", DbType.Boolean, reply.IsDisable); this.database.AddInParameter(sqlStringCommand, "LastEditDate", DbType.DateTime, reply.LastEditDate); this.database.AddInParameter(sqlStringCommand, "LastEditor", DbType.String, reply.LastEditor); this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, reply.Text); this.database.AddInParameter(sqlStringCommand, "Type", DbType.Int32, 2); this.database.AddInParameter(sqlStringCommand, "ActivityId", DbType.Int32, reply.ActivityId); this.database.AddInParameter(sqlStringCommand, "ReplyId", DbType.Int32, reply.Id); return (this.database.ExecuteNonQuery(sqlStringCommand) > 0); }
private bool SaveTextReply(TextReplyInfo model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into vshop_Reply("); builder.Append("Keys,MatchType,ReplyType,MessageType,IsDisable,LastEditDate,LastEditor,Content,Type,ActivityId)"); builder.Append(" values ("); builder.Append("@Keys,@MatchType,@ReplyType,@MessageType,@IsDisable,@LastEditDate,@LastEditor,@Content,@Type,@ActivityId)"); DbCommand sqlStringCommand = this.database.GetSqlStringCommand(builder.ToString()); this.database.AddInParameter(sqlStringCommand, "Keys", DbType.String, model.Keys); this.database.AddInParameter(sqlStringCommand, "MatchType", DbType.Int32, (int) model.MatchType); this.database.AddInParameter(sqlStringCommand, "ReplyType", DbType.Int32, (int) model.ReplyType); this.database.AddInParameter(sqlStringCommand, "MessageType", DbType.Int32, (int) model.MessageType); this.database.AddInParameter(sqlStringCommand, "IsDisable", DbType.Boolean, model.IsDisable); this.database.AddInParameter(sqlStringCommand, "LastEditDate", DbType.DateTime, model.LastEditDate); this.database.AddInParameter(sqlStringCommand, "LastEditor", DbType.String, model.LastEditor); this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, model.Text); this.database.AddInParameter(sqlStringCommand, "Type", DbType.Int32, 1); this.database.AddInParameter(sqlStringCommand, "ActivityId", DbType.Int32, model.ActivityId); return (this.database.ExecuteNonQuery(sqlStringCommand) > 0); }
public ReplyInfo ReaderBind(IDataReader dataReader) { ReplyInfo info = null; object obj2 = dataReader["MessageType"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { if (((MessageType) obj2) == MessageType.Text) { info = new TextReplyInfo(); } else { info = new NewsReplyInfo(); } } obj2 = dataReader["ReplyId"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.Id = (int) obj2; } info.Keys = dataReader["Keys"].ToString(); obj2 = dataReader["MatchType"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.MatchType = (MatchType) obj2; } obj2 = dataReader["ReplyType"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.ReplyType = (ReplyType) obj2; } obj2 = dataReader["MessageType"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.MessageType = (MessageType) obj2; } obj2 = dataReader["IsDisable"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.IsDisable = (bool) obj2; } obj2 = dataReader["LastEditDate"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.LastEditDate = (DateTime) obj2; } info.LastEditor = dataReader["LastEditor"].ToString(); obj2 = dataReader["ActivityId"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { info.ActivityId = (int) obj2; } return info; }
protected void btnAddActivity_Click(object sender, EventArgs e) { if (ReplyHelper.HasReplyKey(this.txtKeyword.Text.Trim())) { this.ShowMsg("关键字重复!", false); } else { string str = string.Empty; if (this.fileUpload.HasFile) { try { str = VShopHelper.UploadTopicImage(this.fileUpload.PostedFile); if (!this.calendarStartDate.SelectedDate.HasValue) { this.ShowMsg("请选择活动开始时间", false); } else if (!this.calendarEndDate.SelectedDate.HasValue) { this.ShowMsg("请选择活动结束时间", false); } else { int num; if (!int.TryParse(this.txtMaxNum.Text, out num) || (num.ToString() != this.txtMaxNum.Text)) { this.ShowMsg("可抽奖次数必须是整数", false); } else { int num2; LotteryActivityInfo info = new LotteryActivityInfo { ActivityName = this.txtActiveName.Text, ActivityKey = this.txtKeyword.Text, ActivityDesc = this.txtdesc.Text, ActivityPic = str, ActivityType = this.type, StartTime = this.calendarStartDate.SelectedDate.Value, EndTime = this.calendarEndDate.SelectedDate.Value, MaxNum = Convert.ToInt32(this.txtMaxNum.Text) }; List<PrizeSetting> list = new List<PrizeSetting>(); if ((int.TryParse(this.txtPrize1Num.Text, out num2) && int.TryParse(this.txtPrize2Num.Text, out num2)) && int.TryParse(this.txtPrize3Num.Text, out num2)) { decimal num3 = Convert.ToDecimal(this.txtProbability1.Text); decimal num4 = Convert.ToDecimal(this.txtProbability2.Text); decimal num5 = Convert.ToDecimal(this.txtProbability3.Text); List<PrizeSetting> collection = new List<PrizeSetting>(); PrizeSetting item = new PrizeSetting { PrizeName = this.txtPrize1.Text, PrizeNum = Convert.ToInt32(this.txtPrize1Num.Text), PrizeLevel = "一等奖", Probability = num3 }; collection.Add(item); PrizeSetting setting2 = new PrizeSetting { PrizeName = this.txtPrize2.Text, PrizeNum = Convert.ToInt32(this.txtPrize2Num.Text), PrizeLevel = "二等奖", Probability = num4 }; collection.Add(setting2); PrizeSetting setting3 = new PrizeSetting { PrizeName = this.txtPrize3.Text, PrizeNum = Convert.ToInt32(this.txtPrize3Num.Text), PrizeLevel = "三等奖", Probability = num5 }; collection.Add(setting3); list.AddRange(collection); } else { this.ShowMsg("奖品数量必须为数字!", false); return; } if (this.ChkOpen.Checked) { if ((string.IsNullOrEmpty(this.txtPrize4.Text) || string.IsNullOrEmpty(this.txtPrize5.Text)) || string.IsNullOrEmpty(this.txtPrize6.Text)) { this.ShowMsg("开启四五六名必须填写", false); return; } if ((int.TryParse(this.txtPrize4Num.Text, out num2) && int.TryParse(this.txtPrize5Num.Text, out num2)) && int.TryParse(this.txtPrize6Num.Text, out num2)) { decimal num6 = Convert.ToDecimal(this.txtProbability4.Text); decimal num7 = Convert.ToDecimal(this.txtProbability5.Text); decimal num8 = Convert.ToDecimal(this.txtProbability6.Text); List<PrizeSetting> list3 = new List<PrizeSetting>(); PrizeSetting setting4 = new PrizeSetting { PrizeName = this.txtPrize4.Text, PrizeNum = Convert.ToInt32(this.txtPrize4Num.Text), PrizeLevel = "四等奖", Probability = num6 }; list3.Add(setting4); PrizeSetting setting5 = new PrizeSetting { PrizeName = this.txtPrize5.Text, PrizeNum = Convert.ToInt32(this.txtPrize5Num.Text), PrizeLevel = "五等奖", Probability = num7 }; list3.Add(setting5); PrizeSetting setting6 = new PrizeSetting { PrizeName = this.txtPrize6.Text, PrizeNum = Convert.ToInt32(this.txtPrize6Num.Text), PrizeLevel = "六等奖", Probability = num8 }; list3.Add(setting6); list.AddRange(list3); } else { this.ShowMsg("奖品数量必须为数字!", false); return; } } info.PrizeSettingList = list; int num9 = VShopHelper.InsertLotteryActivity(info); if (num9 > 0) { ReplyInfo reply = new TextReplyInfo { Keys = info.ActivityKey, MatchType = MatchType.Equal, ActivityId = num9 }; string str2 = ((LotteryActivityType) info.ActivityType).ToString(); object obj2 = Enum.Parse(typeof(ReplyType), str2); reply.ReplyType = (ReplyType) obj2; ReplyHelper.SaveReply(reply); base.Response.Redirect("ManageLotteryActivity.aspx?type=" + this.type, true); this.ShowMsg("添加成功!", true); } } } return; } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } this.ShowMsg("您没有选择上传的图片文件!", false); } }
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); }
protected void btnAddActivity_Click(object sender, EventArgs e) { if (ReplyHelper.HasReplyKey(this.txtKeyword.Text.Trim())) { this.ShowMsg("关键字重复!", false); } else if (!this.calendarStartDate.SelectedDate.HasValue) { this.ShowMsg("请选择活动开始时间", false); } else if (!this.calendarOpenDate.SelectedDate.HasValue) { this.ShowMsg("请选择抽奖开始时间", false); } else if (!this.calendarEndDate.SelectedDate.HasValue) { this.ShowMsg("请选择活动结束时间", false); } else { string str = string.Empty; if (this.fileUpload.HasFile) { try { str = VShopHelper.UploadTopicImage(this.fileUpload.PostedFile); } catch { this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false); return; } } string str2 = string.Empty; for (int i = 0; i < this.cbList.Items.Count; i++) { if (this.cbList.Items[i].Selected) { str2 = str2 + "," + this.cbList.Items[i].Value; } } if (!string.IsNullOrEmpty(str2)) { LotteryTicketInfo info = new LotteryTicketInfo { GradeIds = str2, MinValue = Convert.ToInt32(this.txtMinValue.Text), InvitationCode = this.txtCode.Text.Trim(), ActivityName = this.txtActiveName.Text, ActivityKey = this.txtKeyword.Text, ActivityDesc = this.txtdesc.Text, ActivityPic = str, ActivityType = 4, StartTime = this.calendarStartDate.SelectedDate.Value, OpenTime = this.calendarOpenDate.SelectedDate.Value.AddHours((double) this.ddlHours.SelectedIndex), EndTime = this.calendarEndDate.SelectedDate.Value, PrizeSettingList = new List<PrizeSetting>() }; try { PrizeSetting item = new PrizeSetting { PrizeName = this.txtPrize1.Text, PrizeNum = Convert.ToInt32(this.txtPrize1Num.Text), PrizeLevel = "一等奖" }; info.PrizeSettingList.Add(item); PrizeSetting setting2 = new PrizeSetting { PrizeName = this.txtPrize2.Text, PrizeNum = Convert.ToInt32(this.txtPrize2Num.Text), PrizeLevel = "二等奖" }; info.PrizeSettingList.Add(setting2); PrizeSetting setting3 = new PrizeSetting { PrizeName = this.txtPrize3.Text, PrizeNum = Convert.ToInt32(this.txtPrize3Num.Text), PrizeLevel = "三等奖" }; info.PrizeSettingList.Add(setting3); } catch (FormatException) { this.ShowMsg("奖品数量格式错误", false); return; } if (this.ChkOpen.Checked) { try { PrizeSetting setting4 = new PrizeSetting { PrizeName = this.txtPrize4.Text, PrizeNum = Convert.ToInt32(this.txtPrize4Num.Text), PrizeLevel = "四等奖" }; info.PrizeSettingList.Add(setting4); PrizeSetting setting5 = new PrizeSetting { PrizeName = this.txtPrize5.Text, PrizeNum = Convert.ToInt32(this.txtPrize5Num.Text), PrizeLevel = "五等奖" }; info.PrizeSettingList.Add(setting5); PrizeSetting setting6 = new PrizeSetting { PrizeName = this.txtPrize6.Text, PrizeNum = Convert.ToInt32(this.txtPrize6Num.Text), PrizeLevel = "六等奖" }; info.PrizeSettingList.Add(setting6); } catch (FormatException) { this.ShowMsg("奖品数量格式错误", false); return; } } int num2 = VShopHelper.SaveLotteryTicket(info); if (num2 > 0) { ReplyInfo reply = new TextReplyInfo { Keys = info.ActivityKey, MatchType = MatchType.Equal, MessageType = MessageType.Text, ReplyType = ReplyType.Ticket, ActivityId = num2 }; ReplyHelper.SaveReply(reply); base.Response.Redirect("ManageLotteryTicket.aspx"); } } else { this.ShowMsg("请选择活动会员等级", false); } } }