126 lines
5.1 KiB
C#
126 lines
5.1 KiB
C#
|
|
using Ease.Core.DataAccess;
|
|||
|
|
using HRM.BO;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using static iTextSharp.text.pdf.codec.TiffWriter;
|
|||
|
|
|
|||
|
|
namespace HRM.DA
|
|||
|
|
{
|
|||
|
|
internal class CoursesDA
|
|||
|
|
{
|
|||
|
|
#region Constructor
|
|||
|
|
private CoursesDA()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
//DataReader.GetNullValue()
|
|||
|
|
#region Insert function
|
|||
|
|
internal static void Insert(TransactionContext tc, Courses item)
|
|||
|
|
{
|
|||
|
|
tc.ExecuteNonQuery(
|
|||
|
|
"INSERT INTO LMS_Courses(CourseID, CourseTitle, CourseCode, CourseTypeID, Description, DifficultyLevel, TrainerID, Duration, Status, IsForFree, Price, " +
|
|||
|
|
"TotalEnrollMents, Rating, PopularityScore, CompletionRate, AverageProgress, IsExamRequired, Tags, TargetedAudience, LearningOutcomes, CourseIncludes, " +
|
|||
|
|
"StartGuideLine, CreatedBy, CreationDate)" +
|
|||
|
|
" VALUES(%n,%s,%s,%n,%s,%n,%n,%s,%n,%b,%n,%n,%n,%n,%n,%n,%b,%s,%s,%s,%s,%s,%n,%D)", item.ID, item.CourseTitle, item.CourseCode, item.CourseTypeID,
|
|||
|
|
item.Description, item.DifficultyLevel, item.TrainerID, item.Duration, item.Status, item.IsForFree, item.Price,item.TotalEnrollments, item.Rating,
|
|||
|
|
item.PopularityScore, item.CompletionRate, item.AverageProgress, item.IsExamRequired, item.Tags, item.TargetedAudience, item.LearningOutcomes,
|
|||
|
|
item.CourseIncludes, item.StartGuideLine, item.CreatedBy, item.CreatedDate);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Update function
|
|||
|
|
internal static void Update(TransactionContext tc, Courses item)
|
|||
|
|
{
|
|||
|
|
tc.ExecuteNonQuery(
|
|||
|
|
"UPDATE LMS_Courses set CourseTitle=%s,CourseCode=%s,CourseTypeID=%n,Description=%s,DifficultyLevel=%n,TrainerID=%n,Duration=%s," +
|
|||
|
|
"IsForFree=%b,Price=%n,TotalEnrollMents=%n,Rating=%n,PopularityScore=%n,CompletionRate=%n,AverageProgress=%n,IsExamRequired=%b," +
|
|||
|
|
"Tags=%s,TargetedAudience=%s,LearningOutcomes=%s,CourseIncludes=%s,StartGuideLine=%s,ModifiedBy=%n,ModifiedDate=%D " +
|
|||
|
|
" WHERE CourseID=%n", item.CourseTitle, item.CourseCode, item.CourseTypeID, item.Description, item.DifficultyLevel, item.TrainerID,
|
|||
|
|
item.Duration,item.IsForFree,item.Price,item.TotalEnrollments,item.Rating,item.PopularityScore,item.CompletionRate,item.AverageProgress,
|
|||
|
|
item.IsExamRequired,item.Tags,item.TargetedAudience,item.LearningOutcomes,item.CourseIncludes,item.StartGuideLine,item.ModifiedBy, item.ModifiedDate, item.ID);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Update Course Status
|
|||
|
|
internal static void UpdateStatus(TransactionContext tc, Courses item)
|
|||
|
|
{
|
|||
|
|
tc.ExecuteNonQuery(
|
|||
|
|
"UPDATE LMS_Courses set Status = %n,ModifiedBy=%n,ModifiedDate=%D " +
|
|||
|
|
" WHERE CourseID=%n", item.Status, item.ModifiedBy, item.ModifiedDate, item.ID);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Update Course Total Enrollments
|
|||
|
|
internal static void UpdateTotalEnrollments(TransactionContext tc, int courseID)
|
|||
|
|
{
|
|||
|
|
tc.ExecuteNonQuery(
|
|||
|
|
"UPDATE LMS_Courses set TotalEnrollMents = (TotalEnrollMents+1) WHERE CourseID=%n", courseID);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Delete function
|
|||
|
|
internal static void Delete(TransactionContext tc, int nID)
|
|||
|
|
{
|
|||
|
|
tc.ExecuteNonQuery("DELETE FROM LMS_LessonContent where LessonID in (select LessonID from LMS_Lessons where CourseID = %n)", nID);
|
|||
|
|
tc.ExecuteNonQuery("DELETE FROM LMS_Lessons where CourseID = %n", nID);
|
|||
|
|
tc.ExecuteNonQuery("DELETE FROM LMSTemplate where ObjectID = %n", nID);
|
|||
|
|
tc.ExecuteNonQuery("DELETE FROM LMS_Courses Where CourseID = %n", nID);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Get Function
|
|||
|
|
internal static IDataReader Get(TransactionContext tc, int nID)
|
|||
|
|
{
|
|||
|
|
return tc.ExecuteReader("SELECT * FROM LMS_Courses Where CourseID=%n", nID);
|
|||
|
|
}
|
|||
|
|
internal static IDataReader Get(TransactionContext tc, EnumStatus status)
|
|||
|
|
{
|
|||
|
|
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
|
|||
|
|
{
|
|||
|
|
return tc.ExecuteReader("SELECT * FROM LMS_Courses where Status=%n", status);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return tc.ExecuteReader("SELECT * FROM LMS_Courses order by CourseTitle");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
internal static int GetTotalLesson(TransactionContext tc, int courseID)
|
|||
|
|
{
|
|||
|
|
object total = tc.ExecuteScalar("SELECT count(*) FROM LMS_Lessons where CourseID = %n", courseID);
|
|||
|
|
if (total == null || total == DBNull.Value)
|
|||
|
|
{
|
|||
|
|
total = 0;
|
|||
|
|
}
|
|||
|
|
return Convert.ToInt32(total);
|
|||
|
|
}
|
|||
|
|
internal static int GetTotalContent(TransactionContext tc, int courseID)
|
|||
|
|
{
|
|||
|
|
object total = tc.ExecuteScalar("select COUNT(lmc.LessonContentID) from LMS_LessonContent lmc, LMS_Lessons l, LMS_Courses c " +
|
|||
|
|
"where lmc.LessonID = l.LessonID and l.CourseID = c.CourseID and c.CourseID = %n", courseID);
|
|||
|
|
if (total == null || total == DBNull.Value)
|
|||
|
|
{
|
|||
|
|
total = 0;
|
|||
|
|
}
|
|||
|
|
return Convert.ToInt32(total);
|
|||
|
|
}
|
|||
|
|
internal static IDataReader GetAll(TransactionContext tc)
|
|||
|
|
{
|
|||
|
|
return tc.ExecuteReader("SELECT * FROM LMS_Courses order by CourseTitle");
|
|||
|
|
}
|
|||
|
|
internal static IDataReader GetByRating(TransactionContext tc, float rating)
|
|||
|
|
{
|
|||
|
|
return tc.ExecuteReader("SELECT * FROM LMS_Courses where Rating between %n and %n order by CourseTitle", rating, rating);
|
|||
|
|
}
|
|||
|
|
internal static IDataReader GetByDifficultyLevel(TransactionContext tc, EnumDifficultyLevel level)
|
|||
|
|
{
|
|||
|
|
return tc.ExecuteReader("SELECT * FROM LMS_Courses where DifficultyLevel = %n order by CourseTitle", level);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|