コード例 #1
0
    private string GetMirrorSQL(MirrorsType itype, string sCollege, string sDegree, string sMajor, int Reason, int Period, string sNo, int iAdvisor, int CancelTerm, InitializeModule.EnumOptions iOption, bool isRegisteredPassed)
    {
        string sSQL = "";

        try
        {
            switch (itype)
            {
            case MirrorsType.ProgramMirror:
                sSQL = GetProgramMirrorSQL(sCollege, sDegree, sMajor, Reason, Period, sNo, iAdvisor, CancelTerm, iOption, isRegisteredPassed);
                break;

            case MirrorsType.ExpectedMirror:
                sSQL = GetExpectedMirrorSQL(sCollege, sDegree, sMajor, Reason, Period, sNo, CancelTerm, iOption);
                break;
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("{0} Exception caught.", ex.Message);
        }
        finally
        {
        }
        return(sSQL);
    }
コード例 #2
0
    public List <MirrorCLS> GetMirrorWithSD(string sCollege, string sDegree, string sMajor, int Reason, int Period, string sNo, int iAdvisor, int CancelTerm, InitializeModule.EnumOptions iOption, MirrorsType iType, InitializeModule.EnumCampus Campus, out int iHours, bool iRegisteredPassed)
    {
        List <MirrorCLS> Result     = new List <MirrorCLS>();
        List <Plans>     MyPlans    = new List <Plans>();
        Plans            myPlan     = new Plans();
        PlansDAL         myPlansDAL = new PlansDAL();

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

        Conn.Open();
        iHours = 0;
        try
        {
            MyPlans = myPlansDAL.GetPlans(sCollege, sDegree, sMajor, false, Campus);
            myPlan  = MyPlans[0];
            int iPlan = myPlan.Courses.Count;

            Result = GetStudentData(sCollege, sDegree, sMajor, Reason, Period, sNo, iAdvisor, CancelTerm, myPlan, iOption, Conn, Campus);
            iHours = myPlan.StudyHours;
            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(iType, sCollege, sDegree, sMajor, Reason, Period, sNo, iAdvisor, CancelTerm, iOption, iRegisteredPassed);

                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  = iHours;
                            for (int i = 0; i < iPlan; i++)
                            {
                                Result[iIndex].Mirror[i].iClass = myPlan.Courses[i].iClass;
                            }
                        }
                    }
                    if (iIndex >= 0)
                    {
                        iCrsIndex = int.Parse(Rd["byteOrder"].ToString()) - 1;

                        //Result[iIndex].Mirror[iCrsIndex].sCourse = Rd["sCourse"].ToString
                        //Student has Fainance Problem

                        Result[iIndex].Mirror[iCrsIndex].sGrade = Rd["sGrade"].ToString();
                        iCourseregTerm = int.Parse(Rd["RegTerm"].ToString());

                        if (Rd["bPassIt"].Equals(DBNull.Value))
                        {
                            Result[iIndex].Mirror[iCrsIndex].isPassed = false;
                        }
                        else
                        {
                            if (iCourseregTerm >= iRegTerm)
                            {
                                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
        {
            MyPlans.Clear();
            Conn.Close();
            Conn.Dispose();
        }
        return(Result);
    }