Пример #1
0
        protected override List <StudentScore> GetingItems(DataContext dc, SearchCondition search)
        {
            IQueryable <StudentScore> ret = dc.GetTable <StudentScore>();

            if (search is StudentScoreSearchCondition)
            {
                StudentScoreSearchCondition con = search as StudentScoreSearchCondition;
                if (!string.IsNullOrEmpty(con.StudentID))
                {
                    ret = ret.Where(item => item.StudentID == con.StudentID);
                }
                if (!string.IsNullOrEmpty(con.ProjectID))
                {
                    ret = ret.Where(item => item.ProjectID == con.ProjectID);
                }
                if (con.PhysicalItem != null)
                {
                    ret = ret.Where(item => item.PhysicalItem == con.PhysicalItem.Value);
                }
                if (con.Grade != null)
                {
                    ret = ret.Where(item => item.Grade == con.Grade.Value);
                }
            }
            var temp = ret.ToList();

            return(temp);
        }
Пример #2
0
        private WXResponseMsgBase 查询成绩(string publicWX, WXRequestMsg msg)
        {
            string response = _DefaultResponse;
            var    wx       = WXManager.Current[publicWX];
            var    sid      = new WXBindingBLL(wx.DBConnect).GetBindingStudentID(msg.FromUserName, msg.ToUserName);

            if (string.IsNullOrEmpty(sid))
            {
                new WXTextResponseMsg(msg.FromUserName, msg.ToUserName, DateTime.Now, "您还没有绑定学号,请先绑定学号");
            }
            var s = new StudentBLL(wx.DBConnect).GetByID(sid).QueryObject;

            if (s == null)
            {
                new WXTextResponseMsg(msg.FromUserName, msg.ToUserName, DateTime.Now, "没有找到学生信息");
            }
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Format("学号:{0}", s.ID));
            sb.AppendLine(string.Format("姓名:{0}", s.Name));
            sb.AppendLine(string.Format("性别:{0}", s.Sex == 1 ? "男" : "女"));
            if (s.Grade.HasValue)
            {
                sb.AppendLine(string.Format("年级:{0}", GradeHelper.Instance.GetName(s.Grade.Value)));
            }
            if (!string.IsNullOrEmpty(s.ClassName))
            {
                sb.AppendLine(string.Format("班级:{0}", s.ClassName));
            }
            var con = new StudentScoreSearchCondition()
            {
                Grade = s.Grade, StudentID = s.ID, ProjectID = "TizhiCheshi"
            };
            var scores = new StudentScoreBLL(wx.DBConnect).GetItems(con).QueryObjects;

            scores = (from it in scores orderby it.PhysicalItem ascending select it).ToList();
            var pis = UserSettings.Current.CreateDefaultFormula(s.Grade.Value, s.Sex);

            if (pis != null && pis.Length > 0)
            {
                if (scores != null && scores.Count > 0)
                {
                    var total = CalTotal(s.Grade.Value, scores);
                    if (total > 0)
                    {
                        sb.AppendLine(string.Format("总分:{0}", total));
                    }
                    var jiafen = CalJiafen(scores);
                    if (jiafen.HasValue)
                    {
                        sb.AppendLine(string.Format("加分:{0}", jiafen.Value.Trim()));
                    }
                    sb.AppendLine("----------------------");
                    foreach (var score in scores)
                    {
                        if (pis.Contains(score.PhysicalItem))
                        {
                            if (!score.Result.HasValue || score.PhysicalItem == 1 || score.PhysicalItem == 2)
                            {
                                sb.AppendLine(string.Format("{0}:{1}", score.PhysicalName, score.Score));
                            }
                            else
                            {
                                sb.AppendLine(string.Format("{0}:{1}_{2}分_{3}", score.PhysicalName, score.Score, score.Result.Value.Trim(), score.Rank));
                            }
                        }
                    }
                }
                if (pis.Any(it => scores == null || !scores.Exists(sc => sc.PhysicalItem == it)))
                {
                    sb.AppendLine("------------------未测试科目");
                    foreach (var pi in pis)
                    {
                        if (scores == null || !scores.Exists(it => it.PhysicalItem == pi))
                        {
                            sb.AppendLine(UserSettings.Current.GetPhysicalName(pi));
                        }
                    }
                }
                response = sb.ToString();
            }
            return(new WXTextResponseMsg(msg.FromUserName, msg.ToUserName, DateTime.Now, response));
        }