108 lines
4.9 KiB
C#
108 lines
4.9 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 Ease.CoreV35.DataAccess.SQL;
|
|||
|
|
|||
|
namespace Payroll.Service
|
|||
|
{
|
|||
|
internal class SurveyDA
|
|||
|
{
|
|||
|
#region Constructor
|
|||
|
|
|||
|
private SurveyDA() { }
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Survey
|
|||
|
|
|||
|
#region Insert function
|
|||
|
|
|||
|
|
|||
|
internal static void Insert(TransactionContext tc, Survey item)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("INSERT INTO Survey(SurveyID, CategoryID, Title, Description, FromDate, ToDate,IsForCelyStoped,IsPublished,CreatedBy,CreationDate,PublishDate,SurveyType)" +
|
|||
|
" VALUES(%n, %n, %s, %s, %d, %d, %b,%b,%n,%d,%d,%n)", item.ID.Integer, item.CategoryID, item.Title, item.Description, item.FromDate, item.ToDate, item.IsForCelyStoped,item.IsPublished,item.CreatedBy.Integer,item.CreatedDate,DataReader.GetNullValue(item.PublishDate) ,item.SurveyType);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Update function
|
|||
|
|
|||
|
internal static void Update(TransactionContext tc, Survey item)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("UPDATE Survey SET CategoryID=%n, Title=%s, Description=%s, FromDate=%d, ToDate=%d,IsForCelyStoped=%b,IsPublished=%b,ModifiedBy=%n,ModifiedDate=%d,PublishDate=%d,SurveyType=%n" +
|
|||
|
" WHERE SurveyID=%n", item.CategoryID, item.Title, item.Description, item.FromDate, item.ToDate, item.IsForCelyStoped,item.IsPublished,item.ModifiedBy.Integer,item.ModifiedDate,DataReader.GetNullValue(item.PublishDate),item.SurveyType, item.ID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get Function
|
|||
|
|
|||
|
public static IDataReader Get(TransactionContext tc)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Survey");
|
|||
|
}
|
|||
|
public static IDataReader GetByCategory(TransactionContext tc, int nCategoryId)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Survey WHERE CategoryId=%n", nCategoryId);
|
|||
|
}
|
|||
|
|
|||
|
public static IDataReader Get(TransactionContext tc, DateTime today)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * from Survey WHERE %d BETWEEN FromDate AND ToDate AND IsPublished=1 AND IsForcelyStoped=0", today);
|
|||
|
}
|
|||
|
|
|||
|
//public static IDataReader Get(TransactionContext tc, Employee oEmp)
|
|||
|
//{
|
|||
|
// return tc.ExecuteReader("SELECT * from Survey");
|
|||
|
//}
|
|||
|
public static IDataReader GetByCategory(TransactionContext tc, int nCategoryId, DateTime fromDT, DateTime toDT)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Survey WHERE CategoryId=%n and (FromDate>= %d and FromDate<= %d) OR( ToDate>= %d and ToDate<= %d)", nCategoryId, fromDT, toDT, fromDT, toDT);
|
|||
|
}
|
|||
|
public static IDataReader GetByCategory(TransactionContext tc, DateTime fromDT, DateTime toDT)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Survey WHERE (FromDate>= %d and FromDate<= %d) OR( ToDate>= %d and ToDate<= %d)", fromDT, toDT, fromDT, toDT);
|
|||
|
}
|
|||
|
public static IDataReader GetIncompleteSurveys(TransactionContext tc, int empID, EnumSurveyType type, DateTime fromDT, DateTime toDT)
|
|||
|
{
|
|||
|
//if (type == EnumSurveyType.Self || type == EnumSurveyType.Managerial)
|
|||
|
// return tc.ExecuteReader("SELECT S.* FROM Survey S,SurveyEmployee SE WHERE SE.EmployeeId=%n and S.SurveyType=%n and S.SurveyId=SE.SurveyId and S.PublishFromDate between %d and %d", empID, (int)type, fromDT, toDT);
|
|||
|
//else
|
|||
|
return tc.ExecuteReader("SELECT S.* FROM Survey S,SurveyEmployee SE WHERE SE.EmployeeId=%n and S.SurveyId=SE.SurveyId and S.PublishDate between %d and %d", empID, fromDT, toDT);
|
|||
|
}
|
|||
|
public static IDataReader Get(TransactionContext tc, int nSurveyId)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Survey WHERE SurveyId=%n", nSurveyId);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete function
|
|||
|
|
|||
|
public static void Delete(TransactionContext tc, int nSurveyId)
|
|||
|
{
|
|||
|
SurveyQuestionDA.DeleteSurveyQuestion(tc, nSurveyId);
|
|||
|
SurveyEmployeeDA.DeleteSurveyEmployee(tc, nSurveyId);
|
|||
|
SurveyOrganizationDA.DeleteSurveyOrganization(tc, nSurveyId);
|
|||
|
tc.ExecuteNonQuery("DELETE FROM [Survey] WHERE SurveyId=%n", nSurveyId);
|
|||
|
}
|
|||
|
public static void Publish(TransactionContext tc, Survey survey)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("UPDATE [Survey] SET PublishDate=%d,IsPublished=%b WHERE SurveyId=%n", survey.PublishDate.Value,survey.IsPublished,survey.ID.Integer);
|
|||
|
}
|
|||
|
public static void Stop(TransactionContext tc, Survey survey)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("UPDATE [Survey] SET PublishDate=%d,IsPublished=%b,IsForCelyStoped=%b WHERE SurveyId=%n", DataReader.GetNullValue(survey.PublishDate), survey.IsPublished,survey.IsForCelyStoped, survey.ID.Integer);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|