Exemple #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);
        }
Exemple #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);
        }
Exemple #3
0
        public void calRank(string studentID, Entity.Rate rt)
        {
            ServiceReference1.WebService1SoapClient ws  = new ServiceReference1.WebService1SoapClient();
            ServiceReference2.SAPISoapClient        fap = new ServiceReference2.SAPISoapClient();
            Entity.Rank r = new Entity.Rank();
            r.studentID = studentID;
            string             currentSemester = "Spring2018";
            string             fail            = fap.getFailCourse(r.studentID);
            string             pass            = fap.getPassCourse(r.studentID);
            List <Curricurlum> listPass        = new List <Curricurlum>();
            List <Curricurlum> listFail        = 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;

            if (listFail.Count != 0 && listPass.Count != 0)
            {
                failcourse = ((1 - ((double)listFail.Count) / ((double)listPass.Count + (double)listFail.Count))) * 10;
            }
            failcourse = 0;
            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;

            r.rank = Caculate(gpa, behavior, failcourse, atten, rt.markRate, rt.behRate, rt.failCout, rt.attentRate);
            if (checkExistRank(r.studentID, currentSemester))
            {
                isInsertRank(r.studentID, r.rank, currentSemester);
            }
            else
            {
                isUpdateRank2(r.studentID, r.rank, currentSemester);
            }
        }
        public void Page_Load(object sender, EventArgs e)
        {
            Label10.Text   = "";
            lbNoitice.Text = "";
            Label1.Text    = "";
            Label11.Text   = "";
            lbResult.Text  = "";

            upLabel.Text = "";

            try
            {
                if ((Session["account"]) == null || (Session["role"]) == null || (Session["accountID"]) == null)
                {
                    Response.Redirect("~/UI/Login.aspx");
                }
                string selected  = Request.QueryString["studentID"];
                string checkrole = (string)(Session["role"]);
                string account   = (string)(Session["account"]);
                int    staffID   = (int)(Session["accountID"]);

                lbUserName.Text = account;

                if (checkrole == "HeadStaff")
                {
                    divide.Visible         = true;
                    logCare.Visible        = true;
                    control.Visible        = true;
                    btnUpdateStaff.Visible = true;
                    lbGuide.Visible        = true;
                    drpStaff.Visible       = true;
                }
                else
                {
                    divide.Visible         = false;
                    logCare.Visible        = false;
                    control.Visible        = false;
                    btnUpdateStaff.Visible = false;
                    lbGuide.Visible        = false;
                    drpStaff.Visible       = false;
                }
                Business.ScsBO sbo = new Business.ScsBO();
                //int staffID = (int)(Session["accountID"]);

                //ServiceReference1.WebService1SoapClient ws = new ServiceReference1.WebService1SoapClient();
                //ServiceReference1.Student s = ws.getStudentInf(selected);
                ServiceReference2.SAPISoapClient fap = new ServiceReference2.SAPISoapClient();
                List <StudentProfile>            stp = new List <StudentProfile>();
                string inf = fap.GetStudentById(selected);
                stp = JsonConvert.DeserializeObject <List <StudentProfile> >(inf);
                decimal t = fap.CheckBlance(selected);


                stImage.ImageUrl   = "data:image/png;base64," + Convert.ToBase64String(fap.RetriveImage(selected));
                currrentTerm.Text  = stp[0].currentTermNo;
                finance.Text       = t.ToString("00.##" + "VND");
                dob.Text           = stp[0].dateOfBirth.ToString("dd/MM/yyyy");
                addr.Text          = stp[0].address;
                name.Text          = stp[0].fullName;
                rollnumb.Text      = stp[0].rollNumber;
                phonenumb.Text     = stp[0].phone;
                mail.Text          = stp[0].email;
                curr.Text          = stp[0].batch;
                member.Text        = stp[0].membercode;
                ktx.Text           = stp[0].termPaid;
                dateofissue.Text   = stp[0].dateOfIsue.ToString("dd/MM/yyyy");
                major.Text         = stp[0].major;
                mode.Text          = stp[0].chuuyenNganh;
                status.Text        = stp[0].statusCode;
                limit7year.Text    = stp[0].HanBayNam;
                dropout.Text       = stp[0].QD_ThoiHoc;
                changeCampus.Text  = stp[0].QD_BaoLuu_Exchange;
                changeMajor.Text   = stp[0].qd_chuyennganh;
                getDiscipline.Text = stp[0].qD_kyluat;
                gruadation.Text    = stp[0].qD_Tn;
                svcq.Text          = stp[0].QD_SV_ChinhQuy;
                rejoin.Text        = stp[0].qD_rejoin;
                contact.Text       = stp[0].parentPhone;
                parent.Text        = stp[0].parentName;

                if (!Page.IsPostBack)
                {
                    string  currentSemester = "Spring2018";
                    RankDAL rdal            = new RankDAL();
                    //Comment cm = sbo.getComment(selected);
                    StatusCheck stk = sbo.loadTickCheckProfile(selected);
                    Rank        r   = rdal.loadRank(selected, currentSemester);

                    Student st = sbo.loadTakecareStaff(selected);
                    if (!string.IsNullOrEmpty(st.StaffName))
                    {
                        drpStaff.SelectedValue = st.StaffName;
                    }
                    else
                    {
                        Label24.Text = "Chưa có người chăm sóc , vui lòng chọn NV";
                    }


                    //TextArea1.Value = cm.content+"  bởi  "+cm.staffName;
                    drpChangeRank.SelectedValue = r.rank;

                    cbAttent.Checked = stk.attention;
                }



                Series series = Chart1.Series["Series1"];


                List <GpaTerm> list = sbo.listGpa(selected);
                Chart1.ChartAreas[0].AxisY.Title = "Điểm trung bình (GPA)";

                for (int i = 0; i < list.Count; i++)
                {
                    series.Points.AddXY(list[i].semester.ToString(), Math.Round(list[i].gpa, 2));
                    series.ToolTip = " #VALX  #VALY";
                }

                List <BehaviorTerm> beList = sbo.beList(selected);
                Series series2             = Chart2.Series["Series2"];
                Chart2.ChartAreas[0].AxisY.Title = "Điểm hành vi (Behavior)";
                for (int b = 0; b < beList.Count; b++)
                {
                    series2.Points.AddXY(beList[b].semester.ToString(), Math.Round(beList[b].behavior, 2));
                    series2.ToolTip = " #VALX  #VALY";
                }


                List <Curricurlum> listFail   = new List <Curricurlum>();
                string             failcourse = fap.getFailCourse(selected);
                if (!failcourse.Equals("Data not found"))
                {
                    listFail = JsonConvert.DeserializeObject <List <Curricurlum> >(failcourse);
                }

                for (int f = 0; f < listFail.Count; f++)
                {
                    pnStudy.Controls.Add(new LiteralControl(listFail[f].subjectCode + "</br>"));
                }
                this.lbFailnumb.Text = listFail.Count.ToString();

                //**********************
                //string currentSemester = "Spring2018";
                ServiceReference1.WebService1SoapClient    ws    = new ServiceReference1.WebService1SoapClient();
                ServiceReference1.ArrayOfGetTeacherComment flist = ws.getCommentBehavior(selected);
                for (int be = 0; be < flist.Count; be++)
                {
                    Panel3.Controls.Add(new LiteralControl(flist[be].contentComment + "  " + flist[be].teacherID + "</br>"));
                }
                //*****************

                DataTable dt = sbo.curriculum(selected);

                //Building an HTML string.
                StringBuilder html = new StringBuilder();

                //Table start.
                html.Append("<table id='curi' class='table table-hover'>");
                html.Append("<thead>");
                //Building the Header row.
                html.Append("<tr class='info'>");
                foreach (DataColumn column in dt.Columns)
                {
                    html.Append("<th>");
                    html.Append(column.ColumnName);
                    html.Append("</th>");
                }
                html.Append("</tr>");
                html.Append("</thead>");
                html.Append("<tbody>");
                //Building the Data rows.
                foreach (DataRow row in dt.Rows)
                {
                    html.Append("<tr>");
                    foreach (DataColumn column in dt.Columns)
                    {
                        html.Append("<td>");
                        html.Append(row[column.ColumnName]);
                        html.Append("</td>");
                    }
                    html.Append("</tr>");
                }

                //Table end.
                html.Append("</table>");
                html.Append("</tbody>");
                //Append the HTML string to Placeholder.
                Panel1.Controls.Add(new Literal {
                    Text = html.ToString()
                });

                //***************************************

                DataTable dt2 = sbo.getTimetable(selected);

                //Building an HTML string.
                StringBuilder html2 = new StringBuilder();

                //Table start.
                html2.Append("<table id='time' class='table table-hover'>");
                html2.Append("<thead>");
                //Building the Header row.
                html2.Append("<tr class='info'>");
                foreach (DataColumn column2 in dt2.Columns)
                {
                    html2.Append("<th>");
                    html2.Append(column2.ColumnName);
                    html2.Append("</th>");
                }
                html2.Append("</tr>");
                html2.Append("</thead>");
                html2.Append("<tbody>");
                //Building the Data rows.
                foreach (DataRow row2 in dt2.Rows)
                {
                    html2.Append("<tr>");
                    foreach (DataColumn column2 in dt2.Columns)
                    {
                        html2.Append("<td>");
                        html2.Append(row2[column2.ColumnName]);
                        html2.Append("</td>");
                    }
                    html2.Append("</tr>");
                }

                //Table end.
                html2.Append("</table>");
                html2.Append("</tbody>");
                //Append the HTML string to Placeholder.
                scheduleStudy.Controls.Add(new Literal {
                    Text = html2.ToString()
                });

                //********************************************************

                DataTable dt3 = sbo.scheduleExam(selected);

                //Building an HTML string.
                StringBuilder html3 = new StringBuilder();

                //Table start.
                html3.Append("<table id='exam' class='table table-hover'>");
                html3.Append("<thead>");
                //Building the Header row.
                html3.Append("<tr class='info'>");
                foreach (DataColumn column3 in dt3.Columns)
                {
                    html3.Append("<th>");
                    html3.Append(column3.ColumnName);
                    html3.Append("</th>");
                }
                html3.Append("</tr>");
                html3.Append("</thead>");
                html3.Append("<tbody>");
                //Building the Data rows.
                foreach (DataRow row3 in dt3.Rows)
                {
                    html3.Append("<tr>");
                    foreach (DataColumn column3 in dt3.Columns)
                    {
                        html3.Append("<td>");
                        html3.Append(row3[column3.ColumnName]);
                        html3.Append("</td>");
                    }
                    html3.Append("</tr>");
                }

                //Table end.
                html3.Append("</table>");
                html3.Append("</tbody>");
                //Append the HTML string to Placeholder.
                scheduleExam.Controls.Add(new Literal {
                    Text = html3.ToString()
                });
                //grOtherComment.DataBind();
            }
            catch (Exception ee)
            {
                Response.Redirect("~/UI/Error.aspx");
            }
        }