CEL_Payroll/Payroll.Service/SearchReport/DA/ReportItemDA.cs

99 lines
5.3 KiB
C#
Raw Permalink Normal View History

2024-09-17 14:30:13 +06:00
using System;
using Payroll.BO;
using System.Data;
using System.Linq;
using Ease.CoreV35.Model;
using System.Data.SqlClient;
using Ease.CoreV35.DataAccess;
using System.Collections.Generic;
using Ease.CoreV35.DataAccess.SQL;
namespace Payroll.Service
{
#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,Status) " +
" Values(%n, %n, %s, %s, %s, %s, %s, %n, %n, %n, %b, %b, %b, %b, %b, %b, %b, %b, %b, %n, %d,%s,%s,%n) ", item.ID.Integer,
item.ReportID.Integer, 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.Integer), DataReader.GetNullValue(item.CreatedDate),item.ObjectName,item.FunctionName,(int)item.Status);
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.Integer, 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,IDType.Integer), DataReader.GetNullValue(item.ModifiedDate), item.ID.Integer);
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,Status=%n 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, IDType.Integer), DataReader.GetNullValue(item.ModifiedDate), item.ObjectName, item.FunctionName, (int)item.Status, item.ReportID.Integer);
tc.ExecuteNonQuery(sSQL);
}
#endregion
#region Get Function
internal static IDataReader Get(TransactionContext tc, EnumStatus eStatus)
{
if(eStatus==EnumStatus.Regardless)
return tc.ExecuteReader("SELECT * FROM ReportItem ");
else
return tc.ExecuteReader("SELECT * FROM ReportItem where Status=%n",(int)eStatus);
}
internal static IDataReader GetByReportType(TransactionContext tc, int reportID)
{
return tc.ExecuteReader("SELECT * from ReportItem Where ReportID=%n", reportID);
}
internal static IDataReader Get(TransactionContext tc, ID nID)
{
return tc.ExecuteReader("SELECT * FROM ReportItem WHERE ReportID=%n", nID.Integer);
}
#endregion
#region Delete function
internal static void Delete(TransactionContext tc, ID nID)
{
tc.ExecuteNonQuery("DELETE FROM [ReportItem] WHERE ReportItemID=%n", nID.Integer);
}
#endregion
#region Other Functions
public static bool IsExist(TransactionContext tc, ID ReportID)
{
string str = Ease.CoreV35.DataAccess.SQLParser.MakeSQL("SELECT COUNT(*) FROM ReportItem Where ReportID = %n", ReportID.Integer);
object obj = tc.ExecuteScalar(str);
return Convert.ToInt32(obj) > 0;
}
#endregion
}
#endregion
}