EchoTex_Payroll/HRM.DA/DA/Basic/BankDA.cs

176 lines
8.3 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Data;
using System.Linq;
using System.Data.SqlClient;
using System.Collections.Generic;
using HRM.BO;
using Ease.Core.DataAccess;
namespace HRM.DA
{
internal class BankDA
{
#region Constructor
private BankDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, Bank item)
{
tc.ExecuteNonQuery(
"INSERT INTO Banks(BankID, Code, Name, AccountNo,ACCOUNTNOFORMAT, CreatedBy, CreationDate, SequenceNo, Status, payrolltypeid, BankAddress, ContactPerson, ContactNo)" +
" VALUES(%n, %s, %s,%s, %s, %n, %d, %n, %n, %n, %s,%s, %s)", item.ID, item.Code, item.Name, item.AccountNo,
item.Accountingformat, item.CreatedBy, item.CreatedDate, item.Sequence, item.Status, item.PayrollTypeID, item.BankAddress, item.ContactPerson, item.ContactNo);
}
internal static void ExecutePLSQL(TransactionContext tc)
{
tc.ExecuteNonQuery(@"DECLARE
CURSOR employees_Cur
IS
SELECT employeeid,departmentid
FROM employee where status=1;
pid number;
tr number;
Level1 varchar2(500);
Level2 varchar2(500);
Level3 varchar2(500);
Level4 varchar2(500);
Level5 varchar2(500);
Level6 varchar2(500);
posting varchar2(500);
BEGIN
delete from EMPCURPOS;
commit;
FOR employee_rec
IN employees_Cur
LOOP
Level1 := null;
Level2 := null;
Level3 := null;
Level4 := null;
Level5 := null;
Level6 := null;
select TIRE into tr from DEPARTMENT where DEPARTMENTID=employee_rec.departmentid;
select description into posting from DEPARTMENT where DEPARTMENTID=employee_rec.departmentid;
--DBMS_OUTPUT.put_line (tr);
if tr=1 then
select description into Level1 from DEPARTMENT where DEPARTMENTID=employee_rec.departmentid;
elsif tr=2 then
select description,parentid into Level2,pid from DEPARTMENT where DEPARTMENTID=employee_rec.departmentid;
--DBMS_OUTPUT.put_line (pid);
if pid>0 then
select description into Level1 from DEPARTMENT where DEPARTMENTID=pid;
end if;
elsif tr=3 then
select description,parentid into Level3,pid from DEPARTMENT where DEPARTMENTID=employee_rec.departmentid;
--DBMS_OUTPUT.put_line (pid);
if pid>0 then
select description,parentid into Level2,pid from DEPARTMENT where DEPARTMENTID=pid;
end if;
if pid>0 then
select description,parentid into Level1,pid from DEPARTMENT where DEPARTMENTID=pid;
end if;
elsif tr=4 then
select description,parentid into Level4,pid from DEPARTMENT where DEPARTMENTID=employee_rec.departmentid;
--DBMS_OUTPUT.put_line (pid);
if pid>0 then
select description,parentid into Level3,pid from DEPARTMENT where DEPARTMENTID=pid;
end if;
if pid>0 then
select description,parentid into Level2,pid from DEPARTMENT where DEPARTMENTID=pid;
end if;
if pid>0 then
select description,parentid into Level1,pid from DEPARTMENT where DEPARTMENTID=pid;
end if;
end if;
--select parentid into parentid from DEPARTMENT where DEPARTMENTID=employee_rec.employeeid;
--select TIRE into tire from DEPARTMENT where DEPARTMENTID=employee_rec.employeeid;
insert into EMPCURPOS values(employee_rec.employeeid,posting,Level1,Level2,Level3,Level4);
commit;
--DBMS_OUTPUT.put_line (tire ||'-'|| Level1||','|| Level2||','|| Level3||','|| Level4||','|| Level5||','|| Level6);
END LOOP;
--select * from EmpCurrentDepartment;
END; ");
}
internal static DataSet GetDataSet(TransactionContext tc)
{
return tc.ExecuteDataSet("Select * from Banks");
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, Bank item)
{
tc.ExecuteNonQuery(
"UPDATE Banks SET Code=%s, Name=%s, AccountNo = %s,ACCOUNTNOFORMAT=%s, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n,BankAddress=%s, ContactPerson=%s, ContactNo=%s" +
" WHERE BankID=%n", item.Code, item.Name, item.AccountNo, item.Accountingformat, item.ModifiedBy,
item.ModifiedDate, item.Sequence, item.Status, item.BankAddress, item.ContactPerson, item.ContactNo, item.ID);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM Banks Order By SequenceNO");
}
internal static IDataReader Get(TransactionContext tc, EnumStatus status, int payrollTypeID)
{
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
{
return tc.ExecuteReader("SELECT * FROM Banks where Status=%n and payrollTypeID = %n order by SequenceNO", status, payrollTypeID);
}
else
{
return tc.ExecuteReader("SELECT * FROM Banks where payrolltypeid=%n order by SequenceNO", payrollTypeID);
}
}
//internal static IDataReader Get(TransactionContext tc, EnumStatus status)
//{
// if (EnumStatus.Active == status || EnumStatus.Inactive == status)
// {
// return tc.ExecuteReader("SELECT * FROM Banks where Status=%n order by SequenceNO", status);
// }
// else
// {
// return tc.ExecuteReader("SELECT * FROM Banks where payrolltypeid=%n order by SequenceNO");
// }
//}
internal static IDataReader Get(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM Banks Where BankID=%n", nID);
}
internal static IDataReader GetByBrancID(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM Banks Where BankID=(Select BANKID from Branches where BranchID=%n)",
nID);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM Banks Where BankID=%n", nID);
}
#endregion
}
}