93 lines
3.7 KiB
C#
93 lines
3.7 KiB
C#
using Ease.Core.DataAccess;
|
|
using HRM.BO;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
public class RDReportDA
|
|
{
|
|
#region Constructor
|
|
public RDReportDA() { }
|
|
#endregion
|
|
|
|
#region Insert function
|
|
public static void Insert(TransactionContext tc, RDReport oItem, int fundTypeID)
|
|
{
|
|
tc.ExecuteNonQuery("INSERT INTO FM_RDReport(ReportID, ReportCode, ReportName, ReportType, FundTypeID)" +
|
|
" VALUES(%n, %s, %s, %n, %n)", oItem.ID, oItem.ReportCode, oItem.ReportName, oItem.ReportType, fundTypeID);
|
|
}
|
|
#endregion
|
|
|
|
#region Update function
|
|
public static void Update(TransactionContext tc, RDReport oItem, int fundTypeID)
|
|
{
|
|
tc.ExecuteNonQuery("UPDATE FM_RDReport SET ReportCode=%s, ReportName=%s, ReportType=%n, FundTypeID = %n " +
|
|
" WHERE ReportID=%n", oItem.ReportCode, oItem.ReportName, oItem.ReportType, fundTypeID, oItem.ID);
|
|
}
|
|
#endregion
|
|
|
|
#region ID Generation function
|
|
public static int GetNewID(TransactionContext tc)
|
|
{
|
|
return tc.GenerateID("FM_RDReport", "ReportID");
|
|
}
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
public static bool IsExistCode(TransactionContext tc, string code, int fundTypeID)
|
|
{
|
|
object count = null;
|
|
count = tc.ExecuteScalar("Select count(*) from FM_RDReport where ReportCode=%s AND FundTypeID=%n", code, fundTypeID);
|
|
if (count == null || count == DBNull.Value || Convert.ToInt32(count) <= 0)
|
|
return false;
|
|
else return true;
|
|
}
|
|
public static bool IsExistType(TransactionContext tc, EnumReportType reportType, int fundTypeID)
|
|
{
|
|
object count = null;
|
|
count = tc.ExecuteScalar("Select count(*) from FM_RDReport where ReportType=%n AND ProjectID=%n", reportType, fundTypeID);
|
|
if (count == null || count == DBNull.Value || Convert.ToInt32(count) <= 0)
|
|
return false;
|
|
else return true;
|
|
}
|
|
|
|
public static IDataReader GetByFundType(TransactionContext tc, int fundTypeID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM FM_RDReport where FundTypeID=%n", fundTypeID);
|
|
}
|
|
|
|
public static IDataReader Get(TransactionContext tc, EnumReportType reportType)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM FM_RDReport where ReportType=%n", reportType);
|
|
}
|
|
|
|
public static IDataReader Get(TransactionContext tc, int nReportID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM FM_RDReport WHERE ReportID=%n", nReportID);
|
|
}
|
|
|
|
public static IDataReader GetByReportTypeAndFundTypeID(TransactionContext tc, EnumReportTypes reportType, int fundTypeID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM FM_RDReport where ReportType=%n AND FundTypeID=%n", reportType, fundTypeID);
|
|
}
|
|
#endregion
|
|
|
|
#region Delete function
|
|
public static void Delete(TransactionContext tc, int nReportID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM [FM_RDRowAmountCalItem] WHERE COLRowID IN(SELECT COLRowID FROM FM_RDReportRow WHERE ReportID=%n)", nReportID);
|
|
tc.ExecuteNonQuery("DELETE FROM [FM_RowSumCalcItem] WHERE CalcRowID IN(SELECT COLRowID FROM FM_RDReportRow WHERE ReportID=%n)", nReportID);
|
|
tc.ExecuteNonQuery("DELETE FROM [FM_RDReportRow] WHERE ReportID=%n", nReportID);
|
|
tc.ExecuteNonQuery("DELETE FROM [FM_RDReport] WHERE ReportID=%n", nReportID);
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
}
|