Пример #1
0
 public int AddSubject(M_VoteSubject model)
 {
     SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@Subject", SqlDbType.NVarChar), new SqlParameter("@StartDate", SqlDbType.DateTime), new SqlParameter("@EndDate", SqlDbType.DateTime), new SqlParameter("@RequireLogin", SqlDbType.Bit, 1), new SqlParameter("@CategoryId", SqlDbType.Int, 4), new SqlParameter("@Identity", SqlDbType.Int, 4) };
     commandParameters[0].Value = model.Subject;
     commandParameters[1].Value = model.StartDate;
     commandParameters[2].Value = model.EndDate;
     commandParameters[3].Value = model.RequireLogin;
     commandParameters[4].Value = model.CategoryId;
     commandParameters[5].Value = 0;
     commandParameters[5].Direction = ParameterDirection.Output;
     SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringKy, CommandType.StoredProcedure, "Up_VoteSubject_Add", commandParameters);
     return (int) commandParameters[5].Value;
 }
Пример #2
0
 public void UpdateSubject(M_VoteSubject model)
 {
     SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@VoteSubjectId", SqlDbType.Int, 4), new SqlParameter("@Subject", SqlDbType.NVarChar), new SqlParameter("@StartDate", SqlDbType.DateTime), new SqlParameter("@EndDate", SqlDbType.DateTime), new SqlParameter("@RequireLogin", SqlDbType.Bit, 1), new SqlParameter("@CategoryId", SqlDbType.Int, 4) };
     commandParameters[0].Value = model.SubjectId;
     commandParameters[1].Value = model.Subject;
     commandParameters[2].Value = model.StartDate;
     commandParameters[3].Value = model.EndDate;
     commandParameters[4].Value = model.RequireLogin;
     commandParameters[5].Value = model.CategoryId;
     SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringKy, CommandType.StoredProcedure, "Up_VoteSubject_Update", commandParameters);
 }
Пример #3
0
 public int AddSubject(M_VoteSubject model)
 {
     int num = this.iV.AddSubject(model);
     B_Log.Add(LogType.Add, "新增投票主题成功");
     return num;
 }
Пример #4
0
 public void UpdateSubject(M_VoteSubject model)
 {
     this.iV.UpdateSubject(model);
     B_Log.Add(LogType.Update, "修改投票主题成功 编号:" + model.SubjectId);
 }
Пример #5
0
    /// <summary>
    /// 添加/修改
    /// </summary>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        int voteNum = int.Parse(ddlVoteNum.SelectedValue);
        //
        //检查必须的条件是否满足
        //
        if (txtDescription.Text.Trim() == "")
        {
            Function.ShowSysMsg(0, "<li>投票主题不能为空,请检查</li><li><a href='javascript:window.history.back()'>返回上一步</a></li>");
        }

        for (int i = 1; i <= voteNum; i++)
        {
            TextBox title = (TextBox)Page.FindControl("txtTitle" + i);
            if (title.Text.Trim() == "")
            {
                Function.ShowSysMsg(0, "<li>投票项 " + i + " 不能为空,请检查</li><li><a href='javascript:window.history.back()'>返回上一步</a></li>");
            }
        }

        M_VoteSubject subModel = new M_VoteSubject();
        subModel.Subject = txtDescription.Text;
        subModel.CategoryId = int.Parse(ddlCategory.SelectedValue);
        try
        {
            subModel.EndDate = DateTime.Parse(txtEndTime.Text).Date;
            subModel.StartDate = DateTime.Parse(txtStartTime.Text).Date;
        }
        catch
        {
            Function.ShowSysMsg(0, "<li>输入日期格式不正确,请检查</li><li><a href='javascript:window.history.back()'>返回上一步</a></li>");
        }
        subModel.RequireLogin = chkIsLogin.Checked;

        if (SubjectId == 0)//新增
        {
            //添加投票Subject,并获取 SubjectID 以供后面添加投票用
            int subId = bll.AddSubject(subModel);

            //设置投票主题的SubjectId
            votemodel.SubjectId = subId;
        }
        for (int i = 1; i <= voteNum; i++)
        {
            I = i;
            TextBox title = (TextBox)Page.FindControl("txtTitle" + i);
            votemodel.VoteTitle = title.Text;
            RadioButtonList more = (RadioButtonList)Page.FindControl("rblType" + i);
            votemodel.IsMore = more.SelectedIndex == 1;
            if (SubjectId > 0)
            {
                Literal voteId = (Literal)Page.FindControl("LitVoteId" + i);
                votemodel.VoteId = int.Parse(voteId.Text);
            }
            votemodel.ItemTitle1 = NextItem().Text;
            votemodel.ItemTitle2 = NextItem().Text;
            votemodel.ItemTitle3 = NextItem().Text;
            votemodel.ItemTitle4 = NextItem().Text;
            votemodel.ItemTitle5 = NextItem().Text;
            votemodel.ItemTitle6 = NextItem().Text;
            ResetM();
            votemodel.ItemNum1 = NextNum();
            votemodel.ItemNum2 = NextNum();
            votemodel.ItemNum3 = NextNum();
            votemodel.ItemNum4 = NextNum();
            votemodel.ItemNum5 = NextNum();
            votemodel.ItemNum6 = NextNum();

            if (SubjectId == 0)
            {
                bll.AddVote(votemodel);
            }
            else
            {
                votemodel.SubjectId = SubjectId;
                subModel.SubjectId = SubjectId;
                bll.UpdateSubject(subModel);
                bll.UpdateVote(votemodel);
            }
            ResetM();
        }
        Function.ShowSysMsg(1, "<li>操作成功</li><li><a href='vote/Vote.aspx'>返回投票列表</a></li>");
    }