protected void Page_Load(object sender, EventArgs e)
 {
     this.surveyId = BasePage.RequestInt32("SurveyID");
     if (!base.IsPostBack)
     {
         if (this.surveyId == 0)
         {
             AdminPage.WriteErrMsg("<li>请指定问卷ID</li>", "SurveyManage.aspx");
         }
         else if (!SurveyManager.SurveyIdOfPassedExists(this.surveyId))
         {
             AdminPage.WriteErrMsg("<li>该问卷未启用,不能查看报表!</li>");
         }
         else
         {
             SurveyInfo surveyById = SurveyManager.GetSurveyById(this.surveyId);
             if (!surveyById.IsNull)
             {
                 this.LblSurveyName.Text   = surveyById.SurveyName;
                 this.LblDescription.Text  = surveyById.Description;
                 this.LblTitle.Text        = "[" + surveyById.SurveyName + "]问卷报表";
                 this.LblSurveyNumber.Text = SurveyRecord.GetTotalOfSurveyRecord(this.surveyId).ToString();
                 this.LblDate.Text         = surveyById.CreateDate.ToString() + "/" + surveyById.EndTime.ToString();
             }
             else
             {
                 AdminPage.WriteErrMsg("<li>未找到对应的问卷信息</li>");
             }
         }
         this.BtnReport.Attributes.Add("onclick", "javascript:window.print();return false;");
     }
 }
 protected void BtnDelete_Click(object sender, EventArgs e)
 {
     if (SurveyRecord.Delete(this.m_RecordId.ToString(), this.m_SurveyId))
     {
         AdminPage.WriteSuccessMsg("删除记录成功", "ShowCountData3.aspx?SurveyID=" + this.m_SurveyId);
     }
     else
     {
         AdminPage.WriteErrMsg("<li>删除记录失败</li>");
     }
 }
        public ActionResult Create(SurveyTemplate surveytemplate, FormCollection formcollection)
        {
            if (ModelState.IsValid)
            {
                db.SurveyTemplates.Add(surveytemplate);
                surveytemplate.PreDefined = true;
                db.SaveChanges();
                surveytemplate.SurveyRecords = new List <SurveyRecord>();
                int xindex = 0;
                foreach (SurveyNode snode_ in db.SurveyNodes.ToList())
                {
                    try
                    {
                        if (bool.Parse(formcollection[snode_.SurveyNodeID.ToString() + "_Check"].Split(',')[0]))
                        {
                            SurveyRecord newsurvrec = new SurveyRecord {
                                SurveyNodeID = snode_.SurveyNodeID, OrderNum = xindex, SurveyRecordTypeID = int.Parse(formcollection[snode_.SurveyNodeID.ToString() + "_survrectype"])
                            };
                            surveytemplate.SurveyRecords.Add(newsurvrec);
                            db.SaveChanges();
                            xindex++;
                        }
                    }
                    catch (Exception exx)
                    {
                        ViewBag.CustomErr = exx.Message;
                    }
                }

                return(RedirectToAction("Index"));
            }

            ViewBag.AllSurveyNodes = db.SurveyNodes.ToList();
            var query         = db.RequestTypes.Where(u => db.SurveyTemplates.Where(i => i.PreDefined == true).Select(s => s.RequestTypeID).Contains(u.RequestTypeID));
            var emptyReqTypes = db.RequestTypes.Except(query);

            ViewBag.RequestTypeID = new SelectList(emptyReqTypes, "RequestTypeID", "Description", surveytemplate.RequestTypeID);
            return(View(surveytemplate));
        }
 private void BindData()
 {
     this.RptAnswerList.DataSource = SurveyRecord.GetQuestionAnswer(this.surveyId, "Q" + this.questionId.ToString());
     this.RptAnswerList.DataBind();
 }
        public async Task <ActionResult <SurveyRecord> > AddAsync([FromBody] SurveyRecord surveyRecord)
        {
            var item = await _surveyRecordService.AddAsync(surveyRecord);

            return(CreatedAtAction(nameof(GetByIdAsync), new { id = item.Id }, item));
        }
 private void BindData()
 {
     this.RptAnswerList.DataSource = SurveyRecord.GetList((this.Pager.CurrentPageIndex - 1) * this.Pager.PageSize, this.Pager.PageSize, this.surveyId, 0);
     this.RptAnswerList.DataBind();
     this.Pager.RecordCount = SurveyRecord.GetTotalOfSurveyRecord();
 }
Exemple #7
0
 private void SaveSurveyRecord(int surveyId)
 {
     if (surveyId == 0)
     {
         DynamicPage.WriteErrMsg("问卷调查ID错误!");
     }
     else
     {
         SurveyInfo surveyById = SurveyManager.GetSurveyById(surveyId);
         if (surveyById.IsOpen != 1)
         {
             DynamicPage.WriteErrMsg("问卷调查尚未启用!!!");
         }
         if (surveyById.EndTime != null)//.HasValue)
         {
             DateTime?endTime = surveyById.EndTime;
             DateTime now     = DateTime.Now;
             if (endTime.HasValue ? (endTime.GetValueOrDefault() < now) : false)
             {
                 DynamicPage.WriteErrMsg("问卷调查已经结束!!!");
             }
         }
         if (!SurveyManager.CheckLockUrl(base.Request.ServerVariables["HTTP_REFERER"], surveyById))
         {
             DynamicPage.WriteErrMsg("不允许从外部链接地址提交!!!");
         }
         if (SurveyManager.CheckRepeatIP(PEContext.Current.UserHostAddress, surveyId, surveyById))
         {
             DynamicPage.WriteErrMsg("同一用户不允许填写问卷调查超过" + surveyById.IPRepeat.ToString() + "次!!!");
         }
         if (!string.IsNullOrEmpty(surveyById.SetPassword) && (surveyById.SetPassword != base.Request.Form["SurveyPassword"].ToString()))
         {
             DynamicPage.WriteErrMsg("问卷密码错误!!!");
         }
         if (SurveyManager.CheckIPLock(PEContext.Current.UserHostAddress, surveyById))
         {
             DynamicPage.WriteErrMsg("对不起!您的IP(" + PEContext.Current.UserHostAddress + ")被系统限定,您可以和站长联系。");
         }
         if (surveyById.NeedLogin == 1)
         {
             if (PEContext.Current.User.Identity.IsAuthenticated)
             {
                 if (surveyById.PresentPoint != 0)
                 {
                     int userId = PEContext.Current.User.UserInfo.UserId;
                     Users.Update(userId, "UserPoint", (PEContext.Current.User.UserInfo.UserPoint + surveyById.PresentPoint).ToString());
                     UserPointLogInfo userPointLogInfo = new UserPointLogInfo();
                     userPointLogInfo.IncomePayOut = 1;
                     userPointLogInfo.InfoId       = 0;
                     userPointLogInfo.Inputer      = "System";
                     userPointLogInfo.IP           = PEContext.Current.UserHostAddress;
                     userPointLogInfo.LogId        = UserPointLog.GetTotalInComeAndPayOutAll().Count;
                     userPointLogInfo.LogTime      = DateTime.Now;
                     userPointLogInfo.Memo         = "";
                     userPointLogInfo.ModuleType   = 9;
                     userPointLogInfo.Point        = surveyById.PresentPoint;
                     userPointLogInfo.Remark       = "参与“" + surveyById.SurveyName + "”--问卷调查获得奖励点数";
                     userPointLogInfo.Times        = 1;
                     userPointLogInfo.UserName     = PEContext.Current.User.UserInfo.UserName;
                     UserPointLog.Add(userPointLogInfo);
                 }
             }
             else
             {
                 string absoluteUri = HttpContext.Current.Request.Url.AbsoluteUri;
                 BasePage.ResponseRedirect("../User/Login.aspx?ReturnUrl=" + HttpUtility.UrlEncode(absoluteUri));
             }
         }
         IList <SurveyFieldInfo> fieldList        = SurveyField.GetFieldList(surveyId);
         SurveyRecordInfo        surveyrecordinfo = new SurveyRecordInfo();
         DataTable table = new DataTable();
         table.Columns.Add("Option", typeof(string));
         table.Columns.Add("Input", typeof(string));
         table.Columns.Add("QuestionType", typeof(int));
         table.Columns.Add("InputType", typeof(int));
         table.Columns.Add("QuestionId", typeof(int));
         foreach (SurveyFieldInfo info4 in fieldList)
         {
             string answer = DataSecurity.FilterBadChar(base.Request.Form["Q" + info4.QuestionId]);
             this.CheckForm(info4, answer);
             DataRow row = table.NewRow();
             row["Option"]       = answer;
             row["QuestionType"] = info4.QuestionType;
             row["InputType"]    = info4.InputType;
             row["QuestionId"]   = info4.QuestionId;
             if (info4.InputType > 0)
             {
                 string str3 = DataSecurity.FilterBadChar(base.Request.Form["Q" + info4.QuestionId + "Input"]);
                 row["Input"] = str3;
             }
             if (((info4.QuestionType == 2) || (info4.QuestionType == 4)) || (info4.QuestionType == 7))
             {
                 SurveyVote.Vote(surveyId, info4.QuestionId, DataConverter.CLng(answer));
             }
             if ((info4.QuestionType == 3) || (info4.QuestionType == 5))
             {
                 foreach (string str4 in answer.Split(new char[] { ',' }))
                 {
                     SurveyVote.Vote(surveyId, info4.QuestionId, DataConverter.CLng(str4));
                 }
             }
             table.Rows.Add(row);
         }
         surveyrecordinfo.Answer     = table;
         surveyrecordinfo.UserName   = PEContext.Current.User.UserInfo.UserName;
         surveyrecordinfo.IP         = PEContext.Current.UserHostAddress;
         surveyrecordinfo.SubmitTime = DateTime.Now;
         surveyrecordinfo.SurveyId   = surveyId;
         if (!SurveyRecord.SaveSurveyRecord(surveyrecordinfo))
         {
             DynamicPage.WriteErrMsg("提交问卷失败!");
         }
         else
         {
             DynamicPage.WriteSuccessMsg("提交问卷成功!", "");
         }
     }
 }
 private void BindData()
 {
     this.RptShowCountList.DataSource = SurveyRecord.GetList((this.Pager.CurrentPageIndex - 1) * this.Pager.PageSize, this.Pager.PageSize, this.m_SurveyId, this.m_RecordId);
     this.RptShowCountList.DataBind();
     this.Pager.RecordCount = SurveyRecord.GetTotalOfSurveyRecord();
 }
        public ActionResult Edit(SurveyTemplate surveytemplate, FormCollection formcollection)
        {
            if (ModelState.IsValid)
            {
                if (db.SurveyTemplates.AsNoTracking().Where(i => i.RequestTypeID == surveytemplate.RequestTypeID && i.PreDefined == true && i.SurveyTemplateID != surveytemplate.SurveyTemplateID).ToList().Count > 0)
                {
                    ViewBag.CustomErr = "İlgili İş tipine ait bir taslak zaten var. Lütfen Başka Bir Tip seçiniz";
                    return(RedirectToAction("Edit", new { id = surveytemplate.SurveyTemplateID }));
                }

                db.Entry(surveytemplate).State = EntityState.Modified;
                db.SaveChanges();
                SurveyTemplate mysurvtemplate_ = db.SurveyTemplates.Include(p => p.SurveyRecords).Where(i => i.SurveyTemplateID == surveytemplate.SurveyTemplateID).SingleOrDefault();
                int            xindex          = 0;
                foreach (SurveyNode snode_ in db.SurveyNodes.ToList())
                {
                    try
                    {
                        if (bool.Parse(formcollection[snode_.SurveyNodeID.ToString() + "_Remove"].Split(',')[0]))
                        {
                        }
                        else
                        {
                            SurveyRecord mysurvrec = db.SurveyTemplates.AsNoTracking().Where(i => i.SurveyTemplateID == surveytemplate.SurveyTemplateID).SingleOrDefault().SurveyRecords.Where(u => u.SurveyNodeID == snode_.SurveyNodeID).SingleOrDefault();
                            var          mysrec    = db.SurveyRecords.Find(mysurvrec.SurveyRecordID);
                            surveytemplate.SurveyRecords.Remove(mysrec);
                            db.Entry(surveytemplate).State = EntityState.Modified;

                            //db.SurveyRecords.Remove(mysurvrec);
                            db.SaveChanges();
                            KlmsnContext db_ = new KlmsnContext();
                            var          mysrec_forremove = db_.SurveyRecords.Find(mysurvrec.SurveyRecordID);
                            db_.SurveyRecords.Remove(mysrec_forremove);
                            db_.SaveChanges();
                            db_.Dispose();
                            try
                            {
                                if (bool.Parse(formcollection[snode_.SurveyNodeID.ToString() + "_Check"].Split(',')[0]))
                                {
                                    SurveyRecord newsurvrec = new SurveyRecord {
                                        SurveyNodeID = snode_.SurveyNodeID, OrderNum = xindex, SurveyRecordTypeID = int.Parse(formcollection[snode_.SurveyNodeID.ToString() + "_survrectype"])
                                    };
                                    mysurvtemplate_.SurveyRecords.Add(newsurvrec);
                                    db.SaveChanges();
                                    xindex++;
                                }
                            }
                            catch (Exception ex)
                            {
                                ViewBag.CustomErr = ex.Message;
                            }
                        }
                    }
                    catch
                    {
                        try
                        {
                            if (bool.Parse(formcollection[snode_.SurveyNodeID.ToString() + "_Check"].Split(',')[0]))
                            {
                                SurveyRecord newsurvrec = new SurveyRecord {
                                    SurveyNodeID = snode_.SurveyNodeID, OrderNum = xindex, SurveyRecordTypeID = int.Parse(formcollection[snode_.SurveyNodeID.ToString() + "_survrectype"])
                                };
                                mysurvtemplate_.SurveyRecords.Add(newsurvrec);
                                db.SaveChanges();
                                xindex++;
                            }
                        }
                        catch (Exception ex)
                        {
                            ViewBag.CustomErr = ex.Message;
                        }
                    }
                    xindex++;
                }

                return(RedirectToAction("Index"));
            }

            ViewBag.AllSurveyNodes     = db.SurveyNodes.ToList();
            ViewBag.TheseSurveyRecords = db.SurveyTemplates.Find(surveytemplate.SurveyTemplateID).SurveyRecords.ToList();
            ViewBag.RequestTypeID      = new SelectList(db.RequestTypes, "RequestTypeID", "Description", surveytemplate.RequestTypeID);
            return(View(surveytemplate));
        }