317 lines
9.6 KiB
C#
317 lines
9.6 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using Ease.CoreV35;
|
|
using Ease.CoreV35.Model;
|
|
using Ease.CoreV35.DataAccess;
|
|
using System.Collections.Generic;
|
|
using Payroll.BO;
|
|
using Ease.CoreV35.Caching;
|
|
|
|
namespace Payroll.Service
|
|
{
|
|
#region TaxChallan Service
|
|
[Serializable]
|
|
public class TaxChallanService : ServiceTemplate, ITaxChallanService
|
|
{
|
|
#region Private functions and declaration
|
|
Cache _cache = new Cache(typeof(TaxChallan));
|
|
|
|
#endregion
|
|
public TaxChallanService() { }
|
|
|
|
private void MapObject(TaxChallan oTaxChallan, DataReader oReader)
|
|
{
|
|
base.SetObjectID(oTaxChallan, oReader.GetID("ChallenID"));
|
|
oTaxChallan.SalaryMonthly = oReader.GetDateTime("salaryMonthly").Value;
|
|
oTaxChallan.EmployeeID = oReader.GetID("employeeID");
|
|
oTaxChallan.TaxParameterID = oReader.GetID("taxParamID");
|
|
oTaxChallan.ChallanNo = oReader.GetString("challenNo");
|
|
oTaxChallan.Amount = oReader.GetDouble("amount").Value;
|
|
oTaxChallan.DepositDate = oReader.GetDateTime("depositDate").Value;
|
|
oTaxChallan.CreatedBy = ID.FromInteger(oReader.GetInt32("CreatedBy").GetValueOrDefault());
|
|
oTaxChallan.CreatedDate = oReader.GetDateTime("CreationDate").GetValueOrDefault();
|
|
oTaxChallan.ModifiedBy = ID.FromInteger(oReader.GetInt32("ModifiedBy").GetValueOrDefault());
|
|
oTaxChallan.ModifiedDate = oReader.GetDateTime("ModifiedDate").GetValueOrDefault();
|
|
this.SetObjectState(oTaxChallan, Ease.CoreV35.ObjectState.Saved);
|
|
}
|
|
protected override T CreateObject<T>(DataReader oReader)
|
|
{
|
|
TaxChallan oTaxChallan = new TaxChallan();
|
|
MapObject(oTaxChallan, oReader);
|
|
return oTaxChallan as T;
|
|
}
|
|
protected TaxChallan CreateObject(DataReader oReader)
|
|
{
|
|
TaxChallan oTaxChallan = new TaxChallan();
|
|
MapObject(oTaxChallan, oReader);
|
|
return oTaxChallan;
|
|
}
|
|
#region Service implementation
|
|
public TaxChallan Get(ID id)
|
|
{
|
|
TaxChallan oTaxChallan = new TaxChallan();
|
|
#region Cache Header
|
|
oTaxChallan = _cache["Get", id] as TaxChallan;
|
|
if (oTaxChallan != null)
|
|
return oTaxChallan;
|
|
#endregion
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
DataReader oreader = new DataReader(TaxChallanDA.Get(tc, id));
|
|
if (oreader.Read())
|
|
{
|
|
oTaxChallan = this.CreateObject<TaxChallan>(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(oTaxChallan, "Get", id);
|
|
#endregion
|
|
return oTaxChallan;
|
|
}
|
|
|
|
public ObjectsTemplate<TaxChallan> Get()
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<TaxChallan> taxChallans = _cache["Get"] as ObjectsTemplate<TaxChallan>;
|
|
if (taxChallans != null)
|
|
return taxChallans;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(TaxChallanDA.Get(tc));
|
|
taxChallans = this.CreateObjects<TaxChallan>(dr);
|
|
dr.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(taxChallans, "Get");
|
|
|
|
#endregion
|
|
|
|
return taxChallans;
|
|
}
|
|
|
|
public ObjectsTemplate<TaxChallan> Get(ID nEmpID,ID nTaxParamID)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<TaxChallan> taxChallans = _cache["Get",nEmpID,nTaxParamID] as ObjectsTemplate<TaxChallan>;
|
|
if (taxChallans != null)
|
|
return taxChallans;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(TaxChallanDA.Get(tc,nEmpID,nTaxParamID));
|
|
taxChallans = this.CreateObjects<TaxChallan>(dr);
|
|
dr.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(taxChallans, "Get",nEmpID,nTaxParamID);
|
|
|
|
#endregion
|
|
|
|
return taxChallans;
|
|
}
|
|
|
|
//Tax Challan From Old Table
|
|
public ObjectsTemplate<TaxChallan> GetOldTaxChallan(ID nEmpID, ID nTaxParamID)
|
|
{
|
|
#region Cache Header
|
|
|
|
ObjectsTemplate<TaxChallan> taxChallans = _cache["GetOldTaxChallan", nEmpID, nTaxParamID] as ObjectsTemplate<TaxChallan>;
|
|
if (taxChallans != null)
|
|
return taxChallans;
|
|
|
|
#endregion
|
|
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataReader dr = new DataReader(TaxChallanDA.GetOldTaxChallan(tc, nEmpID, nTaxParamID));
|
|
taxChallans = this.CreateObjects<TaxChallan>(dr);
|
|
dr.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(taxChallans, "GetOldTaxChallan", nEmpID, nTaxParamID);
|
|
|
|
#endregion
|
|
|
|
return taxChallans;
|
|
}
|
|
|
|
public ID Save(TaxChallan oTaxChallan)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
if (oTaxChallan.IsNew)
|
|
{
|
|
int id = tc.GenerateID("TaxChallan", "ChallenID");
|
|
base.SetObjectID(oTaxChallan, ID.FromInteger(id));
|
|
TaxChallanDA.DeleteByEmpIDandChallanNo(tc,oTaxChallan.EmployeeID.Integer, oTaxChallan.ChallanNo);
|
|
TaxChallanDA.Insert(tc, oTaxChallan);
|
|
}
|
|
else
|
|
{
|
|
TaxChallanDA.Update(tc, oTaxChallan);
|
|
}
|
|
tc.End();
|
|
return oTaxChallan.ID;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
public void Delete(ID id)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
TaxChallanDA.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 void DeleteAllByTaxparamID(int nTaxparamID)
|
|
{
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin(true);
|
|
TaxChallanDA.DeleteAllByTaxparamID(tc, nTaxparamID);
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
throw new ServiceException(e.Message, e);
|
|
#endregion
|
|
}
|
|
}
|
|
public DataTable GetChalaCountByTaxParamID(int nTaxParamID)
|
|
{
|
|
DataTable dataTableChalanCount = new DataTable("ChalanCount");
|
|
TransactionContext tc = null;
|
|
try
|
|
{
|
|
tc = TransactionContext.Begin();
|
|
|
|
DataSet dataSet = TaxChallanDA.GetChalaCountByTaxParamID(tc, nTaxParamID);
|
|
dataTableChalanCount = dataSet.Tables[0];
|
|
dataSet.Dispose();
|
|
tc.End();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
#region Handle Exception
|
|
|
|
if (tc != null)
|
|
tc.HandleError();
|
|
ExceptionLog.Write(e);
|
|
|
|
throw new ServiceException(e.Message, e);
|
|
|
|
#endregion
|
|
}
|
|
return dataTableChalanCount;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
#endregion
|
|
}
|