77 lines
2.7 KiB
C#
77 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Payroll.BO;
|
|
using System.Data;
|
|
using Ease.CoreV35.Model;
|
|
using System.Data.SqlClient;
|
|
using Ease.CoreV35.DataAccess;
|
|
using System.Collections.Generic;
|
|
using Ease.CoreV35.DataAccess.SQL;
|
|
|
|
namespace Payroll.Service
|
|
{
|
|
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)" +
|
|
" VALUES(%n, %s, %n, %s, %s, %b, %b, %d, %n, %n,%n)", item.ID.Integer, item.QuestionNo, item.CategoryID, item.QuestionBody, item.Image, item.IsMultiple, item.IsPublished, item.CreationDate, item.UserID,(int) item.QuestionType,item.CreatedBy.Integer);
|
|
}
|
|
|
|
#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" +
|
|
" WHERE QuestionID=%n", item.QuestionNo, item.CategoryID, item.QuestionBody, item.Image, item.IsMultiple, item.IsPublished, item.ModifiedDate, item.UserID, item.QuestionType,item.ModifiedBy.Integer, item.ID.Integer);
|
|
}
|
|
|
|
#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
|
|
}
|
|
}
|