using HRM.BO; using Ease.Core.DataAccess; using System; using System.Data; namespace HRM.DA { #region UnAuthorizeLeaveParameterDA internal class UnAuthorizeLeaveParameterDA { #region Constructor private UnAuthorizeLeaveParameterDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, UnAuthorizeLeaveParam item) { tc.ExecuteNonQuery("INSERT INTO UALeaveParam(UaLeaveParamID, UaLeaveID, CreatedBy, CreationDate, payrolltypeid)" + " VALUES(%n, %n, %n, %d, %n)", item.ID, item.UnAhuthorizeLeaveID, item.CreatedBy, item.CreatedDate,item.PayrollTypeID); } internal static void InsertGrade(TransactionContext tc, UnAuthorizeLeaveParam.UnAuthorizeLeaveParamGrade item) { tc.ExecuteNonQuery("INSERT INTO UALeaveParamGrade(UaLeaveParamIDGradeID,UaLeaveParamID, GradeID)" + " VALUES(%n, %n, %n)", item.id, item.paramID, item.gradeID); } internal static void Insert(TransactionContext tc, UnAuthorizeLeaveParamDetail item) { string sql = SQLParser.MakeSQL( @"INSERT INTO LEAVESUSPENSEDEDUCT(LeaveID,ParamDetailID, UaLeaveParamID, allowanceID, valueInPercent, Type)" + " VALUES(%n,%n, %n, %n, %n, %n)", item.LeaveID, item.ID, item.UNLeaveParamID, item.AllowanceID, item.ValueInPercent, (int)item.Type); tc.ExecuteNonQuery( "INSERT INTO LEAVESUSPENSEDEDUCT(LeaveID,ParamDetailID, UaLeaveParamID, allowanceID, valueInPercent, Type)" + " VALUES(%n,%n, %n, %n, %n, %n)", item.LeaveID, item.ID, item.UNLeaveParamID, item.AllowanceID, item.ValueInPercent, (int)item.Type); } #endregion #region Update function internal static void Update(TransactionContext tc, UnAuthorizeLeaveParam item) { tc.ExecuteNonQuery("UPDATE UALeaveParam SET UaLeaveID=%n, ModifiedBy=%n, ModifiedDate=%d" + " WHERE UaLeaveParamID=%n", item.UnAhuthorizeLeaveID, item.ModifiedBy, item.ModifiedDate, item.ID); } #endregion #region Get Function internal static IDataReader GetbyPayrollType(TransactionContext tc, int payrollTypeID) { return tc.ExecuteReader("SELECT * FROM UALeaveParam where payrollTypeID=%n", payrollTypeID); } internal static IDataReader GetbygradeID(TransactionContext tc, int gradeid) { return tc.ExecuteReader(@"SELECT Distinct u.* FROM UALeaveParam u, UALeaveParamGrade g where g.UaLeaveParamID=u.UaLeaveParamID and g.GradeID=%n ", gradeid); } internal static IDataReader GetUsedGrades(TransactionContext tc, int UaLeaveID) { return tc.ExecuteReader(@"select UALeaveParamGrade.* from UALeaveParamGrade where UaLeaveParamID in ( select UaLeaveParamID from UALeaveParam where UaLeaveID = %n)", UaLeaveID); } internal static IDataReader GetAllGrades(TransactionContext tc) { return tc.ExecuteReader(@"select *from UALeaveParamGrade"); } internal static IDataReader Get(TransactionContext tc, int nID) { return tc.ExecuteReader("SELECT * FROM UALeaveParam WHERE UaLeaveParamID=%n", nID); } internal static IDataReader GetDetail(TransactionContext tc, int nID) { return tc.ExecuteReader("SELECT * FROM LEAVESUSPENSEDEDUCT WHERE UaLeaveParamID=%n", nID); } internal static IDataReader GetAllDetail(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM LEAVESUSPENSEDEDUCT "); } internal static IDataReader GetGrades(TransactionContext tc, int nID) { return tc.ExecuteReader( "SELECT ug.*, g.description as GradeName FROM UALeaveParamGrade ug, GRADES g WHERE ug.gradeid=g.gradeid and UaLeaveParamID=%n", nID); } internal static IDataReader GetByLeaveID(TransactionContext tc, int nLeaveID) { return tc.ExecuteReader("SELECT * FROM UALeaveParam WHERE UaLeaveID=%n", nLeaveID); } #endregion #region Delete function internal static void DeleteDetail(TransactionContext tc, int nID) { tc.ExecuteNonQuery("DELETE FROM LEAVESUSPENSEDEDUCT WHERE UaLeaveParamID=%n", nID); } internal static void DeleteGrade(TransactionContext tc, int nID) { tc.ExecuteNonQuery("DELETE FROM UALeaveParamGrade WHERE UaLeaveParamID=%n", nID); } internal static void Delete(TransactionContext tc, int nID) { tc.ExecuteNonQuery("DELETE FROM LEAVESUSPENSEDEDUCT WHERE UaLeaveParamID=%n", nID); tc.ExecuteNonQuery("DELETE FROM UALeaveParam WHERE UaLeaveParamID=%n", nID); } internal static void DeleteByLeaveID(TransactionContext tc, int nID) { tc.ExecuteNonQuery( "DELETE FROM LEAVESUSPENSEDEDUCT WHERE UaLeaveParamID IN (SELECT UaLeaveParamID FROM UALeaveParam WHERE UaLeaveID =%n)", nID); tc.ExecuteNonQuery("DELETE FROM UALeaveParam WHERE UaLeaveID=%n", nID); } #endregion } #endregion }