348 lines
15 KiB
C#
348 lines
15 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Ease.Core.DataAccess;
|
|
using HRM.BO;
|
|
|
|
namespace HRM.DA
|
|
{
|
|
#region GLTranUserRecord
|
|
|
|
public class GLTranUserRecordDA
|
|
{
|
|
#region Constructor
|
|
|
|
public GLTranUserRecordDA()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Insert function
|
|
|
|
public static void Insert(TransactionContext tc, GLTranUserRecord oItem)
|
|
{
|
|
string sSQL = SQLParser.MakeSQL("INSERT INTO GLTranUserRecord(" +
|
|
"GLTranUserRecordID, " + //1
|
|
"GLID, " + //2
|
|
"GLTranID, " + //3
|
|
"GLTranDetailID, " + //4
|
|
"UserObject1ID, " + //5
|
|
"UserRecord1ID, " + //6
|
|
"UserObject2ID, " + //7
|
|
"UserRecord2ID, " + //8
|
|
"Description, " + //9
|
|
"Amount, " + //10
|
|
"Modifiedby, " + //11
|
|
"ModifiedDate, " + //12
|
|
"OperationalStatus)" + //13
|
|
// 1 2 3 4 5 6 7 8 9 10 11 12 13
|
|
" VALUES(%n, %n, %n, %n, %n, %n, %n, %n, %s, %n, %n, %d, %n)",
|
|
oItem.ID, //1
|
|
oItem.GLID, //2
|
|
oItem.GLTranID, //3
|
|
oItem.GLTranDetailID, //4
|
|
oItem.UserObject1ID, //5
|
|
oItem.UserRecord1ID, //6
|
|
NullHandler.GetNullValue(oItem.UserObject2ID), //7
|
|
NullHandler.GetNullValue(oItem.UserRecord2ID), //8
|
|
oItem.Description, //9
|
|
oItem.Amount, //10
|
|
NullHandler.GetNullValue(oItem.Modifiedby), //11
|
|
NullHandler.GetNullValue(oItem.ModifiedDate), //12
|
|
(int)oItem.OperationalStatus); //13);
|
|
|
|
tc.ExecuteNonQuery(sSQL);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Update function
|
|
|
|
public static void Update(TransactionContext tc, GLTranUserRecord oItem)
|
|
{
|
|
tc.ExecuteNonQuery("UPDATE GLTranUserRecord SET "
|
|
+ "GLID=%n, " //1
|
|
+ "GLTranID=%n, " //2
|
|
+ "GLTranDetailID=%n, " //3
|
|
+ "UserObject1ID=%n, " //4
|
|
+ "UserRecord1ID=%n, " //5
|
|
+ "UserObject2ID=%n, " //6
|
|
+ "UserRecord2ID=%n, " //7
|
|
+ "Description=%s, " //8
|
|
+ "Amount=%n, " //9
|
|
+ "Modifiedby=%n, " //10
|
|
+ "ModifiedDate=%d " //11
|
|
+ "WHERE GLTranUserRecordID=%n", //12
|
|
oItem.GLID, //1
|
|
oItem.GLTranID, //2
|
|
oItem.GLTranDetailID, //3
|
|
oItem.UserObject1ID, //4
|
|
oItem.UserRecord1ID, //5
|
|
NullHandler.GetNullValue(oItem.UserObject2ID), //6
|
|
NullHandler.GetNullValue(oItem.UserRecord2ID), //7
|
|
NullHandler.GetNullValue(oItem.Description), //8
|
|
oItem.Amount, //9
|
|
NullHandler.GetNullValue(oItem.Modifiedby), //10
|
|
NullHandler.GetNullValue(oItem.ModifiedDate), //11
|
|
oItem.GLTranUserRecordID //12
|
|
);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ID Generation function
|
|
|
|
public static int GetNewID(TransactionContext tc)
|
|
{
|
|
return tc.GenerateID("GLTranUserRecord", "GLTranUserRecordID");
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Get Function
|
|
|
|
public static IDataReader Get(TransactionContext tc)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM GLTranUserRecord");
|
|
}
|
|
|
|
public static IDataReader Get(TransactionContext tc, int nGLTranUserRecordID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM GLTranUserRecord WHERE GLTranUserRecordID = %n",
|
|
nGLTranUserRecordID);
|
|
}
|
|
|
|
public static IDataReader GetByGLTranID(TransactionContext tc, int nGLTranID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM GLTranUserRecord WHERE GLTranID = %n", nGLTranID);
|
|
}
|
|
|
|
public static IDataReader GetByGLTranDetailID(TransactionContext tc, int nGLTranDetailID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM GLTranUserRecord WHERE GLTranDetailID = %n", nGLTranDetailID);
|
|
}
|
|
|
|
internal static IDataReader GetByVoucherDate(TransactionContext tc, DateTime firstDate, DateTime lastDate)
|
|
{
|
|
return tc.ExecuteReader("SELECT GLTranUserRecord.* FROM GLTranUserRecord, GLTran "
|
|
+ " WHERE GLTranUserRecord.GLTranID = GLTran.GLTranID "
|
|
+ " AND GLTran.VoucherDate >= %d AND GLTran.VoucherDate <= %d", firstDate,
|
|
lastDate);
|
|
}
|
|
|
|
internal static IDataReader GetByOpenVoucherDate(TransactionContext tc, DateTime firstDate, DateTime lastDate)
|
|
{
|
|
return tc.ExecuteReader("SELECT OpenGLTranUserRecord.* FROM OpenGLTranUserRecord, OpenGLTran"
|
|
+ " WHERE OpenGLTranUserRecord.OpenGLTranID = OpenGLTran.OpenGLTranID"
|
|
+ " AND OpenGLTran.VoucherDate >= %d AND OpenGLTran.VoucherDate <= %d", firstDate,
|
|
lastDate);
|
|
}
|
|
|
|
internal static IDataReader GetByYearEndVoucherDate(TransactionContext tc, DateTime firstDate,
|
|
DateTime lastDate)
|
|
{
|
|
return tc.ExecuteReader("SELECT YearEndGLTranUserRecord.* FROM YearEndGLTranUserRecord, YearEndGLTran"
|
|
+ " WHERE YearEndGLTranUserRecord.YearEndGLTranID = YearEndGLTran.YearEndGLTranID"
|
|
+ " AND YearEndGLTran.VoucherDate >= %d AND YearEndGLTran.VoucherDate <= %d",
|
|
firstDate, lastDate);
|
|
}
|
|
|
|
public static IDataReader GetByGLID(TransactionContext tc, int gLID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM GLTranUserRecord WHERE GLID = %n", gLID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Delete function
|
|
|
|
public static void Delete(TransactionContext tc, int nGLTranUserRecordID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM GLTranUserRecord WHERE GLTranUserRecordID=%n", nGLTranUserRecordID);
|
|
}
|
|
|
|
public static void DeleteGLTanUOByGLTranID(TransactionContext tc, int nGLTranID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM GLTranUserRecord WHERE GLTranID=%n", nGLTranID);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Opening Stock Take
|
|
|
|
public static void InsertOpen(TransactionContext tc, GLTranUserRecord oItem)
|
|
{
|
|
tc.ExecuteNonQuery("INSERT INTO [OpenGLTranUserRecord](" +
|
|
"OpenGLTranUserRecordID, " + //1
|
|
"GLID, " + //2
|
|
"OpenGLTranID, " + //3
|
|
"OpenGLTranDetailID, " + //4
|
|
"UserObject1ID, " + //5
|
|
"UserRecord1ID, " + //6
|
|
"UserObject2ID, " + //7
|
|
"UserRecord2ID, " + //8
|
|
"Description, " + //9
|
|
"Amount, " + //10
|
|
"Modifiedby, " + //11
|
|
"ModifiedDate, " + //12
|
|
"OperationalStatus)" + //13
|
|
// 1 2 3 4 5 6 7 8 9 10 11 12 13
|
|
" VALUES(%n, %n, %n, %n, %n, %n, %n, %n, %s, %n, %n, %d, %n)",
|
|
oItem.ID, //1
|
|
oItem.GLID, //2
|
|
oItem.GLTranID, //3
|
|
oItem.GLTranDetailID, //4
|
|
oItem.UserObject1ID, //5
|
|
oItem.UserRecord1ID, //6
|
|
NullHandler.GetNullValue(oItem.UserObject2ID), //7
|
|
NullHandler.GetNullValue(oItem.UserRecord2ID), //8
|
|
oItem.Description, //9
|
|
oItem.Amount, //10
|
|
NullHandler.GetNullValue(oItem.Modifiedby), //11
|
|
NullHandler.GetNullValue(oItem.ModifiedDate), //12
|
|
(int)oItem.OperationalStatus //13
|
|
);
|
|
}
|
|
|
|
public static void InsertYearEnd(TransactionContext tc, GLTranUserRecord oItem)
|
|
{
|
|
tc.ExecuteNonQuery("INSERT INTO [YearEndGLTranUserRecord](" +
|
|
"YearEndGLTranUserRecordID, " + //1
|
|
"GLID, " + //2
|
|
"YearEndGLTranID, " + //3
|
|
"YearEndGLTranDetailID, " + //4
|
|
"UserObject1ID, " + //5
|
|
"UserRecord1ID, " + //6
|
|
"UserObject2ID, " + //7
|
|
"UserRecord2ID, " + //8
|
|
"Description, " + //9
|
|
"Amount, " + //10
|
|
"Modifiedby, " + //11
|
|
"ModifiedDate, " + //12
|
|
"OperationalStatus)" + //13
|
|
// 1 2 3 4 5 6 7 8 9 10 11 12 13
|
|
" VALUES(%n, %n, %n, %n, %n, %n, %n, %n, %s, %n, %n, %d, %n)",
|
|
oItem.ID, //1
|
|
oItem.GLID, //2
|
|
oItem.GLTranID, //3
|
|
oItem.GLTranDetailID, //4
|
|
oItem.UserObject1ID, //5
|
|
oItem.UserRecord1ID, //6
|
|
NullHandler.GetNullValue(oItem.UserObject2ID), //7
|
|
NullHandler.GetNullValue(oItem.UserRecord2ID), //8
|
|
oItem.Description, //9
|
|
oItem.Amount, //10
|
|
NullHandler.GetNullValue(oItem.Modifiedby), //11
|
|
NullHandler.GetNullValue(oItem.ModifiedDate), //12
|
|
(int)oItem.OperationalStatus //13
|
|
);
|
|
}
|
|
|
|
public static void UpdateOpen(TransactionContext tc, GLTranUserRecord oItem)
|
|
{
|
|
tc.ExecuteNonQuery("UPDATE [OpenGLTranUserRecord] SET "
|
|
+ "GLID=%n, " //1
|
|
+ "OpenGLTranID=%n, " //2
|
|
+ "OpenGLTranDetailID=%n, " //3
|
|
+ "UserObject1ID=%n, " //4
|
|
+ "UserRecord1ID=%n, " //5
|
|
+ "UserObject2ID=%n, " //6
|
|
+ "UserRecord2ID=%n, " //7
|
|
+ "Description=%s, " //8
|
|
+ "Amount=%n, " //9
|
|
+ "Modifiedby=%n, " //10
|
|
+ "ModifiedDate=%d " //11
|
|
+ "WHERE OpenGLTranUserRecordID=%n", //12
|
|
oItem.GLID, //1
|
|
oItem.GLTranID, //2
|
|
oItem.GLTranDetailID, //3
|
|
oItem.UserObject1ID, //4
|
|
oItem.UserRecord1ID, //5
|
|
NullHandler.GetNullValue(oItem.UserObject2ID), //6
|
|
NullHandler.GetNullValue(oItem.UserRecord2ID), //7
|
|
NullHandler.GetNullValue(oItem.Description), //8
|
|
oItem.Amount, //9
|
|
NullHandler.GetNullValue(oItem.Modifiedby), //10
|
|
NullHandler.GetNullValue(oItem.ModifiedDate), //11
|
|
oItem.GLTranUserRecordID //12
|
|
);
|
|
}
|
|
|
|
public static void UpdateYearEnd(TransactionContext tc, GLTranUserRecord oItem)
|
|
{
|
|
tc.ExecuteNonQuery("UPDATE [YearEndGLTranUserRecord] SET "
|
|
+ "GLID=%n, " //1
|
|
+ "YearEndGLTranID=%n, " //2
|
|
+ "YearEndGLTranDetailID=%n, " //3
|
|
+ "UserObject1ID=%n, " //4
|
|
+ "UserRecord1ID=%n, " //5
|
|
+ "UserObject2ID=%n, " //6
|
|
+ "UserRecord2ID=%n, " //7
|
|
+ "Description=%s, " //8
|
|
+ "Amount=%n, " //9
|
|
+ "Modifiedby=%n, " //10
|
|
+ "ModifiedDate=%d " //11
|
|
+ "WHERE YearEndGLTranUserRecordID=%n", //12
|
|
oItem.GLID, //1
|
|
oItem.GLTranID, //2
|
|
oItem.GLTranDetailID, //3
|
|
oItem.UserObject1ID, //4
|
|
oItem.UserRecord1ID, //5
|
|
NullHandler.GetNullValue(oItem.UserObject2ID), //6
|
|
NullHandler.GetNullValue(oItem.UserRecord2ID), //7
|
|
NullHandler.GetNullValue(oItem.Description), //8
|
|
oItem.Amount, //9
|
|
NullHandler.GetNullValue(oItem.Modifiedby), //10
|
|
NullHandler.GetNullValue(oItem.ModifiedDate), //11
|
|
oItem.GLTranUserRecordID //12
|
|
);
|
|
}
|
|
|
|
#region ID Generation function
|
|
|
|
public static int GetNewIDOpen(TransactionContext tc)
|
|
{
|
|
return tc.GenerateID("OpenGLTranUserRecord", "OpenGLTranUserRecordID");
|
|
}
|
|
|
|
public static int GetNewIDYearEnd(TransactionContext tc)
|
|
{
|
|
return tc.GenerateID("YearEndGLTranUserRecord", "YearEndGLTranUserRecordID");
|
|
}
|
|
|
|
#endregion
|
|
|
|
public static IDataReader GetOpen(TransactionContext tc, int nGLTranUserRecordID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM OpenGLTranUserRecord WHERE OpenGLTranUserRecordID = %n",
|
|
nGLTranUserRecordID);
|
|
}
|
|
|
|
public static IDataReader GetByGLTranIDOpen(TransactionContext tc, int nGLTranID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM OpenGLTranUserRecord WHERE OpenGLTranID = %n", nGLTranID);
|
|
}
|
|
|
|
public static IDataReader GetByGLTranDetailIDOpen(TransactionContext tc, int nGLTranDetailID)
|
|
{
|
|
return tc.ExecuteReader("SELECT * FROM OpenGLTranUserRecord WHERE OpenGLTranDetailID = %n",
|
|
nGLTranDetailID);
|
|
}
|
|
|
|
public static void DeleteGLTanUOByGLTranIDOPen(TransactionContext tc, int nGLTranID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM OpenGLTranUserRecord WHERE OpenGLTranID=%n", nGLTranID);
|
|
}
|
|
|
|
public static void DeleteOpen(TransactionContext tc, int nGLTranUserRecordID)
|
|
{
|
|
tc.ExecuteNonQuery("DELETE FROM OpenGLTranUserRecord WHERE OpenGLTranUserRecordID=%n", nGLTranUserRecordID);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
} |