Beispiel #1
0
    public List <CourseLeader> GetList(InitializeModule.EnumCampus Campus, string sCondition, bool isDeafaultIncluded)
    {
        Connection_StringCLS MyConnection_string = new Connection_StringCLS(Campus);
        string        sSQL = GetListSQL(sCondition);
        SqlConnection Conn = new SqlConnection(MyConnection_string.Conn_string.ToString());
        SqlCommand    Cmd  = new SqlCommand(sSQL, Conn);

        Conn.Open();
        SqlDataReader       reader  = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
        List <CourseLeader> results = new List <CourseLeader>();

        try
        {
//Default Value
            CourseLeader myCourseLeader = new CourseLeader();
            if (isDeafaultIncluded)
            {
//Change the code here
                myCourseLeader.AcademicYear = -1;
                myCourseLeader.SemesterID   = -1;
                myCourseLeader.CourseID     = "Select Course";

                results.Add(myCourseLeader);
            }
            while (reader.Read())
            {
                myCourseLeader = new CourseLeader();
                if (reader[LibraryMOD.GetFieldName(AcademicYearFN)].Equals(DBNull.Value))
                {
                    myCourseLeader.AcademicYear = 0;
                }
                else
                {
                    myCourseLeader.AcademicYear = int.Parse(reader[LibraryMOD.GetFieldName(AcademicYearFN)].ToString());
                }
                if (reader[LibraryMOD.GetFieldName(SemesterIDFN)].Equals(DBNull.Value))
                {
                    myCourseLeader.SemesterID = 0;
                }
                else
                {
                    myCourseLeader.SemesterID = int.Parse(reader[LibraryMOD.GetFieldName(SemesterIDFN)].ToString());
                }
                myCourseLeader.CourseID = reader[LibraryMOD.GetFieldName(CourseIDFN)].ToString();
                results.Add(myCourseLeader);
            }
        }
        catch (Exception ex)
        {
            LibraryMOD.ShowErrorMessage(ex);
        }
        finally
        {
            reader.Close();
            reader.Dispose();
            Conn.Close();
            Conn.Dispose();
        }
        return(results);
    }
Beispiel #2
0
    public int UpdateCourseLeader(InitializeModule.EnumCampus Campus, int iMode, int AcademicYear, int SemesterID, string CourseID, int CourseLeaderID, int CreationUserID, DateTime CreationDate, int LastUpdateUserID, DateTime LastUpdateDate, string PCName, string NetUserName, string TemplateCourse, int MoodleCourseNo)
    {
        int iEffected = 0;
        Connection_StringCLS MyConnection_string = new Connection_StringCLS(Campus);
        SqlConnection        Conn = new SqlConnection(MyConnection_string.Conn_string.ToString());

        try
        {
            Conn.Open();
            string       sql             = "";
            CourseLeader theCourseLeader = new CourseLeader();
//'Updates the  table
            switch (iMode)
            {
            case  (int)ECTGlobalDll.InitializeModule.enumModes.EditMode:
                sql = GetUpdateCommand();
                break;

            case (int)ECTGlobalDll.InitializeModule.enumModes.NewMode:
                sql = GetInsertCommand();
                break;
            }
            SqlCommand Cmd = new SqlCommand(sql, Conn);
            Cmd.Parameters.Add(new SqlParameter("@AcademicYear", AcademicYear));
            Cmd.Parameters.Add(new SqlParameter("@SemesterID", SemesterID));
            Cmd.Parameters.Add(new SqlParameter("@CourseID", CourseID));
            Cmd.Parameters.Add(new SqlParameter("@CourseLeaderID", CourseLeaderID));
            Cmd.Parameters.Add(new SqlParameter("@CreationUserID", CreationUserID));
            Cmd.Parameters.Add(new SqlParameter("@CreationDate", CreationDate));
            Cmd.Parameters.Add(new SqlParameter("@LastUpdateUserID", LastUpdateUserID));
            Cmd.Parameters.Add(new SqlParameter("@LastUpdateDate", LastUpdateDate));
            Cmd.Parameters.Add(new SqlParameter("@PCName", PCName));
            Cmd.Parameters.Add(new SqlParameter("@NetUserName", NetUserName));
            Cmd.Parameters.Add(new SqlParameter("@TemplateCourse", TemplateCourse));
            Cmd.Parameters.Add(new SqlParameter("@MoodleCourseNo", MoodleCourseNo));
            iEffected = Cmd.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            LibraryMOD.ShowErrorMessage(ex);
        }
        finally
        {
            Conn.Close();
            Conn.Dispose();
        }
        return(iEffected);
    }
Beispiel #3
0
    public List <CourseLeader> GetCourseLeader(InitializeModule.EnumCampus Campus, string sCondition, bool isDeafaultIncluded)
    {
//' returns a list of Classes instances based on the
//' data in the CourseLeader
        Connection_StringCLS MyConnection_string = new Connection_StringCLS(Campus);
        string sSQL = GetSQL();

        if (!string.IsNullOrEmpty(sCondition))
        {
            sSQL += sCondition;
        }
        SqlConnection Conn = new SqlConnection(MyConnection_string.Conn_string.ToString());
        SqlCommand    Cmd  = new SqlCommand(sSQL, Conn);

        Conn.Open();
        SqlDataReader       reader  = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
        List <CourseLeader> results = new List <CourseLeader>();

        try
        {
//Default Value
            CourseLeader myCourseLeader = new CourseLeader();
            if (isDeafaultIncluded)
            {
//Change the code here
                myCourseLeader.AcademicYear = 0;
                myCourseLeader.SemesterID   = 0;
                myCourseLeader.CourseID     = "";
                myCourseLeader.CourseID     = "Select CourseLeader ...";
                results.Add(myCourseLeader);
            }
            while (reader.Read())
            {
                myCourseLeader = new CourseLeader();
                if (reader[LibraryMOD.GetFieldName(AcademicYearFN)].Equals(DBNull.Value))
                {
                    myCourseLeader.AcademicYear = 0;
                }
                else
                {
                    myCourseLeader.AcademicYear = int.Parse(reader[LibraryMOD.GetFieldName(AcademicYearFN)].ToString());
                }
                if (reader[LibraryMOD.GetFieldName(SemesterIDFN)].Equals(DBNull.Value))
                {
                    myCourseLeader.SemesterID = 0;
                }
                else
                {
                    myCourseLeader.SemesterID = int.Parse(reader[LibraryMOD.GetFieldName(SemesterIDFN)].ToString());
                }
                myCourseLeader.CourseID = reader[LibraryMOD.GetFieldName(CourseIDFN)].ToString();
                if (reader[LibraryMOD.GetFieldName(CourseLeaderIDFN)].Equals(DBNull.Value))
                {
                    myCourseLeader.CourseLeaderID = 0;
                }
                else
                {
                    myCourseLeader.CourseLeaderID = int.Parse(reader[LibraryMOD.GetFieldName(CourseLeaderIDFN)].ToString());
                }
                if (reader[LibraryMOD.GetFieldName(CreationUserIDFN)].Equals(DBNull.Value))
                {
                    myCourseLeader.CreationUserID = 0;
                }
                else
                {
                    myCourseLeader.CreationUserID = int.Parse(reader[LibraryMOD.GetFieldName(CreationUserIDFN)].ToString());
                }
                if (!reader[LibraryMOD.GetFieldName(CreationDateFN)].Equals(DBNull.Value))
                {
                    myCourseLeader.CreationDate = DateTime.Parse(reader[LibraryMOD.GetFieldName(CreationDateFN)].ToString());
                }
                if (reader[LibraryMOD.GetFieldName(LastUpdateUserIDFN)].Equals(DBNull.Value))
                {
                    myCourseLeader.LastUpdateUserID = 0;
                }
                else
                {
                    myCourseLeader.LastUpdateUserID = int.Parse(reader[LibraryMOD.GetFieldName(LastUpdateUserIDFN)].ToString());
                }
                if (!reader[LibraryMOD.GetFieldName(LastUpdateDateFN)].Equals(DBNull.Value))
                {
                    myCourseLeader.LastUpdateDate = DateTime.Parse(reader[LibraryMOD.GetFieldName(LastUpdateDateFN)].ToString());
                }
                myCourseLeader.PCName         = reader[LibraryMOD.GetFieldName(PCNameFN)].ToString();
                myCourseLeader.NetUserName    = reader[LibraryMOD.GetFieldName(NetUserNameFN)].ToString();
                myCourseLeader.TemplateCourse = reader[LibraryMOD.GetFieldName(TemplateCourseFN)].ToString();
                if (reader[LibraryMOD.GetFieldName(MoodleCourseNoFN)].Equals(DBNull.Value))
                {
                    myCourseLeader.MoodleCourseNo = 0;
                }
                else
                {
                    myCourseLeader.MoodleCourseNo = int.Parse(reader[LibraryMOD.GetFieldName(MoodleCourseNoFN)].ToString());
                }
                results.Add(myCourseLeader);
            }
        }
        catch (Exception ex)
        {
            LibraryMOD.ShowErrorMessage(ex);
        }
        finally
        {
            reader.Close();
            reader.Dispose();
            Conn.Close();
            Conn.Dispose();
        }
        return(results);
    }