CEL_Payroll/Payroll.Service/Budget/Service/BudgetProcessMonthlyService.cs

818 lines
32 KiB
C#
Raw Permalink Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ease.CoreV35;
using Ease.CoreV35.Caching;
using Ease.CoreV35.DataAccess;
using Ease.CoreV35.Model;
using Payroll.BO;
using System.Data;
using System.Data.SqlClient;
namespace Payroll.Service
{
[Serializable]
public class BudgetProcessMonthlyService : ServiceTemplate, IBudgetProcessMonthlyService
{
#region Private functions and declaration
Cache _cache = new Cache(typeof(BudgetProcessMonthly));
#endregion
#region Object Mapping
#region Parent Object Mapping
private void MapObject(BudgetProcessMonthly oBudgetProcessMonthly, DataReader oReader)
{
SetObjectID(oBudgetProcessMonthly, oReader.GetID("BudgetProcessMonthlyID"));
oBudgetProcessMonthly.BudgetID = oReader.GetID("BudgetID");
oBudgetProcessMonthly.DepartmentID = oReader.GetID("DepartmentID");
oBudgetProcessMonthly.EmployeeID = oReader.GetID("EmployeeID");
oBudgetProcessMonthly.GradeID = oReader.GetID("GradeID");
oBudgetProcessMonthly.IsConfirm = oReader.GetInt32("IsConfirm").Value;
oBudgetProcessMonthly.LocationID = oReader.GetID("LocationID");
oBudgetProcessMonthly.Month = oReader.GetDateTime("Month").Value;
oBudgetProcessMonthly.NewJoinerID = oReader.GetID("NewJoinerID");
oBudgetProcessMonthly.NewJoinerName = oReader.GetString("NewJoinerName");
SetObjectState(oBudgetProcessMonthly, ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader dr)
{
BudgetProcessMonthly oBudgetProcessMonthly = new BudgetProcessMonthly();
MapObject(oBudgetProcessMonthly, dr);
return oBudgetProcessMonthly as T;
}
#endregion
#region Child Object Mapping
#region BudgetProcessMonthlyDetail Mapping
private void MapBudgetProcessMonthlyDetail(BudgetProcessMonthlyDetail oBudgetProcessMonthlyDetail, DataReader oReader)
{
SetObjectID(oBudgetProcessMonthlyDetail, oReader.GetID("BudgetProcessMonthlyDetailID"));
oBudgetProcessMonthlyDetail.Calculatedamount = oReader.GetDouble("Amount").Value;
oBudgetProcessMonthlyDetail.Changedamount = oReader.GetDouble("Changedamount").Value;
oBudgetProcessMonthlyDetail.BudgetComponentID = oReader.GetID("BudgetComponentID");
oBudgetProcessMonthlyDetail.BudgetProcessMonthlyID = oReader.GetID("BudgetProcessMonthlyID");
oBudgetProcessMonthlyDetail.EmployeeID = oReader.GetID("EmployeeID");
oBudgetProcessMonthlyDetail.Month = oReader.GetDateTime("Month").Value;
oBudgetProcessMonthlyDetail.Name = oReader.GetString("Name");
oBudgetProcessMonthlyDetail.BudgetGroup = (EnumBudgetGroup)oReader.GetInt32("BudgetGroup");
oBudgetProcessMonthlyDetail.BudgetCode = (EnumBudgetCode)oReader.GetInt32("BudgetCode");
oBudgetProcessMonthlyDetail.Position = oReader.GetInt16("Position").Value;
oBudgetProcessMonthlyDetail.OriginID = oReader.GetID("OriginID");
this.SetObjectState(oBudgetProcessMonthlyDetail, ObjectState.Saved);
}
private void MapBudgetProcessMonthlyDetail2(BudgetProcessMonthlyDetail oBudgetProcessMonthlyDetail, DataReader oReader)
{
oBudgetProcessMonthlyDetail.EmployeeID = oReader.GetID("EmpID");
oBudgetProcessMonthlyDetail.Name = oReader.GetString("ItemName");
oBudgetProcessMonthlyDetail.Calculatedamount = oReader.GetDouble("Amount").Value;
oBudgetProcessMonthlyDetail.OriginID = oReader.GetID("OriginID");
oBudgetProcessMonthlyDetail.BudgetCode = (EnumBudgetCode)oReader.GetInt32("BudgetCode");
oBudgetProcessMonthlyDetail.Position = oReader.GetInt16("Position").GetValueOrDefault();
this.SetObjectState(oBudgetProcessMonthlyDetail, ObjectState.Saved);
}
private void MapBudgetProcessMonthlyDetail3(BudgetProcessMonthlyDetail oBudgetProcessMonthlyDetail, DataReader oReader)
{
oBudgetProcessMonthlyDetail.EmployeeID = oReader.GetID("EmpID");
oBudgetProcessMonthlyDetail.Name = oReader.GetString("ItemName");
oBudgetProcessMonthlyDetail.Calculatedamount = oReader.GetDouble("Amount").Value;
oBudgetProcessMonthlyDetail.OriginID = oReader.GetID("OriginID");
oBudgetProcessMonthlyDetail.BudgetCode = (EnumBudgetCode)oReader.GetInt32("BudgetCode");
oBudgetProcessMonthlyDetail.Position = oReader.GetInt16("Position").GetValueOrDefault();
oBudgetProcessMonthlyDetail.BudgetProcessMonthlyID = oReader.GetID("BudgetProcessMonthlyID");
this.SetObjectState(oBudgetProcessMonthlyDetail, ObjectState.Saved);
}
private BudgetProcessMonthlyDetail CreateBudgetDetailObject(DataReader oReader)
{
BudgetProcessMonthlyDetail oBudgetDetail = new BudgetProcessMonthlyDetail();
MapBudgetProcessMonthlyDetail(oBudgetDetail, oReader);
return oBudgetDetail;
}
private BudgetProcessMonthlyDetail CreateBudgetDetailObject2(DataReader oReader)
{
BudgetProcessMonthlyDetail oBudgetDetail = new BudgetProcessMonthlyDetail();
MapBudgetProcessMonthlyDetail2(oBudgetDetail, oReader);
return oBudgetDetail;
}
private BudgetProcessMonthlyDetail CreateBudgetDetailObject3(DataReader oReader)
{
BudgetProcessMonthlyDetail oBudgetDetail = new BudgetProcessMonthlyDetail();
MapBudgetProcessMonthlyDetail3(oBudgetDetail, oReader);
return oBudgetDetail;
}
protected ObjectsTemplate<BudgetProcessMonthlyDetail> CreateBudgetDetailObjects(DataReader oReader)
{
ObjectsTemplate<BudgetProcessMonthlyDetail> oBudgetDetails = new ObjectsTemplate<BudgetProcessMonthlyDetail>();
while (oReader.Read())
{
BudgetProcessMonthlyDetail item = CreateBudgetDetailObject(oReader);
oBudgetDetails.Add(item);
}
return oBudgetDetails;
}
protected ObjectsTemplate<BudgetProcessMonthlyDetail> CreateBudgetDetailObjects2(DataReader oReader)
{
ObjectsTemplate<BudgetProcessMonthlyDetail> oBudgetDetails = new ObjectsTemplate<BudgetProcessMonthlyDetail>();
while (oReader.Read())
{
BudgetProcessMonthlyDetail item = CreateBudgetDetailObject2(oReader);
oBudgetDetails.Add(item);
}
return oBudgetDetails;
}
protected ObjectsTemplate<BudgetProcessMonthlyDetail> CreateBudgetDetailObjects3(DataReader oReader)
{
ObjectsTemplate<BudgetProcessMonthlyDetail> oBudgetDetails = new ObjectsTemplate<BudgetProcessMonthlyDetail>();
while (oReader.Read())
{
BudgetProcessMonthlyDetail item = CreateBudgetDetailObject3(oReader);
oBudgetDetails.Add(item);
}
return oBudgetDetails;
}
#endregion
#region BudgetMonthlyCC Mapping
private void MapBudgetMonthlyCC(BudgetMonthlyCC oBudgetMonthlyCC, DataReader oReader)
{
SetObjectID(oBudgetMonthlyCC, oReader.GetID("BudgetMonthlyCCID"));
oBudgetMonthlyCC.BudgetProcessMonthlyID = oReader.GetID("BudgetProcessMonthlyID");
oBudgetMonthlyCC.CCID = oReader.GetID("CCID");
oBudgetMonthlyCC.EmployeeID = oReader.GetID("EmployeeID");
oBudgetMonthlyCC.Month = oReader.GetDateTime("Month").Value;
oBudgetMonthlyCC.Percentage = oReader.GetDouble("Percentage").Value;
this.SetObjectState(oBudgetMonthlyCC, ObjectState.Saved);
}
private BudgetMonthlyCC CreateBudgetMonthlyCCObject(DataReader oReader)
{
BudgetMonthlyCC oBudgetMonthlyCC = new BudgetMonthlyCC();
MapBudgetMonthlyCC(oBudgetMonthlyCC, oReader);
return oBudgetMonthlyCC;
}
protected ObjectsTemplate<BudgetMonthlyCC> CreateBudgetMonthlyCCObjects(DataReader oReader)
{
ObjectsTemplate<BudgetMonthlyCC> oBudgetMonthlyCCs = new ObjectsTemplate<BudgetMonthlyCC>();
while (oReader.Read())
{
BudgetMonthlyCC item = CreateBudgetMonthlyCCObject(oReader);
oBudgetMonthlyCCs.Add(item);
}
return oBudgetMonthlyCCs;
}
#endregion
#endregion
#endregion
#region Service Implementation
#region Parent's Service Implementation
public BudgetProcessMonthly Get(ID nID, ID PayrollTypeID)
{
BudgetProcessMonthly oBudgetProcessMonthly = new BudgetProcessMonthly();
#region Cache Header
oBudgetProcessMonthly = _cache["Get", nID] as BudgetProcessMonthly;
if (oBudgetProcessMonthly != null)
return oBudgetProcessMonthly;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(BudgetProcessMonthlyDA.Get(tc, nID, PayrollTypeID));
if (oreader.Read())
{
oBudgetProcessMonthly = CreateObject<BudgetProcessMonthly>(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
}
#region Cache Footer
_cache.Add(oBudgetProcessMonthly, "Get", nID);
#endregion
return oBudgetProcessMonthly;
}
public ObjectsTemplate<BudgetProcessMonthly> Get(ID PayrollTypeID)
{
#region Cache Header
ObjectsTemplate<BudgetProcessMonthly> oBudgetProcessMonthlies = _cache["Get"] as ObjectsTemplate<BudgetProcessMonthly>;
if (oBudgetProcessMonthlies != null)
return oBudgetProcessMonthlies;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(BudgetProcessMonthlyDA.Get(tc, PayrollTypeID));
// if (oreader.Read())
//{
oBudgetProcessMonthlies = this.CreateObjects<BudgetProcessMonthly>(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
}
#region Cache Footer
_cache.Add(oBudgetProcessMonthlies, "Get");
#endregion
return oBudgetProcessMonthlies;
}
public ObjectsTemplate<BudgetProcessMonthly> Get(int nBudID, ID PayrollTypeID)
{
#region Cache Header
ObjectsTemplate<BudgetProcessMonthly> oBudgetProcessMonthlies = _cache["Get"] as ObjectsTemplate<BudgetProcessMonthly>;
if (oBudgetProcessMonthlies != null)
return oBudgetProcessMonthlies;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(BudgetProcessMonthlyDA.Get(tc, nBudID, PayrollTypeID));
// if (oreader.Read())
//{
oBudgetProcessMonthlies = this.CreateObjects<BudgetProcessMonthly>(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
}
#region Cache Footer
_cache.Add(oBudgetProcessMonthlies, "Get");
#endregion
return oBudgetProcessMonthlies;
}
public ID Save(BudgetProcessMonthly item, ID PayrollTypeID)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
if (item.IsNew)
{
int id = tc.GenerateID("BudgetProcessMonthly", "BudgetProcessMonthlyID");
SetObjectID(item, ID.FromInteger(id));
BudgetProcessMonthlyDA.Insert(tc, item, PayrollTypeID);
}
else
{
BudgetProcessMonthlyDA.Update(tc, item, PayrollTypeID);
#region delete childrern
BudgetProcessMonthlyDA.Delete(tc, "BudgetProcessMonthlyDetail", "BudgetProcessMonthlyID",item.ID);
BudgetProcessMonthlyDA.Delete(tc, "BudgetMonthlyCC", "BudgetProcessMonthlyID", item.ID);
#endregion
}
#region Insert Children
#region BudgetProcessMonthlyDetails
foreach (BudgetProcessMonthlyDetail oBudgetProcessMonthlyDetail in item.OBudgetProcessMonthlyDetails)
{
oBudgetProcessMonthlyDetail.BudgetProcessMonthlyID = item.ID;
this.SetObjectID(oBudgetProcessMonthlyDetail,ID.FromInteger(tc.GenerateID("BudgetProcessMonthlyDetail","BudgetProcessMonthlyDetailID")));
BudgetProcessMonthlyDA.Insert(tc, oBudgetProcessMonthlyDetail);
}
#endregion
#region BudgetMonthlyCCs
foreach (BudgetMonthlyCC oBBudgetMonthlyCC in item.OBudgetMonthlyCCs)
{
oBBudgetMonthlyCC.BudgetProcessMonthlyID = item.ID;
this.SetObjectID(oBBudgetMonthlyCC, ID.FromInteger(tc.GenerateID("BudgetMonthlyCC", "BudgetMonthlyCCID")));
BudgetProcessMonthlyDA.Insert(tc, oBBudgetMonthlyCC);
}
#endregion
#endregion
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 ID Save(BudgetProcessMonthly item,TransactionContext tc, ID PayrollTypeID)
{
try
{
//if (item.IsNew)
//{
int id = tc.GenerateID("BudgetProcessMonthly", "BudgetProcessMonthlyID");
SetObjectID(item, ID.FromInteger(id));
BudgetProcessMonthlyDA.Insert(tc, item, PayrollTypeID);
//}
//else
//{
// BudgetProcessMonthlyDA.Update(tc, item);
// #region delete childrern
// BudgetProcessMonthlyDA.Delete(tc, "BudgetProcessMonthlyDetail", "BudgetProcessMonthlyID", item.ID);
// BudgetProcessMonthlyDA.Delete(tc, "BudgetMonthlyCC", "BudgetProcessMonthlyID", item.ID);
// #endregion
//}
#region Insert Children
#region BudgetProcessMonthlyDetails
int nPos= tc.GenerateID("BudgetProcessMonthlyDetail", "Position");
foreach (BudgetProcessMonthlyDetail oBudgetProcessMonthlyDetail in item.OBudgetProcessMonthlyDetails)
{
oBudgetProcessMonthlyDetail.BudgetProcessMonthlyID = item.ID;
if( oBudgetProcessMonthlyDetail.BugetComponent!=null)
oBudgetProcessMonthlyDetail.BudgetComponentID = oBudgetProcessMonthlyDetail.BugetComponent.ID;
//oBudgetProcessMonthlyDetail.Position = SetPosition(oBudgetProcessMonthlyDetail.BudgetCode, oBudgetProcessMonthlyDetail.OriginID);
this.SetObjectID(oBudgetProcessMonthlyDetail, ID.FromInteger(tc.GenerateID("BudgetProcessMonthlyDetail", "BudgetProcessMonthlyDetailID")));
BudgetProcessMonthlyDA.Insert(tc, oBudgetProcessMonthlyDetail);
nPos++;
}
#endregion
#region BudgetMonthlyCCs
foreach (BudgetMonthlyCC oBBudgetMonthlyCC in item.OBudgetMonthlyCCs)
{
oBBudgetMonthlyCC.BudgetProcessMonthlyID = item.ID;
this.SetObjectID(oBBudgetMonthlyCC, ID.FromInteger(tc.GenerateID("BudgetMonthlyCC", "BudgetMonthlyCCID")));
BudgetProcessMonthlyDA.Insert(tc, oBBudgetMonthlyCC);
}
#endregion
#endregion
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 BulkSave(ObjectsTemplate<BudgetProcessMonthly> items, TransactionContext tc,int budgetID)
{
try
{
DataTable budTable = new DataTable("BudgetProcessMonthly");
budTable.Columns.Add(new DataColumn("BudgetProcessMonthlyID", typeof(Int64)));
budTable.Columns.Add(new DataColumn("BudgetID", typeof(int)));
budTable.Columns.Add(new DataColumn("DepartmentID", typeof(int)));
budTable.Columns.Add(new DataColumn("EmployeeID", typeof(int)));
budTable.Columns.Add(new DataColumn("GradeID", typeof(int)));
budTable.Columns.Add(new DataColumn("IsConfirm", typeof(int)));
budTable.Columns.Add(new DataColumn("LocationID", typeof(int)));
budTable.Columns.Add(new DataColumn("Month", typeof(DateTime)));
budTable.Columns.Add(new DataColumn("NewJoinerID", typeof(int)));
budTable.Columns.Add(new DataColumn("NewJoinerName", typeof(string)));
budTable.Columns.Add(new DataColumn("PayrollTypeID", typeof(int)));
DataTable budDetailTable = new DataTable("BudgetProcessMonthlyDetail");
budDetailTable.Columns.Add(new DataColumn("BudgetProcessMonthlyDetailID", typeof(Int64)));
budDetailTable.Columns.Add(new DataColumn("Amount", typeof(int)));
budDetailTable.Columns.Add(new DataColumn("Changedamount", typeof(double)));
budDetailTable.Columns.Add(new DataColumn("BudgetComponentID", typeof(int)));
budDetailTable.Columns.Add(new DataColumn("BudgetProcessMonthlyID", typeof(int)));
budDetailTable.Columns.Add(new DataColumn("EmployeeID", typeof(int)));
budDetailTable.Columns.Add(new DataColumn("Month", typeof(DateTime)));
budDetailTable.Columns.Add(new DataColumn("Name", typeof(string)));
budDetailTable.Columns.Add(new DataColumn("BudgetGroup", typeof(int)));
budDetailTable.Columns.Add(new DataColumn("BudgetCode", typeof(int)));
budDetailTable.Columns.Add(new DataColumn("Position", typeof(int)));
budDetailTable.Columns.Add(new DataColumn("OriginID", typeof(int)));
int budID = tc.GenerateID("BudgetProcessMonthly", "BudgetProcessMonthlyID");
int detailID = tc.GenerateID("BudgetProcessMonthlyDetail", "BudgetProcessMonthlyDetailID");
string sConnectionName = tc.Connection.ConnectionString;
foreach (BudgetProcessMonthly item in items)
{
budTable.Rows.Add(budID, budgetID,
DataReader.GetNullValue(item.DepartmentID, IDType.Integer),
DataReader.GetNullValue(item.EmployeeID, IDType.Integer),
DataReader.GetNullValue(item.GradeID, IDType.Integer),
item.IsConfirm,
DataReader.GetNullValue(item.LocationID, IDType.Integer),
item.Month,
DataReader.GetNullValue(item.NewJoinerID, IDType.Integer),
item.NewJoinerName,
SystemInformation.CurrentSysInfo.PayrollTypeID.Integer);
foreach (BudgetProcessMonthlyDetail detail in item.OBudgetProcessMonthlyDetails)
{
//detail.Position = SetPosition(detail.BudgetCode, detail.OriginID);
budDetailTable.Rows.Add(detailID,
detail.Calculatedamount,
detail.Changedamount,
DataReader.GetNullValue(detail.BudgetComponentID, IDType.Integer),
budID,
DataReader.GetNullValue(detail.EmployeeID, IDType.Integer),
detail.Month,
detail.Name,
(int)detail.BudgetGroup,
(int)detail.BudgetCode,
detail.Position,
DataReader.GetNullValue(detail.OriginID, IDType.Integer));
detailID++;
}
budID++;
}
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sConnectionName))
{
bulkCopy.BulkCopyTimeout = 600; // in seconds
bulkCopy.DestinationTableName = "BudgetProcessMonthly";
bulkCopy.WriteToServer(budTable);
bulkCopy.DestinationTableName = "BudgetProcessMonthlyDetail";
bulkCopy.WriteToServer(budDetailTable);
}
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public int SetPosition(EnumBudgetCode eCode,ID nOriginID)
{
int nPos = 0;
foreach (BudgetTempCollection item in GlobalFunctions.GetBudetPositions())
{
if (nOriginID == null)
{
if (eCode == item.enumBudgetCode)
{
nPos = item.position;
break;
}
}
else
{
if (eCode == item.enumBudgetCode && nOriginID.Integer==item.OriginID)
{
nPos = item.position;
break;
}
}
}
return nPos;
}
public void Delete(ID nID, ID PayrollTypeID)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
#region delete childrern
BudgetProcessMonthlyDA.Delete(tc, "BudgetProcessMonthlyDetail", "BudgetProcessMonthlyID", nID);
BudgetProcessMonthlyDA.Delete(tc, "BudgetMonthlyCC", "BudgetProcessMonthlyID", nID);
#endregion
BudgetProcessMonthlyDA.Delete(tc, nID, PayrollTypeID);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
#endregion
#region Child's Service Implementation
public ObjectsTemplate<BudgetProcessMonthlyDetail> GetBudgetDetails(ID id)
{
ObjectsTemplate<BudgetProcessMonthlyDetail> oBudgetProcessMonthlyDetails;
#region Cache Header
oBudgetProcessMonthlyDetails = _cache["Get"] as ObjectsTemplate<BudgetProcessMonthlyDetail>;
if (oBudgetProcessMonthlyDetails != null)
return oBudgetProcessMonthlyDetails;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(BudgetProcessMonthlyDA.GetBudgetDetails(tc,id));
oBudgetProcessMonthlyDetails = CreateBudgetDetailObjects(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
}
#region Cache Footer
_cache.Add(oBudgetProcessMonthlyDetails, "Get");
#endregion
return oBudgetProcessMonthlyDetails;
}
public ObjectsTemplate<BudgetMonthlyCC> GetBudgetMonthlyCCs(ID id)
{
ObjectsTemplate<BudgetMonthlyCC> oBudgetMonthlyCCs;
#region Cache Header
oBudgetMonthlyCCs = _cache["Get"] as ObjectsTemplate<BudgetMonthlyCC>;
if (oBudgetMonthlyCCs != null)
return oBudgetMonthlyCCs;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(BudgetProcessMonthlyDA.GetBudgetMonthlyCCs(tc,id));
oBudgetMonthlyCCs = this.CreateBudgetMonthlyCCObjects(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
}
#region Cache Footer
_cache.Add(oBudgetMonthlyCCs, "Get");
#endregion
return oBudgetMonthlyCCs;
}
public ObjectsTemplate<BudgetMonthlyCC> GetBudgetMonthlyCCs(int nBudgetID,DateTime fromdate,DateTime todate)
{
ObjectsTemplate<BudgetMonthlyCC> oBudgetMonthlyCCs;
#region Cache Header
oBudgetMonthlyCCs = _cache["Get"] as ObjectsTemplate<BudgetMonthlyCC>;
if (oBudgetMonthlyCCs != null)
return oBudgetMonthlyCCs;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(BudgetProcessMonthlyDA.GetBudgetMonthlyCCs(tc, nBudgetID, fromdate, todate));
oBudgetMonthlyCCs = this.CreateBudgetMonthlyCCObjects(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
}
#region Cache Footer
_cache.Add(oBudgetMonthlyCCs, "Get");
#endregion
return oBudgetMonthlyCCs;
}
public ObjectsTemplate<BudgetProcessMonthlyDetail> Get(DateTime dtFrom, DateTime dtTo, int nBudID, ID PayrollTypeID)
{
#region Cache Header
ObjectsTemplate<BudgetProcessMonthlyDetail> oBudgetProcessMonthlyDetails = _cache["Get"] as ObjectsTemplate<BudgetProcessMonthlyDetail>;
if (oBudgetProcessMonthlyDetails != null)
return oBudgetProcessMonthlyDetails;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(BudgetProcessMonthlyDA.Get(tc, dtFrom, dtTo, nBudID, PayrollTypeID));
// if (oreader.Read())
//{
oBudgetProcessMonthlyDetails = CreateBudgetDetailObjects2(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
}
#region Cache Footer
_cache.Add(oBudgetProcessMonthlyDetails, "Get");
#endregion
return oBudgetProcessMonthlyDetails;
}
public ObjectsTemplate<BudgetProcessMonthlyDetail> Get2(DateTime dtFrom, DateTime dtTo, int nBudID, ID PayrollTypeID)
{
#region Cache Header
ObjectsTemplate<BudgetProcessMonthlyDetail> oBudgetProcessMonthlyDetails = _cache["Get2"] as ObjectsTemplate<BudgetProcessMonthlyDetail>;
if (oBudgetProcessMonthlyDetails != null)
return oBudgetProcessMonthlyDetails;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(BudgetProcessMonthlyDA.Get2(tc, dtFrom, dtTo, nBudID, PayrollTypeID));
// if (oreader.Read())
//{
oBudgetProcessMonthlyDetails = CreateBudgetDetailObjects3(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
}
#region Cache Footer
_cache.Add(oBudgetProcessMonthlyDetails, "Get2");
#endregion
return oBudgetProcessMonthlyDetails;
}
public ObjectsTemplate<BudgetProcessMonthlyDetail> GetCTC(DateTime dtFrom, DateTime dtTo, int nBudID)
{
#region Cache Header
ObjectsTemplate<BudgetProcessMonthlyDetail> oBudgetProcessMonthlyDetails = _cache["Get"] as ObjectsTemplate<BudgetProcessMonthlyDetail>;
if (oBudgetProcessMonthlyDetails != null)
return oBudgetProcessMonthlyDetails;
#endregion
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(BudgetProcessMonthlyDA.GetCTC(tc, dtFrom, dtTo, nBudID));
// if (oreader.Read())
//{
oBudgetProcessMonthlyDetails = CreateBudgetDetailObjects2(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
}
#region Cache Footer
_cache.Add(oBudgetProcessMonthlyDetails, "Get");
#endregion
return oBudgetProcessMonthlyDetails;
}
#endregion
#endregion
}
}