using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ease.CoreV35.DataAccess; using System.Data; using HRM.BO; using Ease.Core.DataAccess; namespace HRM.DA { #region AttnWiseAllowanceDA class AttnWiseAllowanceDA { #region Constructor private AttnWiseAllowanceDA() { } #endregion #region Insert function internal static void Insert(TransactionContext tc, AttnWiseAllowance item) { string sql = SQLParser.MakeSQL(@"INSERT INTO AttnWiseAllowance( ShiftID, ProvisionID,ProvisionType, HasHour, HasHourOverShift,IncludeLeave, Multiple,FixedAmount, PercentOfBasic, CreatedBy, CreatedDate, IncludeHoliday, ConsiderPresentHour, PayrollTypeID, TimeDependent, FromTime, ToTime, ConsiderOutTime, WorkTime, GraceTime) VALUES( %n, %n,%n, %n, %n, %n, %b, %b, %b, %n,%D, %n,%n, %n, %b, %D, %D, %n, %n, %n)", item.ShiftID, item.ProvisionID, (int)item.ProvisionType, item.ConsiderShiftHour, item.HoursOverShift, item.OnLeave, item.Multiple, item.FixedAmount, item.PercentOfBasic, item.CreatedBy, item.CreatedDate, item.OnHoliday, item.ConsiderPresentHour, item.PayrollTypeID, item.TimeDependent, DataReader.GetNullValue(item.FromTime), DataReader.GetNullValue(item.ToTime), DataReader.GetNullValue(item.ConsiderOutTime), DataReader.GetNullValue(item.WorkTime), DataReader.GetNullValue(item.GraceTime)); tc.ExecuteNonQuery(sql); } #endregion #region Update function internal static void Update(TransactionContext tc, AttnWiseAllowance item) { string sql = SQLParser.MakeSQL(@"UPDATE AttnWiseAllowance SET ShiftID=%n, ProvisionID=%n,ProvisionType=%n, HasHour=%b, HasHourOverShift=%b,IncludeLeave=%b, Multiple=%n, FixedAmount=%n, PercentOfBasic=%n, ModifiedBy=%n, ModifiedDate=%D, IncludeHoliday=%n, ConsiderPresentHour=%n, TimeDependent = %b, FromTime = %D, ToTime = %D, ConsiderOutTime = %n, WorkTime = %n, GraceTime = %n Where AttnWiseAllowanceID=%n", item.ShiftID, item.ProvisionID, (int)item.ProvisionType, item.ConsiderShiftHour, item.HoursOverShift, item.OnLeave, item.Multiple, item.FixedAmount, item.PercentOfBasic, item.ModifiedBy, item.ModifiedDate.Value, item.OnHoliday, item.ConsiderPresentHour, item.TimeDependent, DataReader.GetNullValue(item.FromTime), DataReader.GetNullValue(item.ToTime), DataReader.GetNullValue(item.ConsiderOutTime), DataReader.GetNullValue(item.WorkTime), DataReader.GetNullValue(item.GraceTime), item.ID); tc.ExecuteNonQuery(sql); } #endregion #region Get Function internal static IDataReader Get(TransactionContext tc, int payrollTypeID) { return tc.ExecuteReader(@"SELECT AttnWiseAllowance.*, Shift.Name ShiftName ,CASE WHEN AttnWiseAllowance.PROVISIONTYPE = 1 THEN 'Ordinary Hour Deduct' WHEN AttnWiseAllowance.PROVISIONTYPE = 22 THEN 'Ordinary Hour Extra' WHEN AttnWiseAllowance.PROVISIONTYPE = 23 THEN 'Badli Shift Allowance' ELSE COALESCE(ALLOWANCEDEDUCTION.NAME,TERM.NAME) END ProvisionName FROM AttnWiseAllowance INNER JOIN Shift ON AttnWiseAllowance.ShiftID = Shift.ShiftID LEFT JOIN ALLOWANCEDEDUCTION ON AttnWiseAllowance.PROVISIONID = ALLOWANCEDEDUCTION.ALLOWDEDUCTID AND AttnWiseAllowance.PROVISIONTYPE = 2 LEFT JOIN TERM ON AttnWiseAllowance.PROVISIONID = TERM.TERMID AND AttnWiseAllowance.PROVISIONTYPE = 4 Where AttnWiseAllowance.PayrollTypeID=%n Order By ProvisionName asc", payrollTypeID); } internal static IDataReader Get(TransactionContext tc, int nID, int payrollTypeID) { return tc.ExecuteReader(@"SELECT AttnWiseAllowance.*, Shift.Name ShiftName, CASE WHEN AttnWiseAllowance.PROVISIONTYPE = 1 THEN 'Ordinary Hour Deduct' WHEN AttnWiseAllowance.PROVISIONTYPE = 22 THEN 'Ordinary Hour Extra' WHEN AttnWiseAllowance.PROVISIONTYPE = 23 THEN 'Badli Shift Allowance' ELSE COALESCE(ALLOWANCEDEDUCTION.NAME,TERM.NAME) END ProvisionName FROM AttnWiseAllowance INNER JOIN Shift ON AttnWiseAllowance.ShiftID = Shift.ShiftID LEFT JOIN ALLOWANCEDEDUCTION ON AttnWiseAllowance.PROVISIONID = ALLOWANCEDEDUCTION.ALLOWDEDUCTID AND AttnWiseAllowance.PROVISIONTYPE = 2 LEFT JOIN TERM ON AttnWiseAllowance.PROVISIONID = TERM.TERMID AND AttnWiseAllowance.PROVISIONTYPE = 4 WHERE AttnWiseAllowanceID=%n AND AttnWiseAllowance.PayrollTypeID=%d", nID, payrollTypeID); } internal static IDataReader Get(TransactionContext tc, int shiftid, EnumAttendanceType attntype, bool value) { if (attntype == EnumAttendanceType.Leave) { return tc.ExecuteReader(@"SELECT AttnWiseAllowance.*, Shift.Name ShiftName, CASE WHEN AttnWiseAllowance.PROVISIONTYPE = 1 THEN 'Ordinary Hour' WHEN AttnWiseAllowance.PROVISIONTYPE = 22 THEN 'Ordinary Hour Extra' WHEN AttnWiseAllowance.PROVISIONTYPE = 23 THEN 'Badli Shift Allowance' ELSE COALESCE(ALLOWANCEDEDUCTION.NAME,TERM.NAME) END ProvisionName FROM AttnWiseAllowance INNER JOIN Shift ON AttnWiseAllowance.ShiftID = Shift.ShiftID LEFT JOIN ALLOWANCEDEDUCTION ON AttnWiseAllowance.PROVISIONID = ALLOWANCEDEDUCTION.ALLOWDEDUCTID AND AttnWiseAllowance.PROVISIONTYPE = 2 LEFT JOIN TERM ON AttnWiseAllowance.PROVISIONID = TERM.TERMID AND AttnWiseAllowance.PROVISIONTYPE = 4 WHERE AttnWiseAllowance.ShiftID=%n AND AttnWiseAllowance.INCLUDELEAVE=%n", shiftid, value); } else if (attntype == EnumAttendanceType.Holiday) { return tc.ExecuteReader(@"SELECT AttnWiseAllowance.*, Shift.Name ShiftName, CASE WHEN AttnWiseAllowance.PROVISIONTYPE = 1 THEN 'Ordinary Hour' ELSE COALESCE(ALLOWANCEDEDUCTION.NAME,TERM.NAME) END ProvisionName FROM AttnWiseAllowance INNER JOIN Shift ON AttnWiseAllowance.ShiftID = Shift.ShiftID LEFT JOIN ALLOWANCEDEDUCTION ON AttnWiseAllowance.PROVISIONID = ALLOWANCEDEDUCTION.ALLOWDEDUCTID AND AttnWiseAllowance.PROVISIONTYPE = 2 LEFT JOIN TERM ON AttnWiseAllowance.PROVISIONID = TERM.TERMID AND AttnWiseAllowance.PROVISIONTYPE = 4 WHERE AttnWiseAllowance.ShiftID=%n AND AttnWiseAllowance.INCLUDEHOLIDAY=%n", shiftid, value); } else if (attntype == EnumAttendanceType.Present) { value = false; return tc.ExecuteReader(@"SELECT AttnWiseAllowance.*, Shift.Name ShiftName, CASE WHEN AttnWiseAllowance.PROVISIONTYPE = 1 THEN 'Ordinary Hour' ELSE COALESCE(ALLOWANCEDEDUCTION.NAME,TERM.NAME) END ProvisionName FROM AttnWiseAllowance INNER JOIN Shift ON AttnWiseAllowance.ShiftID = Shift.ShiftID LEFT JOIN ALLOWANCEDEDUCTION ON AttnWiseAllowance.PROVISIONID = ALLOWANCEDEDUCTION.ALLOWDEDUCTID AND AttnWiseAllowance.PROVISIONTYPE = 2 LEFT JOIN TERM ON AttnWiseAllowance.PROVISIONID = TERM.TERMID AND AttnWiseAllowance.PROVISIONTYPE = 4 WHERE AttnWiseAllowance.ShiftID=%n AND AttnWiseAllowance.INCLUDEHOLIDAY=%n AND AttnWiseAllowance.INCLUDELEAVE=%n", shiftid, value, value); } else { //need to discuss with boss about SecondDay Onward type. value = false; return tc.ExecuteReader(@"SELECT AttnWiseAllowance.*, Shift.Name ShiftName, CASE WHEN AttnWiseAllowance.PROVISIONTYPE = 1 THEN 'Ordinary Hour' ELSE COALESCE(ALLOWANCEDEDUCTION.NAME,TERM.NAME) END ProvisionName FROM AttnWiseAllowance INNER JOIN Shift ON AttnWiseAllowance.ShiftID = Shift.ShiftID LEFT JOIN ALLOWANCEDEDUCTION ON AttnWiseAllowance.PROVISIONID = ALLOWANCEDEDUCTION.ALLOWDEDUCTID AND AttnWiseAllowance.PROVISIONTYPE = 2 LEFT JOIN TERM ON AttnWiseAllowance.PROVISIONID = TERM.TERMID AND AttnWiseAllowance.PROVISIONTYPE = 4 WHERE AttnWiseAllowance.ShiftID=%n AND AttnWiseAllowance.INCLUDEHOLIDAY=%n AND AttnWiseAllowance.INCLUDELEAVE=%n", shiftid, value, value); } } #endregion #region Delete function internal static void Delete(TransactionContext tc, int nID) { tc.ExecuteNonQuery("DELETE FROM AttnWiseAllowance WHERE AttnWiseAllowanceID=%n", nID); } #endregion } #endregion }