130 lines
4.4 KiB
C#
130 lines
4.4 KiB
C#
|
using HRM.BO;
|
|||
|
using Ease.Core.DataAccess;
|
|||
|
using System.Data;
|
|||
|
using System;
|
|||
|
|
|||
|
namespace HRM.DA
|
|||
|
{
|
|||
|
#region StoreDA
|
|||
|
|
|||
|
internal class StoreDA
|
|||
|
{
|
|||
|
#region Constructor
|
|||
|
|
|||
|
private StoreDA()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Insert function
|
|||
|
|
|||
|
internal static void Insert(TransactionContext tc, Store item)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery(
|
|||
|
"INSERT INTO Store(StoreID,Code, Name,Address, Phone, CreatedBy, CreatedDate)" +
|
|||
|
" VALUES(%n, %s, %s,%s,%s, %n, %d)", item.ID, item.Code, item.Name,
|
|||
|
item.Address, item.Phone, item.CreatedBy,
|
|||
|
item.CreatedDate);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Update function
|
|||
|
|
|||
|
internal static void Update(TransactionContext tc, Store item)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery(
|
|||
|
"UPDATE Store SET Code=%s, Name=%s,Address=%s, Phone=%s, ModifiedBy=%n, ModifiedDate=%d" +
|
|||
|
" WHERE StoreID=%n", item.Code, item.Name, item.Address, item.Phone,
|
|||
|
item.ModifiedBy, item.ModifiedDate,
|
|||
|
item.ID);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Get Function
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, EnumStatus status)
|
|||
|
{
|
|||
|
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
|
|||
|
{
|
|||
|
//return tc.ExecuteReader(
|
|||
|
// @"SELECT d.* FROM Store d where d.status=%n order by d.Name", status);
|
|||
|
return tc.ExecuteReader(@"SELECT d.* FROM Store d order by d.Name");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return tc.ExecuteReader(@"SELECT d.* FROM Store d order by d.Name");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//internal static IDataReader Get(TransactionContext tc, EnumStatus status, string sIDs,
|
|||
|
// string sTargetPropertyName, int payrollTypeID)
|
|||
|
//{
|
|||
|
// string sCondition = "";
|
|||
|
// if (sTargetPropertyName != null && sTargetPropertyName != "")
|
|||
|
// sCondition = " AND e." + sTargetPropertyName + " IN(" + sIDs + ") ";
|
|||
|
// if (EnumStatus.Active == status || EnumStatus.Inactive == status)
|
|||
|
// {
|
|||
|
// return tc.ExecuteReader(@"
|
|||
|
// SELECT DISTINCT d.* FROM DESIGNATION d,EMPLOYEE e where d.DESIGNATIONID =e.DESIGNATIONID
|
|||
|
// AND e.PAYROLLTYPEID=%n and d.Status=%n %q order by d.Name", payrollTypeID,
|
|||
|
// status, sCondition);
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// return tc.ExecuteReader(@"
|
|||
|
// SELECT DISTINCT d.* FROM DESIGNATION d,EMPLOYEE e where d.DESIGNATIONID =e.DESIGNATIONID
|
|||
|
// AND e.PAYROLLTYPEID=%n %q order by d.Name", payrollTypeID, sCondition);
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, int ID)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Store WHERE StoreID=%n", ID);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader Get(TransactionContext tc, string sCode)
|
|||
|
{
|
|||
|
return tc.ExecuteReader("SELECT * FROM Store WHERE Code=%s", sCode);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Delete function
|
|||
|
|
|||
|
internal static void Delete(TransactionContext tc, int ID)
|
|||
|
{
|
|||
|
tc.ExecuteNonQuery("DELETE FROM Store WHERE StoreID=%n", ID);
|
|||
|
}
|
|||
|
|
|||
|
internal static IDataReader GetAllStore(TransactionContext tc, EnumStatus status,
|
|||
|
string code, string name)
|
|||
|
{
|
|||
|
string sqlClause = string.Empty;
|
|||
|
//sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("PayrollTypeID = %n", payrollTypeID);
|
|||
|
if (EnumStatus.Active == status || EnumStatus.Inactive == status)
|
|||
|
{
|
|||
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("status = %n", status);
|
|||
|
}
|
|||
|
|
|||
|
if (!string.IsNullOrWhiteSpace(code))
|
|||
|
{
|
|||
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("Code = %s", code);
|
|||
|
}
|
|||
|
|
|||
|
if (!string.IsNullOrWhiteSpace(name))
|
|||
|
{
|
|||
|
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("Name LIKE %s", ("%" + name + "%"));
|
|||
|
}
|
|||
|
|
|||
|
return tc.ExecuteReader("SELECT * FROM Store %q order by name", sqlClause);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|