629 lines
36 KiB
C#
629 lines
36 KiB
C#
using HRM.BO;
|
|
using Ease.Core.DataAccess;
|
|
using System;
|
|
using System.Data;
|
|
|
|
|
|
namespace HRM.DA
|
|
{
|
|
internal class EmployeeBankAccountDA
|
|
{
|
|
#region Constructor
|
|
|
|
private EmployeeBankAccountDA()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Insert function
|
|
|
|
internal static void Insert(TransactionContext tc, EmployeeBankAccount item)
|
|
{
|
|
string sSQL = SQLParser.MakeSQL(
|
|
"INSERT INTO BANKACCOUNTHISTORY(EmpBankAccountID, employeeID, changeDate, accountNo,AccountType, branchID, CreatedBy, CreationDate,userid)" +
|
|
" VALUES(%n, %n, %D, %s,%n, %n, %n, %D,%n)", item.ID, item.EmployeeID, item.EffectDate, item.AccountNo,
|
|
(int)item.AccountType, item.BranchID, DataReader.GetNullValue(item.CreatedBy),
|
|
DataReader.GetNullValue(item.CreatedDate), 1);
|
|
tc.ExecuteNonQuery(sSQL);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Update function
|
|
|
|
internal static void Update(TransactionContext tc, EmployeeBankAccount item)
|
|
{
|
|
string sSQL = SQLParser.MakeSQL(
|
|
@"UPDATE BANKACCOUNTHISTORY SET employeeID=%n, changeDate=%D, accountNo=%s,AccountType=%n, branchID=%n, ModifiedBy=%n, ModifiedDate=%D
|
|
WHERE EmpBankAccountID=%n", item.EmployeeID, item.EffectDate, item.AccountNo, (int)item.AccountType,
|
|
item.BranchID, DataReader.GetNullValue(item.ModifiedBy), DataReader.GetNullValue(item.ModifiedDate),
|
|
item.ID);
|
|
tc.ExecuteNonQuery(sSQL);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
internal static IDataReader GetNotYetProcessUptoToday(TransactionContext tc)
|
|
{
|
|
string sql = SQLParser.MakeSQL("Select * from BANKACCOUNTHISTORY where IsProcessed =%b and CHANGEDATE <=%d",
|
|
false, DateTime.Today);
|
|
return tc.ExecuteReader(sql);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM BANKACCOUNTHISTORY ORDER BY CreationDAte");
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, int ID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM BANKACCOUNTHISTORY WHERE EmpBankAccountId=%n", ID);
|
|
}
|
|
|
|
internal static IDataReader Get(TransactionContext tc, int EmpID, DateTime dEffectDate, int payrollTypeID)
|
|
{
|
|
return tc.ExecuteReader(@"Select * from BANKACCOUNTHISTORY where
|
|
CHANGEDATE=(Select MAX(CHANGEDATE) from BANKACCOUNTHISTORY where EMPLOYEEID=%n and CHANGEDATE<=%d)
|
|
AND EMPLOYEEID=(Select EMPLOYEEID from.Employee where EMPLOYEEID=%n and PAYROLLTYPEID=%n) ",
|
|
EmpID, dEffectDate, EmpID, payrollTypeID);
|
|
}
|
|
|
|
internal static IDataReader GetByEmployeeID(TransactionContext tc, int ID)
|
|
{
|
|
return tc.ExecuteReader(@"Select * from BANKACCOUNTHISTORY Where EmployeeId = %n", ID);
|
|
}
|
|
|
|
internal static IDataReader GetByEmployeeIDAndType(TransactionContext tc, int ID, int AccountType)
|
|
{
|
|
return tc.ExecuteReader(@"Select * from BANKACCOUNTHISTORY Where EmployeeId = %n AND ACCOUNTTYPE = %n", ID, AccountType);
|
|
}
|
|
|
|
internal static DataSet GetEmpBankAdvice(TransactionContext tc, DateTime dateTime, string sEmpID)
|
|
|
|
{
|
|
DataSet oBankAdvices = new DataSet();
|
|
try
|
|
{
|
|
bool bfixedAmount =
|
|
new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "costcenter", "manadatoryinsalary");
|
|
|
|
var companyNameObj = new SystemConfigarationService().GetconfigValue(EnumConfigurationType.Logic, "system", "company");
|
|
string companyName = Convert.ToString(companyNameObj);
|
|
string sSQL;
|
|
//if (!bfixedAmount)
|
|
//{
|
|
// string sSQL = SQLParser.MakeSQL(@"SELECT DISTINCT E.EMPLOYEENO,E.NAME,E.EMAILADDRESS,SP.PAYMENTDATE, SM.AccountNo as AccountNo,SMD.ITEMCODE,
|
|
// SMD.ITEMGROUP,SMD.CHANGEDAMOUNT,ISNULL(CC.DESCRIPTION,'') AS CostCenter
|
|
// FROM SalaryMonthly SM
|
|
// LEFT JOIN EMPLOYEE E ON SM.EMPLOYEEID=E.EMPLOYEEID
|
|
// LEFT JOIN SALARYPROCESS SP ON SM.SALARYMONTH=SP.SALARYMONTH
|
|
// LEFT JOIN SalaryMonthlyDetail SMD ON SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
|
|
// LEFT JOIN BRANCHES as BR ON BR.BranchID=SM.BranchID
|
|
// LEFT JOIN SALARYEMPCOSTCENTER sempcc ON SM.EMPLOYEEID = sempcc.EMPLOYEEID AND SMD.SALARYMONTHLYID = sempcc.SALARYMONTHLYID
|
|
// LEFT JOIN CRG CC ON sempcc.COSTCENTERID = CC.CRGID
|
|
// WHERE SM.SalaryMonth=%d
|
|
// AND SMD.ITEMCODE=%n
|
|
// AND SMD.ITEMGROUP=%n
|
|
// AND SM.ACCOUNTNO != ''
|
|
// AND SM.EmployeeID IN(%q)
|
|
// order by E.EmployeeNo",
|
|
// dateTime, EnumSalaryItemCode.Net_Payable, EnumSalaryGroup.OtherItem, sEmpID);
|
|
|
|
// oBankAdvices = tc.ExecuteDataSet(sSQL);
|
|
//}
|
|
//else
|
|
//{
|
|
sSQL = SQLParser.MakeSQL(@"SELECT E.EMPLOYEENO,E.NAME,E.EMAILADDRESS,SM.AccountNo,SMD.ITEMCODE, SM.PAYMENTDATE,
|
|
SMD.ITEMGROUP,SMD.CHANGEDAMOUNT,'' AS CostCenter
|
|
FROM EMPLOYEE E,SalaryMonthly SM,SalaryMonthlyDetail SMD,
|
|
BRANCHES as BR
|
|
WHERE E.EMPLOYEEID=SM.EMPLOYEEID
|
|
AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
|
|
AND BR.BranchID=SM.BranchID
|
|
AND SM.SalaryMonth=%d AND SMD.ITEMCODE=%n
|
|
AND SMD.ITEMGROUP=%n
|
|
AND SM.EmployeeID IN(%q)
|
|
order by E.EmployeeNo",
|
|
dateTime, EnumSalaryItemCode.Net_Payable, EnumSalaryGroup.OtherItem, sEmpID);
|
|
|
|
oBankAdvices = tc.ExecuteDataSet(sSQL);
|
|
// }
|
|
if (companyName == "SGS Bangladesh Limited")
|
|
{
|
|
sSQL = SQLParser.MakeSQL(@"SELECT distinct E.EMPLOYEENO,E.NAME,E.EMAILADDRESS,SP.PAYMENTDATE,Case SM.categoryID when 7 then E.OutPayAccountNo Else SM.AccountNo end as AccountNo,SMD.ITEMCODE,
|
|
SMD.ITEMGROUP,SMD.CHANGEDAMOUNT--,ISNULL(CC.DESCRIPTION,'') AS CostCenter
|
|
FROM SalaryMonthly SM
|
|
LEFT JOIN EMPLOYEE E ON SM.EMPLOYEEID=E.EMPLOYEEID
|
|
LEFT JOIN SALARYPROCESS SP ON SM.SALARYMONTH=SP.SALARYMONTH
|
|
LEFT JOIN SalaryMonthlyDetail SMD ON SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
|
|
LEFT JOIN BRANCHES as BR ON BR.BranchID=SM.BranchID
|
|
LEFT JOIN SALARYEMPCOSTCENTER sempcc ON SM.EMPLOYEEID = sempcc.EMPLOYEEID AND SMD.SALARYMONTHLYID = sempcc.SALARYMONTHLYID
|
|
LEFT JOIN CRG CC ON sempcc.COSTCENTERID = CC.CRGID
|
|
WHERE E.EMPLOYEEID=SM.EMPLOYEEID
|
|
AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
|
|
AND BR.BranchID=SM.BranchID
|
|
AND SM.SalaryMonth=%d AND SMD.ITEMCODE=%n
|
|
AND SMD.ITEMGROUP=%n
|
|
AND SM.EmployeeID IN(%q)
|
|
order by E.EmployeeNo", dateTime, EnumSalaryItemCode.Net_Payable, EnumSalaryGroup.OtherItem, sEmpID);
|
|
oBankAdvices = tc.ExecuteDataSet(sSQL);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return oBankAdvices;
|
|
}
|
|
|
|
internal static DataTable GetEmpBankAdvice2(TransactionContext tc, DateTime dateTime, string sEmpID)
|
|
{
|
|
DataTable oBankAdvices = new DataTable();
|
|
try
|
|
{
|
|
//oBankAdvices = tc.ExecuteDataSet("SELECT E.EMPLOYEENO,E.NAME,E.EMAILADDRESS,BH.AccountNo,SMD.ITEMCODE,SMD.ITEMGROUP,SMD.CHANGEDAMOUNT"
|
|
// + " FROM BANKACCOUNTHISTORY BH,EMPLOYEE E,SalaryMonthly SM,SalaryMonthlyDetail SMD"
|
|
// + " WHERE SM.EMPLOYEEID=E.EMPLOYEEID AND BH.employeeID=E.EmployeeID AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID"
|
|
// + " AND BH.BranchID=E.BranchID"
|
|
// + " AND SM.SalaryMonth=%d AND SMD.ITEMCODE=%n AND SMD.ITEMGROUP=%n AND BH.EmployeeID IN(%q) order by E.EmployeeNo",
|
|
// dateTime,EnumSalaryItemCode.Net_Payable , EnumSalaryGroup.OtherItem,sEmpID );
|
|
string sMonth = "Salary_" + dateTime.ToString("MMM") + "_" + dateTime.Year;
|
|
string sMonth2 = DateTime.Today.ToString("dd/MM/yyyy");// dateTime.ToString("dd/MM/yyyy");
|
|
oBankAdvices = tc.ExecuteDataTable("SELECT E.EMPLOYEENO 'Customer Reference (16)',E.NAME 'Payee Name (35)',SM.AccountNo 'PayeeBankAccNo',SMD.CHANGEDAMOUNT 'Amount',%s 'Reason (35)',%s 'Payment Date','X0001619368401' 'Debit A/C No.',EMAILADDRESS 'Payee Email Address','' 'Payee Email Address'"
|
|
|
|
+ " FROM EMPLOYEE E,SalaryMonthly SM,SalaryMonthlyDetail SMD,BRANCHES as BR,BANKS as BA"
|
|
+ " WHERE E.EMPLOYEEID=SM.EMPLOYEEID "
|
|
+ " AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID"
|
|
+ " AND BR.BranchID=SM.BranchID"
|
|
+ " And BA.BANKID= BR.BANKID"
|
|
+ " AND SM.SalaryMonth=%d AND SMD.ITEMCODE=%n"
|
|
+ " AND SMD.ITEMGROUP=%n AND SM.EmployeeID IN(%q)"
|
|
+ " order by E.EmployeeNo",
|
|
sMonth, sMonth2, dateTime, EnumSalaryItemCode.Net_Payable, EnumSalaryGroup.OtherItem, sEmpID);
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return oBankAdvices;
|
|
}
|
|
internal static DataSet GetEmpCashAdvice(TransactionContext tc, DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oBankAdvices = new DataSet();
|
|
try
|
|
{
|
|
string sTableName;
|
|
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
|
|
|
|
bool bfixedAmount =
|
|
new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "costcenter", "manadatoryinsalary");
|
|
if (!bfixedAmount)
|
|
{
|
|
string sSQL = SQLParser.MakeSQL(
|
|
@"SELECT E.EMPLOYEENO,E.NAME,E.EMAILADDRESS,SM.AccountNo,SP.ProcessDate PaymentDate,SMD.ITEMCODE,
|
|
SMD.ITEMGROUP,SMD.CHANGEDAMOUNT
|
|
FROM EMPLOYEE E,SalaryMonthly SM,SalaryMonthlyDetail SMD,
|
|
SALARYPROCESS SP
|
|
WHERE E.EMPLOYEEID=SM.EMPLOYEEID
|
|
AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
|
|
AND SP.SALARYPROCESSID=SM.SALARYPROCESSID
|
|
AND SM.SalaryMonth=%d AND SMD.ITEMCODE=%n
|
|
AND SMD.ITEMGROUP=%n
|
|
AND SM.EmployeeID IN(%q) and e.PAYMENTMODE = %n
|
|
order by E.EmployeeNo", dateTime, EnumSalaryItemCode.Net_Payable,
|
|
EnumSalaryGroup.OtherItem, sEmpID, EnumPaymentMode.CashPayment);
|
|
|
|
oBankAdvices = tc.ExecuteDataSet(sSQL);
|
|
}
|
|
else
|
|
{
|
|
string sSQL = SQLParser.MakeSQL(
|
|
@"SELECT E.EMPLOYEENO,E.NAME,E.EMAILADDRESS,SM.AccountNo,SM.PaymentDate,SMD.ITEMCODE,
|
|
SMD.ITEMGROUP,SMD.CHANGEDAMOUNT,'' CostCenter
|
|
FROM EMPLOYEE E,SalaryMonthly SM,SalaryMonthlyDetail SMD
|
|
WHERE E.EMPLOYEEID=SM.EMPLOYEEID
|
|
AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
|
|
AND SM.SalaryMonth=%d AND SMD.ITEMCODE=%n
|
|
AND SMD.ITEMGROUP=%n
|
|
AND SM.EmployeeID IN(%q) and e.PAYMENTMODE = %n
|
|
order by E.EmployeeNo",
|
|
dateTime, EnumSalaryItemCode.Net_Payable, EnumSalaryGroup.OtherItem, sEmpID,
|
|
EnumPaymentMode.CashPayment);
|
|
|
|
oBankAdvices = tc.ExecuteDataSet(sSQL);
|
|
}
|
|
|
|
if (sTableName != "")
|
|
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return oBankAdvices;
|
|
}
|
|
|
|
internal static DataSet GetEmpOPIBankAdvice(TransactionContext tc, DateTime dateTime, string sEmpID, int bankID)
|
|
{
|
|
DataSet oBankAdvices = new DataSet();
|
|
try
|
|
{
|
|
string sTableName;
|
|
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
|
|
|
|
string sSQL = SQLParser.MakeSQL(
|
|
@"SELECT e.EmployeeNo,e.Name,od.AccountNo,Sum(odi.ChangeNetAmount) Amount
|
|
FROM.Employee e
|
|
Left Join OPIProcessDetail od on e.EmployeeID = od.EmployeeID
|
|
LEFT JOIN OPIProcess o ON od.OPIProcessID = o.OPIProcessID
|
|
LEFT JOIN OPIProcessDetailItem odi ON od.OPIProcessDetailID = odi.OPIProcessDetailID
|
|
WHERE o.OPIMonth = %d
|
|
AND odi.OPIType = %n
|
|
AND od.BankID = %n
|
|
AND od.EmployeeID IN(%q)
|
|
GROUP BY e.EmployeeNo,e.Name,od.AccountNo",
|
|
dateTime, (int)EnumOpiType.Payment, bankID, sEmpID);
|
|
|
|
oBankAdvices = tc.ExecuteDataSet(sSQL);
|
|
if (sTableName != "")
|
|
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return oBankAdvices;
|
|
}
|
|
|
|
internal static DataSet GetHNMEmpOPIBankAdvice(TransactionContext tc, DateTime dateTime, string sEmpID)
|
|
{
|
|
DataSet oBankAdvices = new DataSet();
|
|
try
|
|
{
|
|
// string sSQL = SQLParser.MakeSQL(@"SELECT e.EmployeeNo,e.Name,od.AccountNo,Sum(odi.ChangeNetAmount) Amount
|
|
// FROM.Employee e,OPIProcess o,
|
|
// OPIProcessDetail od,OPIProcessDetailItem odi
|
|
// WHERE o.OPIProcessID = od.OPIProcessID
|
|
// AND od.OPIProcessDetailID = odi.OPIProcessDetailID
|
|
// AND od.EmployeeID = e.EmployeeID
|
|
// AND od.AccountNo IS NOT NULL
|
|
// AND odi.OPIType =%n
|
|
// AND o.OPIMonth = %d
|
|
// AND od.EmployeeID IN(%q)
|
|
// GROUP BY e.EmployeeNo,e.Name,e.EMAILADDRESS,od.AccountNo",
|
|
// (int)EnumOpiType.Payment, dateTime, sEmpID);
|
|
|
|
string sTableName;
|
|
sEmpID = IDHelper.GetIDs(tc, sEmpID, out sTableName);
|
|
|
|
string sSQL = SQLParser.MakeSQL(
|
|
@"SELECT e.EmployeeNo,e.Name,od.AccountNo,cc.Code CostCenter,Sum(odi.ChangeNetAmount) Amount
|
|
FROM.Employee e
|
|
INNER Join
|
|
OPIProcessDetail od
|
|
ON od.EmployeeID = e.EmployeeID
|
|
AND od.AccountNo IS NOT NULL
|
|
AND od.EmployeeID IN(%q)
|
|
INNER Join
|
|
OPIProcessDetailItem odi
|
|
ON od.OPIProcessDetailID = odi.OPIProcessDetailID
|
|
AND odi.OPIType =%n
|
|
INNER Join
|
|
OPIProcess o
|
|
ON o.OPIProcessID = od.OPIProcessID
|
|
AND o.OPIMonth = %d
|
|
LEFT JOIN.EMPCOSTCENTER ecs
|
|
ON e.EMPLOYEEID = ecs.EMPLOYEEID
|
|
AND ecs.CurrentCC = 1
|
|
LEFT JOIN CRG cc
|
|
ON cc.CRGID = ecs.COSTCENTERID
|
|
GROUP BY e.EmployeeNo,e.Name,e.EMAILADDRESS,od.AccountNo,cc.Code",
|
|
sEmpID, (int)EnumOpiType.Payment, dateTime);
|
|
|
|
oBankAdvices = tc.ExecuteDataSet(sSQL);
|
|
if (sTableName != "")
|
|
tc.ExecuteNonQuery("Drop TAble %q", sTableName);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return oBankAdvices;
|
|
}
|
|
|
|
//internal static DataSet GetEmpExpenseAmount(TransactionContext tc, DateTime dateTime, string sEmpID)
|
|
//{
|
|
// DataSet oEmpExpenseAmount = new DataSet();
|
|
// try
|
|
// {
|
|
// SELECT e.EmployeeNo,e.Name,e.EMAILADDRESS,od.AccountNo FROM.Employee e,OPIProcess o,
|
|
//OPIProcessDetail od,OPIProcessDetailItem odi
|
|
//WHERE o.OPIProcessID = od.OPIProcessID
|
|
//AND od.OPIProcessDetailID = odi.OPIProcessDetailID
|
|
//AND od.EmployeeID = e.EmployeeID
|
|
//AND odi.OPIItemID=1
|
|
//AND o.OPIMonth = '30 Apr 2014'
|
|
|
|
// oEmpExpenseAmount = tc.ExecuteDataSet("Select EMEx.EmployeeNo,SUM(Amount) Amount from"
|
|
// + ".EmployeeMonthlyExpense EMEx where"
|
|
// + " EMEx.EmployeeNo in(%q) "
|
|
// + " and EMEx.ExpenseMonth=%d"
|
|
// + " group by EMEx.EmployeeNo",
|
|
// sEmpID,dateTime);
|
|
|
|
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// throw new Exception(ex.Message);
|
|
// }
|
|
// return oEmpExpenseAmount;
|
|
//}
|
|
|
|
internal static DataSet GetEmpBankHistory(TransactionContext tc, DateTime dateTime, int payrollTypeID)
|
|
{
|
|
DataSet oBankAdvices = new DataSet();
|
|
try
|
|
{
|
|
string sql = SQLParser.MakeSQL(
|
|
@"Select BA.EmpBankAccountID AccountID,Emp.EMPLOYEEID ID, Emp.EMPLOYEENO,Emp.NAME,B.NAME CBank,BA.ACCOUNTNO CACCOUNTNO,BR.NAME CBranch,BA.CHANGEDATE,
|
|
US.LoginID CommitedBy,BA.CreationDate from BANKACCOUNTHISTORY BA,EMPLOYEE Emp,BANKS B,
|
|
BRANCHES BR,USERS US
|
|
where BA.EMPLOYEEID=Emp.EMPLOYEEID AND B.BANKID=BR.BANKID AND BA.BRANCHID=BR.BRANCHID AND US.UserID=BA.CreatedBy
|
|
AND BA.CHANGEDATE between %d and %d ANd Emp.PayrollTypeId = %n order by Emp.EMPLOYEENO",
|
|
PayrollGlobalFunctions.PayrollFirstDateOfMonth(dateTime),
|
|
PayrollGlobalFunctions.PayrollLastDateOfMonth(dateTime), payrollTypeID);
|
|
|
|
//oBankAdvices = tc.ExecuteDataSet("Select Emp.EMPLOYEENO,Emp.NAME,B.NAME CBank,BA.ACCOUNTNO CACCOUNTNO,BR.NAME CBranch,BA.CHANGEDATE,US.LoginID CommitedBy,BA.CreationDate"
|
|
// + " from BANKACCOUNTHISTORY BA,EMPLOYEE Emp,BANKS B,BRANCHES BR,USERS US "
|
|
// + " where BA.EMPLOYEEID=Emp.EMPLOYEEID"
|
|
// + " AND B.BANKID=BR.BANKID"
|
|
// + " AND BA.BRANCHID=BR.BRANCHID"
|
|
// + " AND US.UserID=BA.CreatedBy"
|
|
// + " AND BA.CHANGEDATE between %d and %d ANd Emp.PayrollTypeId=%n"
|
|
// + " order by Emp.EMPLOYEENO",PayrollGlobalFunctions.PayrollFirstDateOfMonth(dateTime),
|
|
// PayrollGlobalFunctions.PayrollLastDateOfMonth(dateTime), SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|
oBankAdvices = tc.ExecuteDataSet(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return oBankAdvices;
|
|
}
|
|
|
|
internal static DataSet GetEmpBankHistory(TransactionContext tc, DateTime dSFromDate, DateTime dSToDate,
|
|
int payrollTypeID)
|
|
{
|
|
DataSet oBankAdvices = new DataSet();
|
|
try
|
|
{
|
|
string sql = SQLParser.MakeSQL(
|
|
@"Select BA.EmpBankAccountID AccountID,Emp.EMPLOYEEID ID, Emp.EMPLOYEENO,Emp.NAME,B.NAME CBank,BA.ACCOUNTNO CACCOUNTNO,BR.NAME CBranch,BA.CHANGEDATE,
|
|
US.LoginID CommitedBy,BA.CreationDate from BANKACCOUNTHISTORY BA,EMPLOYEE Emp,BANKS B,
|
|
BRANCHES BR,USERS US
|
|
where BA.EMPLOYEEID=Emp.EMPLOYEEID AND B.BANKID=BR.BANKID AND BA.BRANCHID=BR.BRANCHID AND US.UserID=BA.CreatedBy
|
|
AND BA.CHANGEDATE between %d and %d ANd Emp.PayrollTypeId = %n order by Emp.EMPLOYEENO",
|
|
PayrollGlobalFunctions.PayrollFirstDateOfMonth(dSFromDate),
|
|
PayrollGlobalFunctions.PayrollLastDateOfMonth(dSToDate), payrollTypeID);
|
|
|
|
//oBankAdvices = tc.ExecuteDataSet("Select Emp.EMPLOYEENO,Emp.NAME,B.NAME CBank,BA.ACCOUNTNO CACCOUNTNO,BR.NAME CBranch,BA.CHANGEDATE,US.LoginID CommitedBy,BA.CreationDate"
|
|
// + " from BANKACCOUNTHISTORY BA,EMPLOYEE Emp,BANKS B,BRANCHES BR,USERS US "
|
|
// + " where BA.EMPLOYEEID=Emp.EMPLOYEEID"
|
|
// + " AND B.BANKID=BR.BANKID"
|
|
// + " AND BA.BRANCHID=BR.BRANCHID"
|
|
// + " AND US.UserID=BA.CreatedBy"
|
|
// + " AND BA.CHANGEDATE between %d and %d ANd Emp.PayrollTypeId=%n"
|
|
// + " order by Emp.EMPLOYEENO",PayrollGlobalFunctions.PayrollFirstDateOfMonth(dateTime),
|
|
// PayrollGlobalFunctions.PayrollLastDateOfMonth(dateTime), SystemInformation.CurrentSysInfo.PayrollTypeID);
|
|
oBankAdvices = tc.ExecuteDataSet(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return oBankAdvices;
|
|
}
|
|
|
|
|
|
internal static DataSet GetEmpPrvBankHistory(TransactionContext tc, DateTime dateTime, int payrollTypeID)
|
|
{
|
|
DataSet oBankAdvices = new DataSet();
|
|
try
|
|
{
|
|
oBankAdvices = tc.ExecuteDataSet(
|
|
"Select Emp.EMPLOYEENO,Emp.NAME,B.NAME PBank,BA.ACCOUNTNO PACCOUNTNO,BR.NAME PBranch,BA.CHANGEDATE,US.UserName CommitedBy,BA.CreationDate"
|
|
+ " from BANKACCOUNTHISTORY BA,EMPLOYEE Emp,BANKS B,BRANCHES BR,USERS US "
|
|
+ " where BA.EMPLOYEEID=Emp.EMPLOYEEID"
|
|
+ " AND B.BANKID=BR.BANKID"
|
|
+ " AND BA.BRANCHID=BR.BRANCHID"
|
|
+ " AND US.UserID=BA.CreatedBy"
|
|
+ " AND BA.CHANGEDATE <%d ANd Emp.PayrollTypeiD=%n"
|
|
+ " order by Emp.EMPLOYEENO", PayrollGlobalFunctions.PayrollFirstDateOfMonth(dateTime)
|
|
, payrollTypeID);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return oBankAdvices;
|
|
}
|
|
|
|
internal static IDataReader GetByDate(TransactionContext tc, DateTime startDate, DateTime endDate,
|
|
int payrollTypeID)
|
|
{
|
|
string sql =
|
|
SQLParser.MakeSQL("Select * from BANKACCOUNTHISTORY where CHANGEDATE between %d and %d AND EmployeeID in(select EmployeeID from EMPLOYEE where PAYROLLTYPEID=%n) order by CreationDate ",
|
|
startDate, endDate, payrollTypeID);
|
|
return tc.ExecuteReader(sql);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Delete function
|
|
|
|
internal static void DeleteByBankEffectDate(TransactionContext tc, DateTime effectDate, int empID)
|
|
{
|
|
//string sSQL = SQLParser.MakeSQL("Delete from BANKACCOUNTHISTORY Where CHANGEDATE >= %d And CHANGEDATE <= (SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,%d)+1,0))) and EMPLOYEEID=%n", effectDate, effectDate, empID);
|
|
string sSQL = SQLParser.MakeSQL("Delete from BANKACCOUNTHISTORY Where CHANGEDATE >= %d and EMPLOYEEID=%n",
|
|
effectDate, empID);
|
|
tc.ExecuteNonQuery(sSQL);
|
|
}
|
|
|
|
internal static void Delete(TransactionContext tc, int ID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM BANKACCOUNTHISTORY WHERE EmpBankAccountID=%n", ID);
|
|
}
|
|
|
|
internal static void DeleteByBankEffectDate(TransactionContext tc, DateTime effectDate, int empID,
|
|
EnumBankAccountType type)
|
|
{
|
|
//string sSQL = SQLParser.MakeSQL("Delete from BANKACCOUNTHISTORY Where CHANGEDATE >= %d And CHANGEDATE <= (SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,%d)+1,0))) and EMPLOYEEID=%n", effectDate, effectDate, empID);
|
|
string sSQL =
|
|
SQLParser.MakeSQL(
|
|
"Delete from BANKACCOUNTHISTORY Where CHANGEDATE >= %d and EMPLOYEEID=%n and AccountType = %n",
|
|
effectDate, empID, (int)type);
|
|
tc.ExecuteNonQuery(sSQL);
|
|
}
|
|
internal static void DeleteByBankAccountNoEffectDate(TransactionContext tc, DateTime effectDate, int empID,
|
|
EnumBankAccountType type, string accountNo)
|
|
{
|
|
//string sSQL = SQLParser.MakeSQL("Delete from BANKACCOUNTHISTORY Where CHANGEDATE >= %d And CHANGEDATE <= (SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,%d)+1,0))) and EMPLOYEEID=%n", effectDate, effectDate, empID);
|
|
string sSQL =
|
|
SQLParser.MakeSQL(
|
|
"Delete from BANKACCOUNTHISTORY Where CHANGEDATE >= %d and EMPLOYEEID=%n and AccountType = %n and AccountNo = %s",
|
|
effectDate, empID, (int)type, accountNo);
|
|
tc.ExecuteNonQuery(sSQL);
|
|
}
|
|
|
|
internal static void DeleteAll(TransactionContext tc)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM BANKACCOUNTHISTORY");
|
|
}
|
|
|
|
#endregion
|
|
|
|
internal static DataSet GetEmpBankAdvice(TransactionContext tc, DateTime salaryMonthDate, int bankID)
|
|
{
|
|
DataSet oBankAdvices = new DataSet();
|
|
try
|
|
{
|
|
string sSQL = SQLParser.MakeSQL(
|
|
@"SELECT E.EMPLOYEENO,E.NAME,SM.AccountNo,SMD.CHANGEDAMOUNT,BR.Name Branch,BR.Code
|
|
FROM EMPLOYEE E,SalaryMonthly SM,SalaryMonthlyDetail SMD,BRANCHES BR,Banks bn
|
|
WHERE E.EMPLOYEEID=SM.EMPLOYEEID
|
|
AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
|
|
AND BR.BranchID=SM.BranchID
|
|
And bn.BankID = br.BankID
|
|
AND SM.SalaryMonth=%d AND SMD.ITEMCODE=%n
|
|
AND SMD.ITEMGROUP=%n AND bn.BankId=%n
|
|
order by E.EmployeeNo",
|
|
salaryMonthDate, EnumSalaryItemCode.Net_Payable, EnumSalaryGroup.OtherItem, bankID);
|
|
|
|
oBankAdvices = tc.ExecuteDataSet(sSQL);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return oBankAdvices;
|
|
}
|
|
|
|
internal static DataSet GetEmpOPIBankAdvice(TransactionContext tc, DateTime salaryMonthDate, int bankID)
|
|
{
|
|
DataSet oBankAdvices = new DataSet();
|
|
try
|
|
{
|
|
string sSQL = SQLParser.MakeSQL(
|
|
@"SELECT E.EMPLOYEENO,E.NAME,opd.AccountNo,Sum(opdi.ChangeNetAmount) CHANGEDAMOUNT,
|
|
BR.Name Branch,BR.Code
|
|
FROM EMPLOYEE E, OPIProcess op,OPIProcessDetail opd,OPIProcessDetailItem opdi,
|
|
BRANCHES BR,Banks bn
|
|
WHERE E.EMPLOYEEID = opd.EMPLOYEEID
|
|
AND opd.OPIProcessID = op.OPIProcessID
|
|
AND opd.OPIProcessDetailID = opdi.OPIProcessDetailID
|
|
AND BR.BranchID = opd.BranchID
|
|
And bn.BankID = br.BankID
|
|
AND op.OPIMonth = %d
|
|
AND bn.BankId = %n
|
|
GROUP BY E.EMPLOYEENO,E.NAME,opd.AccountNo,BR.Name,BR.Code
|
|
order by E.EmployeeNo",
|
|
salaryMonthDate, bankID);
|
|
|
|
oBankAdvices = tc.ExecuteDataSet(sSQL);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
return oBankAdvices;
|
|
}
|
|
|
|
internal static DataSet GetEmpBankAdviceWithRoutingNo(TransactionContext tc, DateTime dateTime, string sEmpID)
|
|
|
|
{
|
|
DataSet oBankAdvices = new DataSet();
|
|
try
|
|
{
|
|
bool bfixedAmount =
|
|
new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "costcenter", "manadatoryinsalary");
|
|
|
|
var companyNameObj = new SystemConfigarationService().GetconfigValue(EnumConfigurationType.Logic, "system", "company");
|
|
string companyName = Convert.ToString(companyNameObj);
|
|
string sSQL;
|
|
sSQL = SQLParser.MakeSQL(@"SELECT E.EMPLOYEENO,E.NAME,E.EMAILADDRESS,SM.AccountNo,SMD.ITEMCODE, SM.PAYMENTDATE,
|
|
SMD.ITEMGROUP,SMD.CHANGEDAMOUNT,'' AS CostCenter,BR.ROUTINGNO as BankRoutingNo
|
|
FROM EMPLOYEE E,SalaryMonthly SM,SalaryMonthlyDetail SMD,
|
|
BRANCHES as BR
|
|
WHERE E.EMPLOYEEID=SM.EMPLOYEEID
|
|
AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
|
|
AND BR.BranchID=SM.BranchID
|
|
AND SM.SalaryMonth=%d AND SMD.ITEMCODE=%n
|
|
AND SMD.ITEMGROUP=%n
|
|
AND SM.EmployeeID IN(%q)
|
|
order by E.EmployeeNo",
|
|
dateTime, EnumSalaryItemCode.Net_Payable, EnumSalaryGroup.OtherItem, sEmpID);
|
|
|
|
oBankAdvices = tc.ExecuteDataSet(sSQL);
|
|
if (companyName == "SGS Bangladesh Limited")
|
|
{
|
|
sSQL = SQLParser.MakeSQL(@"SELECT distinct E.EMPLOYEENO,E.NAME,E.EMAILADDRESS,SP.PAYMENTDATE,Case SM.categoryID when 7 then E.OutPayAccountNo Else SM.AccountNo end as AccountNo,SMD.ITEMCODE,
|
|
SMD.ITEMGROUP,SMD.CHANGEDAMOUNT--,ISNULL(CC.DESCRIPTION,'') AS CostCenter
|
|
FROM SalaryMonthly SM
|
|
LEFT JOIN EMPLOYEE E ON SM.EMPLOYEEID=E.EMPLOYEEID
|
|
LEFT JOIN SALARYPROCESS SP ON SM.SALARYMONTH=SP.SALARYMONTH
|
|
LEFT JOIN SalaryMonthlyDetail SMD ON SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
|
|
LEFT JOIN BRANCHES as BR ON BR.BranchID=SM.BranchID
|
|
LEFT JOIN SALARYEMPCOSTCENTER sempcc ON SM.EMPLOYEEID = sempcc.EMPLOYEEID AND SMD.SALARYMONTHLYID = sempcc.SALARYMONTHLYID
|
|
LEFT JOIN CRG CC ON sempcc.COSTCENTERID = CC.CRGID
|
|
WHERE E.EMPLOYEEID=SM.EMPLOYEEID
|
|
AND SM.SALARYMONTHLYID=SMD.SALARYMONTHLYID
|
|
AND BR.BranchID=SM.BranchID
|
|
AND SM.SalaryMonth=%d AND SMD.ITEMCODE=%n
|
|
AND SMD.ITEMGROUP=%n
|
|
AND SM.EmployeeID IN(%q)
|
|
order by E.EmployeeNo", dateTime, EnumSalaryItemCode.Net_Payable, EnumSalaryGroup.OtherItem, sEmpID);
|
|
oBankAdvices = tc.ExecuteDataSet(sSQL);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return oBankAdvices;
|
|
}
|
|
}
|
|
} |