CEL_Payroll/Payroll.Service/Workflow/DA/WFSetupDA.cs

279 lines
11 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
{
internal class WFSetupDA
{
#region WFSetupDA
#region Constructor
private WFSetupDA() { }
#endregion
#region Insert
internal static void Insert(TransactionContext tc, WFSetup item)
{
tc.ExecuteNonQuery("INSERT INTO WFSETUP(WFSETUPID, WFTYPEID, CREATEDBY, CREATEDDATE, SEQUENCENO)"
+ " VALUES(%n, %n, %n, %d, %n)",
+item.ID.Integer, item.WFTypeId.Integer, item.CreatedBy.Integer, item.CreatedDate, item.Sequence);
}
#endregion
#region Update
internal static void Update(TransactionContext tc, WFSetup item)
{
tc.ExecuteNonQuery("UPDATE WFSETUP SET WFTYPEID=%n, MODIFIEDBY=%n, MODIFIEDDATE=%d, SEQUENCENO=%n"
+ " WHERE WFSETUPID=%n ",
+item.WFTypeId.Integer, item.ModifiedBy.Integer, item.ModifiedDate, item.Sequence, item.ID.Integer);
}
#endregion
#region Delete
internal static void Delete(TransactionContext tc, ID id)
{
tc.ExecuteNonQuery("DELETE FROM WFRULEMANUAL WHERE WFSETUPID=%n", id.Integer);
tc.ExecuteNonQuery("DELETE FROM WFRDDESIGNATION WHERE WFSETUPID=%n", id.Integer);
tc.ExecuteNonQuery("DELETE FROM WFRULEDNODE WHERE WFSETUPID=%n", id.Integer);
tc.ExecuteNonQuery("DELETE FROM WFRDETAILOS WHERE WFSETUPID=%n", id.Integer);
tc.ExecuteNonQuery("DELETE FROM WFSETUPRULE WHERE WFSETUPID=%n", id.Integer);
tc.ExecuteNonQuery("DELETE FROM WFSETUP WHERE WFSETUPID=%n", id.Integer);
}
//internal static void DeleteChild(TransactionContext tc, ID id)
//{
// tc.ExecuteNonQuery("DELETE FROM WFRULEMANUAL WHERE WFSETUPID=%n", id.Integer);
// tc.ExecuteNonQuery("DELETE FROM WFRDDESIGNATION WHERE WFSETUPID=%n", id.Integer);
// tc.ExecuteNonQuery("DELETE FROM WFRULEDNODE WHERE WFSETUPID=%n", id.Integer);
// tc.ExecuteNonQuery("DELETE FROM WFRDETAILOS WHERE WFSETUPID=%n", id.Integer);
// tc.ExecuteNonQuery("DELETE FROM WFSETUPRULE WHERE WFSETUPID=%n", id.Integer);
// tc.ExecuteNonQuery("DELETE FROM WFSETUP WHERE WFSETUPID=%n", id.Integer);
//}
#endregion
#region Get
internal static IDataReader Get(TransactionContext tc, ID id)
{
return tc.ExecuteReader("SELECT * FROM WFSETUP WHERE WFSETUPID=%n", id.Integer);
}
internal static IDataReader Get(TransactionContext tc)
{
return tc.ExecuteReader("SELECT * FROM WFSETUP");
}
#endregion
#endregion
#region WFSetupRule
#region Insert
internal static void InsertWFSetupRule(TransactionContext tc, WFSetupRule item)
{
if (item.FinalDestinationNode != null && !item.FinalDestinationNode.IsUnassigned)
{
tc.ExecuteNonQuery("INSERT INTO WFSETUPRULE(WFSETUPRULEID,WFSETUPID,STAUTHORITYLEVEL,PRIORITY,WFRULETYPE,"
+ " LEVELDEPTH,REQAPPALL,AUTONOTIFICATIONNODE,FINALDESTINATIONNODE, RAUTHORITY)"
+ " VALUES(%n,%n,%n,%n,"
+ " %n,%n,%n,%n,%n,%n)",
item.ID.Integer, item.WFSetupId.Integer, item.StAuthorityLevel, item.Priority, item.WFRuleType,
item.LevelDepth, item.ReqAppAll, item.AutoNotificationNode, item.FinalDestinationNode.Integer, item.IsRAuthority);
}
else
{
tc.ExecuteNonQuery("INSERT INTO WFSETUPRULE(WFSETUPRULEID,WFSETUPID,STAUTHORITYLEVEL,PRIORITY,WFRULETYPE,"
+ " LEVELDEPTH,REQAPPALL,AUTONOTIFICATIONNODE,FINALDESTINATIONNODE, RAUTHORITY)"
+ " VALUES(%n,%n,%n,%n,"
+ " %n,%n,%n,%n,%n,%n)",
item.ID.Integer, item.WFSetupId.Integer, item.StAuthorityLevel, item.Priority, item.WFRuleType,
item.LevelDepth, item.ReqAppAll, item.AutoNotificationNode, item.FinalDestinationNode, item.IsRAuthority);
}
}
#endregion
#region Update
internal static void UpdateWFSetupRule(TransactionContext tc, WFSetupRule item)
{
string sSQL = string.Empty;
sSQL = SQLParser.MakeSQL("UPDATE WFSETUPRULE SET WFSETUPID=%n, STAUTHORITYLEVEL=%n, PRIORITY=%n, WFRULETYPE=%n,"
+ " LEVELDEPTH=%n, REQAPPALL=%n, FINALDESTINATIONNODE = %n, RAUTHORITY=%n WHERE WFSETUPRULEID=%n",
item.WFSetupId.Integer, item.StAuthorityLevel, item.Priority, item.WFRuleType,
item.LevelDepth, item.ReqAppAll, DataReader.GetNullValue(item.FinalDestinationNode, IDType.Integer), item.IsRAuthority, item.ID.Integer);
tc.ExecuteNonQuery(sSQL);
}
#endregion
#region Delete
internal static void DeleteWFSetupRule(TransactionContext tc, ID iD)
{
tc.ExecuteNonQuery("DELETE FROM WFSETUPRULE WHERE WFSETUPID=%n", iD.Integer);
}
internal static void DeleteWFSetupRulebyRuleID(TransactionContext tc, ID ruleId)
{
tc.ExecuteNonQuery("DELETE FROM WFSETUPRULE WHERE WFSETUPRULEID=%n", ruleId.Integer);
}
#endregion
#region Get
internal static IDataReader Get4WFSetupRule(TransactionContext tc, ID id)
{
return tc.ExecuteReader("SELECT * FROM WFSETUPRULE WHERE WFSETUPID=%n", id.Integer);
}
#endregion
#endregion
#region WFRuleDetailDesignation
#region Insert
internal static void InsertWFRuleDetailDesignation(TransactionContext tc, WFRuleDetailDesignation item)
{
tc.ExecuteNonQuery("INSERT INTO WFRDDESIGNATION(WFRULEDETAILID, DESIGNATIONID, WFSETUPID, WFSETUPRULEID, SEQUENCEID)"
+ " VALUES(%n, %n, %n, %n, %n)",
item.ID.Integer, item.DesignationId.Integer, item.WfSetupId.Integer, item.WfSetupRuleId.Integer, item.SequenceId);
}
#endregion
#region Delete
internal static void DeleteWFRuleDetailDesignation(TransactionContext tc, ID iD)
{
tc.ExecuteNonQuery("DELETE FROM WFRDDESIGNATION WHERE WFSETUPID=%n", iD.Integer);
}
#endregion
#region Get
//internal static IDataReader Get4WFRuleDD(TransactionContext tc, ID id)
//{
// return tc.ExecuteReader("SELECT * FROM WFRDDESIGNATION WHERE WFSETUPID=%n", id.Integer);
//}
internal static IDataReader Get4WFRuleDD(TransactionContext tc, int nRuleID)
{
return tc.ExecuteReader("SELECT * FROM WFRDDESIGNATION WHERE WFSETUPRULEID=%n", nRuleID);
}
#endregion
#endregion
#region WFRuleDetailNode
#region Insert
internal static void InsertRuleDetailNode(TransactionContext tc, WFRuleDetailNode item)
{
tc.ExecuteNonQuery("INSERT INTO WFRULEDNODE(WFRULEDNODEID, WFSETUPID, WFSETUPRULEID, NODEID, SEQUENCEID)"
+ " VALUES(%n, %n, %n, %n, %n)",
item.ID.Integer, item.WfSetupId.Integer, item.WfSetupRuleId.Integer, item.NodeId.Integer, item.SequenceId);
}
internal static void InsertRuleManual(TransactionContext tc, WFRuleDetailManual item)
{
tc.ExecuteNonQuery("INSERT INTO WFRULEMANUAL(WFRULEDETAILID, WFSETUPID, WFSETUPRULEID, RuleType, SEQUENCEID, ObjectID)"
+ " VALUES(%n, %n, %n, %n, %n, %n)",
item.ID.Integer, item.WfSetupId.Integer, item.WfSetupRuleId.Integer, item.RuleType, item.SequenceId, item.ObjectID);
}
#endregion
#region Update
internal static void UpdateRuleDetailNode(TransactionContext tc, WFRuleDetailNode item)
{
string sSQL = SQLParser.MakeSQL("UPDATE WFRULEDNODE SET NODEID=%n, SEQUENCEID=%n WHERE WFSETUPID=%n AND WFSETUPRULEID=%n AND WFRULEDNODEID=%n",
item.NodeId.Integer, item.SequenceId, item.WfSetupId.Integer, item.WfSetupRuleId.Integer, item.ID.Integer);
tc.ExecuteNonQuery(sSQL);
}
#endregion
#region Delete
internal static void DeleteWFRuleDetailNode(TransactionContext tc, ID iD)
{
tc.ExecuteNonQuery("DELETE FROM WFRULEDNODE WHERE WFSETUPID=%n", iD.Integer);
}
#endregion
#region Get
//internal static IDataReader Get4WFRuleNode(TransactionContext tc, ID id)
//{
// return tc.ExecuteReader("SELECT * FROM WFRULEDNODE WHERE WFSETUPRULEID=%n", id.Integer);
//}
internal static IDataReader Get4WFRuleNode(TransactionContext tc, int nRuleID)
{
return tc.ExecuteReader("SELECT * FROM WFRULEDNODE WHERE WFSetupRuleID=%n", nRuleID);
}
#endregion
#endregion
#region WFRuleDetailOS
#region Insert
internal static void InsertRuleDetailOS(TransactionContext tc, WFRuleDetailOS item)
{
string sSQL = SQLParser.MakeSQL("INSERT INTO WFRDETAILOS(WFRULEDETAILID, OSID, WFSETUPID, WFSETUPRULEID, SEQUENCEID)"
+ " VALUES(%n, %n, %n, %n, %n)",
item.ID.Integer, item.OsID.Integer, item.WfSetupId.Integer, item.WfSetupRuleId.Integer, item.SequenceId);
tc.ExecuteNonQuery(sSQL);
}
#endregion
#region Update
internal static void UpdateRuleDetailOS(TransactionContext tc, WFRuleDetailOS item)
{
string sSQL = SQLParser.MakeSQL("UPDATE WFRDETAILOS SET OSID=%n, SEQUENCEID=%n WHERE WFSETUPID=%n AND WFSETUPRULEID=%n AND WFRULEDETAILID=%n",
item.OsID.Integer, item.SequenceId, item.WfSetupId.Integer, item.WfSetupRuleId.Integer, item.ID.Integer);
tc.ExecuteNonQuery(sSQL);
}
#endregion
#region Delete
internal static void DeleteWFRuleDetailOS(TransactionContext tc, ID iD)
{
tc.ExecuteNonQuery("DELETE FROM WFRDETAILOS WHERE WFSETUPID=%n", iD.Integer);
}
internal static void DeleteWFRuleDetailManual(TransactionContext tc, ID iD)
{
tc.ExecuteNonQuery("DELETE FROM WFRULEMANUAL WHERE WFSETUPID=%n", iD.Integer);
}
#endregion
#region Get
internal static IDataReader Get4WFRuleDetailOS(TransactionContext tc, ID ruleid)
{
return tc.ExecuteReader("SELECT * FROM WFRDETAILOS WHERE WFSETUPRULEID=%n", ruleid.Integer);
}
internal static IDataReader Get4WFRuleDetailManual(TransactionContext tc, ID ruleid)
{
return tc.ExecuteReader("SELECT * FROM WFRULEMANUAL WHERE WFSETUPRULEID=%n", ruleid.Integer);
}
internal static IDataReader Get4WFRuleDetailOS(TransactionContext tc, int nWFSetupID, int nSetupRuleID)
{
return tc.ExecuteReader("SELECT * FROM WFRDETAILOS WHERE WFSETUPID=%n AND WFSETUPRULEID=%n", nWFSetupID, nSetupRuleID);
}
internal static IDataReader Get4WFRuleDetailManual(TransactionContext tc, int nWFSetupID, int nSetupRuleID)
{
return tc.ExecuteReader("SELECT * FROM WFRULEMANUAL WHERE WFSETUPID=%n AND WFSETUPRULEID=%n Order by SEQUENCEID", nWFSetupID, nSetupRuleID);
}
#endregion
#endregion
}
}