public override void OnInitTemplatePage(EventArgs e) { if (!base.IsPostBack) { this.generalId = DataConverter.CLng(base.Request.Form["GeneralId"]); VoteInfo voteInfoByGeneralId = Votes.GetVoteInfoByGeneralId(this.generalId); if (!voteInfoByGeneralId.IsNull) { this.GetItems(voteInfoByGeneralId); Votes.Update(voteInfoByGeneralId); BasePage.ResponseRedirect(SiteConfig.SiteInfo.VirtualPath + "Common/Vote.aspx?GeneralId=" + this.generalId); } } }
public void Add(int id) { VoteInfo voteInfoByGeneralId = Votes.GetVoteInfoByGeneralId(this.generalId); voteInfoByGeneralId.GeneralId = id; voteInfoByGeneralId.VoteTitle = this.TxtVoteTitle.Text; voteInfoByGeneralId.IsAlive = this.ChkIsAlive.Checked; voteInfoByGeneralId.StartTime = DataConverter.CDate(this.DpkStartTime.Text); voteInfoByGeneralId.EndTime = DataConverter.CDate(this.DpkEndTime.Text); voteInfoByGeneralId.VoteItem = this.GetItems(); voteInfoByGeneralId.ItemType = DataConverter.CLng(this.DropItemType.SelectedValue); if (voteInfoByGeneralId.IsNull && this.ChkIsAlive.Checked) { Votes.Add(voteInfoByGeneralId); } else { Votes.Update(voteInfoByGeneralId); } }
private void InitControl() { if (!base.IsPostBack && (this.generalId > 0)) { VoteInfo voteInfoByGeneralId = Votes.GetVoteInfoByGeneralId(this.generalId); if (!voteInfoByGeneralId.IsNull) { this.ChkIsAlive.Checked = voteInfoByGeneralId.IsAlive; this.TxtVoteTitle.Text = voteInfoByGeneralId.VoteTitle; this.DpkStartTime.Text = voteInfoByGeneralId.StartTime.ToString(); this.DpkEndTime.Text = voteInfoByGeneralId.EndTime.ToString(); this.DropItemType.SelectedValue = voteInfoByGeneralId.ItemType.ToString(); this.InitItem(voteInfoByGeneralId.VoteItem); } else { this.DpkEndTime.Text = DateTime.Now.AddMonths(1).ToString(); this.DpkStartTime.Text = DateTime.Now.ToString(); } } }