using HRM.BO; using Ease.Core.DataAccess; using System; using System.Collections.Generic; using System.Data; namespace HRM.DA { internal class SurveyAnswerCountDA { #region Constructor private SurveyAnswerCountDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, SurveyAnswerCount item) { tc.ExecuteNonQuery("INSERT INTO SurveyAnswerCount(SurveyID, QuestionID, AnswerID, HitCount)" + " VALUES(%n, %n, %n, %n)", item.SurveyID, item.QuestionID, item.AnswerID, item.HitCount); } public static void InsertSurveyAnswerCount(TransactionContext tc, int nSurveyId, int nQuestionId, int nAnswerId) { tc.ExecuteNonQuery("INSERT INTO SurveyAnswerCount(SurveyId, QuestionId, AnswerId, HitCount)" + " VALUES(%n, %n, %n, %n)", nSurveyId, nQuestionId, nAnswerId, 1); } #endregion #region Update function internal static void Update(TransactionContext tc, SurveyAnswerCount item) { tc.ExecuteNonQuery("UPDATE SurveyAnswerCount SET QuestionID=%n, AnswerID=%n, HitCount=%n" + " WHERE SurveyID=%n", item.QuestionID, item.AnswerID, item.HitCount, item.SurveyID); } public static void UpdateSurveyAnswerCount(TransactionContext tc, int nSurveyId, int nQuestionId, int nAnswerId) { tc.ExecuteNonQuery("UPDATE SurveyAnswerCount SET HitCount=HitCount+1" + " WHERE SurveyId=%n AND QuestionId=%n AND AnswerId=%n", nSurveyId, nQuestionId, nAnswerId); } #endregion #region Get Function public static IDataReader GetSurveyAnswerCount(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM SurveyAnswerCount"); } public static IDataReader GetSurveyAnswerCount(TransactionContext tc, int nSurveyId) { return tc.ExecuteReader("SELECT * FROM SurveyAnswerCount WHERE SurveyId=%n", nSurveyId); } public static int GetSurveyAnswerHitCount(TransactionContext tc, int nSurveyId, int nQuestionId, int nAnswerId) { string str = "SELECT * FROM SurveyAnswerCount WHERE SurveyId=%n AND QuestionId=%n AND AnswerId=%n"; object obj; obj = tc.ExecuteScalar(str, nSurveyId, nQuestionId, nAnswerId); if (obj == null || obj == DBNull.Value) return 0; else return Convert.ToInt32(obj); } public static IDataReader GetSurveyAnswerCount(TransactionContext tc, int nSurveyId, int nQuestionId, int nAnswerId) { return tc.ExecuteReader( "SELECT * FROM SurveyAnswerCount WHERE SurveyId=%n AND QuestionId=%n AND AnswerId=%n", nSurveyId, nQuestionId, nAnswerId); } #endregion #region Delete function internal static void Delete(TransactionContext tc, int nID) { tc.ExecuteNonQuery("DELETE FROM SurveyAnswerCount WHERE SurveyID=%n", nID); } #endregion } }