727 lines
26 KiB
C#
727 lines
26 KiB
C#
|
using HRM.BO;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using Ease.Core.Model;
|
|||
|
using Ease.Core.Utility;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Data;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
#region Letter Request Service
|
|||
|
|
|||
|
public class LetterRequestService : ServiceTemplate, ILetterRequestService
|
|||
|
{
|
|||
|
public LetterRequestService() { }
|
|||
|
|
|||
|
private void MapObject(LetterRequest oLetterRequest, DataReader oReader)
|
|||
|
{
|
|||
|
base.SetObjectID(oLetterRequest, oReader.GetInt32("LetterRequestID").Value);
|
|||
|
oLetterRequest.Name = oReader.GetString("Name", true, string.Empty);
|
|||
|
oLetterRequest.EmployeeId = oReader.GetInt32("EmployeeId").Value;
|
|||
|
oLetterRequest.ApproverId = oReader.GetString("ApproverId") != null ? oReader.GetInt32("ApproverId").Value : 0;
|
|||
|
oLetterRequest.Designation = oReader.GetString("Designation", true, string.Empty);
|
|||
|
oLetterRequest.Department = oReader.GetString("Department", true, string.Empty);
|
|||
|
oLetterRequest.Purpose = oReader.GetString("Purpose") != null ? (EnumLetterRequestPurpose)oReader.GetInt32("Purpose").Value : 0;
|
|||
|
oLetterRequest.PurposeName = oReader.GetString("PurposeName", true, string.Empty);
|
|||
|
oLetterRequest.AddressLine1 = oReader.GetString("AddressLine1", true, string.Empty);
|
|||
|
oLetterRequest.VisaType = oReader.GetString("VisaType") != null ? (enumLetterVisaType)oReader.GetInt32("VisaType").Value : null;
|
|||
|
oLetterRequest.AddressLine2 = oReader.GetString("AddressLine2", true, string.Empty);
|
|||
|
oLetterRequest.Remarks = oReader.GetString("Remarks", true, string.Empty);
|
|||
|
oLetterRequest.RejectComment = oReader.GetString("RejectComment", true, string.Empty);
|
|||
|
oLetterRequest.FromDate = oReader.GetString("FromDate") != null ? oReader.GetDateTime("FromDate").Value : DateTime.Now;
|
|||
|
oLetterRequest.ToDate = oReader.GetString("ToDate") != null ? oReader.GetDateTime("ToDate").Value : DateTime.Now;
|
|||
|
oLetterRequest.ApprovalNeeded = oReader.GetString("ApprovalNeeded") != null ? (EnumLetterRequestApprovalNeeded)oReader.GetInt32("ApprovalNeeded").Value : EnumLetterRequestApprovalNeeded.No;
|
|||
|
oLetterRequest.LetterRequestStatus = (EnumLetterRequestStatus)oReader.GetInt32("Status").Value;
|
|||
|
oLetterRequest.WfStatus = oReader.GetString("WfStatus") != null ? (enumwfStatus)oReader.GetInt32("WfStatus").Value : enumwfStatus.Not_yet_Initiated;
|
|||
|
oLetterRequest.PassportNo = oReader.GetString("Department", true, string.Empty);
|
|||
|
oLetterRequest.Nationality = oReader.GetString("Nationality", true, string.Empty);
|
|||
|
oLetterRequest.CountryToVisit = oReader.GetString("COUNTRYTOVISIT", true, string.Empty);
|
|||
|
oLetterRequest.ConferenceName = oReader.GetString("conferrencename", true, string.Empty);
|
|||
|
oLetterRequest.Organizer = oReader.GetString("Organizer", true, string.Empty);
|
|||
|
oLetterRequest.Hostingcity = oReader.GetString("Hostingcity", true, string.Empty);
|
|||
|
|
|||
|
oLetterRequest.BankEmpDesignation = oReader.GetString("BankEmpDesignation", true, string.Empty);
|
|||
|
oLetterRequest.Bank = oReader.GetString("Bank", true, string.Empty);
|
|||
|
oLetterRequest.BankLocation = oReader.GetString("BankLocation", true, string.Empty);
|
|||
|
oLetterRequest.Barcode = oReader.GetString("Barcode", true, string.Empty);
|
|||
|
oLetterRequest.ApprovalDate = oReader.GetDateTime("ApprovalDate");
|
|||
|
|
|||
|
oLetterRequest.CreatedBy = oReader.GetString("CreatedBy") == null ? 0 : oReader.GetInt32("CreatedBy").Value;
|
|||
|
oLetterRequest.CreatedDate = oReader.GetString("CreationDate") != null ? oReader.GetDateTime("CreationDate").Value : DateTime.Now;
|
|||
|
oLetterRequest.ModifiedBy = oReader.GetString("ModifiedBy") == null ? 0 : oReader.GetInt32("ModifiedBy").Value;
|
|||
|
oLetterRequest.ModifiedDate = oReader.GetDateTime("ModifiedDate");
|
|||
|
oLetterRequest.AddressLine3 = oReader.GetString("AddressLine3", true, string.Empty);
|
|||
|
oLetterRequest.CountryId = oReader.GetInt32("CountryId", true, 0);
|
|||
|
oLetterRequest.RequestDate = oReader.GetString("LETTERREQUESTDATE") != null ? oReader.GetDateTime("LETTERREQUESTDATE").Value : DateTime.Now;
|
|||
|
oLetterRequest.SignatoryId = oReader.GetInt32("AuthorizedPersonId", true, 0);
|
|||
|
oLetterRequest.LastWorkingDate = oReader.GetDateTime("LastWorkingDate");
|
|||
|
oLetterRequest.RecipeintDesignation = oReader.GetString("RecipeintDesignation", true, string.Empty);
|
|||
|
oLetterRequest.IsDisgitalSinature = oReader.GetBoolean("IsDisgitalSinature", true, false);
|
|||
|
oLetterRequest.TripType = oReader.GetString("TripType") != null ? (EnumLetterRequestTrip)oReader.GetInt32("TripType").Value : EnumLetterRequestTrip.None;
|
|||
|
this.SetObjectState(oLetterRequest, Ease.Core.ObjectState.Saved);
|
|||
|
}
|
|||
|
protected override T CreateObject<T>(DataReader oReader)
|
|||
|
{
|
|||
|
LetterRequest oLetterRequest = new LetterRequest();
|
|||
|
MapObject(oLetterRequest, oReader);
|
|||
|
return oLetterRequest as T;
|
|||
|
}
|
|||
|
|
|||
|
#region Service implementation
|
|||
|
public LetterRequest Get(int id)
|
|||
|
{
|
|||
|
LetterRequest oLetterRequest = null;
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
DataReader oreader = new DataReader(LetterRequestDA.Get(tc, id));
|
|||
|
if (oreader.Read())
|
|||
|
{
|
|||
|
oLetterRequest = this.CreateObject<LetterRequest>(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 oLetterRequest;
|
|||
|
}
|
|||
|
|
|||
|
public List<LetterRequest> Get()
|
|||
|
{
|
|||
|
List<LetterRequest> LetterRequests = new List<LetterRequest>();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(LetterRequestDA.Get(tc));
|
|||
|
LetterRequests = this.CreateObjects<LetterRequest>(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
|
|||
|
}
|
|||
|
return LetterRequests;
|
|||
|
}
|
|||
|
|
|||
|
public List<LetterRequest> GetByEmployee(int id)
|
|||
|
{
|
|||
|
List<LetterRequest> LetterRequests = new List<LetterRequest>();
|
|||
|
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
|
|||
|
DataReader dr = new DataReader(LetterRequestDA.GetByEmployee(tc, id));
|
|||
|
LetterRequests = this.CreateObjects<LetterRequest>(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
|
|||
|
}
|
|||
|
return LetterRequests;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetLetterRequests(int id)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = LetterRequestDA.GetLetterRequests(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
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
public DataSet GetLetterRequestsForApproval()
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = LetterRequestDA.GetLetterRequestsForApproval(tc);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetLetterRequestsForApprovalForSC()
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = LetterRequestDA.GetLetterRequestsForApprovalForSC(tc);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetLetterRequestsHistory(string fromDate, string toDate)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = LetterRequestDA.GetLetterRequestsHistory(tc, fromDate, toDate);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetPendingLetterRequestsForApproval()
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = LetterRequestDA.GetPendingLetterRequest(tc);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetRequestedLetterRequestItems(DateTime? fromDate, DateTime? toDate,int empId)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = LetterRequestDA.GetRequestedLetterRequest(tc,fromDate, toDate, empId);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetLetterRequestsHistoryForSc(string fromDate, string toDate)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = LetterRequestDA.GetLetterRequestsHistoryForSc(tc, fromDate, toDate);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetHospital()
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = LetterRequestDA.GetHospital(tc);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetGrossItems(int employeeId, DateTime salaryMonth)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = LetterRequestDA.GetGrossItems(tc, employeeId, salaryMonth);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetDivisionOfEmployee(string employeeNo, string divisionOrDept)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = LetterRequestDA.GetDivisionOfEmployee(tc, employeeNo, divisionOrDept);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetOrganization()
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = LetterRequestDA.GetOrganization(tc);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetOrganizationByOrganizationType(EnumLetterOrganizationType type)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = LetterRequestDA.GetOrganizationByOrganizationType(tc, type);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
public int Save(LetterRequest oLetterRequest)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
// needed for workflow
|
|||
|
if(oLetterRequest.SignatoryId != null && oLetterRequest.ApproverId == 0)
|
|||
|
{
|
|||
|
AuthorizedPerson op = new AuthorizedPersonService().Get((int)oLetterRequest.SignatoryId);
|
|||
|
oLetterRequest.ApproverId = op.EmployeeId;
|
|||
|
}
|
|||
|
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
if (oLetterRequest.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("LetterRequest", "LetterRequestID");
|
|||
|
//oLetterRequest.Barcode = BarcodeHelper.GenerateBarcode(EnumBarcodeFor.Letter, oLetterRequest.EmployeeNo, id);
|
|||
|
base.SetObjectID(oLetterRequest,id);
|
|||
|
LetterRequestDA.Insert(tc, oLetterRequest);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
LetterRequestDA.Update(tc, oLetterRequest);
|
|||
|
}
|
|||
|
if (oLetterRequest.LetterRequestStatus == EnumLetterRequestStatus.Submitted && Convert.ToBoolean(oLetterRequest.IsDisgitalSinature))
|
|||
|
{
|
|||
|
this.InitiateLetterRequestWorkFlow(tc, oLetterRequest, oLetterRequest.EmployeeId, oLetterRequest.CreatedBy);
|
|||
|
}
|
|||
|
|
|||
|
tc.End();
|
|||
|
return oLetterRequest.ID;
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void InitiateLetterRequestWorkFlow(TransactionContext tc, LetterRequest item, int initiateEmpID, int userID)
|
|||
|
{
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
string ClaimDesc = "";
|
|||
|
string LetterRequestNo = "";
|
|||
|
|
|||
|
LetterRequestNo = "Letter Request Type: [" + item.Purpose.ToString() + "] ," ;
|
|||
|
Employee emp = new EmployeeService().Get(tc, item.EmployeeId);
|
|||
|
if (item.LetterRequestStatus == EnumLetterRequestStatus.Submitted)
|
|||
|
{
|
|||
|
|
|||
|
//string subject = "Employee:" + emp.Name + "[ " + emp.EmployeeNo + "]" + " has raised " + ClaimDesc + " on " + item.ClaimDate.ToString() + ". Your Approval is required";
|
|||
|
string subject = "Employee:" + emp.Name + "[ " + emp.EmployeeNo + "]" + " has raised " + LetterRequestNo + " on " + item.RequestDate.ToString() + ". Your Approval is required";
|
|||
|
HRM.DA.WFManager<IworkflowInterface> om = new HRM.DA.WFManager<IworkflowInterface>(item);
|
|||
|
om.InitiateProcess(tc, initiateEmpID, item.SetupID, item.ID, "", subject);
|
|||
|
LetterRequestDA.UpdateLetterRequestStatus(tc, item.ObjectID, EnumLetterRequestStatus.Submitted);
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void SaveLetters(List<LetterRequest> oLetterRequests)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
foreach (LetterRequest oLetterRequest in oLetterRequests)
|
|||
|
{
|
|||
|
if (oLetterRequest.IsNew)
|
|||
|
{
|
|||
|
int id = tc.GenerateID("LetterRequest", "LetterRequestID");
|
|||
|
base.SetObjectID(oLetterRequest, id);
|
|||
|
LetterRequestDA.Insert(tc, oLetterRequest);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
LetterRequestDA.Update(tc, oLetterRequest);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
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);
|
|||
|
LetterRequestDA.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 DataSet GetHospitalInsurance()
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = LetterRequestDA.GetHospitalInsurance(tc);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetLetterRequestForApproval(int id)
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = LetterRequestDA.GetLetterRequestForApproval(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
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
|
|||
|
public void ApproveLetterRequest(WFMovementTran approver)
|
|||
|
{
|
|||
|
LetterRequest item = this.Get(approver.ObjectID);
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
string LetterReqDesc = string.Empty;
|
|||
|
LetterReqDesc = "Letter Request Date:" + item.RequestDate.ToString() + "[" + item.Purpose.ToString() + "]" + ",";
|
|||
|
SearchEmployee s = new SearchEmployeeService().get(approver.FromEmployeeID);
|
|||
|
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
|
|||
|
string subject = "Employee:" + s.Name + " has approved your Claim:" + LetterReqDesc;
|
|||
|
WFMovementTran newTran = new HRM.DA.WFManager<IworkflowInterface>().Approve(tc, approver.ID,
|
|||
|
approver.FromEmployeeID, approver.Remarks, subject);
|
|||
|
|
|||
|
|
|||
|
if (newTran.Status == EnumwfStatus.End)
|
|||
|
{
|
|||
|
LetterRequestDA.UpdateLetterRequestStatus(tc, newTran.ObjectID,
|
|||
|
EnumLetterRequestStatus.Approved);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
LetterRequestDA.UpdateLetterRequestStatus(tc, newTran.ObjectID,
|
|||
|
EnumLetterRequestStatus.Submitted);
|
|||
|
}
|
|||
|
|
|||
|
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 RejectLetterRequest(WFMovementTran rejectTran)
|
|||
|
{
|
|||
|
TransactionContext tc = null;
|
|||
|
LetterRequest item = this.Get(rejectTran.ObjectID);
|
|||
|
try
|
|||
|
{
|
|||
|
SearchEmployee s = new SearchEmployeeService().get(rejectTran.FromEmployeeID);
|
|||
|
|
|||
|
string LetterReqDesc = string.Empty;
|
|||
|
LetterReqDesc = "Letter Request Date:" + item.RequestDate.ToString() + "[" + item.Purpose.ToString() + "]" + ",";
|
|||
|
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
|
|||
|
string subject = "Employee:" + s.Name + " has rejected your Claim:" + LetterReqDesc;
|
|||
|
|
|||
|
|
|||
|
tc = TransactionContext.Begin(true);
|
|||
|
new HRM.DA.WFManager<IworkflowInterface>().Reject(tc, rejectTran.ID, rejectTran.FromEmployeeID, rejectTran.Remarks, subject);
|
|||
|
LetterRequestDA.UpdateLetterRequestStatus(tc, item.ID, EnumLetterRequestStatus.Rejected);
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public DataSet GetHospitalDirectPayment()
|
|||
|
{
|
|||
|
DataSet oDataSet = null;
|
|||
|
TransactionContext tc = null;
|
|||
|
try
|
|||
|
{
|
|||
|
tc = TransactionContext.Begin();
|
|||
|
oDataSet = LetterRequestDA.GetHospitalDirect(tc);
|
|||
|
|
|||
|
tc.End();
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
#region Handle Exception
|
|||
|
if (tc != null)
|
|||
|
tc.HandleError();
|
|||
|
ExceptionLog.Write(e);
|
|||
|
throw new ServiceException(e.Message, e);
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
return oDataSet;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|