CEL_Payroll/Payroll.BO/Survey/SurveyResult.cs
2024-09-17 14:30:13 +06:00

346 lines
8.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.CoreV35;
using Ease.CoreV35.Model;
using Ease.CoreV35.Caching;
using System.Data.Linq.Mapping;
using System.Data;
namespace Payroll.BO
{
[Serializable]
public class SurveyResult : AuditTrailBase
{
#region Cache Store
private static Cache _cache = new Cache(typeof(SurveyResult));
#endregion
#region Constructor
#region Input validator
//public string[] InputValidator()
//{
// string[] sErrorString = new string[2];
// if (this.Code == "")
// {
// sErrorString[0] = "Code can not be empty";
// sErrorString[1] = "Code";
// return sErrorString;
// }
// if (this.Name == "")
// {
// sErrorString[0] = "Description can not be empty";
// sErrorString[1] = "Description";
// return sErrorString;
// }
// sErrorString = null;
// return sErrorString;
//}
#endregion
public SurveyResult()
{
_surveyID = null;
_employeeID = 0;
_questionID = 0;
_answerID = 0;
_isCorrect = false;
_forEmployeeID = 0;
_weight = 0;
}
#endregion
#region Properties
#region SurveyID : ID
private ID _surveyID;
public ID SurveyID
{
get { return _surveyID; }
set
{
base.OnPropertyChange<ID>("SurveyOrganizationID", _surveyID, value);
_surveyID = value;
}
}
#endregion
#region EmployeeID : int
private int _employeeID;
public int EmployeeID
{
get { return _employeeID; }
set
{
base.OnPropertyChange<int>("AnswerID", _employeeID, value);
_employeeID = value;
}
}
#endregion
#region QuestionID : int
private int _questionID;
public int QuestionID
{
get { return _questionID; }
set
{
base.OnPropertyChange<int>("QuestionID", _questionID, value);
_questionID = value;
}
}
#endregion
#region AnswerID : int
private int _answerID;
public int AnswerID
{
get { return _answerID; }
set
{
base.OnPropertyChange<int>("AnswerID", _answerID, value);
_answerID = value;
}
}
#endregion
#region IsCorrect : bool
private bool _isCorrect;
public bool IsCorrect
{
get { return _isCorrect; }
set
{
base.OnPropertyChange<bool>("IsCorrect", _isCorrect, value);
_isCorrect = value;
}
}
#endregion
#region ForEmployeeID : int
private int _forEmployeeID;
public int ForEmployeeID
{
get { return _forEmployeeID; }
set
{
base.OnPropertyChange<int>("ForEmployeeID", _forEmployeeID, value);
_forEmployeeID = value;
}
}
#endregion
#region Weight : double
private double _weight;
public double Weight
{
get { return _weight; }
set
{
base.OnPropertyChange<double>("Weight", _weight, value);
_weight = value;
}
}
#endregion
#region Service Factory IPFTransactionService : IPFTransactionService
internal static ISurveyResultService Service
{
get { return Services.Factory.CreateService<ISurveyResultService>(typeof(ISurveyResultService)); }
}
#endregion
#endregion
#region Functions
public DataSet GetSurveyResultReport()
{
return Service.GetSurveyResultReport(this.ID);
}
public static ObjectsTemplate<SurveyResult> GetSurveyResult()
{
#region Cache Header
ObjectsTemplate<SurveyResult> SurveyResults = _cache["GetSurveyResult"] as ObjectsTemplate<SurveyResult>;
if (SurveyResults != null)
return SurveyResults;
#endregion
try
{
SurveyResults = Service.GetSurveyResult();
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(SurveyResults, "GetSurveyResult");
#endregion
return SurveyResults;
}
public static ObjectsTemplate<SurveyResult> GetSurveyResult(ID surveyId)
{
#region Cache Header
ObjectsTemplate<SurveyResult> SurveyResults = _cache["GetSurveyResult", surveyId] as ObjectsTemplate<SurveyResult>;
if (SurveyResults != null)
return SurveyResults;
#endregion
try
{
SurveyResults = Service.GetSurveyResult(surveyId);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(SurveyResults, "GetSurveyResult", surveyId);
#endregion
return SurveyResults;
}
public static ObjectsTemplate<SurveyResult> GetSurveyResult(int surveyId, string employeeIds)
{
#region Cache Header
ObjectsTemplate<SurveyResult> SurveyResults = _cache["GetSurveyResult", surveyId, employeeIds] as ObjectsTemplate<SurveyResult>;
if (SurveyResults != null)
return SurveyResults;
#endregion
try
{
SurveyResults = Service.GetSurveyResult(surveyId, employeeIds);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(SurveyResults, "GetSurveyResult", surveyId, employeeIds);
#endregion
return SurveyResults;
}
public static ObjectsTemplate<SurveyResult> GetSurveyResult(int surveyId, int employeeId, int questionID)
{
#region Cache Header
ObjectsTemplate<SurveyResult> SurveyResults = _cache["GetSurveyResult", surveyId, employeeId, questionID] as ObjectsTemplate<SurveyResult>;
if (SurveyResults != null)
return SurveyResults;
#endregion
try
{
SurveyResults = Service.GetSurveyResult(surveyId, employeeId, questionID);
}
catch (ServiceException e)
{
throw new Exception(e.Message, e);
}
#region Cache Footer
_cache.Add(SurveyResults, "GetSurveyResult", surveyId, employeeId, questionID);
#endregion
return SurveyResults;
}
//#region Input validator
//public string[] InputValidator()
//{
// string[] sErrorString = new string[2];
// if (this.Code == "")
// {
// sErrorString[0] = "Code can not be empty";
// sErrorString[1] = "Code";
// return sErrorString;
// }
// if (this.Name == "")
// {
// sErrorString[0] = "Description can not be empty";
// sErrorString[1] = "Description";
// return sErrorString;
// }
// sErrorString = null;
// return sErrorString;
//}
//#endregion
public ID Save()
{
base.SetAuditTrailProperties();
return SurveyResult.Service.Save(this);
}
public static void Save(ObjectsTemplate<SurveyResult> oSrslts)
{
SurveyResult.Service.Save(oSrslts);
}
public void Delete(ID id)
{
SurveyResult.Service.Delete(id);
}
#endregion
}
#region ISurveyResult Service
public interface ISurveyResultService
{
ObjectsTemplate<SurveyResult> GetSurveyResult(ID surveyId);
ObjectsTemplate<SurveyResult> GetSurveyResult(int surveyId, string employeeIds);
ObjectsTemplate<SurveyResult> GetSurveyResult(int surveyId, int employeeId, int questionID);
ObjectsTemplate<SurveyResult> GetSurveyResult();
DataSet GetSurveyResultReport(ID surveyID);
ID Save(SurveyResult item);
void Save(ObjectsTemplate<SurveyResult> oSrslts);
void Delete(ID id);
}
#endregion
}