65 lines
2.1 KiB
C#
65 lines
2.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;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
public class EnrollmentDA
|
|
{
|
|
#region Constructor
|
|
private EnrollmentDA()
|
|
{
|
|
}
|
|
#endregion
|
|
|
|
#region Insert function
|
|
internal static void Insert(TransactionContext tc, Enrollments item)
|
|
{
|
|
tc.ExecuteNonQuery(
|
|
"INSERT INTO LMS_Enrollments(EnrollmentID,UserID,CourseID,EnrollDate,IsCurrentEnroll,NoOfEnroll)" +
|
|
" VALUES(%n,%n,%n,%D,%b,%n)", item.ID, item.UserID,item.CourseID,DateTime.Now,item.IsCurrentEnroll,item.NoOfEnroll);
|
|
}
|
|
#endregion
|
|
|
|
#region Update Lesson Status
|
|
internal static void UpdateEnrollStatus(TransactionContext tc, Enrollments item)
|
|
{
|
|
tc.ExecuteNonQuery(
|
|
"UPDATE LMS_Enrollments set IsCurrentEnroll = %b WHERE EnrollmentID=%n", item.IsCurrentEnroll, item.ID);
|
|
}
|
|
|
|
internal static void UpdateEnrollStatusForEnrollment(TransactionContext tc, Enrollments item)
|
|
{
|
|
tc.ExecuteNonQuery("UPDATE LMS_Enrollments set IsCurrentEnroll = %b WHERE UserID=%n and EnrollmentID != %n", false, item.UserID, item.ID);
|
|
tc.ExecuteNonQuery("UPDATE LMS_Enrollments set IsCurrentEnroll = %b, NoOfEnroll=%n WHERE EnrollmentID=%n", item.IsCurrentEnroll, item.NoOfEnroll, item.ID);
|
|
}
|
|
#endregion
|
|
|
|
#region Get Function
|
|
internal static IDataReader GetAll(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM LMS_Enrollments");
|
|
}
|
|
internal static IDataReader Get(TransactionContext tc, int ID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM LMS_Enrollments Where EnrollmentID=%n ", ID);
|
|
}
|
|
|
|
internal static IDataReader GetByDate(TransactionContext tc, DateTime fromDate, DateTime toDate)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM LMS_Enrollments Where enrollDate between %d and %d", fromDate, toDate);
|
|
}
|
|
|
|
internal static IDataReader GetForEnrollment(TransactionContext tc, int courseID, int UserID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM LMS_Enrollments Where CourseID=%n and UserID = %n", courseID, UserID);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|