private void EditSavePage() { int id = int.Parse(Utils.GetRequest("id", "post", 2, @"^[0-9]\d*$", "ID错误")); if (!new BCW.BLL.Votes().Exists(id)) { Utils.Error("不存在的记录", ""); } string Title = Utils.GetRequest("Title", "post", 2, @"^[^\^]{1,30}$", "标题限1-30字"); string Content = Utils.GetRequest("Content", "post", 2, @"^[^\^]{1,5000}$", "内容限1-5000字"); string Vote = Utils.GetRequest("Vote", "post", 2, @"^[^\#]{1,50}(?:\#[^\#]{1,50}){1,500}$", "投票选项必须用#隔开、选项两个以上"); int VoteType = int.Parse(Utils.GetRequest("VoteType", "post", 2, @"^[0-1]$", "投票类型选择错误")); int VoteLeven = int.Parse(Utils.GetRequest("VoteLeven", "post", 2, @"^[0-9]\d*$", "等级数填写错误")); int VoteTiple = int.Parse(Utils.GetRequest("VoteTiple", "post", 2, @"^[0-1]$", "投票性质选择错误")); int Readcount = int.Parse(Utils.GetRequest("Readcount", "post", 2, @"^[0-9]\d*$", "人气点击填写错误")); int Status = int.Parse(Utils.GetRequest("Status", "post", 2, @"^[0-1]$", "状态选择错误")); DateTime VoteExTime = Utils.ParseTime(Utils.GetRequest("VoteExTime", "post", 2, DT.RegexTime, "截止投票时间格式填写出错,正确格式如" + DateTime.Now.ToString("yyy-MM-dd HH:mm:ss") + "")); DateTime AddTime = Utils.ParseTime(Utils.GetRequest("AddTime", "post", 2, DT.RegexTime, "发布时间格式填写出错,正确格式如" + DateTime.Now.ToString("yyy-MM-dd HH:mm:ss") + "")); BCW.Model.Votes model = new BCW.Model.Votes(); model.ID = id; model.Types = 0; model.UsID = 0; model.Title = Title; model.Content = Content; model.Vote = Vote; model.VoteType = VoteType; model.VoteLeven = VoteLeven; model.VoteTiple = VoteTiple; model.Readcount = Readcount; model.Status = Status; model.VoteExTime = VoteExTime; model.AddTime = AddTime; new BCW.BLL.Votes().Update(model); Utils.Success("修改投票", "修改投票成功..", Utils.getUrl("votes.aspx?act=edit&id=" + id + ""), "1"); }
private void SavePage() { string Title = Utils.GetRequest("Title", "post", 2, @"^[^\^]{1,30}$", "标题限1-30字"); string Content = Utils.GetRequest("Content", "post", 2, @"^[^\^]{1,5000}$", "内容限1-5000字"); string Vote = Utils.GetRequest("Vote", "post", 2, @"^[^\#]{1,50}(?:\#[^\#]{1,50}){1,500}$", "投票选项必须用#隔开、选项两个以上"); int VoteType = int.Parse(Utils.GetRequest("VoteType", "post", 2, @"^[0-1]$", "投票类型选择错误")); int VoteLeven = int.Parse(Utils.GetRequest("VoteLeven", "post", 2, @"^[0-9]\d*$", "等级数填写错误")); int VoteTiple = int.Parse(Utils.GetRequest("VoteTiple", "post", 2, @"^[0-1]$", "投票性质选择错误")); DateTime VoteExTime = Utils.ParseTime(Utils.GetRequest("VoteExTime", "post", 2, DT.RegexTime, "截止投票时间格式填写出错,正确格式如" + DateTime.Now.ToString("yyy-MM-dd HH:mm:ss") + "")); //统计项 string[] sVote = Vote.Split("#".ToCharArray()); string sAddVote = string.Empty; for (int i = 0; i < sVote.Length; i++) { sAddVote += "#0"; } sAddVote = Utils.Mid(sAddVote, 1, sAddVote.Length); BCW.Model.Votes model = new BCW.Model.Votes(); model.Types = 0; model.UsID = 0; model.Title = Title; model.Content = Content; model.Vote = Vote; model.AddVote = sAddVote; model.VoteType = VoteType; model.VoteLeven = VoteLeven; model.VoteTiple = VoteTiple; model.Readcount = 0; model.VoteExTime = VoteExTime; model.AddTime = DateTime.Now; new BCW.BLL.Votes().Add(model); Utils.Success("发布投票", "发表投票成功..", Utils.getUrl("votes.aspx"), "1"); }
private void OkPage() { int id = int.Parse(Utils.GetRequest("id", "all", 2, @"^[0-9]\d*$", "ID错误")); int voteid = int.Parse(Utils.GetRequest("voteid", "all", 2, @"^[0-9]\d*$", "投票选择错误")); if (!new BCW.BLL.Votes().Exists(id)) { Utils.Error("不存在的记录", ""); } int meid = new BCW.User.Users().GetUsId(); if (meid == 0) { Utils.Login(); } int IsVerify = new BCW.BLL.User().GetIsVerify(meid); if (IsVerify == 0) { Utils.Error("您属于手工注册会员,还未通过短信验证<br /><a href=\"/reg.aspx\">免费验证会员</a>", ""); } BCW.Model.Votes model = new BCW.BLL.Votes().GetVotes(id); //等级限制 if (model.VoteLeven > 0) { int Leven = new BCW.BLL.User().GetLeven(meid); if (model.VoteLeven > Leven) { Utils.Error("本投票需" + model.VoteLeven + "级才能投票", ""); } } if (model.VoteExTime < DateTime.Now) { Utils.Error("投票已截止了", ""); } //生成多选投票识别 string inum = voteid + "_" + meid; //投票逻辑 if (!string.IsNullOrEmpty(model.Vote)) { bool vote = false; string AddVoteString = string.Empty; string[] addvote = model.AddVote.Split("#".ToCharArray()); for (int i = 0; i < addvote.Length; i++) { int ivote = int.Parse(addvote[i]); if (voteid == i) { ivote = ivote + 1; AddVoteString += "#" + ivote.ToString(); } else { AddVoteString += "#" + addvote[i]; } } AddVoteString = Utils.Mid(AddVoteString, 1, AddVoteString.Length); if (!string.IsNullOrEmpty(model.VoteID)) { string[] svoteid = model.VoteID.Split("#".ToCharArray()); for (int i = 0; i < svoteid.Length; i++) { if (model.VoteTiple == 0)//如果为单选 { if (Convert.ToInt32(svoteid[i]) == meid) { vote = true; break; } } else { if (svoteid[i] == inum) { vote = true; break; } } } } if (vote == true) { Utils.Error("请不要重复投票", ""); } //写入数据库 BCW.Model.Votes addmodel = new BCW.Model.Votes(); string VoteIDString = string.Empty; if (model.VoteTiple == 0) { if (!string.IsNullOrEmpty(model.VoteID)) { VoteIDString = model.VoteID + "#" + meid; } else { VoteIDString = meid.ToString(); } } else { if (!string.IsNullOrEmpty(model.VoteID)) { VoteIDString = model.VoteID + "#" + inum; } else { VoteIDString = inum; } } addmodel.ID = id; addmodel.AddVote = AddVoteString; addmodel.VoteID = VoteIDString; new BCW.BLL.Votes().UpdateVote(addmodel); Utils.Success("投票成功", "恭喜,投票成功,正在返回..", Utils.getPage("votes.aspx"), "2"); } }
/// <summary> /// 更新投票 /// </summary> public void UpdateVote(BCW.Model.Votes model) { dal.UpdateVote(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BCW.Model.Votes model) { return(dal.Add(model)); }