101 lines
5.1 KiB
C#
101 lines
5.1 KiB
C#
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 ConfigarationDA
|
|
|
|
internal class ConfigarationDA
|
|
{
|
|
#region Constructor
|
|
|
|
private ConfigarationDA() { }
|
|
|
|
#endregion
|
|
|
|
internal static void Insert(TransactionContext tc, Configaration item)
|
|
{
|
|
tc.ExecuteNonQuery("INSERT INTO Configuration(ConfigurationID, ParentID, Node, Value, Type, CreatedBy, CreatedDate)" +
|
|
" VALUES(%n, %n, %s, %s, %n, %n, %d)", item.ID.Integer, DataReader.GetNullValue(item.ParentID, IDType.Integer), item.Node, item.Value, item.Type, item.CreatedBy.Integer, item.CreatedDate);
|
|
}
|
|
internal static void Insert(TransactionContext tc, Configaration.ConfigurationAttribute item)
|
|
{
|
|
tc.ExecuteNonQuery("INSERT INTO ConfigurationAttribute(AttributeID, ParentID, AttributeName,Value)" +
|
|
" VALUES(%n, %n, %s, %s)", item.ID.Integer, item.ConfigurationID.Integer, item.AttributeName, item.Value);
|
|
}
|
|
internal static void Update(TransactionContext tc, Configaration item)
|
|
{
|
|
tc.ExecuteNonQuery("UPDATE Configuration SET ParentID=%n, Node=%s, Value=%s, Type=%n, ModifiedBy=%n, ModifiedDate=%d" +
|
|
" WHERE ConfigurationID=%n", DataReader.GetNullValue(item.ParentID, IDType.Integer), item.Node, item.Value, item.Type, item.ModifiedBy.Integer, item.ModifiedDate, item.ID.Integer);
|
|
}
|
|
internal static void DeleteChildren(TransactionContext tc, ID parentID)
|
|
{
|
|
tc.ExecuteNonQuery(@"DELETE FROM ConfigurationAttribute WHERE ParentID=%n", parentID.Integer);
|
|
}
|
|
internal static void Delete(TransactionContext tc, ID parentID)
|
|
{
|
|
tc.ExecuteNonQuery(@"DELETE FROM ConfigurationAttribute WHERE ParentID=%n;
|
|
DELETE FROM Configuration WHERE ParentID=%n", parentID.Integer, parentID.Integer);
|
|
}
|
|
internal static IDataReader GetAllParent(TransactionContext tc)
|
|
{
|
|
//return tc.ExecuteReader("SELECT * FROM Configuration Order by ConfigurationID");
|
|
return tc.ExecuteReader("SELECT * FROM Configuration Order by ConfigurationID");
|
|
}
|
|
internal static void DeleteAll(TransactionContext tc, EnumConfigurationType type)
|
|
{
|
|
string SQLAttribute = string.Format("Delete from configurationAttribute where ParentID in (Select ConfigurationID from Configuration where type={0})", Convert.ToInt32(type));
|
|
tc.ExecuteNonQuery(SQLAttribute);
|
|
string SQLConfig = string.Format("Delete from configuration Where type = {0}", Convert.ToInt32(type));
|
|
tc.ExecuteNonQuery(SQLConfig);
|
|
}
|
|
internal static IDataReader GetAllChildrens(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM ConfigurationAttribute Order by AttributeID");
|
|
}
|
|
internal static IDataReader GetAllParent(TransactionContext tc, EnumConfigurationType type)
|
|
{
|
|
//return tc.ExecuteReader("SELECT * FROM Configuration Order by ConfigurationID");
|
|
return tc.ExecuteReader("SELECT * FROM Configuration where type=%n Order by ConfigurationID", type);
|
|
}
|
|
internal static IDataReader GetAttribute(TransactionContext tc, ID attributeID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM ConfigurationAttribute WHERE AttributeID=%n", attributeID.Integer);
|
|
}
|
|
internal static IDataReader GetChildren(TransactionContext tc, ID ConfigurationID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM ConfigurationAttribute WHERE ParentID=%n Order by AttributeID", ConfigurationID.Integer);
|
|
}
|
|
internal static IDataReader GetChildrenByNode(TransactionContext tc, int sNode)
|
|
{
|
|
return tc.ExecuteReader("select * from dbo.ConfigurationAttribute where parentid=%n Order by AttributeID", sNode);
|
|
}
|
|
internal static IDataReader GetChildrenByValue(TransactionContext tc, string sMenuKey)
|
|
{
|
|
return tc.ExecuteReader("select * from dbo.ConfigurationAttribute where parentid in(select parentid from dbo.ConfigurationAttribute where value=%s and attributename='key') Order by AttributeID", sMenuKey);
|
|
}
|
|
internal static IDataReader GetAllChildren(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("select * from dbo.ConfigurationAttribute where parentid in(select parentid from dbo.ConfigurationAttribute where attributename='key') Order by AttributeID");
|
|
}
|
|
internal static IDataReader Get(TransactionContext tc, ID ConfigurationID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM Configuration WHERE ConfigurationID=%n", ConfigurationID.Integer);
|
|
}
|
|
internal static IDataReader Get(TransactionContext tc, EnumConfigurationType configType)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM Configuration Where Type=%n Order by ConfigurationID", configType);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|