EchoTex_Payroll/HRM.DA/DA/GrievanceManagement/DAMasterDA.cs

266 lines
9.6 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Ease.Core.DataAccess;
using Ease.Core.Model;
using HRM.BO;
using static HRM.BO.DAMaster;
namespace HRM.DA
{
internal class DAMasterDA
{
#region Get
public static IDataReader Get(TransactionContext tc, int daid)
{
return tc.ExecuteReader("SELECT * FROM DAMaster Where DAMasterID = %n", daid);
}
internal static IDataReader GetDAMasterList(TransactionContext tc, DateTime? fromDate, DateTime? toDate, string daCode)
{
//DataSet dSet = new DataSet();
string sql = string.Empty;
if (fromDate != null)
{
sql = SQLParser.TagSQL(sql) + SQLParser.MakeSQL("CAST(l.DAMDATE as DATE) >= CAST(%d as Date)", fromDate);
}
if (toDate != null)
{
sql = SQLParser.TagSQL(sql) + SQLParser.MakeSQL("CAST(l.DAMDATE as DATE) <= CAST(%d as Date)", toDate);
}
if (daCode != null)
{
sql = SQLParser.TagSQL(sql) + SQLParser.MakeSQL("l.DAMCODE = %s", daCode);
}
string sqlQuery = SQLParser.MakeSQL(@"SELECT * FROM DAMASTER l %q", sql);
return tc.ExecuteReader(sqlQuery);
}
public static IDataReader Get(TransactionContext tc, string code)
{
return tc.ExecuteReader("SELECT * FROM DAMaster Where DAMCODE = %s", code);
}
public static IDataReader GetDAs(TransactionContext tc, string sql)
{
return tc.ExecuteReader(sql);
}
#region Childs Get
public static IDataReader GetDAEmployees(TransactionContext tc, int id)
{
string sql = string.Empty;
if (id != 0)
{
sql = SQLParser.TagSQL(sql) + SQLParser.MakeSQL("emp.EMPLOYEEID = %n", id);
}
string sqlQuery = SQLParser.MakeSQL(@"Select d.DAEMPID, d.DAID, emp.EMPLOYEENO, emp.NAME, dsg.NAME DESIGNATION From DAEMPLOYEE d"
+" INNER JOIN EMPLOYEE emp ON emp.EMPLOYEEID = d.EMPLOYEEID"
+" INNER JOIN DESIGNATION dsg ON emp.DESIGNATIONID=dsg.DESIGNATIONID %q", sql);
return tc.ExecuteReader(sqlQuery);
}
public static IDataReader GetDAComplains(TransactionContext tc, int id)
{
return tc.ExecuteReader("Select * from DAComplain where DAID = %n", id);
}
public static IDataReader GetDAEmpExplanations(TransactionContext tc, int id)
{
return tc.ExecuteReader("Select * from DAEmpExplanation where DAID = %n", id);
}
public static IDataReader GetDAPunishments(TransactionContext tc, int id)
{
return tc.ExecuteReader("Select * from DAPunishment where DAID = %n", id);
}
public static IDataReader GetDAComEmps(TransactionContext tc, int id)
{
return tc.ExecuteReader("select * from DAComEmp where DAID = %n", id);
}
public static IDataReader GetDAPEmployees(TransactionContext tc, int id)
{
return tc.ExecuteReader("select * from DAPEmployee where PID = %n", id);
}
public static IDataReader GetDAPRIEmps(TransactionContext tc, int id)
{
return tc.ExecuteReader("select * from DAPRIEmp where DAID = %n", id);
}
#endregion
#endregion
#region Insert
public static void Insert(TransactionContext tc, DAMaster item)
{
string sql = SQLParser.MakeSQL("INSERT INTO DAMaster(DAMasterID,DACNote,DACOMFileName,DAMCode,DAMDate,DAMFileName,DAMNote,DAPRIFileName,DCDate,DPRIDate,DACSheetFileName,DACSheetNote,DCSheetDate)" +
" VALUES(%n, %s, %s, %s, %d, %s, %s, %s, %d, %d,%s,%s,%d)",
item.ID, item.DACNote, item.DACOMFileName,
item.DAMCode, item.DAMDate,
item.DAMFileName, item.DAMNote, item.DAPRIFileName,
item.DCDate, item.DPRIDate, item.DACSheetFileName, item.DACSheetNote, item.DCSheetDate);
tc.ExecuteNonQuery(sql);
}
#region Insert Child
public static void InsertDAEmployee(TransactionContext tc, DAEmployee item)
{
string sql = SQLParser.MakeSQL
(@"Insert into DAEmployee(DAEMPID,DAID,EmployeeID) VALUES(%n,%n,%n)",
item.ID, item.DAID, item.EmployeeID);
tc.ExecuteNonQuery(sql);
}
public static void InsertDAComplain(TransactionContext tc, DAComplain item)
{
string sql = SQLParser.MakeSQL
(@"Insert into DAComplain(DACompID,DAID,ComplainID) VALUES(%n,%n,%n)",
item.ID, item.DAID, item.ComplainID);
tc.ExecuteNonQuery(sql);
}
public static void InsertDAEmpExplanation(TransactionContext tc, DAEmpExplanation item)
{
string sql = SQLParser.MakeSQL
(@"Insert into DAEmpExplanation(DAExpID,DAID,DAEXNote,DAEXDate
,EmployeeID,FileName) VALUES(%n,%n,%s,%d,%n,%s)",
item.ID, item.DAID, item.DAEXNote,
item.DAEXDate, item.EmployeeID, item.FileName);
tc.ExecuteNonQuery(sql);
}
public static void InsertDAPunishment(TransactionContext tc, DAPunishment item)
{
string sql = SQLParser.MakeSQL
(@"Insert into DAPunishment(DAPID,DAID,DAPDate,DAPFromDate
,DAPToDate,DAPNote,EmployeeID,DAPFileName) VALUES(%n,%n,%d,%d,%d,%s,%n,%s)",
item.ID, item.DAID, item.DAPDate,
item.DAPFromDate, item.DAPToDate, item.DAPNote,
item.EmployeeID, item.DAPFileName);
tc.ExecuteNonQuery(sql);
}
public static void InsertDAComEmp(TransactionContext tc, DAComEmp item)
{
string sql = SQLParser.MakeSQL
(@"Insert into DAComEmp(DACEID,DAID,EMPLOYEEID)
VALUES(%n,%n,%n)",
item.ID, item.DAID, item.EmployeeID);
tc.ExecuteNonQuery(sql);
}
public static void InsertDAPEmployee(TransactionContext tc, DAPEmployee item)
{
string sql = SQLParser.MakeSQL
(@"Insert into DAPEmployee(DAPEID,DAID,EmpID,PID
,PunishmentID) VALUES(%n,%n,%n,%n,%n)",
item.ID, item.DAID, item.EmpID,
item.PID, item.PunishmentID);
tc.ExecuteNonQuery(sql);
}
public static void InsertDAPRIEmp(TransactionContext tc, DAPRIEmp item)
{
string sql = SQLParser.MakeSQL
(@"Insert into DAPRIEmp(DAPRIID,DAID,EmployeeID)
VALUES(%n,%n,%n)",
item.ID, item.DAID, item.EmployeeID);
tc.ExecuteNonQuery(sql);
}
#endregion
#endregion
#region Update
public static void Update(TransactionContext tc, DAMaster item)
{
string sql =
SQLParser.MakeSQL(
"Update DAMaster SET DACNote=%s,DACOMFileName=%s,DAMCode=%s,DAMDate=%d,DAMFileName=%s,DAMNote=%s,DAPRIFileName=%s,DCDate=%d,DPRIDate=%d,DACSheetFileName=%s,DACSheetNote=%s,DCSheetDate=%d " +
"Where DAMAsterID=%n",
item.DACNote, item.DACOMFileName,
item.DAMCode, item.DAMDate,
item.DAMFileName, item.DAMNote, item.DAPRIFileName,
item.DCDate, item.DPRIDate, item.DACSheetFileName, item.DACSheetNote, item.DCSheetDate, item.ID);
tc.ExecuteNonQuery(sql);
}
#endregion
#region Delete
public static void Delete(TransactionContext tc, int id)
{
tc.ExecuteNonQuery("Delete From DAMaster Where DAMasterID=%n", id);
}
#region Child Delete
public static void DeleteDAEmployee(TransactionContext tc, int id)
{
tc.ExecuteNonQuery("Delete from DAEmployee where DAEMPID=%n", id);
}
public static void DeleteDAComplains(TransactionContext tc, int id)
{
tc.ExecuteNonQuery("Delete from DAComplain where DAID=%n", id);
}
public static void DeleteDAEmpExplanations(TransactionContext tc, int id)
{
tc.ExecuteNonQuery("Delete from DAEmpExplanation where DAID=%n", id);
}
public static void DeleteDAPunishments(TransactionContext tc, int id)
{
tc.ExecuteNonQuery("Delete from DAPunishment where DAID=%n", id);
}
public static void DeleteDAComEmps(TransactionContext tc, int id)
{
tc.ExecuteNonQuery("Delete from DAComEmp where DAID=%n", id);
}
public static void DeleteDAPEmployees(TransactionContext tc, int id)
{
tc.ExecuteNonQuery("Delete from DAPEmployee where DAID=%n", id);
}
public static void DeleteDAPRIEmps(TransactionContext tc, int id)
{
tc.ExecuteNonQuery("Delete from DAPRIEmp where DAID=%n", id);
}
#endregion
#endregion
#region Check
public static bool CheckDAMasterDuplicateCode(TransactionContext tc, string damCode)
{
if (((int)tc.ExecuteScalar("Select Count(*) from DAMaster where DAMCODE=%s", damCode)) == 0)
{
return false;
}
return true;
}
#endregion
}
}