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 Ease.CoreV35.DataAccess.SQL; namespace Payroll.Service { 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.Integer, 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.Integer); } #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); } #endregion } }