public ArrayList GetVoteOptionInfoArrayList(int publishmentSystemId, int nodeId, int contentId) { var voteOptionInfoArrayList = new ArrayList(); var parms = new IDataParameter[] { GetParameter(ParmPublishmentsystemId, EDataType.Integer, publishmentSystemId), GetParameter(ParmNodeId, EDataType.Integer, nodeId), GetParameter(ParmContentId, EDataType.Integer, contentId) }; using (var rdr = ExecuteReader(SqlSelectAll, parms)) { while (rdr.Read()) { var i = 0; var info = new VoteOptionInfo(GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetString(rdr, i++), GetInt(rdr, i)); voteOptionInfoArrayList.Add(info); } rdr.Close(); } return(voteOptionInfoArrayList); }
public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { if (this.contentID == 0) { var contentInfo = new VoteContentInfo(); try { InputTypeParser.AddValuesToAttributes(tableStyle, tableName, PublishmentSystemInfo, relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes); contentInfo.NodeId = nodeID; contentInfo.PublishmentSystemId = PublishmentSystemId; contentInfo.AddUserName = Body.AdministratorName; if (contentInfo.AddDate.Year == DateUtils.SqlMinValue.Year) { FailMessage($"投票添加失败:系统时间不能为{DateUtils.SqlMinValue.Year}年"); return; } contentInfo.LastEditUserName = contentInfo.AddUserName; contentInfo.LastEditDate = DateTime.Now; contentInfo.IsChecked = false; contentInfo.IsSummary = TranslateUtils.ToBool(Request.Form["IsSummary"]); contentInfo.Summary = tbSummary.Text; contentInfo.MaxSelectNum = TranslateUtils.ToInt(ddlMaxSelectNum.SelectedValue); contentInfo.AddDate = dtbAddDate.DateTime; if (string.IsNullOrEmpty(ddlEndDate.SelectedValue)) { contentInfo.EndDate = dtbEndDate.DateTime; } else { contentInfo.EndDate = TranslateUtils.ToDateTime(ddlEndDate.SelectedValue); } contentInfo.IsVotedView = TranslateUtils.ToBool(rblIsVotedView.SelectedValue); contentInfo.HiddenContent = tbHiddenContent.Text; var checkedLevel = 0; contentInfo.IsChecked = CheckManager.GetUserCheckLevel(Body.AdministratorName, PublishmentSystemInfo, nodeID, out checkedLevel); contentInfo.CheckedLevel = checkedLevel; var contentID = DataProvider.ContentDao.Insert(tableName, PublishmentSystemInfo, contentInfo); var itemCount = TranslateUtils.ToInt(Request.Form["itemCount"]); var voteOptionInfoArrayList = new ArrayList(); for (var i = 0; i < itemCount; i++) { var title = Request.Form["options[" + i + "]"]; if (!string.IsNullOrEmpty(title)) { var optionInfo = new VoteOptionInfo(0, PublishmentSystemId, nodeID, contentID, title, string.Empty, string.Empty, 0); voteOptionInfoArrayList.Add(optionInfo); } } DataProvider.VoteOptionDao.Insert(voteOptionInfoArrayList); contentInfo.Id = contentID; } catch (Exception ex) { FailMessage(ex, $"投票添加失败:{ex.Message}"); LogUtils.AddErrorLog(ex); return; } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(PublishmentSystemId, nodeID, contentInfo.Id); } Body.AddSiteLog(PublishmentSystemId, nodeID, contentInfo.Id, "添加投票", $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},投票标题:{contentInfo.Title}"); PageUtils.Redirect(PageContentAddAfter.GetRedirectUrl(PublishmentSystemId, nodeID, contentInfo.Id, returnUrl)); } else { var contentInfo = DataProvider.VoteContentDao.GetContentInfo(PublishmentSystemInfo, contentID); try { InputTypeParser.AddValuesToAttributes(tableStyle, tableName, PublishmentSystemInfo, relatedIdentities, Request.Form, contentInfo.Attributes, ContentAttribute.HiddenAttributes); contentInfo.LastEditUserName = Body.AdministratorName; contentInfo.LastEditDate = DateTime.Now; contentInfo.IsSummary = TranslateUtils.ToBool(Request.Form["IsSummary"]); contentInfo.Summary = tbSummary.Text; contentInfo.MaxSelectNum = TranslateUtils.ToInt(ddlMaxSelectNum.SelectedValue); contentInfo.AddDate = dtbAddDate.DateTime; contentInfo.EndDate = dtbEndDate.DateTime; contentInfo.IsVotedView = TranslateUtils.ToBool(rblIsVotedView.SelectedValue); contentInfo.HiddenContent = tbHiddenContent.Text; DataProvider.ContentDao.Update(tableName, PublishmentSystemInfo, contentInfo); var itemCount = TranslateUtils.ToInt(Request.Form["itemCount"]); var voteOptionInfoArrayList = new ArrayList(); for (var i = 0; i < itemCount; i++) { var title = Request.Form["options[" + i + "]"]; if (!string.IsNullOrEmpty(title)) { var optionInfo = new VoteOptionInfo(0, PublishmentSystemId, nodeID, contentID, title, string.Empty, string.Empty, 0); voteOptionInfoArrayList.Add(optionInfo); } } DataProvider.VoteOptionDao.UpdateVoteOptionInfoArrayList(PublishmentSystemId, nodeID, contentID, voteOptionInfoArrayList); } catch (Exception ex) { FailMessage(ex, $"投票修改失败:{ex.Message}"); LogUtils.AddErrorLog(ex); return; } if (contentInfo.IsChecked) { CreateManager.CreateContentAndTrigger(PublishmentSystemId, nodeID, contentID); } Body.AddSiteLog(PublishmentSystemId, nodeID, contentID, "修改投票", $"栏目:{NodeManager.GetNodeNameNavigation(PublishmentSystemId, contentInfo.NodeId)},投票标题:{contentInfo.Title}"); PageUtils.Redirect(returnUrl); } } }