Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Sid <= 0)
         {
             function.WriteErrMsg("缺少问卷投票的ID参数!", "../Plus/SurveyManage.aspx"); return;
         }
         M_Survey info = surBll.GetSurveyBySid(Sid);
         if (info.IsNull)
         {
             function.WriteErrMsg("该问卷投票不存在!可能已被删除", "../Plus/SurveyManage.aspx"); return;
         }
         //this.lblSurveyName.Text = info.SurveyName;
         //this.lblDesp.Text = info.Description;
         //if (!string.IsNullOrEmpty(info.Description))
         //{
         //    this.lblDesp.Text = "问卷描述:" + info.Description;
         //}
         MyBind();
         IList <M_Question> list = new List <M_Question>();
         list = B_Survey.GetQueList(Sid);
         rptReuslt.DataSource = list;
         rptReuslt.DataBind();
         Call.SetBreadCrumb(Master, "<li><a href='SurveyManage.aspx'>问卷投票</a></li><li><a href='Survey.aspx?SID=" + info.SurveyID + "'>" + info.SurveyName + "</a></li><li class='active'>问卷投票结果</li>");
     }
 }
Ejemplo n.º 2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            M_Survey info = surBll.GetSurveyBySid(Sid);

            if (info.IsNull)
            {
                function.WriteErrMsg("该问卷不存在!可能已被删除");
            }
            DateTime SubmitDate = DateTime.Now;
            string   SIP        = IPScaner.GetUserIP();
            //----如该问卷是不用登录的,则以随机码作为用户名
            int UserID = GetUserID(info);

            if (info.IsCheck && !CheckVCode(SendVcode.Text.Trim()))
            {
                function.Script(this, "alert('验证码不正确');");
                return;
            }
            IList <M_Question> list = B_Survey.GetQueList(Sid);

            for (int i = 0; i < list.Count; i++)
            {
                M_Answer ans         = new M_Answer();
                string   re          = Request.Form["vote_" + i];
                string[] OptionValue = list[i].QuestionContent.Split(new char[] { '|' });
                if (list[i].TypeID == 2)
                {
                    string[] ReArr = re.Split(new char[] { ',' });
                    for (int s = 0; s < ReArr.Length; s++)
                    {
                        ans.AnswerID      = 0;
                        ans.AnswerContent = ReArr[s];
                        ans.QuestionID    = list[i].QuestionID;
                        ans.SurveyID      = Sid;
                        ans.SubmitIP      = SIP;
                        ans.SubmitDate    = SubmitDate;
                        ans.UserID        = UserID;
                        B_Survey.AddAnswer(ans);
                    }
                }
                else
                {
                    ans.AnswerID      = 0;
                    ans.AnswerContent = re;
                    ans.QuestionID    = list[i].QuestionID;
                    ans.SurveyID      = Sid;
                    ans.SubmitIP      = SIP;
                    ans.SubmitDate    = SubmitDate;
                    ans.UserID        = UserID;
                    B_Survey.AddAnswer(ans);
                }
            }
            B_Survey.AddAnswerRecord(Sid, UserID, SIP, SubmitDate, 1);
            string url = "VoteResult.aspx?SID=" + Sid;

            function.WriteSuccessMsg("提交成功!感谢您的参与!", Page.ResolveClientUrl(url));
        }
Ejemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     ////判断是否被屏蔽
     //string ip = Request.UserHostAddress;
     //if (IsIPShielded(ip))
     //{
     //    function.WriteErrMsg("你的IP已被列入黑名单, 禁止访问此页面!", "../Plus/SurveyManage.aspx");
     //    return;
     //}
     if (!this.Page.IsPostBack)
     {
         //B_Admin badmin = new B_Admin();
         //
         int SID = string.IsNullOrEmpty(Request.QueryString["SID"]) ? 0 : DataConverter.CLng(Request.QueryString["SID"]);
         if (SID <= 0)
         {
             function.WriteErrMsg("缺少问卷投票的ID参数!");
         }
         else
         {
             M_Survey info = new B_Survey().GetSurveyBySid(SID);
             if (info.IsNull)
             {
                 function.WriteErrMsg("该问卷投票不存在!可能已被删除");
             }
             else
             {
                 if (info.IsShow == 0)
                 {
                     function.WriteErrMsg("该问卷结果前台显示未启用!!");
                 }
                 this.ltlSurveyName.Text = info.SurveyName;
                 this.ltlDate.Text       = DateTime.Now.AddSeconds(-30).ToString("yyyy-MM-dd hh:mm:ss");
                 IList <M_Question> list = new List <M_Question>();
                 list = B_Survey.GetQueList(SID);
                 rptResult.DataSource = list;
                 rptResult.DataBind();
             }
         }
     }
 }
Ejemplo n.º 4
0
        protected void CheckInsert()
        {
            M_Survey info = surBll.GetSurveyBySid(Sid);
            //判断是否登录
            DateTime SubmitDate = DateTime.Now;
            string   SIP        = Request.UserHostAddress;
            int      UserID     = GetUserID(info);

            //判断是否已参与了该问卷
            if (B_Survey.HasAnswerBySID(Sid, UserID))
            {
                function.WriteErrMsg("您已提交过该问卷!");
            }
            if (info.IPRepeat > 0)
            {
                if (B_Survey.HasAnswerCountIP(Sid, SIP) >= info.IPRepeat)
                {
                    function.WriteErrMsg("于IP:" + SIP + " 提交的问卷次数已达到限定次数:" + info.IPRepeat.ToString() + "次!");
                }
            }
            IList <M_Question> list = new List <M_Question>();

            list = B_Survey.GetQueList(Sid);
            for (int i = 0; i < list.Count; i++)
            {
                M_Answer ans         = new M_Answer();
                string   re          = Request.Form["vote_" + i];
                string[] OptionValue = list[i].QuestionContent.Split(new char[] { '|' });
                if (string.IsNullOrEmpty(re))
                {
                    re = "";
                }
                if (list[i].TypeID == 1)
                {
                    if (list[i].IsNull && string.IsNullOrEmpty(Request.Form["vote_" + i]))
                    {
                        function.WriteErrMsg(list[i].QuestionTitle + ":为必填选项");
                    }
                    //ans.AnswerID = 0;
                    ans.AnswerContent = DataConvert.CStr(re);
                    ans.AnswerScore   = surBll.GetScoreByContent(list[i].QuestionContent, re);
                    ans.QuestionID    = list[i].QuestionID;
                    ans.SurveyID      = Sid;
                    ans.SubmitIP      = SIP;
                    ans.SubmitDate    = SubmitDate;
                    ans.UserID        = UserID;
                    B_Survey.AddAnswer(ans);
                }
                else
                {
                    string[] ReArr = re.Split(new char[] { ',' });
                    for (int s = 0; s < ReArr.Length; s++)
                    {
                        //ans.AnswerID = 0;
                        ans.AnswerContent = DataConvert.CStr(ReArr[s]);
                        ans.QuestionID    = list[i].QuestionID;
                        ans.SurveyID      = Sid;
                        ans.SubmitIP      = SIP;
                        ans.SubmitDate    = SubmitDate;
                        ans.UserID        = UserID;
                        B_Survey.AddAnswer(ans);
                    }
                }
            }
        }
Ejemplo n.º 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         M_UserInfo mu   = buser.GetLogin();
         M_Survey   info = surBll.GetSurveyBySid(Sid);
         if (Sid <= 0)
         {
             function.WriteErrMsg("缺少问卷投票的ID参数!", Request.UrlReferrer.ToString());
         }
         if (info == null || info.IsNull)
         {
             function.WriteErrMsg("缺少问卷!!");
         }
         if (!B_Survey.HasQuestion(Sid))
         {
             function.WriteErrMsg("该投票没有设定投票问题!");
         }
         if (info.NeedLogin)
         {
             B_User.CheckIsLogged(Request.RawUrl);
         }
         if (info.IsCheck)
         {
             regVcodeRegister.Visible = true;
         }
         if (!info.IsOpen)
         {
             function.WriteErrMsg("对不起,该问卷尚未启用!!", Request.UrlReferrer.ToString());
         }
         if (info.StartTime > DateTime.Now || info.EndTime < DateTime.Now)
         {
             function.WriteErrMsg("对不起,每年填写或报名时间是" + info.StartTime.ToLongDateString() + "到" + info.EndTime.ToLongDateString());
         }
         //判断是否已参与了该问卷
         if (B_Survey.HasAnswerBySID(Sid, mu.UserID))
         {
             function.WriteErrMsg("您已提交过该问卷!");
         }
         CheckIP(info);
         Random_Hid.Value = GetRandomID().ToString();
         DataTable tblAnswers = new DataTable();
         if (Request.QueryString["UID"] != null && Request.QueryString["PTime"] != null)
         {
             int    uid  = DataConverter.CLng(Request.QueryString["UID"]);
             string time = Server.UrlDecode(Request.QueryString["PTime"]);
             tblAnswers = B_Answer.GetUserAnswers(Sid, uid, time);
         }
         if (tblAnswers.Rows.Count > 0)
         {
             btnSubmit.Visible = false;
             btnExport.Visible = true;
         }
         else
         {
             btnExport.Visible = false;
             btnSubmit.Visible = true;
         }
         this.SurveyName_L.Text  = info.SurveyName;
         this.Description_L.Text = info.Description;
         this.CreateDate_L.Text  = info.CreateDate.ToString("yyyy-MM-dd");
         qtitle.Visible          = !string.IsNullOrEmpty(info.Description);
         StringBuilder      sb   = new StringBuilder();
         IList <M_Question> list = new List <M_Question>();
         list = B_Survey.GetQueList(Sid);
         for (int i = 0; i < list.Count; i++)
         {
             if (list[i].IsNull)
             {
                 sb.AppendLine("<li id='mao_" + i + "' name='mao_" + i + " '>");
                 IsNull_H.Value += "vote_" + i + ",";
             }
             else
             {
                 sb.AppendLine("<li id='mao_" + i + "' name='mao_" + i + " '>");
             }
             sb.AppendLine("<table id='tbl_" + i + "' style='width:100%;'>");
             sb.AppendLine("<tr style='border-bottom:1px solid #ddd;padding-bottom:5px;'><th>" + (i + 1) + ". " + list[i].QuestionTitle + (list[i].IsNull ? "<span style='color:#f00;margin-left:10px;'>*</span>" : "") + "</th></tr>");
             sb.AppendLine("<tr><td>" + list[i].QuestionContent + "</td></tr>");
             List <string> optionlist  = new List <string>();
             JObject       jobj        = JsonConvert.DeserializeObject <JObject>(list[i].Qoption);
             string[]      OptionValue = list[i].TypeID == 0 ? jobj["sel_op_body"].ToString().Split(',') : jobj["text_str_dp"].ToString().Split(',');
             string        optiontype  = list[i].TypeID == 0 ? jobj["sel_type_rad"].ToString() : jobj["text_type_rad"].ToString();
             if (tblAnswers.Rows.Count > 0)
             {
                 sb.AppendLine(SetAnswers(i, list[i].TypeID, list[i].QuestionID, tblAnswers, OptionValue));
             }
             else
             {
                 sb.AppendLine(SetOptions(i, optiontype, OptionValue));
             }
             sb.AppendLine("</table></li>");
         }
         IsNull_H.Value     = IsNull_H.Value.Trim(',');
         ltlResultHtml.Text = sb.ToString();
     }
 }
Ejemplo n.º 6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            M_Survey   info = surveyBll.GetSurveyBySid(Sid);
            M_UserInfo mu   = buser.GetLogin();
            string     SIP  = EnviorHelper.GetUserIP();

            if (info.NeedLogin && mu == null || mu.UserID < 1)
            {
                function.WriteErrMsg("该问卷需登录才能参与问卷,请先登录!");
            }
            if (B_Survey.HasAnswerBySID(Sid, mu.UserID))
            {
                function.WriteErrMsg("您已提交过该问卷!");
            }
            if (info.IPRepeat > 0 && B_Survey.HasAnswerCountIP(Sid, SIP) >= info.IPRepeat)
            {
                function.WriteErrMsg("于IP:" + SIP + " 提交的问卷次数已达到限定次数:" + info.IPRepeat.ToString() + "次!");
            }
            //--------------------------
            IList <M_Question> list = B_Survey.GetQueList(Sid);

            for (int i = 0; i < list.Count; i++)
            {
                M_Answer anMod = new M_Answer();
                anMod.AnswerContent = Request.Form["result_" + list[i].QuestionID];
                anMod.QuestionID    = list[i].QuestionID;
                anMod.SurveyID      = Sid;
                anMod.SubmitIP      = SIP;
                anMod.UserID        = mu.UserID;
                B_Survey.AddAnswer(anMod);
            }
            if (B_Survey.AddAnswerRecord(Sid, mu.UserID, SIP, DateTime.Now, 0))
            {
                function.WriteSuccessMsg("提交成功!感谢您的参与!");
            }
            //for (int i = 0; i < list.Count; i++)
            //{
            //    M_Answer ans = new M_Answer();
            //    string re = Request.Form["txt_" + i];
            //    string[] OptionValue = list[i].QuestionContent.Split(new char[] { '|' });
            //    if (string.IsNullOrEmpty(re))
            //    {
            //        re = OptionValue[0];
            //    }

            //    if (list[i].TypeID == 1)
            //    {
            //        ans.AnswerID = 0;
            //        ans.AnswerContent = re;
            //        ans.QuestionID = list[i].QuestionID;
            //        ans.SurveyID = Sid;
            //        ans.SubmitIP = SIP;
            //        ans.UserID = mu.UserID;
            //        B_Survey.AddAnswer(ans);
            //    }
            //    else
            //    {
            //        string[] ReArr = re.Split(new char[] { ',' });
            //        for (int s = 0; s < ReArr.Length; s++)
            //        {
            //            ans.AnswerID = 0;
            //            ans.AnswerContent = ReArr[s];
            //            ans.QuestionID = list[i].QuestionID;
            //            ans.SurveyID = Sid;
            //            ans.SubmitIP = SIP;
            //            ans.UserID = mu.UserID;
            //            B_Survey.AddAnswer(ans);
            //        }
            //    }
            //}
        }