using Ease.Core.DataAccess; using HRM.BO; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HRM.DA { internal class MaternityLeaveDA { #region Save Methods internal static void Save(TransactionContext tc, MaternityLeave oItem) { string strSQL = SQLParser.MakeSQL("INSERT INTO MaternityLeave(MaternityLeaveID, EmployeeID, ApplicationDate," + " LeaveFromDate ,LeaveToDate, DateOfApproval, ApproveDays, CurrentStatus, DailyAvgEarning," + " MaternityBenifit, TaxAmount, NetAmount, PaidAmount, CreatedBy, CreatedDate)" + " VALUES(%n, %n, %d, %d, %d, %d, %n, %n, %n, %n, %n, %n, %n, %n, %d)", oItem.ID, oItem.EmployeeID, oItem.ApplicationDate, oItem.LeaveFromDate, oItem.LeaveToDate, DataReader.GetNullValue(oItem.DateOfApproval), DataReader.GetNullValue(oItem.ApproveDays), oItem.CurrentStatus, oItem.DailyAvgEarning, oItem.MaternityBenifit, oItem.TaxAmount, oItem.NetAmount, DataReader.GetNullValue(oItem.PaidAmount), oItem.CreatedBy, oItem.CreatedDate); tc.ExecuteNonQuery(strSQL); } internal static void SaveMItemDetail(TransactionContext tc, MaternityLeave.MaternityItemDetail oItem) { string strSQL = SQLParser.MakeSQL("INSERT INTO MaternityItemDetail(MaternityItemDetailID, MaternityLeaveID," + " ItemType, Amount ,Description, MonthDate, IncomeTaxItemType, SalaryComponentID, CreatedBy, CreatedDate)" + "VALUES(%n ,%n, %n, %n, %s, %d, %n, %n, %n, %d)", oItem.ID, oItem.MaternityLeaveID, Convert.ToInt16(oItem.ItemType), oItem.Amount, oItem.Description, oItem.MonthDate, Convert.ToInt16(oItem.IncomeTaxItemType), oItem.SalaryComponentID, oItem.CreatedBy, oItem.CreatedDate); tc.ExecuteNonQuery(strSQL); } internal static void SaveMStatusDetail(TransactionContext tc, MaternityLeave.MaternityStatusDetail oItem) { string strSQL = SQLParser.MakeSQL("INSERT INTO MaternityStatusDetail(MaternityStatusDetailID, MaternityLeaveID, Status," + "PaymentDate, Amount, PaymentDays, CreatedBy, CreatedDate) VALUES(%n, %n, %n, %d, %n, %n, %n, %d)", oItem.ID, oItem.MaternityLeaveID, oItem.Status, DataReader.GetNullValue(oItem.PaymentDate), oItem.Amount, oItem.PaymentDays, oItem.CreatedBy, oItem.CreatedDate); tc.ExecuteNonQuery(strSQL); } #endregion Save Methods #region Update Methods internal static void Update(TransactionContext tc, MaternityLeave oItem) { string sSql = SQLParser.MakeSQL("UPDATE MaternityLeave SET ApplicationDate=%d," + " LeaveFromDate=%d ,LeaveToDate=%d, DateOfApproval=%d, ApproveDays=%n, CurrentStatus=%n," + " DailyAvgEarning=%n,MaternityBenifit=%n, TaxAmount=%n, NetAmount=%n, PaidAmount=%n, " + "ModifiedBy=%n, ModifiedDate=%d WHERE MaternityLeaveID=%n", oItem.ApplicationDate, oItem.LeaveFromDate, oItem.LeaveToDate, oItem.DateOfApproval, oItem.ApproveDays, oItem.CurrentStatus, oItem.DailyAvgEarning, oItem.MaternityBenifit, oItem.TaxAmount, oItem.NetAmount, oItem.PaidAmount, oItem.ModifiedBy, oItem.ModifiedDate, oItem.ID); tc.ExecuteNonQuery(sSql); } #endregion Update Methods #region Get Methods internal static IDataReader Get(TransactionContext tc) { return tc.ExecuteReader("SELECT * FROM MaternityLeave ORDER BY MaternityLeaveID DESC"); } internal static IDataReader Get(TransactionContext tc, Employee oEmployee) { return tc.ExecuteReader("SELECT * FROM MaternityLeave WHERE EmployeeID =%n", oEmployee.ID); } internal static IDataReader Get(TransactionContext tc, int id) { return tc.ExecuteReader("SELECT * FROM MaternityLeave WHERE MaternityLeaveID = %n", id); } internal static IDataReader GetMItemDetailByParent(TransactionContext tc, int maternityLeaveID) { return tc.ExecuteReader("SELECT * FROM MaternityItemDetail WHERE MaternityLeaveID = %n", maternityLeaveID); } internal static IDataReader GetMStatusDetailByParent(TransactionContext tc, int maternityLeaveID) { return tc.ExecuteReader("SELECT * FROM MaternityStatusDetail WHERE MaternityLeaveID = %n", maternityLeaveID); } internal static int GetTotalMonthlyHolidays(TransactionContext tc, int loactionNumber, DateTime firstDateOfMonth, DateTime lastDateOfMonth) { int totalMonthlyHolidays = 0; object holidays = tc.ExecuteScalar("SELECT Count(*) FROM HolidayCalendar WHERE HoliDayDate >= %d AND HoliDayDate <= %d AND LocationID=%n", firstDateOfMonth, lastDateOfMonth, loactionNumber); if (holidays != DBNull.Value) { totalMonthlyHolidays = Convert.ToInt32(holidays); } return totalMonthlyHolidays; } #endregion Get Methods #region Delete Methods internal static void Delete(TransactionContext tc, int maternityLeaveID) { tc.ExecuteNonQuery("DELETE FROM MaternityLeave WHERE MaternityLeaveID=%n", maternityLeaveID); } internal static void DeleteMItemDetailByParent(TransactionContext tc, int maternityLeaveID) { tc.ExecuteNonQuery("DELETE FROM MaternityItemDetail WHERE MaternityLeaveID=%n", maternityLeaveID); } internal static void DeleteMStatusDetailByParent(TransactionContext tc, int maternityLeaveID) { tc.ExecuteNonQuery("DELETE FROM MaternityStatusDetail WHERE MaternityLeaveID=%n", maternityLeaveID); } #endregion Delete Methods } }