EchoTex_Payroll/HRM.DA/DA/SearchReport/ReportItemDA.cs
2024-10-14 10:01:49 +06:00

114 lines
5.1 KiB
C#

using HRM.BO;
using Ease.Core.DataAccess;
using Ease.Core.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace HRM.DA
{
#region ReportItemDA
internal class ReportItemDA
{
#region Constructor
private ReportItemDA()
{
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, ReportItem item)
{
string sSQL = SQLParser.MakeSQL(
"INSERT INTO ReportItem(ReportItemID, reportID, Name, reportType, defaultHeader, " +
"userHeader1, userHeader2, chronology, searchFrom, itemType, bankNeeded, isCompanyInfo, " +
" isDateMonth, isSearchCriteria, isGroupEachPage, isPageNo, isDateTime, isGroupbyCriteria, isPrintSignature, " +
" CreatedBy, CreationDate,ObjectName,FunctionName) " +
" Values(%n, %n, %s, %s, %s, %s, %s, %n, %n, %n, %b, %b, %b, %b, %b, %b, %b, %b, %b, %n, %d,%s,%s) ",
item.ID,
item.ReportID, item.Name, item.ReportType, item.DefaultHeader, item.UserHeader1, item.UserHeader2,
item.Chronology, item.SearchFrom, item.ItemType, item.BankNeeded, item.IsCompanyInfo, item.IsDateMonth,
item.IsSearchCriteria, item.IsGroupEachPage, item.IsPageNo, item.IsDateMonth, item.IsGroupbyCriteria,
item.IsSignatoriesEachPageFooter, DataReader.GetNullValue(item.CreatedBy),
DataReader.GetNullValue(item.CreatedDate), item.ObjectName, item.FunctionName);
tc.ExecuteNonQuery(sSQL);
}
#endregion
#region Update function
internal static void Update(TransactionContext tc, ReportItem item)
{
//string sSQL = SQLParser.MakeSQL("UPDATE ReportItem SET reportID=%n, name=%s, reportType=%s, defaultHeader=%s," +
// "userHeader1=%s, userHeader2=%s, chronology=%n, searchFrom=%n, itemType=%n, bankNeeded=%b, isCompanyInfo=%b, " +
// "isDateMonth=%b,isSearchCriteria=%b, isGroupEachPage=%b, isPageNo=%b, isDateTime=%b, isGroupbyCriteria=%b, " +
// "isPrintSignature = %b, ModifiedBy=%n, ModifiedDate=%d Where ReportItemID =%n",
// item.ReportID, item.Name, item.ReportType,
// item.DefaultHeader, item.UserHeader1, item.UserHeader2, item.Chronology, item.SearchFrom, item.ItemType,
// item.BankNeeded, item.IsCompanyInfo, item.IsDateMonth, item.IsSearchCriteria, item.IsGroupEachPage,
// item.IsPageNo, item.IsDateTime, item.IsGroupbyCriteria, item.IsSignatoriesEachPageFooter,
// DataReader.GetNullValue(item.ModifiedBy,0), DataReader.GetNullValue(item.ModifiedDate), item.ID);
string sSQL = SQLParser.MakeSQL("UPDATE ReportItem SET name=%s, reportType=%s, defaultHeader=%s," +
"userHeader1=%s, userHeader2=%s, chronology=%n, searchFrom=%n, itemType=%n, bankNeeded=%b, isCompanyInfo=%b, " +
"isDateMonth=%b,isSearchCriteria=%b, isGroupEachPage=%b, isPageNo=%b, isDateTime=%b, isGroupbyCriteria=%b, " +
"isPrintSignature = %b, ModifiedBy=%n, ModifiedDate=%d,ObjectName=%s,FunctionName=%s Where ReportID =%n",
item.Name, item.ReportType,
item.DefaultHeader, item.UserHeader1, item.UserHeader2, item.Chronology, item.SearchFrom, item.ItemType,
item.BankNeeded, item.IsCompanyInfo, item.IsDateMonth, item.IsSearchCriteria, item.IsGroupEachPage,
item.IsPageNo, item.IsDateTime, item.IsGroupbyCriteria, item.IsSignatoriesEachPageFooter,
DataReader.GetNullValue(item.ModifiedBy), DataReader.GetNullValue(item.ModifiedDate), item.ObjectName,
item.FunctionName, item.ReportID);
tc.ExecuteNonQuery(sSQL);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM ReportItem");
}
internal static IDataReader GetByReportType(TransactionContext tc, int reportID)
{
return tc.ExecuteReader("SELECT * from ReportItem Where ReportID=%n", reportID);
}
internal static IDataReader Get(TransactionContext tc, int nID)
{
return tc.ExecuteReader("SELECT * FROM ReportItem WHERE ReportID=%n", nID);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, int nID)
{
tc.ExecuteNonQuery("DELETE FROM ReportItem WHERE ReportItemID=%n", nID);
}
#endregion
#region Other Functions
public static bool IsExist(TransactionContext tc, int ReportID)
{
string str =
Ease.Core.DataAccess.SQLParser.MakeSQL("SELECT COUNT(*) FROM ReportItem Where ReportID = %n", ReportID);
object obj = tc.ExecuteScalar(str);
return Convert.ToInt32(obj) > 0;
}
#endregion
}
#endregion
}