Example #1
0
        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);
        }
Example #2
0
        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();
        }