CEL_Payroll/Payroll.Service/Vender/DA/VendorDA.cs
2024-09-17 14:30:13 +06:00

72 lines
2.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Ease.CoreV35.DataAccess;
using Ease.CoreV35.Model;
using Payroll.BO;
namespace Payroll.Service
{
internal class VendorDA
{
internal static IDataReader Get(TransactionContext tc, ID id)
{
return tc.ExecuteReader("SELECT * FROM Vendor where VendorID=%n", id.Integer);
}
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);
}
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, Address, Balance, ContactPerson, EmailAddress,Mobile,Telephone,VendorType,Status,CreatedBy,CreatedDate)" +
" VALUES(%n,%s, %s, %n, %s, %s,%s,%s,%n,%n,%n,%d)", item.ID.Integer, item.Name, item.Address, item.Balance, item.ContactPerson, item.EmailAddress, item.Mobile, item.Telephone, (int)item.VendorType,(int)item.Status,DataReader.GetNullValue(item.CreatedBy.Integer),DataReader.GetNullValue(item.CreatedDate));
tc.ExecuteNonQuery(sql);
}
internal static void Update(TransactionContext tc, Vendor item)
{
string sql =
SQLParser.MakeSQL(
"UPDATE Vendor SET Name=%s, Address=%s, Balance=%n, ContactPerson=%s, EmailAddress=%s,Mobile=%s,Telephone=%s,VendorType=%n,Status=%n,ModifiedBy=%n,ModifiedDate=%d" +
" WHERE VendorID=%n", item.Name, item.Address, item.Balance, item.ContactPerson, item.EmailAddress, item.Mobile, item.Telephone, (int)item.VendorType, item.Status,DataReader.GetNullValue(item.ModifiedBy.Integer),DataReader.GetNullValue(item.ModifiedDate), item.ID.Integer);
tc.ExecuteNonQuery(sql);
}
internal static void Delete(TransactionContext tc, ID id)
{
tc.ExecuteNonQuery("DELETE FROM Vendor WHERE VendorID=%n", id.Integer);
}
}
}