309 lines
8.7 KiB
C#
309 lines
8.7 KiB
C#
|
using System;
|
|||
|
using System.Data;
|
|||
|
using Ease.Core.Model;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using Ease.Core;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Ease.Core.Utility;
|
|||
|
using HRM.BO;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
public class MarketSalarySurveyService : ServiceTemplate
|
|||
|
{
|
|||
|
#region Object Mapping
|
|||
|
|
|||
|
private void MapObject(MarketSalarySurvey obMarketSurvey, DataReader oReader)
|
|||
|
{
|
|||
|
SetObjectID(obMarketSurvey, (oReader.GetInt32("MarketSurveyID").Value));
|
|||
|
obMarketSurvey.GradeID = oReader.GetInt32("GradeID", 0);
|
|||
|
obMarketSurvey.CompanyID = oReader.GetInt32("CompanyID", 0);
|
|||
|
obMarketSurvey.Amount = (double)oReader.GetDouble("Amount");
|
|||
|
obMarketSurvey.SurveyYear = (DateTime)oReader.GetDateTime("SurveyYear");
|
|||
|
//new DateTime((int)oReader.GetInt32("SurveyYear"), 1, 1);
|
|||
|
obMarketSurvey.SurveyOn = (EnumSurveyOn)oReader.GetInt32("SurveyOn");
|
|||
|
}
|
|||
|
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
MarketSalarySurvey oMarketSurvey = new MarketSalarySurvey();
|
|||
|
MapObject(oMarketSurvey, oReader);
|
|||
|
return oMarketSurvey as T;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Service Implementayion
|
|||
|
|
|||
|
public MarketSalarySurvey Get(int nID)
|
|||
|
{
|
|||
|
MarketSalarySurvey oMarketSurvey = new MarketSalarySurvey();
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(MarketSalarySurveyDA.Get(tc, nID));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oMarketSurvey = CreateObject<MarketSalarySurvey>(oreader);
|
|||
|
}
|
|||
|
|
|||
|
oreader.Close();
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oMarketSurvey;
|
|||
|
}
|
|||
|
|
|||
|
public List<MarketSalarySurvey> Get(DateTime surveryYear)
|
|||
|
{
|
|||
|
List<MarketSalarySurvey> oMarketSurvey = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(MarketSalarySurveyDA.Get(tc, surveryYear));
|
|||
|
oMarketSurvey = this.CreateObjects<MarketSalarySurvey>(oreader);
|
|||
|
oreader.Close();
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oMarketSurvey;
|
|||
|
}
|
|||
|
|
|||
|
public List<MarketSalarySurvey> Get(DateTime surveryYear, int nSurveyOn, int nGradeID)
|
|||
|
{
|
|||
|
List<MarketSalarySurvey> oMarketSurvey = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(MarketSalarySurveyDA.Get(tc, surveryYear, nSurveyOn, nGradeID));
|
|||
|
oMarketSurvey = this.CreateObjects<MarketSalarySurvey>(oreader);
|
|||
|
oreader.Close();
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oMarketSurvey;
|
|||
|
}
|
|||
|
|
|||
|
public List<MarketSalarySurvey> Get(DateTime surveryYear, int nSurveyOn)
|
|||
|
{
|
|||
|
List<MarketSalarySurvey> oMarketSurvey = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(MarketSalarySurveyDA.Get(tc, surveryYear, nSurveyOn));
|
|||
|
oMarketSurvey = this.CreateObjects<MarketSalarySurvey>(oreader);
|
|||
|
oreader.Close();
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oMarketSurvey;
|
|||
|
}
|
|||
|
|
|||
|
public int Save(MarketSalarySurvey item)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (item.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("MarketSurvey", "MarketSurveyID");
|
|||
|
SetObjectID(item, (id));
|
|||
|
MarketSalarySurveyDA.Insert(tc, item);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
MarketSalarySurveyDA.Update(tc, item);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
|
|||
|
return item.ID;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void SaveAll(List<MarketSalarySurvey> allItems)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
foreach (MarketSalarySurvey item in allItems)
|
|||
|
{
|
|||
|
if (item.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("MarketSalarySurvey", "MarketSurveyID");
|
|||
|
SetObjectID(item, (id));
|
|||
|
MarketSalarySurveyDA.Insert(tc, item);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
MarketSalarySurveyDA.Update(tc, item);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Update(MarketSalarySurvey item)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
MarketSalarySurveyDA.Update(tc, item);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Delete(int id)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
MarketSalarySurveyDA.Delete(tc, id);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public bool CheckDesignationExistsOrNot(int iD, DateTime year)
|
|||
|
{
|
|||
|
bool flag = true;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
DataSet oDs = null;
|
|||
|
oDs = MarketSalarySurveyDA.CheckDesignationExistsOrNot(tc, iD, year);
|
|||
|
if (oDs.Tables[0].Rows.Count > 0)
|
|||
|
{
|
|||
|
flag = false;
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return flag;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|