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 CapitalizationDA { #region Constructor private CapitalizationDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, Capitalization item) { tc.ExecuteNonQuery("INSERT INTO Capitalization(CapitalizationID, SalaryMonth, DepartmentID, Percentage, CreatedBy, CreationDate)" + " VALUES(%n, %d, %n, %n, %n, %d)", item.ID.Integer, item.SalaryMonth, item.DepartmentID.Integer, item.Percent, item.CreatedBy.Integer, item.CreatedDate); } #endregion #region Update function internal static void Update(TransactionContext tc, Capitalization item) { tc.ExecuteNonQuery("UPDATE Capitalization SET SalaryMonth=%d, DepartmentID=%n, Percentage=%n, ModifiedBy=%n, ModifiedDate=%d" + " WHERE CapitalizationID=%n", item.SalaryMonth, item.DepartmentID.Integer, item.Percent, item.ModifiedBy.Integer, item.ModifiedDate, item.ID.Integer); } #endregion #region Get Function internal static IDataReader Get(TransactionContext tc, ID departmentID, DateTime salaryMonth) { return tc.ExecuteReader("SELECT * FROM Capitalization WHERE DepartmentID=%n AND SalaryMonth=%d", departmentID.Integer, salaryMonth); } internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM Capitalization"); } internal static IDataReader Get(TransactionContext tc, ID departmentID) { return tc.ExecuteReader("SELECT * FROM Capitalization Where DepartmentID = %n", departmentID.Integer); } internal static IDataReader Get(TransactionContext tc, DateTime salaryMonth) { return tc.ExecuteReader("SELECT * FROM Capitalization Where SalaryMonth=%d", salaryMonth); } #endregion public static bool IsExist(TransactionContext tc, ID DepartmentID, DateTime SalaryMonth) { bool Exist = false; Object obj = tc.ExecuteScalar("Select COUNT (*) FROM Capitalization WHERE DepartmentID=%n AND SalaryMonth=%d", DepartmentID.Integer, SalaryMonth); Exist = Convert.ToInt32(obj) > 0 ? true : false; return Exist; } public static void Delete(TransactionContext tc, ID deptID) { tc.ExecuteNonQuery("DELETE FROM Capitalization WHERE DepartmentID=%n", deptID.Integer); } internal static IDataReader GetMaxDate(TransactionContext tc) { string sql = SQLParser.MakeSQL(@"SELECT MAX(SalaryMonth) MaximumSalaryMonth FROM Capitalization"); return tc.ExecuteReader(sql); } } }