80 lines
2.7 KiB
C#
80 lines
2.7 KiB
C#
using HRM.BO;
|
|
using Ease.Core.DataAccess;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
internal class QuestionDA
|
|
{
|
|
#region Constructor
|
|
|
|
private QuestionDA()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Insert function
|
|
|
|
internal static void Insert(TransactionContext tc, Question item)
|
|
{
|
|
tc.ExecuteNonQuery(
|
|
"INSERT INTO Question(QuestionID, QuestionNo, CategoryID, QuestionBody, Image, IsMultiple, IsPublished, CreationDate, UserID, QuestionType,CreatedBy,ESTIMATEDTIME)" +
|
|
" VALUES(%n, %s, %n, %s, %s, %b, %b, %d, %n, %n,%n,%n)", item.ID, item.QuestionNo, item.CategoryID,
|
|
item.QuestionBody, item.Image, item.IsMultiple, item.IsPublished, item.CreatedDate, item.UserID,
|
|
(int)item.QuestionType, item.CreatedBy,item.EstimatedTime);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Update function
|
|
|
|
internal static void Update(TransactionContext tc, Question item)
|
|
{
|
|
tc.ExecuteNonQuery(
|
|
"UPDATE Question SET QuestionNo=%s, CategoryID=%n, QuestionBody=%s, Image=%s, IsMultiple=%n, IsPublished=%n, ModifiedDate=%d, UserID=%n, QuestionType=%n,ModifiedBy=%n,ESTIMATEDTIME=%n" +
|
|
" WHERE QuestionID=%n", item.QuestionNo, item.CategoryID, item.QuestionBody, item.Image,
|
|
item.IsMultiple, item.IsPublished, item.ModifiedDate, item.UserID, item.QuestionType, item.ModifiedBy,item.EstimatedTime,
|
|
item.ID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
public static IDataReader Get(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM Question");
|
|
}
|
|
|
|
public static IDataReader Get(TransactionContext tc, int nQuestionId)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM Question WHERE QuestionId=%n", nQuestionId);
|
|
}
|
|
|
|
public static IDataReader GetByCategory(TransactionContext tc, int nCategoryId)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM Question WHERE CategoryId=%n", nCategoryId);
|
|
}
|
|
|
|
public static bool IsTagged(TransactionContext tc, int questionID)
|
|
{
|
|
object ob;
|
|
ob = tc.ExecuteScalar("SELECT count(*) FROM SurveyQuestion where QuestionId=%n", questionID);
|
|
return ob == DBNull.Value ? false : Convert.ToInt32(ob) > 0 ? true : false;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Delete function
|
|
|
|
public static void Delete(TransactionContext tc, int nQuestionId)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM Question WHERE QuestionId=%n", nQuestionId);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |