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 GradeDA internal class GradeDA { #region Constructor private GradeDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, Grade item) { tc.ExecuteNonQuery("INSERT INTO GRADES(GradeID, code, description,colorcode, maxbasic, minbasic, isfreetransport, hasGrossConcept, basicPercentofGross, hasPayscale, confirmMonthDuration, gradeSegmentID, CreatedBy, CreationDate, SequenceNo, Status,PAYROLLTYPEID,RequiredDays)" + " VALUES(%n, %s, %s,%s, %n, %n, %b, %b, %n, %b, %n, %n, %n, %d, %n, %n,%n,%n)", item.ID.Integer, item.Code, item.Name, item.ColorCode, item.MaxBasic, item.MinBasic, item.IsTransport, item.HasGrossConcept, item.BasicPercentofGross, item.HasPayscale, item.ConfirmMonthDuration, item.GradeSegmentID.Integer, item.CreatedBy.Integer, item.CreatedDate, item.Sequence, item.Status, SystemInformation.CurrentSysInfo.PayrollTypeID.Integer, item.RequiredDays); } #endregion #region Update function internal static void Update(TransactionContext tc, Grade item) { tc.ExecuteNonQuery("UPDATE GRADES SET code=%s, description=%s,colorcode=%s, maxbasic=%n, minbasic=%n, isfreetransport=%b, hasGrossConcept=%b, basicPercentofGross=%n, hasPayscale=%b, confirmMonthDuration=%n, gradeSegmentID=%n, ModifiedBy=%n, ModifiedDate=%d, SequenceNo=%n, Status=%n,RequiredDays=%n" + " WHERE GradeID=%n", item.Code, item.Name,item.ColorCode, item.MaxBasic, item.MinBasic, item.IsTransport, item.HasGrossConcept, item.BasicPercentofGross, item.HasPayscale, item.ConfirmMonthDuration, item.GradeSegmentID.Integer, item.ModifiedBy.Integer, item.ModifiedDate, item.Sequence, item.Status,item.RequiredDays, item.ID.Integer); tc.ExecuteNonQuery("UPDATE IncomeTaxYearly SET ItemCode=-222,Itemid=-222 WHERE Description='L.T.A. / Medical Allowance'"); } #endregion #region Get Function internal static IDataReader GetRegardlessPayrollType(TransactionContext tc, EnumStatus status, int payrollTypeID) { if (EnumStatus.Active == status || EnumStatus.Inactive == status) return tc.ExecuteReader("SELECT * FROM GRADES where Status=%n order by Code", status, payrollTypeID); else return tc.ExecuteReader("SELECT * FROM GRADES order by Code", payrollTypeID); } internal static IDataReader Get(TransactionContext tc, EnumStatus status, int payrollTypeID) { if (EnumStatus.Active == status || EnumStatus.Inactive == status) return tc.ExecuteReader("SELECT * FROM GRADES where Status=%n AND PayrollTypeID=%n order by SequenceNo", status, payrollTypeID); else return tc.ExecuteReader("SELECT * FROM GRADES Where PayrollTypeID=%n order by SequenceNo", payrollTypeID); //if (EnumStatus.Active == status || EnumStatus.Inactive == status) // return tc.ExecuteReader("SELECT * FROM GRADES where Status=%n order by SequenceNo", status); //else // return tc.ExecuteReader("SELECT * FROM GRADES order by SequenceNo"); } internal static IDataReader GetAllPayrollTypes(TransactionContext tc, EnumStatus status) { if (EnumStatus.Active == status || EnumStatus.Inactive == status) return tc.ExecuteReader("SELECT * FROM GRADES where Status=%n order by SequenceNo", status); else return tc.ExecuteReader("SELECT * FROM GRADES order by SequenceNo"); } internal static IDataReader GetAllowableGrades(TransactionContext tc, int nOpiItmeID, int nOpiParamID, int payrollTypeID) { return tc.ExecuteReader("SELECT * FROM Grades WHERE GradeID NOT IN (SELECT DISTINCT(GradeID) FROM OpiParameterGrade, OpiParameter " + "WHERE OpiParameterGrade.OpiParameterID=OpiParameter.OpiParameterID " + "AND OpiParameterGrade.OpiItemID=%n AND OpiParameterGrade.OpiParameterID <> %n)" + "AND Grades.PayrollTypeID=%n", nOpiItmeID, nOpiParamID, payrollTypeID); } internal static IDataReader GetAddableGrades(TransactionContext tc, int nAllowDeductID, int nADParamID, int payrollTypeID) { string sQuary = SQLParser.MakeSQL("SELECT * FROM Grades WHERE GradeID NOT IN (SELECT DISTINCT(GradeID) FROM ADParameterGrade, ADParameterBasic " + "WHERE ADParameterGrade.ADParameterID=ADParameterBasic.ADParameterID " + "AND AllowDeductID=%n AND ADParameterGrade.ADParameterID <> %n)" + "AND Grades.PayrollTypeID=%n order by Grades.Code", nAllowDeductID, nADParamID, payrollTypeID); return tc.ExecuteReader(sQuary); } internal static IDataReader GetAddableGradesForOT(TransactionContext tc, int nTermID, int nTermParameterID, int payrollTypeID) { return tc.ExecuteReader("SELECT * FROM Grades Where GradeID NOT IN(SELECT Distinct(GradeID) FROM TermEntityGrade, TermParameter " + "WHERE TermEntityGrade.TermEntityID=TermParameter.TermParameterID " + "AND TermID=%n AND TermEntityGrade.TermEntityID <> %n)" + "AND Grades.PayrollTypeID=%n", nTermID, nTermParameterID, payrollTypeID); } internal static IDataReader GetAddableGradesForBonus(TransactionContext tc, int nBonusID, int payrollTypeID) { return tc.ExecuteReader("SELECT * FROM Grades Where GradeID NOT IN "+ "(SELECT Distinct(GradeID) FROM BonusGrades,BONUSPARAMETER "+ "WHERE BonusGrades.BonusID=BONUSPARAMETER.BonusID AND BONUSPARAMETER.BonusID=%n AND BonusParameter.BonusID<>%n) " + "AND Grades.PayrollTypeID=%n", nBonusID, nBonusID,payrollTypeID); } internal static IDataReader GetAddableGradesForLoanParameter(TransactionContext tc, int LoaniD, int LoanParameterId, int payrollTypeID) { string sSQL = string.Format("Select * from GRADES where GRADEID not in (Select Distinct GradeID from LoanGrades,"+ " LoanParameter where LoanParameter.LoanParameterID=LoanGrades.LoanParameterID AND LoanGrades.LoanID={0} " + " AND LoanGrades.LoanParameterID <>{1}) AND Grades.PayrollTypeID={2} Order by CODE", LoaniD, LoanParameterId, payrollTypeID); string query = SQLParser.MakeSQL(sSQL); return tc.ExecuteReader(query); } internal static IDataReader Get(TransactionContext tc, ID nID) { return tc.ExecuteReader("SELECT * FROM GRADES WHERE GradeID=%n", nID.Integer); } internal static IDataReader Get(TransactionContext tc, string sCode, int payrollTypeID) { return tc.ExecuteReader("SELECT * FROM GRADES WHERE Code=%s AND PayrollTypeID=%n ", sCode, payrollTypeID); } #endregion #region Delete function internal static void Delete(TransactionContext tc, ID nID) { tc.ExecuteNonQuery("UPDATE [GRADES] SET CreatedBy=%n,modifiedby=%n Where GradeID=%n", Payroll.BO.User.CurrentUser.ID.Integer, Payroll.BO.User.CurrentUser.ID.Integer, nID.Integer); tc.ExecuteNonQuery("DELETE FROM [GRADES] WHERE GradeID=%n", nID.Integer); } #endregion } #endregion }