示例#1
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            Student      student    = bindingSource_StudentDB.Current as Student;
            List <Score> temp       = EasOP.GetScores(student.StuID);
            String       CourseName = comboBoxCourseName.SelectedItem.ToString();
            String       Year       = comboBoxYear.SelectedItem.ToString();
            String       Term       = comboBoxTerm.SelectedItem.ToString();
            String       Credit     = comboBoxCreditNum.SelectedItem.ToString();

            if (CourseName != " ")
            {
                Score Course = temp.FirstOrDefault(p => p.LessonName == CourseName);
                bindingSource_StuScore.DataSource = Course;
                bindingSource_StuScore.ResetBindings(false);
                return;
            }

            if (Credit != " ")
            {
                temp = temp.Where(p => p.Credit == Credit).OrderBy(p => p.Year).ThenBy(p => p.Term).ToList();
            }

            if (Year != " ")
            {
                temp = temp.Where(p => p.Year == Year).OrderBy(p => p.Term).ThenBy(p => p.Credit).ToList();
            }

            if (Term != " ")
            {
                temp = temp.Where(p => p.Term == Term).OrderBy(p => p.Year).ThenBy(p => p.Credit).ToList();
            }

            bindingSource_StuScore.DataSource = temp;
            bindingSource_StuScore.ResetBindings(false);
        }
示例#2
0
        private void tab3Init()
        {
            if (bindingSource_StudentDB.Count != 0)
            {
                Student student = bindingSource_StudentDB.Current as Student;
                bindingSource_StuScore.DataSource = EasOP.GetScores(student.StuID);
                AllScoredataGridView.DataSource   = bindingSource_StuScore;

                //防止列乱序
                AllScoredataGridView.AutoGenerateColumns = false;
                //为DataGridView增加可选框
                DataGridViewCheckBoxColumn checkBoxColumn = new DataGridViewCheckBoxColumn();
                checkBoxColumn.Name = "select";
                //列名
                checkBoxColumn.HeaderText = "选择";
                //第一列插入checkbox
                AllScoredataGridView.Columns.Insert(0, checkBoxColumn);
                AllScoredataGridView.RowHeadersVisible = false;

                AllScoredataGridView.Columns[0].Width = 50;

                //初始化combobox
                List <Score> combo = EasOP.GetScores(student.StuID);
                //提取成绩列表中的唯一值
                List <String> CourseName = combo.Select(x => x.LessonName).Distinct().ToList();
                CourseName.Insert(0, " ");
                List <String> Credit = combo.Select(x => x.Credit).Distinct().ToList();
                Credit.Insert(0, " ");
                List <String> Year = combo.Select(x => x.Year).Distinct().ToList();
                Year.Insert(0, " ");
                List <String> Term = new List <string> {
                    " ", "1", "2"
                };
                comboBoxCourseName.DataSource = CourseName;
                comboBoxCreditNum.DataSource  = Credit;
                comboBoxYear.DataSource       = Year;
                comboBoxTerm.DataSource       = Term;
            }
        }
示例#3
0
        public override int HandleImpl()
        {
            string StuID     = EasOP.GetStuID(fromQQ);
            Regex  regex     = new Regex(@"[0-9]{4}");
            Regex  regexTerm = new Regex(@"第?[123一二三]?学期?");            //可以匹配1,2,3,一,二,三,第x学期
            Regex  regexAny  = new Regex(@"[A-Za-z0-9\u4e00-\u9fa5]+"); //匹配课程名

            if (StuID != "")
            {
                List <Score> Slist     = EasOP.GetScores(StuID);
                List <Score> SlistTemp = EasOP.GetScores(StuID);//用于查询单科使用
                GPAInfo      StuGPA;
                int          isIlegal = 0;
                bool         flag     = false;
                string       msg      = message.Replace(" ", ""); //去除空格
                //无额外操作,直接返回总成绩
                if (msg == "计算成绩")
                {
                    StuGPA = ScoreService.AllCredit(Slist);
                    CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), $"【GPA信息】\nGPA:{StuGPA.GPA}\n平均分:{StuGPA.AverageScore}\n所选学分:{StuGPA.CreditSum}");
                }
                //存在操作
                else
                {
                    try
                    {
                        string       msg1         = msg.Substring(4);
                        string[]     msgprocess   = msg1.Split('|');
                        bool         isCourseFlag = false;
                        int          isCourse     = 0;
                        List <Score> SlistCourse  = new List <Score>();
                        for (int i = 0; i < msgprocess.Length; i++)
                        {
                            isIlegal = 0;
                            string msgtemp = msgprocess[i];
                            if (regexAny.IsMatch(msgtemp) && (isCourse == 0 || isCourseFlag))//处理操作中有课程名,若为课程名,则其他去除公选的操作不考虑
                            {
                                List <Score> temp = ScoreService.onlyThisCourse(SlistTemp, msgtemp);
                                if (temp.Count != 0)
                                {
                                    SlistCourse.AddRange(temp);
                                    isCourseFlag = true;
                                    isCourse++;
                                    continue;
                                }
                            }
                            if (msgtemp == "去除公选")
                            {
                                Slist = ScoreService.noGongXuan(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除公必")
                            {
                                Slist = ScoreService.noGongBi(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除专选")
                            {
                                Slist = ScoreService.noZhuanXuan(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除专必")
                            {
                                Slist = ScoreService.noZhuanBi(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除非本院")
                            {
                                Slist = ScoreService.onlyDepartment(Slist, EasOP.GetCollege(StuID));
                                isIlegal++;
                            }
                            if (regex.IsMatch(msgtemp))
                            {
                                Slist = ScoreService.onlyThisYear(Slist, msgtemp);
                                isIlegal++;
                            }
                            if (regexTerm.IsMatch(msgtemp))
                            {
                                msgtemp = msgtemp.Replace("一", "1");
                                msgtemp = msgtemp.Replace("二", "2");
                                msgtemp = msgtemp.Replace("三", "3");
                                Slist   = ScoreService.onlyThisTerm(Slist, msgtemp[1].ToString());
                                isIlegal++;
                            }
                            if (isIlegal == 0)
                            {
                                flag = true;
                            }
                            if (i == msgprocess.Length - 1 && flag == true)
                            {
                                CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【存在非法指令】\n非法指令已被跳过,请检查后重新输入。");
                            }
                        }
                        if (isCourseFlag)
                        {
                            Slist = SlistCourse;
                        }
                        StuGPA = ScoreService.Compute(Slist);
                        CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), $"【GPA信息】\nGPA:{StuGPA.GPA}\n平均分:{StuGPA.AverageScore}\n所选学分:{StuGPA.CreditSum}");
                    }
                    catch (Exception e)
                    {
                        if (e.Message == "学年不存在")
                        {
                            CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【学年不存在】\n请输入正确的学年进行查询");
                        }
                        if (e.Message == "学期不存在")
                        {
                            CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【学期不存在】\n请输入正确的学年及学期进行查询");
                        }
                    }
                }
            }
            else
            {
                CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【未绑定教务系统】\n请先绑定教务系统,格式:绑定教务系统 学号|密码");
            }

            return(0);
        }
示例#4
0
        private void buttonRestore_Click(object sender, EventArgs e)
        {
            Student student = bindingSource_StudentDB.Current as Student;

            bindingSource_StuScore.DataSource = EasOP.GetScores(student.StuID);
        }
        public override int HandleImpl()
        {
            string StuID     = EasOP.GetStuID(fromQQ);
            Regex  regex     = new Regex(@"[0-9]{4}");
            Regex  regexTerm = new Regex(@"第+[123一二三]+学+期+");           //可以匹配1,2,3,一,二,三,第x学期
            Regex  regexAny  = new Regex(@"[A-Za-z0-9\u4e00-\u9fa5]+"); //匹配课程名

            if (StuID != "")
            {
                List <Score> Slist     = EasOP.GetScores(StuID);
                List <Score> SlistTemp = EasOP.GetScores(StuID);//用于查询单科使用
                GPAInfo      StuGPA;
                int          isIlegal = 0;
                bool         flag     = false;
                string       msg      = message.Replace(" ", ""); //去除空格
                string       str;
                str = padRightEx("课程名", 8) + padRightEx("学分", 6) + padRightEx("成绩", 6) + "\n";
                //str = string.Format("{0,30}", "课程名") + string.Format("{0,6}", "学分") + string.Format("{0,6}", "成绩") + "\n";
                //无额外操作,直接返回总成绩
                if (msg == "查询成绩")
                {
                    foreach (Score temp in Slist)
                    {
                        //str += string.Format("{0,30}", temp.LessonName) + string.Format("{0,6}", temp.Credit) + string.Format("{0,6}", temp.Mark) + "\n";
                        str += padRightEx(temp.LessonName, 36) + "\n" + padRightEx(temp.Credit, 6) + padRightEx(temp.Mark, 6) + "\n";

                        /* str.Append(padRightEx(temp.LessonName, 30) + padRightEx(temp.Credit, 6) + padRightEx(temp.Mark, 6));
                         * str.Append(Environment.NewLine);*/
                    }
                    CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), $"【成绩信息】\n" + str);
                }
                //存在操作
                else
                {
                    try
                    {
                        string       msg1         = msg.Substring(4);
                        string[]     msgprocess   = msg1.Split('|');
                        bool         isCourseFlag = false;
                        int          isCourse     = 0;
                        List <Score> SlistCourse  = new List <Score>();
                        for (int i = 0; i < msgprocess.Length; i++)
                        {
                            isIlegal = 0;
                            string msgtemp = msgprocess[i];
                            if (regexAny.IsMatch(msgtemp) && (isCourse == 0 || isCourseFlag))//处理操作中有课程名,若为课程名,则其他去除公选的操作不考虑
                            {
                                List <Score> temp = ScoreService.onlyThisCourse(SlistTemp, msgtemp);
                                if (temp.Count != 0)
                                {
                                    SlistCourse.AddRange(temp);
                                    isCourseFlag = true;
                                    isCourse++;
                                    continue;
                                }
                            }
                            if (msgtemp == "去除公选")
                            {
                                Slist = ScoreService.noGongXuan(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除公必")
                            {
                                Slist = ScoreService.noGongBi(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除专选")
                            {
                                Slist = ScoreService.noZhuanXuan(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除专必")
                            {
                                Slist = ScoreService.noZhuanBi(Slist);
                                isIlegal++;
                            }
                            if (msgtemp == "去除非本院")
                            {
                                Slist = ScoreService.onlyDepartment(Slist, EasOP.GetCollege(StuID));
                                isIlegal++;
                            }
                            if (regex.IsMatch(msgtemp))
                            {
                                Slist = ScoreService.onlyThisYear(Slist, msgtemp);
                                isIlegal++;
                            }
                            if (regexTerm.IsMatch(msgtemp))
                            {
                                msgtemp = msgtemp.Replace("一", "1");
                                msgtemp = msgtemp.Replace("二", "2");
                                msgtemp = msgtemp.Replace("三", "3");
                                Slist   = ScoreService.onlyThisTerm(Slist, msgtemp[1].ToString());
                                isIlegal++;
                            }
                            if (isIlegal == 0)
                            {
                                flag = true;
                            }
                            if (i == msgprocess.Length - 1 && flag == true)
                            {
                                CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【存在非法指令】\n非法指令已被跳过,请检查后重新输入。");
                            }
                        }
                        if (isCourseFlag)
                        {
                            Slist = SlistCourse;
                        }
                        foreach (Score temp in Slist)
                        {
                            //str += string.Format("{0,30}", temp.LessonName) + string.Format("{0,6}", temp.Credit) + string.Format("{0,6}", temp.Mark) + "\n";
                            str += padRightEx(temp.LessonName, 36) + "\n" + padRightEx(temp.Credit, 6) + padRightEx(temp.Mark, 6) + "\n";

                            /*str.Append(padRightEx(temp.LessonName, 30) + padRightEx(temp.Credit, 6) + padRightEx(temp.Mark, 6));
                             * str.Append(Environment.NewLine);*/
                        }
                        CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), $"【成绩信息】\n" + str);
                    }
                    catch (Exception e)
                    {
                        if (e.Message == "学年不存在")
                        {
                            CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【学年不存在】\n请输入正确的学年进行查询");
                        }
                        if (e.Message == "学期不存在")
                        {
                            CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【学期不存在】\n请输入正确的学年及学期进行查询");
                        }
                    }
                }
            }
            else
            {
                CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【未绑定教务系统】\n请先绑定教务系统,格式:绑定教务系统 学号|密码");
            }

            return(0);
        }