95 lines
3.0 KiB
C#
95 lines
3.0 KiB
C#
using HRM.BO;
|
|
using Ease.Core.DataAccess;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
|
|
|
|
namespace HRM.DA
|
|
{
|
|
internal class QuestionAnswerDA
|
|
{
|
|
#region Constructor
|
|
|
|
private QuestionAnswerDA()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Insert function
|
|
|
|
internal static void Insert(TransactionContext tc, QuestionAnswer item)
|
|
{
|
|
tc.ExecuteNonQuery(
|
|
"INSERT INTO QuestionAnswer(AnswerID, QuestionID, AnswerBody, Image, IsCorrect, DisplayOrder, Weight)" +
|
|
" VALUES(%n, %n, %s, %s, %b, %n, %n)", item.ID, item.QuestionID, item.AnswerBody, item.Image,
|
|
item.IsCorrect, item.DisplayOrder, item.Weight);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Update function
|
|
|
|
internal static void Update(TransactionContext tc, QuestionAnswer item)
|
|
{
|
|
tc.ExecuteNonQuery(
|
|
"UPDATE QuestionAnswer SET QuestionID=%n, AnswerBody=%s, Image=%s, IsCorrect=%n,DisplayOrder=%n, Weight=%n" +
|
|
" WHERE AnswerID=%n", item.QuestionID, item.AnswerBody, item.Image, item.IsCorrect, item.DisplayOrder,
|
|
item.Weight, item.AnswerID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
//internal static IDataReader Get(TransactionContext tc, EnumStatus status)
|
|
//{
|
|
// if (EnumStatus.Active == status || EnumStatus.Inactive == status)
|
|
// {
|
|
// return tc.ExecuteReader("SELECT * FROM QuestionAnswer where Status=%n", status);
|
|
// }
|
|
// else
|
|
// {
|
|
// return tc.ExecuteReader("SELECT * FROM QuestionAnswer");
|
|
// }
|
|
|
|
//}
|
|
public static IDataReader Get(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM QuestionAnswer");
|
|
}
|
|
|
|
public static IDataReader GetByQuestionID(TransactionContext tc, int questionId)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM QuestionAnswer where QuestionId=%n order by DisplayOrder ASC",
|
|
questionId);
|
|
}
|
|
|
|
public static IDataReader Get(TransactionContext tc, int nAnswerId)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM QuestionAnswer WHERE AnswerId=%n", nAnswerId);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Delete function
|
|
|
|
public static void Delete(TransactionContext tc, int nAnswerId)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM QuestionAnswer WHERE AnswerId=%n", nAnswerId);
|
|
}
|
|
|
|
public static void DeleteByQuestionId(TransactionContext tc, int nQuestionId)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM QuestionAnswer WHERE QuestionId=%n", nQuestionId);
|
|
}
|
|
public static IDataReader GetAttachmentByQuestionID(TransactionContext tc, int questionId)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM QUESTIONANSWERATTACHMENT where QuestionId=%n",
|
|
questionId);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |