Ejemplo n.º 1
0
    public List <MirrorCLS> GetGeneralMirror(string sCollege, string sDegree, string sMajor, int Reason, int Period, string sNo, InitializeModule.EnumCampus Campus)
    {
        List <MirrorCLS>     Result              = new List <MirrorCLS>();
        List <Plans>         Plan                = new List <Plans>();
        PlansDAL             myPlansDAL          = new PlansDAL();
        Connection_StringCLS myConnection_String = new Connection_StringCLS(Campus);
        SqlConnection        Conn                = new SqlConnection(myConnection_String.Conn_string);

        Conn.Open();
        try
        {
            string sSQL = "select * from GetGrades('" + sCollege + "','" + sDegree + "','" + sMajor + "'," + Reason + "," + Period + ",'" + sNo + "')";
            sSQL += " union all";
            sSQL += " select * from GetRegistered('" + sCollege + "','" + sDegree + "','" + sMajor + "'," + Reason + "," + Period + ",'" + sNo + "')";
            sSQL += " union all";
            sSQL += " select * from GetEllective('" + sCollege + "','" + sDegree + "','" + sMajor + "'," + Reason + "," + Period + ",'" + sNo + "')";
            sSQL += " order by lngSerial,byteOrder";

            Plan = myPlansDAL.GetPlans(sCollege, sDegree, sMajor, false, Campus);
            int           iPlan    = Plan[0].Courses.Count;
            SqlCommand    Cmd      = new SqlCommand(sSQL, Conn);
            SqlDataReader Rd       = Cmd.ExecuteReader();
            string        sSno     = "";
            MirrorCLS     myMirror = new MirrorCLS();;
            myMirror.StudentNumber = "Begin";
            myMirror.Serial        = 0;
            int iSerial = 0;
            int iIndex  = 0;

            while (Rd.Read())
            {
                if (sSno != Rd["sStudentNumber"].ToString())
                {
                    Result.Add(myMirror);
                    iSerial += 1;
                    myMirror = new MirrorCLS();
                    myMirror.StudentNumber = Rd["sStudentNumber"].ToString();
                    sSno            = myMirror.StudentNumber;
                    myMirror.Serial = iSerial;
                    myMirror.Mirror = new StudentCourses.StudentMirror[iPlan];
                    myMirror.Hours  = Plan[0].StudyHours;
                    myMirror.Passed = 0;
                    for (int i = 0; i < iPlan; i++)
                    {
                        myMirror.Mirror[i].sCourse = Plan[0].Courses[i].sCourse;
                        myMirror.Mirror[i].iCredit = Plan[0].Courses[i].iCredit;
                        myMirror.Mirror[i].iOrder  = Plan[0].Courses[i].iOrder;
                        myMirror.Mirror[i].iClass  = Plan[0].Courses[i].iClass;
                    }
                }
                iIndex = int.Parse(Rd["byteOrder"].ToString()) - 1;
                //myMirror.Mirror[iIndex].sCourse = Rd["sCourse"].ToString();


                myMirror.Mirror[iIndex].sGrade = Rd["sGrade"].ToString();


                if (Rd["bPassIt"].Equals(DBNull.Value))
                {
                    myMirror.Mirror[iIndex].isPassed = false;
                }
                else
                {
                    myMirror.Mirror[iIndex].isPassed = bool.Parse(Rd["bPassIt"].ToString());
                }

                //if (myMirror.IsAccWanted && myMirror.Mirror[iIndex].isPassed)
                //{
                //    myMirror.Mirror[iIndex].sGrade = "*";
                //}
            }
            //Add the last
            Result.Add(myMirror);
            Rd.Close();
        }
        catch (Exception ex)
        {
            Console.WriteLine("{0} Exception caught.", ex.Message);
        }
        finally
        {
            Plan.Clear();
            Conn.Close();
            Conn.Dispose();
        }
        return(Result);
    }
Ejemplo n.º 2
0
    public List <MirrorCLS> GetMirrorForAdvising(string sCollege, string sDegree, string sMajor, int Period, string sNo, int iAdvisor, out Plans Plan, InitializeModule.EnumCampus Campus, bool isRegisteredPassed)
    {
        List <MirrorCLS> Result = new List <MirrorCLS>();

        Plan = new Plans();
        List <Plans> myPlans    = new List <Plans>();
        PlansDAL     myPlansDAL = new PlansDAL();

        Connection_StringCLS myConnection_String = new Connection_StringCLS(Campus);
        SqlConnection        Conn = new SqlConnection(myConnection_String.Conn_string);

        Conn.Open();
        try
        {
            myPlans = myPlansDAL.GetPlans(sCollege, sDegree, sMajor, true, Campus);
            int iPlan = myPlans[0].Courses.Count;
            Plan = myPlans[0];

            Result = GetStudentData(sCollege, sDegree, sMajor, 0, Period, sNo, 0, 0, Plan, 0, Conn, Campus);
            if (Result.Count > 0)
            {
                //string sSQL = "select * from GetGrades('" + sCollege + "','" + sDegree + "','" + sMajor + "'," + Reason + "," + Period + ",'" + sNo + "')";
                //sSQL += " union all";
                //sSQL += " select * from GetRegistered('" + sCollege + "','" + sDegree + "','" + sMajor + "'," + Reason + "," + Period + ",'" + sNo + "')";
                //sSQL += " union all";
                //sSQL += " select * from GetEllective('" + sCollege + "','" + sDegree + "','" + sMajor + "'," + Reason + "," + Period + ",'" + sNo + "')";
                //sSQL += " order by lngSerial,byteOrder";

                string sSQL = GetMirrorSQL(MirrorsType.ProgramMirror, sCollege, sDegree, sMajor, 0, Period, sNo, iAdvisor, 0, 0, isRegisteredPassed);

                SqlCommand    Cmd = new SqlCommand(sSQL, Conn);
                SqlDataReader Rd  = Cmd.ExecuteReader();

                int    iIndex         = 0;
                int    iCrsIndex      = 0;
                string sSno           = "";
                int    iCourseregTerm = 0;
                int    iRegTerm       = LibraryMOD.GetRegTerm();

                while (Rd.Read())
                {
                    if (sSno != Rd["sStudentNumber"].ToString())
                    {
                        sSno   = Rd["sStudentNumber"].ToString();
                        iIndex = Result.FindIndex(delegate(MirrorCLS M) { return(M.StudentNumber == sSno); });
                        if (iIndex >= 0)
                        {
                            //Result[iIndex].Mirror = new StudentCourses.StudentMirror[iPlan];
                            Result[iIndex].Passed = 0;
                            Result[iIndex].Hours  = Plan.StudyHours;
                            for (int i = 0; i < iPlan; i++)
                            {
                                Result[iIndex].Mirror[i].iClass = Plan.Courses[i].iClass;
                                //Result[iIndex].Mirror[i].iCredit = Plan.Courses[i].iCredit;
                                //Result[iIndex].Mirror[i].sGrade = ".";
                                //Result[iIndex].Mirror[i].isPassed = false;
                            }
                        }
                    }
                    if (iIndex >= 0)
                    {
                        iCrsIndex = int.Parse(Rd["byteOrder"].ToString()) - 1;
                        //Result[iIndex].Mirror[iCrsIndex].sCourse = Rd["sCourse"].ToString

                        Result[iIndex].Mirror[iCrsIndex].sGrade = Rd["sGrade"].ToString();
                        Result[iIndex].Mirror[iCrsIndex].iOrder = Convert.ToInt32(Rd["byteOrder"].ToString());

                        iCourseregTerm = int.Parse(Rd["RegTerm"].ToString());

                        if (Rd["bPassIt"].Equals(DBNull.Value))
                        {
                            Result[iIndex].Mirror[iCrsIndex].isPassed = false;
                        }
                        else
                        {
                            if (iCourseregTerm > 0)
                            {
                                if (iCourseregTerm < iRegTerm && isRegisteredPassed == true)
                                {
                                    Result[iIndex].Mirror[iCrsIndex].isPassed = true;
                                }
                                else
                                {
                                    Result[iIndex].Mirror[iCrsIndex].isPassed = false;
                                }
                            }
                            else
                            {
                                Result[iIndex].Mirror[iCrsIndex].isPassed = bool.Parse(Rd["bPassIt"].ToString());
                            }
                        }

                        //if (Result[iIndex].IsAccWanted && Result[iIndex].Mirror[iCrsIndex].isPassed)
                        //{
                        //    Result[iIndex].Mirror[iCrsIndex].sGrade = "*";
                        //}
                    }
                }
                Rd.Close();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("{0} Exception caught.", ex.Message);
        }
        finally
        {
            Conn.Close();
            Conn.Dispose();
        }
        return(Result);
    }
Ejemplo n.º 3
0
    public List <Advised.Courses> Advise(int Year, int Semester, int iShift, string sNo, string sCollege, string sDegree, string sMajor, bool isRegisteredPassed, decimal CGPA, int iSemMax, StudentCourses.StudentMirror[] myMirror, InitializeModule.EnumCampus Campus, string sCSemester1)
    {
        List <Advised.Courses> myAdvise = new List <Advised.Courses>();

        List <Plans> myPlans    = new List <Plans>();
        PlansDAL     myPlansDAL = new PlansDAL();
        Plans        myPlan     = new Plans();

        try
        {
            myPlans = myPlansDAL.GetPlans(sCollege, sDegree, sMajor, true, Campus);
            myPlan  = myPlans[0];

            int             iPreFounded   = 0;
            int             iPre          = 0;
            int             iPreIndex     = 0;
            int             iHours        = 0;
            int             iCredit       = 0;
            bool            isPassed      = false;
            bool            isRecommended = false;
            bool            isRegistered  = false;
            bool            isLow         = false;
            Advised.Courses Rec;
            int             iOrder  = 0;
            bool            isEmpty = false;
            bool            isOver  = false;

            for (int i = 0; i < myPlan.Courses.Count; i++)
            {
                isRecommended = false;
                isRegistered  = false;
                isPassed      = false;
                isLow         = false;
                isEmpty       = false;

                string sCSemester = sCSemester1;

                switch (Semester)
                {
                case 1:
                    sCSemester = "@S2";
                    break;

                case 2:
                    sCSemester = "@F";
                    break;

                case 3:
                    sCSemester = "@W";
                    break;

                case 4:
                    sCSemester = "@S1";
                    break;
                }
                //is Registered Courses Considered as Passed Courses
                isRegistered = (myMirror[i].sGrade.Contains(sCSemester) == true);

                if (isRegisteredPassed)
                {
                    isPassed = (myMirror[i].isPassed || isRegistered);
                }
                else
                {
                    isPassed = (myMirror[i].isPassed);
                }
                myMirror[i].isPassed = isPassed;

                //Must Repeate 6 Credit of F & D at least
                isLow         = ((myMirror[i].sGrade == "D" || myMirror[i].sGrade == "F") && CGPA < 2);
                isRecommended = ((!isPassed) || (isLow));
                isEmpty       = (myMirror[i].sGrade == ".");

                iCredit = myMirror[i].iCredit;
                isOver  = (iHours + iCredit > iSemMax);
                if (isRecommended && (iHours + iCredit <= (iSemMax + 9)))//changed to 1 for summer//add 3 course as alternative
                {
                    //Not Registered

                    iPreFounded = 0;
                    iPre        = myPlan.Courses[i].iPre.Count;

                    for (int j = 0; j < iPre; j++)
                    {
                        iPreIndex = myPlan.Courses[i].iPre[j] - 1;
                        if (myMirror[iPreIndex].isPassed == true)
                        {
                            iPreFounded++;
                        }
                    }

                    if (iPreFounded == iPre)
                    {
                        iOrder++;
                        myMirror[i].isRecommended = true;
                        iHours     += iCredit;
                        Rec         = new Advised.Courses();
                        Rec.iOrder  = iOrder;
                        Rec.isOver  = isOver;
                        Rec.isLow   = isLow;
                        Rec.sCourse = myMirror[i].sCourse;

                        Rec.sDesc  = myPlan.Courses[i].sDesc;
                        Rec.iShift = iShift;
                        myAdvise.Add(Rec);
                        //removed by bahaa 29-01-2020 dont force to recommend the corequisiste courses

                        //if (myPlan.Courses[i].sParallel != "-")
                        //{
                        //    iOrder++;
                        //    Rec = new Advised.Courses();
                        //    Rec.iOrder = iOrder;
                        //    Rec.sCourse = myPlan.Courses[i].sParallel;
                        //    Rec.sDesc = myPlan.Courses[i + 1].sDesc;
                        //    Rec.iShift = iShift;
                        //    Rec.isOver = isOver;
                        //    Rec.isLow = isLow;
                        //    myAdvise.Add(Rec);
                        //    i = 4;
                        //}
                    }
                }
            }
        }
        catch (Exception ex)
        {
            LibraryMOD.ShowErrorMessage(ex);
        }
        finally
        {
            myPlans.Clear();
        }
        return(myAdvise);
    }