EchoTex_Payroll/HRM.DA/DA/Vendor/VendorDA.cs

84 lines
3.5 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using HRM.BO;
using Ease.Core.DataAccess;
using System;
using System.Collections.Generic;
using System.Data;
namespace HRM.DA
{
internal class VendorDA
{
internal static IDataReader Get(TransactionContext tc, int id)
{
return tc.ExecuteReader("SELECT * FROM Vendor where VendorID=%n", id);
}
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM Vendor");
}
internal static IDataReader Get(TransactionContext tc, EnumVendorType vendorType)
{
return tc.ExecuteReader("SELECT * FROM Vendor where VendorType=%n", (int)vendorType);
}
//internal static IDataReader Get(TransactionContext tc, EnumStatus status)
//{
// if (status == EnumStatus.Regardless)
// {
// return tc.ExecuteReader("SELECT * FROM Vendor");
// }
// return tc.ExecuteReader("SELECT * FROM Vendor where Status=%n", (int)status);
//}
internal static IDataReader Get(TransactionContext tc, EnumStatus status, int payrollTypeID)
{
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
{
return tc.ExecuteReader(
@"SELECT d.* FROM Vendor d where d.status=%n and d.PayrollTypeID=%n order by d.Code",
status, payrollTypeID);
}
else
{
return tc.ExecuteReader(
@"SELECT d.* FROM Vendor d Where d.PayrollTypeID=%n order by d.Code", payrollTypeID);
}
}
public static IDataReader Get(TransactionContext tc, string subStr)
{
subStr = "%" + subStr + "%";
string sql = SQLParser.MakeSQL("SELECT * FROM Vendor v WHERE NAME LIKE %s", subStr);
return tc.ExecuteReader(sql);
}
internal static void Insert(TransactionContext tc, Vendor item)
{
string sql = SQLParser.MakeSQL(
"INSERT INTO Vendor(VendorID, Name, Code, Status,CreatedBy,CreatedDate,PAYROLLTYPEID,SEQUENCENO,Mobile,EmailAddress,Address,Telephone,VendorType,ContactPerson)" +
" VALUES(%n,%s, %s, %n, %n, %d,%n,%n,%s,%s,%s,%s,%n,%s)", item.ID, item.Name, item.Code,
(int)item.Status, DataReader.GetNullValue(item.CreatedBy), DataReader.GetNullValue(item.CreatedDate),item.PayrollTypeID,item.Sequence,item.Mobile, item.EmailAddress,
item.Address,item.Telephone,(int)item.VendorType,item.ContactPerson);
tc.ExecuteNonQuery(sql);
}
internal static void Update(TransactionContext tc, Vendor item)
{
string sql =
SQLParser.MakeSQL(
"UPDATE Vendor SET Name=%s, Code=%s, Status=%n, ModifiedBy=%n,ModifiedDate=%d,Mobile=%s,EmailAddress=%s,Address=%s,Telephone=%s,VendorType=%n,ContactPerson=%s" +
" WHERE VendorID=%n", item.Name, item.Code,item.Status,
DataReader.GetNullValue(item.ModifiedBy), DataReader.GetNullValue(item.ModifiedDate), item.Mobile, item.EmailAddress,
item.Address, item.Telephone, (int)item.VendorType, item.ContactPerson, item.ID);
tc.ExecuteNonQuery(sql);
}
internal static void Delete(TransactionContext tc, int id)
{
tc.ExecuteNonQuery("DELETE FROM Vendor WHERE VendorID=%n", id);
}
}
}