protected void btnSave_Click(object sender, EventArgs e) { NoName.NetShop.Vote.BLL.VoteItemGroup gbll = new NoName.NetShop.Vote.BLL.VoteItemGroup(); NoName.NetShop.Vote.BLL.VoteItem ibll = new NoName.NetShop.Vote.BLL.VoteItem(); NoName.NetShop.Vote.Model.VoteItemGroup gmodel = gbll.GetModel(int.Parse(this.lblGroupId.Text)); if (gmodel == null) { gmodel = new NoName.NetShop.Vote.Model.VoteItemGroup(); gmodel.ItemGroupId = 0; gmodel.VoteId = int.Parse(lblVoteId.Text); } gmodel.Subject = txtSubject.Text.Trim(); gmodel.Content = txtContent.Text.Trim(); gbll.Save(gmodel); foreach (GridViewRow row in gvItems.Rows) { int itemId = int.Parse(gvItems.DataKeys[row.RowIndex].Values["ItemId"].ToString()); NoName.NetShop.Vote.Model.VoteItem imodel = ibll.GetModel(itemId); imodel.ItemContent = (row.FindControl("txtContent") as TextBox).Text.Trim(); ibll.Save(imodel); } Response.Redirect("ShowVoteInfo.aspx?voteId=" + gmodel.VoteId); }
protected void btnAdd_Click(object sender, EventArgs e) { NoName.NetShop.Vote.BLL.VoteItemGroup gbll = new NoName.NetShop.Vote.BLL.VoteItemGroup(); NoName.NetShop.Vote.BLL.VoteItem ibll = new NoName.NetShop.Vote.BLL.VoteItem(); NoName.NetShop.Vote.Model.VoteItemGroup gmodel = gbll.GetModel(int.Parse(lblGroupId.Text)); if (gmodel == null) { gmodel = new NoName.NetShop.Vote.Model.VoteItemGroup(); gmodel.ItemGroupId = 0; gmodel.VoteId = int.Parse(lblVoteId.Text); gmodel.Subject = txtSubject.Text.Trim(); gmodel.Content = txtContent.Text.Trim(); gbll.Save(gmodel); lblVoteId.Text = gmodel.VoteId.ToString(); lblGroupId.Text = gmodel.ItemGroupId.ToString(); } NoName.NetShop.Vote.Model.VoteItem imodel = new NoName.NetShop.Vote.Model.VoteItem(); imodel.ItemContent = String.Empty; imodel.ItemGroupId = gmodel.ItemGroupId; imodel.VoteId = gmodel.VoteId; imodel.ItemId = 0; ibll.Save(imodel); List <NoName.NetShop.Vote.Model.VoteItem> list = ibll.GetItemsOfGroup(int.Parse(lblGroupId.Text)); this.gvItems.DataSource = list; this.gvItems.DataBind(); }
private void ShowVote(int voteId) { NetShop.Vote.BLL.VoteTopic vbll = new NoName.NetShop.Vote.BLL.VoteTopic(); vmodel = vbll.GetModel(voteId); this.litContent.Text = vmodel.Remark; this.litTitle.Text = vmodel.Topic; NetShop.Vote.BLL.VoteItemGroup gbll = new NoName.NetShop.Vote.BLL.VoteItemGroup(); rpList.DataSource = gbll.GetModelList(voteId); rpList.DataBind(); }
private void ShowInfo(int voteId) { Vote.BLL.VoteTopic vbll = new NoName.NetShop.Vote.BLL.VoteTopic(); Vote.BLL.VoteItemGroup gbll = new NoName.NetShop.Vote.BLL.VoteItemGroup(); Vote.BLL.VoteItem ibll = new NoName.NetShop.Vote.BLL.VoteItem(); Vote.Model.VoteTopic vmodel = vbll.GetModel(voteId); if (vmodel != null) { this.lblEndDate.Text = vmodel.EndTime == null ? "" : (vmodel.EndTime ?? DateTime.MaxValue).ToShortDateString(); this.lblStartDate.Text = vmodel.StartTime == null ? "" : (vmodel.StartTime ?? DateTime.MaxValue).ToShortDateString(); this.chkIsMulti.Checked = vmodel.IsMulti; this.chkIsRegUser.Checked = vmodel.IsRegUser; this.chkStatus.Checked = vmodel.Status; this.lblRemark.Text = vmodel.Remark; this.lblTopic.Text = vmodel.Topic; this.lblVoteId.Text = vmodel.VoteId.ToString(); this.lblVoteUserNum.Text = vmodel.VoteUserNum.ToString(); } rpGroups.DataSource = gbll.GetModelList(voteId); rpGroups.DataBind(); }
private void ShowVoteGroupInfo(int groupId, int voteId) { NoName.NetShop.Vote.BLL.VoteItemGroup gbll = new NoName.NetShop.Vote.BLL.VoteItemGroup(); NoName.NetShop.Vote.BLL.VoteItem ibll = new NoName.NetShop.Vote.BLL.VoteItem(); NoName.NetShop.Vote.Model.VoteItemGroup gmodel = gbll.GetModel(groupId); if (gmodel != null) { this.txtContent.Text = gmodel.Content; this.txtSubject.Text = gmodel.Subject; this.lblGroupId.Text = gmodel.ItemGroupId.ToString(); this.lblVoteId.Text = gmodel.VoteId.ToString(); this.gvItems.DataSource = ibll.GetItemsOfGroup(groupId); this.gvItems.DataKeyNames = new string[] { "ItemId" }; this.gvItems.DataBind(); } else { this.lblVoteId.Text = voteId.ToString(); this.lblGroupId.Text = "0"; } }
private string GetVoteInfo(HttpContext context) { NameValueCollection nv = GetParas(context); int voiteId = int.Parse(nv["voteid"]); Vote.BLL.VoteTopic vtbll = new NoName.NetShop.Vote.BLL.VoteTopic(); Vote.BLL.VoteItemGroup vgbll = new NoName.NetShop.Vote.BLL.VoteItemGroup(); Vote.BLL.VoteItem vibll = new NoName.NetShop.Vote.BLL.VoteItem(); StringBuilder sb = new StringBuilder(200); JsonWriter jw = new JsonWriter(new StringWriter(sb)); Vote.Model.VoteTopic vtmodel = vtbll.GetModel(voiteId); List <Vote.Model.VoteItemGroup> vgmodels = vgbll.GetModelList(voiteId); List <Vote.Model.VoteItem> vimodels = vibll.GetItemsOfVote(voiteId); if (vtmodel != null && vtmodel.StartTime < DateTime.Now && vtmodel.EndTime > DateTime.Now && vtmodel.Status == true) { jw.WriteStartObject(); jw.WritePropertyName("voteid"); jw.WriteValue(vtmodel.VoteId); jw.WritePropertyName("topic"); jw.WriteValue(vtmodel.Topic); jw.WritePropertyName("votenum"); jw.WriteValue(vtmodel.VoteUserNum); jw.WritePropertyName("ismulti"); jw.WriteValue(vtmodel.IsMulti); jw.WritePropertyName("groupcount"); jw.WriteValue(vgmodels.Count); if (vgmodels.Count > 0) { jw.WritePropertyName("groups"); jw.WriteStartArray(); foreach (Vote.Model.VoteItemGroup vgmodel in vgmodels) { jw.WriteStartObject(); jw.WritePropertyName("subject"); jw.WriteValue(vgmodel.Subject); jw.WritePropertyName("groupid"); jw.WriteValue(vgmodel.ItemGroupId); jw.WritePropertyName("items"); jw.WriteStartArray(); foreach (Vote.Model.VoteItem vitem in vimodels.Where(s => s.ItemGroupId == vgmodel.ItemGroupId)) { jw.WriteStartObject(); jw.WritePropertyName("itemid"); jw.WriteValue(vitem.ItemId); jw.WritePropertyName("subject"); jw.WriteValue(vitem.ItemContent); jw.WritePropertyName("count"); jw.WriteValue(vitem.VoteCount); jw.WritePropertyName("percent"); jw.WriteValue(vitem.Percent); jw.WriteEndObject(); } jw.WriteEndArray(); jw.WriteEndObject(); } jw.WriteEndArray(); } jw.WriteEndObject(); jw.Close(); } return(sb.ToString()); }