403 lines
18 KiB
C#
403 lines
18 KiB
C#
|
using HRM.BO;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using System;
|
|||
|
using System.Data;
|
|||
|
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
#region LetterRequest
|
|||
|
|
|||
|
public class LetterRequestDA
|
|||
|
{
|
|||
|
#region Constructor
|
|||
|
|
|||
|
private LetterRequestDA() { }
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Insert function
|
|||
|
|
|||
|
internal static void Insert(TransactionContext tc, LetterRequest item)
|
|||
|
{
|
|||
|
string sql = SQLParser.MakeSQL(@"
|
|||
|
INSERT INTO LETTERREQUEST
|
|||
|
(
|
|||
|
LETTERREQUESTID,
|
|||
|
NAME,
|
|||
|
EMPLOYEEID,
|
|||
|
DESIGNATION,
|
|||
|
DEPARTMENT,
|
|||
|
PURPOSE,
|
|||
|
PURPOSENAME,
|
|||
|
ADDRESSLINE1,
|
|||
|
ADDRESSLINE2,
|
|||
|
REMARKS,
|
|||
|
FROMDATE,
|
|||
|
TODATE,
|
|||
|
ApprovalNeeded,
|
|||
|
Status,
|
|||
|
CREATEDBY,
|
|||
|
CREATIONDATE,
|
|||
|
WfStatus,
|
|||
|
COUNTRYTOVISIT,
|
|||
|
conferrencename,
|
|||
|
Organizer,
|
|||
|
Hostingcity,
|
|||
|
BankEmpDesignation,
|
|||
|
Bank,
|
|||
|
BankLocation,
|
|||
|
Barcode,VisaType,ApproverId,ApprovalDate,RejectComment,ORGANIZATIONID,ORGANIZATIONTYPE,LETTERREQUESTDATE,CountryId,PassportNo,Nationality,AddressLine3,LastWorkingDate,
|
|||
|
AuthorizedPersonId,RecipeintDesignation,IsDisgitalSinature,TripType
|
|||
|
)
|
|||
|
VALUES
|
|||
|
(
|
|||
|
%n,
|
|||
|
%s,
|
|||
|
%n,
|
|||
|
%s,
|
|||
|
%s,
|
|||
|
%n,
|
|||
|
%s,
|
|||
|
%s,
|
|||
|
%s,
|
|||
|
%s,
|
|||
|
%d,
|
|||
|
%d,
|
|||
|
%n,
|
|||
|
%n,
|
|||
|
%n,
|
|||
|
%d,
|
|||
|
%n,
|
|||
|
%s,
|
|||
|
%s,
|
|||
|
%s,
|
|||
|
%s,
|
|||
|
%s,
|
|||
|
%s,
|
|||
|
%s,
|
|||
|
%s,%n,%n,%d,%s,%n,%n,%d,%n,%s,%s,%s,%d,%n,%s,%b,%n
|
|||
|
)",
|
|||
|
item.ID, item.Name, item.EmployeeId,
|
|||
|
item.Designation, item.Department, item.Purpose, item.PurposeName, item.AddressLine1, item.AddressLine2, item.Remarks,
|
|||
|
DataReader.GetNullValue(item.FromDate), DataReader.GetNullValue(item.ToDate), item.ApprovalNeeded, item.Status,
|
|||
|
item.CreatedBy,
|
|||
|
DataReader.GetNullValue(item.CreatedDate), item.WfStatus, item.CountryToVisit, item.ConferenceName, item.Organizer, item.Hostingcity,
|
|||
|
item.BankEmpDesignation, item.Bank, item.BankLocation, item.Barcode, item.VisaType, item.ApproverId, item.ApprovalDate, item.RejectComment,item.OrganizationId,(int)item.OrganizationType,
|
|||
|
item.RequestDate,item.CountryId,item.PassportNo,item.Nationality,item.AddressLine3,item.LastWorkingDate,item.SignatoryId,item.RecipeintDesignation,item.IsDisgitalSinature,(int)item.TripType);
|
|||
|
tc.ExecuteNonQuery(sql);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Update function
|
|||
|
|
|||
|
internal static void Update(TransactionContext tc, LetterRequest item)
|
|||
|
{
|
|||
|
string sql = SQLParser.MakeSQL(@"UPDATE LETTERREQUEST
|
|||
|
SET
|
|||
|
NAME = %s,
|
|||
|
EMPLOYEEID = %n,
|
|||
|
DESIGNATION = %s,
|
|||
|
DEPARTMENT = %s,
|
|||
|
PURPOSE = %n,
|
|||
|
PURPOSENAME = %s,
|
|||
|
ADDRESSLINE1 = %s,
|
|||
|
ADDRESSLINE2 = %s,
|
|||
|
REMARKS = %s,
|
|||
|
FROMDATE = %d,
|
|||
|
TODATE = %d,
|
|||
|
ApprovalNeeded = %n,
|
|||
|
Status = %n,
|
|||
|
MODIFIEDBY = %n,
|
|||
|
MODIFIEDDATE = %d,WfStatus=%n,
|
|||
|
COUNTRYTOVISIT = %s,
|
|||
|
conferrencename = %s,
|
|||
|
Organizer = %s,
|
|||
|
Hostingcity = %s, BankEmpDesignation=%s,Bank=%s,BankLocation=%s,Barcode=%s,VisaType=%n,ApproverId=%n,ApprovalDate=%d,RejectComment=%s,ORGANIZATIONID=%n,ORGANIZATIONTYPE=%n,RecipeintDesignation=%s,IsDisgitalSinature=%b,TripType=%n WHERE LETTERREQUESTID = %n",
|
|||
|
item.Name, item.EmployeeId,
|
|||
|
item.Designation, item.Department, item.Purpose, item.PurposeName, item.AddressLine1, item.AddressLine2, item.Remarks,
|
|||
|
DataReader.GetNullValue(item.FromDate), DataReader.GetNullValue(item.ToDate),
|
|||
|
item.ApprovalNeeded, item.Status,
|
|||
|
item.ModifiedBy,
|
|||
|
DataReader.GetNullValue(item.ModifiedDate), item.WfStatus, item.CountryToVisit, item.ConferenceName, item.Organizer, item.Hostingcity,
|
|||
|
item.BankEmpDesignation, item.Bank, item.BankLocation, item.Barcode, item.VisaType, item.ApproverId, item.ApprovalDate, item.RejectComment,item.Organizer,(int)item.OrganizationType,item.RecipeintDesignation,item.IsDisgitalSinature,item.TripType,
|
|||
|
item.ID);
|
|||
|
tc.ExecuteNonQuery(sql);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get Function
|
|||
|
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, int nID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM LetterRequest where LETTERREQUESTID=%n", nID);
|
|||
|
}
|
|||
|
internal static IDataReader GetByEmployee(TransactionContext tc, int nID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM LetterRequest where EMPLOYEEID=%n", nID);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM LetterRequest");
|
|||
|
}
|
|||
|
internal static DataSet GetLetterRequests(TransactionContext tc, int id)
|
|||
|
{
|
|||
|
DataSet dSet = new DataSet();
|
|||
|
string sql = string.Empty;
|
|||
|
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT e.EMPLOYEENO EmployeeNo, e.NAME EmployeeName,l.* FROM LetterRequest l INNER JOIN EMPLOYEE e ON l.EMPLOYEEID = e.EMPLOYEEID WHERE l.EMPLOYEEID = %n ORDER BY l.LETTERREQUESTID DESC", id);
|
|||
|
|
|||
|
dSet = tc.ExecuteDataSet(sql);
|
|||
|
dSet.Tables[0].TableName = "LetterRequests";
|
|||
|
|
|||
|
return dSet;
|
|||
|
}
|
|||
|
internal static DataSet GetLetterRequestsForApproval(TransactionContext tc)
|
|||
|
{
|
|||
|
DataSet dSet = new DataSet();
|
|||
|
string sql = string.Empty;
|
|||
|
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT sg.get(e.EMPLOYEENO) EmployeeNo, sg.get(e.NAME) EmployeeName,l.* FROM LetterRequest l INNER JOIN EMPLOYEE e ON l.EMPLOYEEID = e.EMPLOYEEID WHERE l.WFSTATUS = 2 AND l.PURPOSE != 5 AND l.PURPOSE != 8");
|
|||
|
|
|||
|
dSet = tc.ExecuteDataSet(sql);
|
|||
|
dSet.Tables[0].TableName = "LetterRequests";
|
|||
|
|
|||
|
return dSet;
|
|||
|
}
|
|||
|
|
|||
|
internal static DataSet GetLetterRequestsForApprovalForSC(TransactionContext tc)
|
|||
|
{
|
|||
|
DataSet dSet = new DataSet();
|
|||
|
string sql = string.Empty;
|
|||
|
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT sg.get(e.EMPLOYEENO) EmployeeNo, sg.get(e.NAME) EmployeeName,l.* FROM LetterRequest l INNER JOIN EMPLOYEE e ON l.EMPLOYEEID = e.EMPLOYEEID WHERE l.WFSTATUS = 2 AND (l.PURPOSE = 5 OR l.PURPOSE = 8)");
|
|||
|
|
|||
|
dSet = tc.ExecuteDataSet(sql);
|
|||
|
dSet.Tables[0].TableName = "LetterRequests";
|
|||
|
|
|||
|
return dSet;
|
|||
|
}
|
|||
|
|
|||
|
internal static DataSet GetPendingLetterRequest(TransactionContext tc)
|
|||
|
{
|
|||
|
DataSet dSet = new DataSet();
|
|||
|
string sql = string.Empty;
|
|||
|
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT e.EMPLOYEENO EmployeeNo, e.NAME EmployeeName,l.* FROM LetterRequest l INNER JOIN EMPLOYEE e ON l.EMPLOYEEID = e.EMPLOYEEID WHERE (l.PURPOSE = 5 OR l.PURPOSE = 8)");
|
|||
|
|
|||
|
dSet = tc.ExecuteDataSet(sql);
|
|||
|
dSet.Tables[0].TableName = "LetterRequests";
|
|||
|
|
|||
|
return dSet;
|
|||
|
}
|
|||
|
|
|||
|
internal static DataSet GetRequestedLetterRequest(TransactionContext tc, DateTime? fromDate, DateTime? toDate,int empId)
|
|||
|
{
|
|||
|
DataSet dSet = new DataSet();
|
|||
|
string sql = string.Empty;
|
|||
|
if (fromDate != null)
|
|||
|
{
|
|||
|
sql = SQLParser.TagSQL(sql) + SQLParser.MakeSQL("CAST(l.CREATIONDATE as DATE) >= CAST(%d as Date)", fromDate);
|
|||
|
}
|
|||
|
|
|||
|
if (toDate != null)
|
|||
|
{
|
|||
|
sql = SQLParser.TagSQL(sql) + SQLParser.MakeSQL("CAST(l.CREATIONDATE as DATE) <= CAST(%d as Date)", toDate);
|
|||
|
}
|
|||
|
if (empId > 0)
|
|||
|
{
|
|||
|
sql = SQLParser.TagSQL(sql) + SQLParser.MakeSQL("e.EMPLOYEEID = %n", empId);
|
|||
|
}
|
|||
|
|
|||
|
sql = SQLParser.TagSQL(sql) + SQLParser.MakeSQL("l.PURPOSE NOT IN (5,8)"); //salary certificate && salary concern
|
|||
|
string sqlQuery = SQLParser.MakeSQL(@"SELECT e.EMPLOYEENO EmployeeNo, e.NAME EmployeeName,l.* FROM LetterRequest l INNER JOIN EMPLOYEE e ON l.EMPLOYEEID = e.EMPLOYEEID %q", sql);
|
|||
|
|
|||
|
dSet = tc.ExecuteDataSet(sqlQuery);
|
|||
|
dSet.Tables[0].TableName = "LetterRequests";
|
|||
|
|
|||
|
return dSet;
|
|||
|
}
|
|||
|
|
|||
|
internal static DataSet GetLetterRequestsHistory(TransactionContext tc, string fromDate, string toDate)
|
|||
|
{
|
|||
|
DataSet dSet = new DataSet();
|
|||
|
string sql = string.Empty;
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(fromDate) || string.IsNullOrEmpty(toDate))
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT sg.get(e.EMPLOYEENO) EmployeeNo, sg.get(e.NAME) EmployeeName,l.* FROM LetterRequest l INNER JOIN EMPLOYEE e ON l.EMPLOYEEID = e.EMPLOYEEID WHERE l.PURPOSE != 5 AND l.PURPOSE != 8 ORDER BY l.CREATIONDATE DESC, l.STATUS");
|
|||
|
else
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT sg.get(e.EMPLOYEENO) EmployeeNo, sg.get(e.NAME) EmployeeName,l.* FROM LetterRequest l INNER JOIN EMPLOYEE e ON l.EMPLOYEEID = e.EMPLOYEEID WHERE l.CREATIONDATE >= %d AND l.CREATIONDATE <= %d AND l.PURPOSE != 5 AND l.PURPOSE != 8 ORDER BY l.CREATIONDATE DESC, l.STATUS", DateTime.Parse(fromDate), DateTime.Parse(toDate));
|
|||
|
|
|||
|
dSet = tc.ExecuteDataSet(sql);
|
|||
|
dSet.Tables[0].TableName = "LetterRequests";
|
|||
|
|
|||
|
return dSet;
|
|||
|
}
|
|||
|
|
|||
|
internal static DataSet GetLetterRequestsHistoryForSc(TransactionContext tc, string fromDate, string toDate)
|
|||
|
{
|
|||
|
DataSet dSet = new DataSet();
|
|||
|
string sql = string.Empty;
|
|||
|
|
|||
|
if (string.IsNullOrEmpty(fromDate) || string.IsNullOrEmpty(toDate))
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT sg.get(e.EMPLOYEENO) EmployeeNo, sg.get(e.NAME) EmployeeName,l.* FROM LetterRequest l INNER JOIN EMPLOYEE e ON l.EMPLOYEEID = e.EMPLOYEEID WHERE (l.PURPOSE = 5 OR l.PURPOSE = 8) ORDER BY l.CREATIONDATE DESC, l.STATUS");
|
|||
|
else
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT sg.get(e.EMPLOYEENO) EmployeeNo, sg.get(e.NAME) EmployeeName,l.* FROM LetterRequest l INNER JOIN EMPLOYEE e ON l.EMPLOYEEID = e.EMPLOYEEID WHERE l.CREATIONDATE >= %d AND l.CREATIONDATE <= %d AND (l.PURPOSE = 5 OR l.PURPOSE = 8) ORDER BY l.CREATIONDATE DESC, l.STATUS", DateTime.Parse(fromDate), DateTime.Parse(toDate));
|
|||
|
|
|||
|
dSet = tc.ExecuteDataSet(sql);
|
|||
|
dSet.Tables[0].TableName = "LetterRequests";
|
|||
|
|
|||
|
return dSet;
|
|||
|
}
|
|||
|
|
|||
|
internal static DataSet GetHospital(TransactionContext tc)
|
|||
|
{
|
|||
|
DataSet dSet = new DataSet();
|
|||
|
string sql = string.Empty;
|
|||
|
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT * FROM HOSPITAL ORDER BY CODE");
|
|||
|
|
|||
|
dSet = tc.ExecuteDataSet(sql);
|
|||
|
dSet.Tables[0].TableName = "Hospital";
|
|||
|
|
|||
|
return dSet;
|
|||
|
}
|
|||
|
|
|||
|
internal static DataSet GetGrossItems(TransactionContext tc, int employeeId, DateTime salaryMonth)
|
|||
|
{
|
|||
|
DataSet dSet = new DataSet();
|
|||
|
string sql = string.Empty;
|
|||
|
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT smd.DESCRIPTION, smd.CHANGEDAMOUNT FROM SALARYMONTHLY sm INNER JOIN SALARYMONTHLYDETAIL smd
|
|||
|
ON sm.SALARYMONTHLYID = smd.SALARYMONTHLYID
|
|||
|
WHERE sm.SALARYMONTH = %d AND sm.EMPLOYEEID = %n", salaryMonth, employeeId);
|
|||
|
|
|||
|
dSet = tc.ExecuteDataSet(sql);
|
|||
|
dSet.Tables[0].TableName = "GrossItems";
|
|||
|
|
|||
|
return dSet;
|
|||
|
}
|
|||
|
|
|||
|
internal static DataSet GetDivisionOfEmployee(TransactionContext tc, string employeeNo, string divisionOrDept)
|
|||
|
{
|
|||
|
DataSet dSet = new DataSet();
|
|||
|
string sql = string.Empty;
|
|||
|
try
|
|||
|
{
|
|||
|
string machineName = "SalaryCertificateView";//Environment.MachineName;
|
|||
|
machineName = machineName.Substring(0, 5) + DateTime.Now.ToString("hhmmss"); //Environment.MachineName;
|
|||
|
EmployeeDA.CreateEmpBasicView(tc, machineName);
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT %q FROM %q WHERE EMPLOYEENO = %s", divisionOrDept, "VW_EMPLOYEEBASIC_" + machineName, employeeNo);
|
|||
|
|
|||
|
dSet = tc.ExecuteDataSet(sql);
|
|||
|
dSet.Tables[0].TableName = "EmpDivision";
|
|||
|
|
|||
|
EmployeeDA.DropEmpBasicView(tc, machineName);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
throw new Exception(ex.Message);
|
|||
|
}
|
|||
|
return dSet;
|
|||
|
}
|
|||
|
|
|||
|
internal static DataSet GetOrganization(TransactionContext tc)
|
|||
|
{
|
|||
|
DataSet dSet = new DataSet();
|
|||
|
string sql = string.Empty;
|
|||
|
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT * FROM ORGANIZATION ORDER BY CODE");
|
|||
|
|
|||
|
dSet = tc.ExecuteDataSet(sql);
|
|||
|
dSet.Tables[0].TableName = "ORGANIZATION";
|
|||
|
|
|||
|
return dSet;
|
|||
|
}
|
|||
|
|
|||
|
internal static DataSet GetOrganizationByOrganizationType(TransactionContext tc, EnumLetterOrganizationType type)
|
|||
|
{
|
|||
|
DataSet dSet = new DataSet();
|
|||
|
string sql = string.Empty;
|
|||
|
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT * FROM ORGANIZATION WHERE ORGANIZATIONTYPE = %n ORDER BY CODE", type);
|
|||
|
|
|||
|
dSet = tc.ExecuteDataSet(sql);
|
|||
|
dSet.Tables[0].TableName = "ORGANIZATION";
|
|||
|
|
|||
|
return dSet;
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete function
|
|||
|
|
|||
|
internal static void Delete(TransactionContext tc, int nID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM LetterRequest WHERE LetterRequestID=%n", nID);
|
|||
|
}
|
|||
|
|
|||
|
internal static DataSet GetHospitalInsurance(TransactionContext tc)
|
|||
|
{
|
|||
|
DataSet dSet = new DataSet();
|
|||
|
string sql = string.Empty;
|
|||
|
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT * FROM HOSPITAL WHERE TYPE IN (1,3) ORDER BY CODE");
|
|||
|
|
|||
|
dSet = tc.ExecuteDataSet(sql);
|
|||
|
dSet.Tables[0].TableName = "Hospital";
|
|||
|
|
|||
|
return dSet;
|
|||
|
}
|
|||
|
internal static DataSet GetHospitalDirect(TransactionContext tc)
|
|||
|
{
|
|||
|
DataSet dSet = new DataSet();
|
|||
|
string sql = string.Empty;
|
|||
|
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT * FROM HOSPITAL WHERE TYPE IN (2,3) ORDER BY CODE");
|
|||
|
|
|||
|
dSet = tc.ExecuteDataSet(sql);
|
|||
|
dSet.Tables[0].TableName = "Hospital";
|
|||
|
|
|||
|
return dSet;
|
|||
|
}
|
|||
|
|
|||
|
internal static void UpdateLetterRequestStatus(TransactionContext tc, int pkid, EnumLetterRequestStatus status)
|
|||
|
{
|
|||
|
string ssql = "";
|
|||
|
|
|||
|
ssql = SQLParser.MakeSQL(
|
|||
|
"UPDATE LetterRequest SET Status=%n WHERE LetterRequestID=%n",
|
|||
|
(int)status,
|
|||
|
pkid);
|
|||
|
|
|||
|
tc.ExecuteNonQuery(ssql);
|
|||
|
}
|
|||
|
|
|||
|
internal static DataSet GetLetterRequestForApproval(TransactionContext tc, int id)
|
|||
|
{
|
|||
|
DataSet dSet = new DataSet();
|
|||
|
string sql = string.Empty;
|
|||
|
|
|||
|
sql = SQLParser.MakeSQL(@"SELECT e.EMPLOYEENO EmployeeNo, e.NAME EmployeeName,d.description deptName,d2.Name Designation,
|
|||
|
org.Name Organization, l.*
|
|||
|
FROM LetterRequest l
|
|||
|
INNER JOIN EMPLOYEE e ON l.EMPLOYEEID = e.EMPLOYEEID
|
|||
|
INNER JOIN DEPARTMENT AS d ON e.DEPARTMENTID=d.DEPARTMENTID
|
|||
|
INNER JOIN DESIGNATION AS d2 ON d2.DESIGNATIONID = e.DESIGNATIONID
|
|||
|
LEFT JOIN ORGANIZATION AS org ON org.ORGANIZATIONID = l.ORGANIZATIONID
|
|||
|
WHERE l.LETTERREQUESTID =%n ORDER BY l.LETTERREQUESTID DESC", id);
|
|||
|
|
|||
|
dSet = tc.ExecuteDataSet(sql);
|
|||
|
dSet.Tables[0].TableName = "LetterRequests";
|
|||
|
|
|||
|
return dSet;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|