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("SurveyOrganizationID", _surveyID, value); _surveyID = value; } } #endregion #region EmployeeID : int private int _employeeID; public int EmployeeID { get { return _employeeID; } set { base.OnPropertyChange("AnswerID", _employeeID, value); _employeeID = value; } } #endregion #region QuestionID : int private int _questionID; public int QuestionID { get { return _questionID; } set { base.OnPropertyChange("QuestionID", _questionID, value); _questionID = value; } } #endregion #region AnswerID : int private int _answerID; public int AnswerID { get { return _answerID; } set { base.OnPropertyChange("AnswerID", _answerID, value); _answerID = value; } } #endregion #region IsCorrect : bool private bool _isCorrect; public bool IsCorrect { get { return _isCorrect; } set { base.OnPropertyChange("IsCorrect", _isCorrect, value); _isCorrect = value; } } #endregion #region ForEmployeeID : int private int _forEmployeeID; public int ForEmployeeID { get { return _forEmployeeID; } set { base.OnPropertyChange("ForEmployeeID", _forEmployeeID, value); _forEmployeeID = value; } } #endregion #region Weight : double private double _weight; public double Weight { get { return _weight; } set { base.OnPropertyChange("Weight", _weight, value); _weight = value; } } #endregion #region Service Factory IPFTransactionService : IPFTransactionService internal static ISurveyResultService Service { get { return Services.Factory.CreateService(typeof(ISurveyResultService)); } } #endregion #endregion #region Functions public DataSet GetSurveyResultReport() { return Service.GetSurveyResultReport(this.ID); } public static ObjectsTemplate GetSurveyResult() { #region Cache Header ObjectsTemplate SurveyResults = _cache["GetSurveyResult"] as ObjectsTemplate; 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 GetSurveyResult(ID surveyId) { #region Cache Header ObjectsTemplate SurveyResults = _cache["GetSurveyResult", surveyId] as ObjectsTemplate; 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 GetSurveyResult(int surveyId, string employeeIds) { #region Cache Header ObjectsTemplate SurveyResults = _cache["GetSurveyResult", surveyId, employeeIds] as ObjectsTemplate; 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 GetSurveyResult(int surveyId, int employeeId, int questionID) { #region Cache Header ObjectsTemplate SurveyResults = _cache["GetSurveyResult", surveyId, employeeId, questionID] as ObjectsTemplate; 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 oSrslts) { SurveyResult.Service.Save(oSrslts); } public void Delete(ID id) { SurveyResult.Service.Delete(id); } #endregion } #region ISurveyResult Service public interface ISurveyResultService { ObjectsTemplate GetSurveyResult(ID surveyId); ObjectsTemplate GetSurveyResult(int surveyId, string employeeIds); ObjectsTemplate GetSurveyResult(int surveyId, int employeeId, int questionID); ObjectsTemplate GetSurveyResult(); DataSet GetSurveyResultReport(ID surveyID); ID Save(SurveyResult item); void Save(ObjectsTemplate oSrslts); void Delete(ID id); } #endregion }