Пример #1
0
        private void CommitSurvey()
        /*存储提交的调查问卷数据*/
        {
            string         CommitHistory = this.RequestData.Get <string>("CommitHistory");
            IList <string> list          = this.RequestData.GetList <string>("commitArr");

            if (list.Count > 0 && !string.IsNullOrEmpty(CommitHistory))
            {
                IList <SurveyResult> ents  = list.Select(ten => JsonHelper.GetObject <SurveyResult>(ten) as SurveyResult).ToArray();
                SurveyCommitHistory  shEnt = JsonHelper.GetObject <SurveyCommitHistory>(CommitHistory);
                foreach (var v in ents)
                {
                    v.DoCreate();
                }
                shEnt.DoCreate();
            }
        }
Пример #2
0
        private void CommitSurvey()
        /*存储提交的调查问卷数据*/
        {
            string         CommitHistory = this.RequestData.Get <string>("CommitHistory");
            IList <string> list          = this.RequestData.GetList <string>("commitArr");

            if (list.Count > 0 && !string.IsNullOrEmpty(CommitHistory))
            {
                IList <SurveyedResult> ents  = list.Select(ten => JsonHelper.GetObject <SurveyedResult>(ten) as SurveyedResult).ToArray();
                SurveyCommitHistory    shEnt = JsonHelper.GetObject <SurveyCommitHistory>(CommitHistory);

                if (!string.IsNullOrEmpty(shEnt.SurveyedUserId))
                {
                    var UserEnt = SysUser.Find(shEnt.SurveyedUserId);
                    shEnt.WorkNo           = UserEnt.WorkNo;
                    shEnt.SurveyedUserName = UserEnt.Name;
                }

                try
                {
                    foreach (var v in ents)
                    {
                        v.DoCreate();
                    }
                }
                catch (Exception ex)
                {
                    string SQL = "delete from FL_Culture..SurveyedResult where SurveyId='{0}' and UserId='{1}' ";
                    SQL = string.Format(SQL, Id, uid);
                    DataHelper.ExecSql(SQL);
                }

                int    totalScore = -1;           //计算总分  -1 表示无分值项
                string SocreInfo  = string.Empty; // 分值总分

                var Ents = QuestionAnswerItem.FindAllByProperties(QuestionAnswerItem.Prop_SurveyId, shEnt.SurveyId);
                QuestionAnswerItem[] QArr = Ents.Where(ten => ten.Score.HasValue).ToArray();
                if (QArr.Length > 0)
                {
                    string sql = "select FL_Culture.dbo.f_SumSurveyScore('{0}','{1}') As TotalScore";
                    sql = string.Format(sql, shEnt.SurveyId, shEnt.SurveyedUserId);
                    object obj = DataHelper.QueryValue(sql);

                    int tryVal = 0;
                    if (int.TryParse(obj.ToString(), out tryVal))
                    {
                        tryVal = int.Parse(obj.ToString());
                    }
                    totalScore = tryVal;
                    SocreInfo  = GetScoreInfo(shEnt.SurveyId, shEnt.SurveyedUserId);
                }

                //添加积分项
                SurveyQuestion SQ = SurveyQuestion.Find(shEnt.SurveyId);
                if (SQ.Score.HasValue)
                {
                    SurveyScore Score = new SurveyScore();
                    Score.Score    = SQ.Score;
                    Score.Sign     = "s";
                    Score.UserID   = shEnt.SurveyedUserId;
                    Score.UserName = shEnt.SurveyedUserName;
                    Score.Detail   = SQ.SurveyTitile;
                    Score.Ext1     = SQ.Id;//SurveyId
                    Score.DoCreate();
                }

                shEnt.TotalScore = totalScore;
                shEnt.ScoreInfo  = SocreInfo;

                shEnt.DoCreate();
            }
        }