示例#1
0
        public DataTable myStudentForHead()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Mssv");
            dt.Columns.Add("Tên");
            dt.Columns.Add("GPA");
            dt.Columns.Add("Hành vi");
            dt.Columns.Add("Điểm danh");
            dt.Columns.Add("Môn nợ");
            dt.Columns.Add("Xếp loại");
            ServiceReference1.WebService1SoapClient ws  = new ServiceReference1.WebService1SoapClient();
            ServiceReference2.SAPISoapClient        fap = new ServiceReference2.SAPISoapClient();
            StaffTakeCare stc = null;
            RankDAL       rdl = new RankDAL();
            SqlConnection con = DbConnect.GetConnection();

            con.Open();
            string        sql = "SELECT TOP 10 Student.studentID,Student.studentName FROM Student LEFT JOIN Rank ON Student.studentID=Rank.studentID WHERE takecareStatus=0  AND caution=0 ORDER BY rankName DESC";
            SqlCommand    cmd = new SqlCommand(sql, con);
            SqlDataReader dr  = cmd.ExecuteReader();

            this.compareForHead = new List <Compare>();
            while (dr.Read())
            {
                Compare xx = null;
                stc             = new StaffTakeCare();
                stc.studentID   = dr["studentID"].ToString();
                stc.studentName = dr["studentName"].ToString();


                string currentSemester = "Spring2018";
                //FreedomeF.ServiceReference1.Failcourse[] flist = ws.getFailcourse(r.studentID, ws.getCurrentSemester(r.studentID));
                List <Curricurlum> listFail = new List <Curricurlum>();
                string             fail     = fap.getFailCourse(stc.studentID);
                string             pass     = fap.getPassCourse(stc.studentID);
                List <Curricurlum> listPass = new List <Curricurlum>();
                listPass = JsonConvert.DeserializeObject <List <Curricurlum> >(pass);
                listFail = JsonConvert.DeserializeObject <List <Curricurlum> >(fail);


                List <Gpa> gpaList = new List <Gpa>();
                string     t2      = fap.getGPA(stc.studentID, currentSemester);
                gpaList = JsonConvert.DeserializeObject <List <Gpa> >(t2);
                int    totalCredit = 0;
                double avg         = 0;

                for (int j = 0; j < gpaList.Count; j++)
                {
                    double temp = 0;
                    if (gpaList[j].averageMark != null)
                    {
                        temp = gpaList[j].credits * (double)gpaList[j].averageMark;
                    }
                    if (temp > 0)
                    {
                        totalCredit += gpaList[j].credits;
                        avg         += temp;
                    }
                }

                double gpa        = Math.Round(((double)avg) / ((double)totalCredit), 2);
                int    failcourse = listFail.Count;

                double behavior = ws.getBehaviorMark(stc.studentID, currentSemester).behaviorMark;

                List <Curricurlum> attenList = new List <Curricurlum>();
                string             t         = fap.getAttendanceMark(stc.studentID, currentSemester);
                attenList = JsonConvert.DeserializeObject <List <Curricurlum> >(t);

                int totalAbsent = 0;
                for (int i = 0; i < attenList.Count; i++)
                {
                    totalAbsent += attenList[i].absentTotal;
                }


                double atten = Math.Round(((double)(attenList.Count * 30) - totalAbsent) / ((double)attenList.Count * 30), 2) * 10;
                var    ds    = dt.NewRow();
                ds["Mssv"]      = stc.studentID;
                ds["Tên"]       = stc.studentName;
                ds["GPA"]       = gpa;
                ds["Hành vi"]   = behavior;
                ds["Điểm danh"] = atten;
                ds["Môn nợ"]    = failcourse;

                Rank rk = new Rank();


                rk             = rdl.loadRank(stc.studentID, currentSemester);
                ds["Xếp loại"] = rk.rank;
                //}
                dt.Rows.Add(ds);



                // compare previous semerter
                List <Gpa> gpaList2 = new List <Gpa>();
                string     getGpa2  = fap.getGPA(stc.studentID, previousTerm(currentSemester));
                gpaList2 = JsonConvert.DeserializeObject <List <Gpa> >(getGpa2);
                int    totalCredit2 = 0;
                double avg2         = 0;

                for (int k = 0; k < gpaList2.Count; k++)
                {
                    double temp2 = 0;
                    if (gpaList2[k].averageMark != null)
                    {
                        temp2 = gpaList2[k].credits * (double)gpaList2[k].averageMark;
                    }
                    if (temp2 > 0)
                    {
                        totalCredit2 += gpaList2[k].credits;
                        avg2         += temp2;
                    }
                }

                double gpa2      = ((double)avg2) / ((double)totalCredit2);
                double behavior2 = ws.getBehaviorMark(stc.studentID.ToString(), previousTerm(currentSemester)).behaviorMark;

                List <Curricurlum> attenList2 = new List <Curricurlum>();
                string             attent2    = fap.getAttendanceMark(stc.studentID, previousTerm(currentSemester));
                attenList2 = JsonConvert.DeserializeObject <List <Curricurlum> >(attent2);

                int totalAbsent2 = 0;
                for (int f = 0; f < attenList2.Count; f++)
                {
                    totalAbsent2 += attenList2[f].absentTotal;
                }

                double atten2 = (((double)(attenList2.Count * 30) - totalAbsent2) / ((double)attenList2.Count * 30)) * 10;
                xx             = new Compare();
                xx.gpa         = gpa;
                xx.gpa2        = gpa2;
                xx.behavior    = behavior;
                xx.behavior2   = behavior2;
                xx.atten       = atten;
                xx.atten2      = atten2;
                xx.failcourse  = failcourse;
                xx.failcourse2 = failcourse;
                this.compareForHead.Add(xx);
            }
            return(dt);
        }
示例#2
0
        public Entity.Rank changeRankByCoefficient()
        {
            ServiceReference1.WebService1SoapClient ws = new ServiceReference1.WebService1SoapClient();
            //FreedomeF.ServiceReference1.ListStudentID[] list = ws.getStudentID();
            ServiceReference2.SAPISoapClient fap = new ServiceReference2.SAPISoapClient();

            Entity.Rank   r   = null;
            SqlConnection con = DbConnect.GetConnection();

            con.Open();
            string        sql = "SELECT studentID FROM Student WHERE takecareStatus=0";
            SqlCommand    cmd = new SqlCommand(sql, con);
            RankDAL       rdl = new RankDAL();
            SqlDataReader dr  = cmd.ExecuteReader();

            while (dr.Read())
            {
                r           = new Entity.Rank();
                r.studentID = dr["studentID"].ToString();
                string currentSemester = "Spring2018";

                List <Curricurlum> listFail = new List <Curricurlum>();
                string             fail     = fap.getFailCourse(r.studentID);
                string             pass     = fap.getPassCourse(r.studentID);
                List <Curricurlum> listPass = new List <Curricurlum>();
                if (!pass.Equals("Data not found"))
                {
                    listPass = JsonConvert.DeserializeObject <List <Curricurlum> >(pass);
                }
                if (!fail.Equals("Data not found"))
                {
                    listFail = JsonConvert.DeserializeObject <List <Curricurlum> >(fail);
                }
                List <Gpa> gpaList = new List <Gpa>();
                string     t2      = fap.getGPA(r.studentID, currentSemester);

                if (!t2.Equals("Data not found"))
                {
                    gpaList = JsonConvert.DeserializeObject <List <Gpa> >(t2);
                }

                int    totalCredit = 0;
                double avg         = 0;

                for (int j = 0; j < gpaList.Count; j++)
                {
                    double temp = 0;
                    if (gpaList[j].averageMark != null)
                    {
                        temp = gpaList[j].credits * (double)gpaList[j].averageMark;
                    }
                    if (temp > 0)
                    {
                        totalCredit += gpaList[j].credits;
                        avg         += temp;
                    }
                }

                double gpa        = ((double)avg) / ((double)totalCredit);
                double failcourse = ((1 - ((double)listFail.Count) / ((double)listPass.Count + (double)listFail.Count))) * 10;

                double behavior = ws.getBehaviorMark(r.studentID, currentSemester).behaviorMark;

                List <Curricurlum> attenList = new List <Curricurlum>();

                string t = fap.getAttendanceMark(r.studentID, currentSemester);
                if (!t.Equals("Data not found"))
                {
                    attenList = JsonConvert.DeserializeObject <List <Curricurlum> >(t);
                }


                int totalAbsent = 0;
                for (int i = 0; i < attenList.Count; i++)
                {
                    totalAbsent += attenList[i].absentTotal;
                }


                double      atten = Math.Round(((double)(attenList.Count * 30) - totalAbsent) / ((double)attenList.Count * 30), 2) * 10;
                Entity.Rate rt    = new Entity.Rate();
                rt               = getRate();
                r.rank           = Caculate(gpa, behavior, failcourse, atten, rt.markRate, rt.behRate, rt.failCout, rt.attentRate);
                r                = new Entity.Rank();
                r.studymark      = gpa;
                r.failcourseNumb = failcourse;
                r.behaviorMark   = behavior;
                r.attendance     = atten;
                r.rank           = Caculate(gpa, behavior, failcourse, atten, rt.markRate, rt.behRate, rt.failCout, rt.attentRate);
                isUpdateRank2(r.studentID.ToString(), r.rank, currentSemester);
            }
            return(r);
        }