HRM-10/HRM.DA/Service/FundEss/PFWithdrawalRequestService.cs

993 lines
41 KiB
C#
Raw Normal View History

2026-11-03 13:06:00 +06:00
using Ease.Core.DataAccess;
using Ease.Core.Model;
using Ease.Core.Utility;
using HRM.BO;
using HRM.BO.Configuration;
using HRM.DA.Fund;
using iTextSharp.text.pdf.qrcode;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static iTextSharp.awt.geom.Point2D;
namespace HRM.DA
{
public class PFWithdrawalRequestService : ServiceTemplate, IPFWithdrawalRequestService
{
public PFWithdrawalRequestService() { }
#region MapObject For PFWithdrawalRequest
private void MapObject(PFWithdrawalRequest pFWithdrawalRequest, DataReader oReader)
{
base.SetObjectID(pFWithdrawalRequest, oReader.GetInt32("PFWithdrawalRequestID").Value);
pFWithdrawalRequest.PFWithdrawalRequestID = oReader.GetInt32("PFWithdrawalRequestID").Value;
pFWithdrawalRequest.RequestEmployeeID = oReader.GetInt32("RequestEmployeeID").Value;
pFWithdrawalRequest.RequestMemberID = oReader.GetInt32("RequestMemberID").Value;
pFWithdrawalRequest.RequestDate = oReader.GetDateTime("RequestDate").Value;
pFWithdrawalRequest.AuditedEPF = oReader.GetDecimal("AuditedEPF").Value;
pFWithdrawalRequest.UnAuditedEPF = oReader.GetDecimal("UnAuditedEPF").Value;
pFWithdrawalRequest.AuditedCPF = oReader.GetDecimal("AuditedCPF").Value;
pFWithdrawalRequest.UnAuditedCPF = oReader.GetDecimal("UnAuditedCPF").Value;
pFWithdrawalRequest.LoanOutStanding = oReader.GetDecimal("LoanOutStanding").Value;
pFWithdrawalRequest.Lapes = oReader.GetDecimal("Lapes").Value;
pFWithdrawalRequest.PaidAmount = oReader.GetDecimal("PaidAmount").Value;
pFWithdrawalRequest.TotalAmount = oReader.GetDecimal("TotalAmount").Value;
pFWithdrawalRequest.Status = (EnumPFWithdrawalStatus)oReader.GetInt16("Status").Value;
pFWithdrawalRequest.ConfirmDate = oReader.GetDateTime("ConfirmDate");
pFWithdrawalRequest.StatusUpdateDate = oReader.GetDateTime("StatusUpdateDate");
pFWithdrawalRequest.Remarks = oReader.GetString("Remarks");
pFWithdrawalRequest.DiscontinueDate = oReader.GetDateTime("DiscontinueDate")==null?DateTime.Now : oReader.GetDateTime("DiscontinueDate");
pFWithdrawalRequest.HRApproveDate = oReader.GetDateTime("HRApproveDate");
pFWithdrawalRequest.TrusteesApproveDate = oReader.GetDateTime("trusteesapprovedate");
pFWithdrawalRequest.TrusteesID = oReader.GetInt16("trusteesid", 0);
pFWithdrawalRequest.TrusteesApproveRemarks = oReader.GetString("trusteesapproveremarks");
pFWithdrawalRequest.SecondTrusteesApproveDate = oReader.GetDateTime("secondtrusteesapprovedate");
pFWithdrawalRequest.SecondTrusteesID = oReader.GetInt16("secondtrusteesid", 0);
pFWithdrawalRequest.SecondTrusteesApproveRemarks = oReader.GetString("secondtrusteesapproveremarks");
pFWithdrawalRequest.DepositDate = oReader.GetDateTime("DepositDate");
pFWithdrawalRequest.SettleDate = oReader.GetDateTime("SettleDate");
pFWithdrawalRequest.CreatedBy = oReader.GetInt32("CreatedBy").Value;
pFWithdrawalRequest.CreatedDate = oReader.GetDateTime("CreatedDate").Value;
pFWithdrawalRequest.UpdatedBy = oReader.GetInt32("UpdatedBy");
pFWithdrawalRequest.UpdatedDate = oReader.GetDateTime("UpdatedDate");
pFWithdrawalRequest.isRejected = oReader.GetBoolean("isRejected") == null ? false : oReader.GetBoolean("isRejected").Value;
pFWithdrawalRequest.WFStatus = (EnumPFWithdrawalStatus)oReader.GetInt32("WFSTATUS", 1);
base.SetObjectState(pFWithdrawalRequest, Ease.Core.ObjectState.Saved);
}
protected override T CreateObject<T>(DataReader oReader)
{
PFWithdrawalRequest oPFWithdrawalRequest = new PFWithdrawalRequest();
MapObject(oPFWithdrawalRequest, oReader);
return oPFWithdrawalRequest as T;
}
#endregion MapObject For PFWithdrawalRequest
#region Child Object Mapping
private PfWithdrawalRequestAttachment CreatePFWithdrawalRequestAttachment(DataReader oReader)
{
PfWithdrawalRequestAttachment oPfWithdrawalRequestAttachment = new PfWithdrawalRequestAttachment();
MapPfWithdrawalRequestAttachmentObject(oPfWithdrawalRequestAttachment, oReader);
return oPfWithdrawalRequestAttachment;
}
private void MapPfWithdrawalRequestAttachmentObject(PfWithdrawalRequestAttachment oPfWithdrawalRequestAttachment, DataReader oReader)
{
SetObjectID(oPfWithdrawalRequestAttachment, oReader.GetInt32("pfwithdrawalrequestattachmentid").Value);
oPfWithdrawalRequestAttachment.PfWithdrawalRequestID = oReader.GetInt32("pfwithdrawalrequestid").Value;
oPfWithdrawalRequestAttachment.PfWithdrawalRequestDocType = (EnumDocumentType)(enumLoanDocType)oReader.GetInt32("pfwithdrawalrequestattachmentdoctype").Value;
oPfWithdrawalRequestAttachment.FileName = oReader.GetString("filename");
oPfWithdrawalRequestAttachment.FileData = oReader.GetLob("filedata");
//oPfWithdrawalRequestAttachment.FileDataString = oReader.GetString("FileDataString");
oPfWithdrawalRequestAttachment.uploadDate = oReader.GetDateTime("uploaddate").Value;
oPfWithdrawalRequestAttachment.uploadBy = oReader.GetInt32("uploadby").Value;
SetObjectState(oPfWithdrawalRequestAttachment, Ease.Core.ObjectState.Saved);
}
#endregion
#region Child LoadLoanEarlySettlementAttachment function
public PfWithdrawalRequestAttachment LoadPfWithdrawalRequestAttachment(PFWithdrawalRequest oPFWithdrawalRequest)
{
PfWithdrawalRequestAttachment oPfWithdrawalRequestAttachment = new PfWithdrawalRequestAttachment();
try
{
if (oPFWithdrawalRequest != null && oPFWithdrawalRequest.PFWithdrawalRequestID != 0)
{
DataTable dTPfWithdrawalRequestAttachment = GetPfWithdrawalRequestAttachment(oPFWithdrawalRequest.PFWithdrawalRequestID);
if (dTPfWithdrawalRequestAttachment != null && dTPfWithdrawalRequestAttachment.Rows.Count > 0)
{
foreach (DataRow dr in dTPfWithdrawalRequestAttachment.Rows)
{
Member oMember = new MemberService().Get(oPFWithdrawalRequest.RequestMemberID);
oPfWithdrawalRequestAttachment.FileName = oPFWithdrawalRequest.PfWithdrawalRequestAttachment.FileName = "EmpNo-" + oMember.EmpCode + "-" + dr["filename"].ToString();
oPfWithdrawalRequestAttachment.FileData = oPFWithdrawalRequest.PfWithdrawalRequestAttachment.FileData = (byte[])(dr["filedata"]);
oPfWithdrawalRequestAttachment.FileDataString = Convert.ToBase64String(oPFWithdrawalRequest.PfWithdrawalRequestAttachment.FileData);
//string sPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads") + "\\" + "EmpNo-" + oMember.EmpCode + "-" + oPFWithdrawalRequest.PfWithdrawalRequestAttachment.FileName;
//Byte[] FileBuffer = oPFWithdrawalRequest.PfWithdrawalRequestAttachment.FileData;
//System.IO.File.WriteAllBytes(sPath, FileBuffer);
//Process.Start(new ProcessStartInfo
//{
// FileName = sPath,
// UseShellExecute = true
//});
}
}
}
}
catch (Exception e)
{
throw e;
}
return oPfWithdrawalRequestAttachment;
}
#endregion
#region Service Implemantation
PFWithdrawalRequest IPFWithdrawalRequestService.Get(int id)
{
PFWithdrawalRequest oPFWithdrawalRequest = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PFWithdrawalRequestDA.Get(tc, id));
if (oreader.Read())
{
oPFWithdrawalRequest = this.CreateObject<PFWithdrawalRequest>(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 oPFWithdrawalRequest;
}
PFWithdrawalRequest IPFWithdrawalRequestService.GetByMemberID(int id)
{
PFWithdrawalRequest oPFWithdrawalRequest = null;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader oreader = new DataReader(PFWithdrawalRequestDA.GetByMemberID(tc, id));
if (oreader.Read())
{
oPFWithdrawalRequest = this.CreateObject<PFWithdrawalRequest>(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 oPFWithdrawalRequest;
}
public int PFWithdrawalRequestCount(int MemberID)
{
int RequestCount = 0;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
RequestCount = PFWithdrawalRequestDA.PFWithdrawalRequestCount(tc, MemberID);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return RequestCount;
}
public List<PFWithdrawalRequest> GetAll()
{
List<PFWithdrawalRequest> PFWithdrawalRequestList = new List<PFWithdrawalRequest>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(PFWithdrawalRequestDA.GetAll(tc));
PFWithdrawalRequestList = this.CreateObjects<PFWithdrawalRequest>(dr);
dr.Close();
//foreach (PFWithdrawalRequest item in PFWithdrawalRequestList)
//{
// LoadPfWithdrawalRequestAttachment(item);
//}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return PFWithdrawalRequestList;
}
public DataTable GetPfWithdrawalRequestAttachment(int PfWithdrawalRequestId)
{
DataTable dTPfWithdrawalRequestAttachment = null;
TransactionContext tc = null;
try
{
if (PfWithdrawalRequestId != 0)
{
tc = TransactionContext.Begin();
dTPfWithdrawalRequestAttachment = PFWithdrawalRequestDA.GetPfWithdrawalRequestAttachment(tc, PfWithdrawalRequestId);
tc.End();
}
}
catch (Exception e)
{
throw e;
}
return dTPfWithdrawalRequestAttachment;
}
public int Save(PFWithdrawalRequest oPFWithdrawalRequest)
{
TransactionContext tc = null;
try
{
bool isnew = false;
tc = TransactionContext.Begin(true);
if (oPFWithdrawalRequest.IsNew)
{
oPFWithdrawalRequest.WFStatus = EnumPFWithdrawalStatus.Submitted;
isnew = true;
int id = tc.GenerateID("FM_PFWithdrawalRequest", "PFWithdrawalRequestID");
base.SetObjectID(oPFWithdrawalRequest, id);
PFWithdrawalRequestDA.Insert(tc, oPFWithdrawalRequest);
}
else
{
PFWithdrawalRequestDA.Update(tc, oPFWithdrawalRequest);
}
int attid = tc.GenerateID("FM_PfWithdrawalRequestAttachment", "PfWithdrawalRequestAttachmentID");
#region Insert Childs
if (oPFWithdrawalRequest.PfWithdrawalRequestAttachment != null)
{
if (oPFWithdrawalRequest.PfWithdrawalRequestAttachment.FileData != null)
{
oPFWithdrawalRequest.PfWithdrawalRequestAttachment.PfWithdrawalRequestID = oPFWithdrawalRequest.ID;
oPFWithdrawalRequest.PfWithdrawalRequestAttachment.uploadDate = DateTime.Now;
oPFWithdrawalRequest.PfWithdrawalRequestAttachment.uploadBy = oPFWithdrawalRequest.RequestMemberID;
oPFWithdrawalRequest.PfWithdrawalRequestAttachment.ID = attid;
base.SetObjectID(oPFWithdrawalRequest.PfWithdrawalRequestAttachment, attid);
PFWithdrawalRequestDA.InsertPfWithdrawalAttachment(tc, oPFWithdrawalRequest.PfWithdrawalRequestAttachment);
attid = attid + 1;
}
else
{
oPFWithdrawalRequest.PfWithdrawalRequestAttachment.PfWithdrawalRequestID = oPFWithdrawalRequest.PFWithdrawalRequestID;
oPFWithdrawalRequest.PfWithdrawalRequestAttachment.FileData = null;
oPFWithdrawalRequest.PfWithdrawalRequestAttachment.FileName = null;
oPFWithdrawalRequest.PfWithdrawalRequestAttachment.ID = attid;
base.SetObjectID(oPFWithdrawalRequest.PfWithdrawalRequestAttachment, attid);
PFWithdrawalRequestDA.InsertPfWithdrawalAttachment(tc, oPFWithdrawalRequest.PfWithdrawalRequestAttachment);
attid = attid + 1;
}
}
if (isnew == true)
{
Member member = new Member();
member = new MemberService().Get(tc, oPFWithdrawalRequest.RequestMemberID);
string subject = member.EmpCode + "-" + member.Name + ", has applied " + " PF Withdrawal Request";
WFManager<IworkflowInterface> om = new WFManager<IworkflowInterface>(oPFWithdrawalRequest);
om.InitiateProcess(tc, oPFWithdrawalRequest.RequestEmployeeID, oPFWithdrawalRequest.SetupID, oPFWithdrawalRequest.ID, "", subject);
}
tc.End();
#endregion
return oPFWithdrawalRequest.ID;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public void ApprovePPFWithdrawalRequest(WFMovementTran approver, CurrentUser currentUser)
{
TransactionContext tc = null;
LoanApplication oloan = new LoanApplicationService().GetLoanAppById(approver.ObjectID);
Employee requestedEmp = new EmployeeService().Get(approver.FromEmployeeID);
try
{
tc = TransactionContext.Begin(true);
string approveString = currentUser.LoginID + "-" + currentUser.UserName + ", has approved " + requestedEmp.EmployeeNo + "-" + requestedEmp.Name + " PF Withdrawal request.";
WFMovementTran newTran = new WFManager<IworkflowInterface>().Approve(tc, approver.ID, approver.FromEmployeeID, approver.Remarks, approveString);
if (newTran.Status == EnumwfStatus.End)
{
PFWithdrawalRequestDA.UpdatePFWithdrawalStatus(tc, approver.ObjectID, EnumPFWithdrawalStatus.Approved);
}
else
{
PFWithdrawalRequestDA.UpdatePFWithdrawalStatus(tc, approver.ObjectID, EnumPFWithdrawalStatus.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 PFWithdrawalApplicationReject(WFMovementTran rejectTran, CurrentUser currentUser)
{
TransactionContext tc = null;
try
{
Member member = new Member();
member = new MemberService().Get(currentUser.LoginID, EnumFundType.Provident_Fund);
LoanApplication oloan = new LoanApplicationService().GetLoanAppById(rejectTran.ObjectID);
tc = TransactionContext.Begin(true);
string rejectString = member.EmpCode + "-" + member.Name + ", has rejected your PF Withdrawal request ";
new WFManager<IworkflowInterface>().Reject(tc, rejectTran.ID, rejectTran.FromEmployeeID, rejectTran.Remarks, rejectString);
PFWithdrawalRequestDA.UpdatePFWithdrawalStatus(tc, rejectTran.ObjectID, EnumPFWithdrawalStatus.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 int UpdatePfMembershipWithdrawalApproveByTrustees(PFWithdrawalRequest oPFWithdrawalRequest)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
oPFWithdrawalRequest.WFStatus = oPFWithdrawalRequest.Status;
PFWithdrawalRequestDA.UpdatePfMembershipWithdrawalApproveByTrustees(tc, oPFWithdrawalRequest);
return oPFWithdrawalRequest.PFWithdrawalRequestID;
}
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 int UpdatePfMembershipWithdrawalApproveBySecondTrustees(PFWithdrawalRequest oPFWithdrawalRequest)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
PFWithdrawalRequestDA.UpdatePfMembershipWithdrawalApproveBySecondTrustees(tc, oPFWithdrawalRequest);
return oPFWithdrawalRequest.PFWithdrawalRequestID;
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
finally
{
tc.End();
}
}
#region Send Mail
public string SendMailToPfMembershipWithdrawalApplicant(PFWithdrawalRequest oPFWithdrawalRequest, EmailSettings emailSettings)
{
var omember = new MemberService().Get(oPFWithdrawalRequest.RequestMemberID);
DataTable empInfo = new DataTable();
empInfo = new MemberService().GetDashboardMember(omember.EmpCode);
FMLoan oLoan = new FMLoanService().GetByMemberID(oPFWithdrawalRequest.RequestMemberID);
string mailAddress = empInfo.Rows[0]["EMAILADDRESS"].ToString();
string EmployeeCode = empInfo.Rows[0]["EmpCode"].ToString();
string Name = empInfo.Rows[0]["Name"].ToString();
string error = string.Empty;
string body = string.Empty;
if (oLoan != null && oLoan.EarlySettleDate != null)
{
body = "Dear <<TOEMPLOYEE>>," +
"<br/><br/>" +
"Your PF Membership Withdrawal Application is approved!The bank transaction will made within 10 working days. " +
"You are not able to apply for loan before (" + oLoan.EarlySettleDate + "). " +
"Your account will remain open for the download of documents only. No operational task will continue before PF membership." +
"<br/><br/>";
}
else
{
body = "Dear <<TOEMPLOYEE>>," +
"<br/><br/>" +
"Your PF Membership Withdrawal Application is approved!The bank transaction will made within 10 working days. " +
"Your account will remain open for the download of documents only. No operational task will continue before PF membership." +
"<br/><br/>";
}
try
{
body = body.Replace("<<TOEMPLOYEE>>", Name);
body = body.Replace("<<TOEMPLOYEEID>>", EmployeeCode);
//body = body.Replace(" <<PFLoanType>>", oLoanApplication.);
//body = body.Replace("<<FROMDATE>>", Convert.ToDateTime(item["FROMDATE"].ToString()).ToString("dd MMM yyyy"));
MailSender mailSender = new MailSender();
mailSender.AddTo(mailAddress);
mailSender.Subject = "PF Membership Withdrawal Approved";
mailSender.Body = "<p>" + body + "</p>";
mailSender.ThreadSendMail(emailSettings);
}
catch (Exception)
{
error = "Could Not Send Mail to " + Name + " [" + EmployeeCode + "]";
}
return error;
}
public string SendMailToPfMembershipWithdrawalHR(PFWithdrawalRequest oPFWithdrawalRequest, EmailSettings emailSettings, int HrID)
{
var oApplicant = new MemberService().Get((int)oPFWithdrawalRequest.RequestMemberID);
DataTable applicantInfo = new DataTable();
applicantInfo = new MemberService().GetDashboardMember(oApplicant.EmpCode);
var oHr = new MemberService().Get(HrID);
DataTable hrInfo = new DataTable();
hrInfo = new MemberService().GetDashboardMember(oHr.EmpCode);
string mailAddress = hrInfo.Rows[0]["EMAILADDRESS"].ToString();
string EmployeeCode = hrInfo.Rows[0]["EmpCode"].ToString();
string Name = hrInfo.Rows[0]["Name"].ToString();
string error = string.Empty;
string body =
"Dear <<TOEMPLOYEE>>," +
"<br/><br/>" +
"A PF Withdrawal Request has been submitted by " + applicantInfo.Rows[0]["Name"].ToString() + " [" + applicantInfo.Rows[0]["EmpCode"].ToString()
+ "]<br/>";
try
{
body = body.Replace("<<TOEMPLOYEE>>", Name);
body = body.Replace("<<TOEMPLOYEEID>>", EmployeeCode);
MailSender mailSender = new MailSender();
mailSender.AddTo(mailAddress);
mailSender.Subject = "PF Membership Withdrawal Applied";
mailSender.Body = "<p>" + body + "</p>";
mailSender.ThreadSendMail(emailSettings);
}
catch (Exception)
{
error = "Could Not Send Mail to " + Name + " [" + EmployeeCode + "]";
}
return error;
}
#endregion Send Mail
public void Delete(int id)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
PFWithdrawalRequestDA.Delete(tc, id);
}
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 DateTime getSystemDate(int id)
{
TransactionContext tc = null;
DateTime monthenddate = new DateTime();
DataTable empInfo = new DataTable();
try
{
tc = TransactionContext.Begin(true);
empInfo = PFWithdrawalRequestDA.GetMonthEndDate(tc, id).Tables[0];
monthenddate = (DateTime)empInfo.Rows[0]["LASTMONTHENDDATE"];
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
finally
{
tc.End();
}
return monthenddate;
}
public string SendRejectionMailOfEmployeeToSecondTrustee(PFWithdrawalRequest oPfWithdrawalRequest, EmailSettings emailSettings)
{
var omember = new MemberService().Get(oPfWithdrawalRequest.RequestMemberID);
Member trustee = new MemberService().Get((int)oPfWithdrawalRequest.TrusteesID);
Member secondTrustee = new MemberService().Get((int)oPfWithdrawalRequest.SecondTrusteesID);
DataTable empInfo = new DataTable();
empInfo = new MemberService().GetDashboardMember(omember.EmpCode);
DataTable secondTrusteeEmail = new DataTable();
secondTrusteeEmail = new MemberService().GetDashboardMember(secondTrustee.EmpCode);
string mailAddress = secondTrusteeEmail.Rows[0]["EMAILADDRESS"].ToString();
string EmployeeCode = empInfo.Rows[0]["EmpCode"].ToString();
string Name = empInfo.Rows[0]["Name"].ToString();
string error = string.Empty;
string body =
"Dear <<TOSECONDTRUSTEE>>," +
"<br/><br/>" +
"A PF withdrawal Request Application of <<TOEMPLOYEE>> [<<TOEMPLOYEEID>>] was rejected by <<TOTRUSTEE>>.<br/>" +
"Please go to " + emailSettings.WebAddress + " for details.<br/><br/>";
try
{
body = body.Replace("<<TOTRUSTEE>>", trustee.Name);
body = body.Replace("<<TOSECONDTRUSTEE>>", secondTrustee.Name);
body = body.Replace("<<TOEMPLOYEE>>", Name);
body = body.Replace("<<TOEMPLOYEEID>>", EmployeeCode);
MailSender mailSender = new MailSender();
mailSender.AddTo(mailAddress);
mailSender.Subject = "Employee PF Withdrawal Request Rejected";
mailSender.Body = "<p>" + body + "</p>";
mailSender.ThreadSendMail(emailSettings);
}
catch (Exception)
{
error = "Could Not Send Mail to " + Name + " [" + EmployeeCode + "]";
}
return error;
}
public string SendMailToTheRejectedPFWithdrawalRequestApplicant(PFWithdrawalRequest oPfWithdrawalRequest, EmailSettings emailSettings)
{
var omember = new MemberService().Get(oPfWithdrawalRequest.RequestMemberID);
DataTable empInfo = new DataTable();
empInfo = new MemberService().GetDashboardMember(omember.EmpCode);
string mailAddress = empInfo.Rows[0]["EMAILADDRESS"].ToString();
string EmployeeCode = empInfo.Rows[0]["EmpCode"].ToString();
string Name = empInfo.Rows[0]["Name"].ToString();
string error = string.Empty;
string body =
"Dear <<TOEMPLOYEE>>," +
"<br/><br/>" +
"Your PF Withdrawal Request Application is Rejected.<br/>" +
"Please go to " + emailSettings.WebAddress + " for details.<br/><br/>"
;
try
{
body = body.Replace("<<TOEMPLOYEE>>", Name);
body = body.Replace("<<TOEMPLOYEEID>>", EmployeeCode);
//body = body.Replace(" <<PFLoanType>>", oLoanApplication.);
//body = body.Replace("<<FROMDATE>>", Convert.ToDateTime(item["FROMDATE"].ToString()).ToString("dd MMM yyyy"));
MailSender mailSender = new MailSender();
mailSender.AddTo(mailAddress);
mailSender.Subject = "PF Withdrawal Request Rejected";
mailSender.Body = "<p>" + body + "</p>";
mailSender.ThreadSendMail(emailSettings);
}
catch (Exception)
{
error = "Could Not Send Mail to " + Name + " [" + EmployeeCode + "]";
}
return error;
}
public string SendRejectionMailOfEmployeeToTrustee(PFWithdrawalRequest oPfWithdrawalRequest, EmailSettings emailSettings)
{
var omember = new MemberService().Get(oPfWithdrawalRequest.RequestMemberID);
Member trustee = new MemberService().Get((int)oPfWithdrawalRequest.TrusteesID);
Member secondTrustee = new MemberService().Get((int)oPfWithdrawalRequest.SecondTrusteesID);
DataTable empInfo = new DataTable();
empInfo = new MemberService().GetDashboardMember(omember.EmpCode);
DataTable trusteeEmail = new DataTable();
trusteeEmail = new MemberService().GetDashboardMember(trustee.EmpCode);
string mailAddress = trusteeEmail.Rows[0]["EMAILADDRESS"].ToString();
string EmployeeCode = empInfo.Rows[0]["EmpCode"].ToString();
string Name = empInfo.Rows[0]["Name"].ToString();
string error = string.Empty;
string body =
"Dear <<TOTRUSTEE>>," +
"<br/><br/>" +
"A PF Withdrawal Request Application of <<TOEMPLOYEE>> [<<TOEMPLOYEEID>>] was rejected by <<TOSECONDTRUSTEE>>.<br/>" +
"Please go to " + emailSettings.WebAddress + " for details.<br/><br/>";
try
{
body = body.Replace("<<TOTRUSTEE>>", trustee.Name);
body = body.Replace("<<TOSECONDTRUSTEE>>", secondTrustee.Name);
body = body.Replace("<<TOEMPLOYEE>>", Name);
body = body.Replace("<<TOEMPLOYEEID>>", EmployeeCode);
MailSender mailSender = new MailSender();
mailSender.AddTo(mailAddress);
mailSender.Subject = "Employee PF Withdrawal Request Rejected";
mailSender.Body = "<p>" + body + "</p>";
mailSender.ThreadSendMail(emailSettings);
}
catch (Exception)
{
error = "Could Not Send Mail to " + Name + " [" + EmployeeCode + "]";
}
return error;
}
public string SendMailOfTheRejectedPFWithdrawalBySecondTrusteeToHR(PFWithdrawalRequest oPfWithdrawalRequest, string HrNo, EmailSettings emailSettings)
{
var omember = new MemberService().Get(oPfWithdrawalRequest.RequestMemberID);
DataTable empInfo = new DataTable();
empInfo = new MemberService().GetDashboardMember(omember.EmpCode);
DataTable hrInfo = new DataTable();
hrInfo = new MemberService().GetDashboardMember(HrNo);
Member secondTrustee = new MemberService().Get((int)oPfWithdrawalRequest.SecondTrusteesID);
string mailAddress = hrInfo.Rows[0]["EMAILADDRESS"].ToString();
string EmployeeCode = empInfo.Rows[0]["EmpCode"].ToString();
string Name = empInfo.Rows[0]["Name"].ToString();
string hrName = hrInfo.Rows[0]["Name"].ToString();
string error = string.Empty;
string body =
"Dear <<HR>>," +
"<br/><br/>" +
"A PF Withdrawal Request of <<TOEMPLOYEE>> [<<TOEMPLOYEEID>>] was rejected by <<Trustee>>.<br/>" +
"Please go to " + emailSettings.WebAddress + " for details.<br/><br/>";
try
{
body = body.Replace("<<TOEMPLOYEE>>", Name);
body = body.Replace("<<TOEMPLOYEEID>>", EmployeeCode);
body = body.Replace("<<HR>>", hrName);
body = body.Replace("<<Trustee>>", secondTrustee.Name);
//body = body.Replace(" <<PFLoanType>>", oLoanApplication.);
//body = body.Replace("<<FROMDATE>>", Convert.ToDateTime(item["FROMDATE"].ToString()).ToString("dd MMM yyyy"));
MailSender mailSender = new MailSender();
mailSender.AddTo(mailAddress);
mailSender.Subject = "PF Withdrawal Request Rejected";
mailSender.Body = "<p>" + body + "</p>";
mailSender.ThreadSendMail(emailSettings);
}
catch (Exception)
{
error = "Could Not Send Mail to " + Name + " [" + EmployeeCode + "]";
}
return error;
}
public string SendMailOfTheRejectedPFWithdrawalByFirstTrusteeToHR(PFWithdrawalRequest oPfWithdrawalRequest, string HrNo, EmailSettings emailSettings)
{
var omember = new MemberService().Get(oPfWithdrawalRequest.RequestMemberID);
DataTable empInfo = new DataTable();
empInfo = new MemberService().GetDashboardMember(omember.EmpCode);
DataTable hrInfo = new DataTable();
hrInfo = new MemberService().GetDashboardMember(HrNo);
Member firstTrustee = new MemberService().Get((int)oPfWithdrawalRequest.TrusteesID);
string mailAddress = hrInfo.Rows[0]["EMAILADDRESS"].ToString();
string EmployeeCode = empInfo.Rows[0]["EmpCode"].ToString();
string Name = empInfo.Rows[0]["Name"].ToString();
string hrName = hrInfo.Rows[0]["Name"].ToString();
string error = string.Empty;
string body =
"Dear <<HR>>," +
"<br/><br/>" +
"A PF Withdrawal Request of <<TOEMPLOYEE>> [<<TOEMPLOYEEID>>] was rejected by <<Trustee>>.<br/>" +
"Please go to " + emailSettings.WebAddress + " for details.<br/><br/>";
try
{
body = body.Replace("<<TOEMPLOYEE>>", Name);
body = body.Replace("<<TOEMPLOYEEID>>", EmployeeCode);
body = body.Replace("<<HR>>", hrName);
body = body.Replace("<<Trustee>>", firstTrustee.Name);
//body = body.Replace(" <<PFLoanType>>", oLoanApplication.);
//body = body.Replace("<<FROMDATE>>", Convert.ToDateTime(item["FROMDATE"].ToString()).ToString("dd MMM yyyy"));
MailSender mailSender = new MailSender();
mailSender.AddTo(mailAddress);
mailSender.Subject = "PF Withdrawal Request Rejected";
mailSender.Body = "<p>" + body + "</p>";
mailSender.ThreadSendMail(emailSettings);
}
catch (Exception)
{
error = "Could Not Send Mail to " + Name + " [" + EmployeeCode + "]";
}
return error;
}
public List<PFWithdrawalRequest> GetAllRequestByDateRange(DateTime FromDate, DateTime ToDate, int Status)
{
List<PFWithdrawalRequest> PFWithdrawalRequestList = new List<PFWithdrawalRequest>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(PFWithdrawalRequestDA.GetAllRequestByDateRange(tc, FromDate, ToDate, Status));
PFWithdrawalRequestList = this.CreateObjects<PFWithdrawalRequest>(dr);
dr.Close();
foreach (PFWithdrawalRequest oPFWithdrawalRequest in PFWithdrawalRequestList)
{
oPFWithdrawalRequest.Member = new MemberService().Get(oPFWithdrawalRequest.RequestMemberID);
PfWithdrawalRequestAttachment(oPFWithdrawalRequest);
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return PFWithdrawalRequestList;
}
internal void PfWithdrawalRequestAttachment(PFWithdrawalRequest oPFWithdrawalRequest)
{
try
{
if (oPFWithdrawalRequest.PFWithdrawalRequestID != 0)
{
DataTable dTPfWithdrawalRequestAttachment = GetPfWithdrawalRequestAttachment(oPFWithdrawalRequest.PFWithdrawalRequestID);
if (dTPfWithdrawalRequestAttachment != null && dTPfWithdrawalRequestAttachment.Rows.Count > 0)
{
foreach (DataRow dr in dTPfWithdrawalRequestAttachment.Rows)
{
oPFWithdrawalRequest.PfWithdrawalRequestAttachment.FileName = dr["filename"].ToString();
oPFWithdrawalRequest.PfWithdrawalRequestAttachment.FileData = (byte[])(dr["filedata"]);
oPFWithdrawalRequest.PfWithdrawalRequestAttachment.PfWithdrawalRequestDocType = (EnumDocumentType)dr["pfwithdrawalrequestdoctype"];
}
}
}
}
catch (Exception e)
{
throw e;
}
}
public void UpdatePFWRApproveByTrustees(PFWithdrawalRequest oPFWithdrawalRequest)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
PFWithdrawalRequestDA.UpdatePFWRApproveByTrustees(tc, oPFWithdrawalRequest);
}
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(PFWithdrawalRequest pfWithdrawalRequest)
{
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin(true);
PFWithdrawalRequestDA.Update(tc, pfWithdrawalRequest);
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
}
public List<PFWithdrawalRequest> GetPFWithdrawalByMemberID(int id)
{
List<PFWithdrawalRequest> PFWithdrawalRequestList = new List<PFWithdrawalRequest>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(PFWithdrawalRequestDA.GetPFWithdrawalByMemberID(tc,id));
PFWithdrawalRequestList = this.CreateObjects<PFWithdrawalRequest>(dr);
dr.Close();
foreach (PFWithdrawalRequest oPFWithdrawalRequest in PFWithdrawalRequestList)
{
PfWithdrawalRequestAttachment(oPFWithdrawalRequest);
}
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return PFWithdrawalRequestList;
}
#endregion Service Implemantation
}
}