EchoTex_Payroll/HRM.Report/Attendence/Class/AttendanceReport.cs
2024-10-14 10:01:49 +06:00

1693 lines
97 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using Payroll.BO;
using Ease.CoreV35;
using Ease.Core.Model;
using Ease.Core.Utility;
using System.Windows;
using HRM.BO;
using HRM.DA;
using System.IO;
using Microsoft.Reporting.NETCore;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Math.EC.Multiplier;
using static HRM.BO.ADParameter;
using static System.Net.Mime.MediaTypeNames;
using NPOI.SS.Formula.Functions;
using Microsoft.VisualBasic;
using System.Net.NetworkInformation;
namespace HRM.Report
{
public class AttendanceReport
{
List<AllowanceDeduction> oAllDeducts;
public byte[] GetMonthlyAttendanceReportNew(DateTime dFromDate, DateTime dToDate, string sEmpID, string reportType, int payrollTypeID)
{
DataRow tempDatarow = null;
DataSet resultingDataSet = new DataSet();
string RDLCName = "HRM.Report.Attendence.RDLC.MonthlyAttendanceReportNew.rdlc";
int presentDays = 0, absentDays = 0, lateDays = 0, leaveDays = 0, weeklyHolidays = 0, osdDays = 0, festivalHolidays = 0;
Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyAttendanceReportNewDataTable oMonthlyAttendanceReportNewDataTable = new Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyAttendanceReportNewDataTable();
DataSet AttendanceReportData = new DailyAttnProcessService().GetMonthlyAttendanceReportData(dFromDate, dToDate, sEmpID);
if (AttendanceReportData != null && AttendanceReportData.Tables.Count > 0)
{
foreach (DataRow dr in AttendanceReportData.Tables[0].Rows)
{
tempDatarow = oMonthlyAttendanceReportNewDataTable.NewRow();
tempDatarow["DEPNAME"] = dr["DEPNAME"] != DBNull.Value ? dr["DEPNAME"].ToString() : string.Empty;
tempDatarow["EMPLOYEENO"] = dr["EMPLOYEENO"] != DBNull.Value ? dr["EMPLOYEENO"].ToString() : string.Empty;
tempDatarow["NAME"] = dr["NAME"] != DBNull.Value ? dr["NAME"].ToString() : string.Empty;
tempDatarow["DESNAME"] = dr["DESNAME"] != DBNull.Value ? dr["DESNAME"].ToString() : string.Empty;
tempDatarow["LOC"] = dr["LOC"] != DBNull.Value ? dr["LOC"].ToString() : string.Empty;
tempDatarow["AttnDate"] = dr["AttnDate"] != DBNull.Value ? Convert.ToDateTime(dr["AttnDate"].ToString()).ToString("dd-MMM-yyyy") : string.Empty;
tempDatarow["InTime"] = dr["InTime"] != DBNull.Value ? Convert.ToDateTime(dr["InTime"].ToString()).ToString("hh:mm tt") : string.Empty;
tempDatarow["OutTime"] = dr["OutTime"] != DBNull.Value ? Convert.ToDateTime(dr["OutTime"].ToString()).ToString("hh:mm tt") : string.Empty;
tempDatarow["WorkHour"] = dr["WorkHour"] != DBNull.Value ? Convert.ToDouble(dr["WorkHour"].ToString()).ToString("0.00") : string.Empty;
tempDatarow["LateHour"] = dr["LateHour"] != DBNull.Value ? Convert.ToDouble(dr["LateHour"].ToString()).ToString("0.00") : string.Empty;
tempDatarow["AttenType"] = dr["AttenType"] != DBNull.Value ? dr["AttenType"].ToString() : string.Empty;
string tempAttnType = GlobalFunctions.GetShortAttnType((EnumAttendanceType)Convert.ToInt32(dr["AttenType"].ToString()), ref presentDays, ref absentDays, ref lateDays, ref leaveDays, ref weeklyHolidays, ref osdDays, ref festivalHolidays);
tempDatarow["WorkDayName"] = dr["WorkDayName"] != DBNull.Value ? dr["WorkDayName"].ToString() : tempAttnType;
oMonthlyAttendanceReportNewDataTable.Rows.Add(tempDatarow);
}
}
oMonthlyAttendanceReportNewDataTable.TableName = "AttendenceDataSet_MonthlyAttendanceReportNew";
resultingDataSet.Tables.Add(oMonthlyAttendanceReportNewDataTable);
List<ReportParameter> PReportParameters = SetExtraMonthlyAttendanceReportNewParameter(dFromDate, dToDate);
return new ReportProcessor().CommonReportView(null, RDLCName, resultingDataSet, null, PReportParameters, true, payrollTypeID, reportType);
}
public List<ReportParameter> SetExtraMonthlyAttendanceReportNewParameter(DateTime fromDate, DateTime toDate)
{
List<ReportParameter> PReportParameters = new List<ReportParameter>();
ReportParameter oReportParameter = null;
oReportParameter = new ReportParameter("FromDate", fromDate.ToString("dd-MMM-yyyy"));
PReportParameters.Add(oReportParameter);
oReportParameter = new ReportParameter("ToDate", toDate.ToString("dd-MMM-yyyy"));
PReportParameters.Add(oReportParameter);
return PReportParameters;
}
public byte[] GetMonthlyKPI(EnumAttendanceType eAttnType, DateTime dFromDate, DateTime dToDate, string sEmpID, string reportType, int payrollTypeID)
{
ReportProcessor reportProcessor = new ReportProcessor();
DataSet oMonthlyKPIDetail = null;
oMonthlyKPIDetail = new DailyAttnProcessService().GetMonthlyKPIDetail(dFromDate, dToDate, sEmpID, eAttnType);
//DataSet MonthlyKpiDetailsWithLeave = calculateLeave(oMonthlyKPIDetail);
HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.MnthlyKPIDtlSummaryDataTable oMnthlyKPIDtlSummary = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.MnthlyKPIDtlSummaryDataTable();
#region Summary Parts
if (oMonthlyKPIDetail.Tables.Count > 0 && oMonthlyKPIDetail.Tables[0].Rows.Count > 0)
{
var groupedData = oMonthlyKPIDetail.Tables[0]
.AsEnumerable()
.GroupBy(x => x.Field<string>("IDNo"))
.Select(g => new { EmployeeNo = g.Key, OTSum = g.Sum(x => Convert.ToDouble(x["OTHour"].ToString())), OTAvg = g.Sum(x => Convert.ToDouble(x["OTHour"].ToString())) / g.Count(), OTGreaterThan5 = g.Count(x => Convert.ToDouble(x["OTHour"].ToString()) > 5) })
.ToList();
DataRow dRow = oMnthlyKPIDtlSummary.NewRow();
dRow["ManPower"] = groupedData.Count();
dRow["PerAvgOTGreater2"] = groupedData.Count(x => x.OTAvg > 2);
dRow["PerSumOTGreater75"] = groupedData.Count(x => x.OTSum > 75);
dRow["PerSumOTGreater100"] = groupedData.Count(x => x.OTSum > 100);
dRow["PerSumOTGreater52"] = groupedData.Count(x => x.OTSum > 52);
dRow["PerOneOTGreater5"] = groupedData.Count(x => x.OTGreaterThan5 > 0);
oMnthlyKPIDtlSummary.Rows.Add(dRow);
}
#endregion
oMnthlyKPIDtlSummary.TableName = "MnthlyKPIDtlSummary";
oMonthlyKPIDetail.Tables.Add(oMnthlyKPIDtlSummary);
List<ReportParameter> _parameters = new List<ReportParameter>();
ReportParameter rParam = new ReportParameter("FromDate", dFromDate.ToString("dd MMM yyyy"));
_parameters.Add(rParam);
rParam = new ReportParameter("ToDate", dToDate.LastDateOfMonth().ToString("dd MMM yyyy"));
_parameters.Add(rParam);
string filePath = "HRM.Report.Attendence.RDLC.MonthlyAttendanceReport.rdlc";
return reportProcessor.CommonReportView(null, filePath, oMonthlyKPIDetail, null, _parameters, true, payrollTypeID, reportType);
}
#region for Schedular
private DataSet RefreshDataSetForMailSender(DateTime fromDate, DateTime toDate, EnumAttendanceType attnType, int payrollTypeid)
{
Attendence.AttendenceDataSet.AttendenceDataSet.DailyAttnReportForMailSenderDataTable attnData = new Attendence.AttendenceDataSet.AttendenceDataSet.DailyAttnReportForMailSenderDataTable();
List<DailyAttnMailSenderReport> empDapForlastDay = new DailyAttnProcessService().AttendanceDataForMailSchedular(fromDate, toDate, attnType, payrollTypeid);
List<LeaveEntry> leaveEntrys = new LeaveEntryService().Get(fromDate, toDate, EnumLeaveStatus.OnApproval);
List<Leave> leaves = new LeaveService().GetLeaves(payrollTypeid);
foreach (DailyAttnMailSenderReport item in empDapForlastDay)
{
LeaveEntry tempLeaveEntry = leaveEntrys.Find(le => le.EmpID == item.EmployeeId && le.AppliedFromDate <= item.AttnDate && le.AppliedToDate >= item.AttnDate);
Leave tempLeave = tempLeaveEntry != null ? leaves.Find(l => l.ID == tempLeaveEntry.LeaveID) : null;
DataRow dRow = attnData.NewRow();
dRow["EMPLOYEENO"] = item.EmployeeNo;
dRow["NAME"] = item.Name;
dRow["DESIGNATION"] = item.Designation;
dRow["DEPARTMENT"] = item.Department;
dRow["AttnDate"] = item.AttnDate.ToString("dd MMM yyyy");
dRow["day"] = item.Day;
dRow["InTime"] = item.InTime != DateTime.MinValue ? item.InTime.ToString("hh:mm tt") : string.Empty;
dRow["OutTime"] = item.OutTime != DateTime.MinValue ? item.OutTime.ToString("hh:mm tt") : string.Empty;
dRow["AttnType"] = item.AttnType;
dRow["NotPresentType"] = item.NotPresentType.Trim() != string.Empty ? item.NotPresentType.Trim() : tempLeave != null ? tempLeave.Description : item.AttnType;
dRow["LINEMANAGERNO"] = item.LineManagerNo;
dRow["LINEMANAGERNAME"] = item.LineManagerName;
dRow["TotalWorkingHour"] = item.TotalWorkingHour != "0:0" ? item.TotalWorkingHour : string.Empty;
dRow["LateCount"] = item.LateCount;
attnData.Rows.Add(dRow);
}
DataSet DailyAttnMailSenderReportDs = new DataSet();
attnData.TableName = "AttendanceDataSet_DailyAttnReportForMailSender";
DailyAttnMailSenderReportDs.Tables.Add(attnData);
return DailyAttnMailSenderReportDs;
}
private DataSet RefreshDataSetForMonthlyAttendanceSummaryCordinator(int id, DateTime fromDate, DateTime toDate, EnumAttendanceType attnType, int payrollTypeid)
{
DataSet monthlyAttendanceSummaryDataSet = new DataSet();
//Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyAttendanceSummaryDataTable oDTable = new Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyAttendanceSummaryDataTable();
//List<DailyAttnMailSenderReport> empDapForlastDay = new DailyAttnProcessService().AttendanceDataForMailSchedular(fromDate, toDate, attnType, payrollTypeid);
//List<LeaveEntry> leaveEntrys = new LeaveEntryService().Get(fromDate, toDate, EnumLeaveStatus.OnApproval);
List<Leave> leaves = new LeaveService().GetLeaves(payrollTypeid);
//List<MonthlyAttendanceSummary> monthlyAttendanceSummary = new DailyAttnProcessService().MonthlyAttendanceSummaryForMailSchedular(fromDate, toDate, attnType, payrollTypeid);
monthlyAttendanceSummaryDataSet = new DailyAttnProcessService().MonthlyAttendanceSummaryForMailSchedularCordinator(id, fromDate, toDate, attnType, payrollTypeid);
DataTable oDTable = new DataTable();
oDTable.Columns.Add("SlNo");
oDTable.Columns.Add("ID");
oDTable.Columns.Add("Name");
oDTable.Columns.Add("Position");
oDTable.Columns.Add("OrgUnit");
oDTable.Columns.Add("WorkDays");
oDTable.Columns.Add("TotAttend");
oDTable.Columns.Add("TotAbsent");
oDTable.Columns.Add("TotLate");
oDTable.Columns.Add("TotLeave");
DataRow oDR = null;
int serial = 1;
foreach (DataRow oDRow in monthlyAttendanceSummaryDataSet.Tables[0].Rows)
{
oDR = oDTable.NewRow();
oDR["SlNo"] = serial.ToString();
oDR["ID"] = oDRow["EMPLOYEENO"];
oDR["Name"] = oDRow["Name"];
oDR["Position"] = oDRow["Designation"];
oDR["OrgUnit"] = " ";
oDR["WorkDays"] = oDRow["TotalWorkingDays"];
oDR["TotAttend"] = oDRow["TotalAttendedDays"];
oDR["TotAbsent"] = oDRow["TotalAbsentDays"];
oDR["TotLate"] = oDRow["TotalLateDays"];
oDR["TotLeave"] = oDRow["TotalLeaveDays"];
oDTable.Rows.Add(oDR);
serial++;
}
DataSet MonthlyAttendanceSummary = new DataSet();
oDTable.TableName = "AttendanceDataSet_MonthlyAttendanceSummary";
MonthlyAttendanceSummary.Tables.Add(oDTable);
return MonthlyAttendanceSummary;
}
private DataSet RefreshDataSetForMonthlyAttendanceSummary(int id, DateTime fromDate, DateTime toDate, EnumAttendanceType attnType, int payrollTypeid)
{
DataSet monthlyAttendanceSummaryDataSet = new DataSet();
//Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyAttendanceSummaryDataTable oDTable = new Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyAttendanceSummaryDataTable();
//List<DailyAttnMailSenderReport> empDapForlastDay = new DailyAttnProcessService().AttendanceDataForMailSchedular(fromDate, toDate, attnType, payrollTypeid);
//List<LeaveEntry> leaveEntrys = new LeaveEntryService().Get(fromDate, toDate, EnumLeaveStatus.OnApproval);
List<Leave> leaves = new LeaveService().GetLeaves(payrollTypeid);
//List<MonthlyAttendanceSummary> monthlyAttendanceSummary = new DailyAttnProcessService().MonthlyAttendanceSummaryForMailSchedular(fromDate, toDate, attnType, payrollTypeid);
monthlyAttendanceSummaryDataSet = new DailyAttnProcessService().MonthlyAttendanceSummaryForMailSchedular(id, fromDate, toDate, attnType, payrollTypeid);
DataTable oDTable = new DataTable();
oDTable.Columns.Add("SlNo");
oDTable.Columns.Add("ID");
oDTable.Columns.Add("Name");
oDTable.Columns.Add("Position");
oDTable.Columns.Add("OrgUnit");
oDTable.Columns.Add("WorkDays");
oDTable.Columns.Add("TotAttend");
oDTable.Columns.Add("TotAbsent");
oDTable.Columns.Add("TotLate");
oDTable.Columns.Add("TotLeave");
DataRow oDR = null;
int serial = 1;
foreach (DataRow oDRow in monthlyAttendanceSummaryDataSet.Tables[0].Rows)
{
oDR = oDTable.NewRow();
oDR["SlNo"] = serial;
oDR["ID"] = oDRow["EMPLOYEENO"];
oDR["Name"] = oDRow["Name"];
oDR["Position"] = oDRow["Designation"];
oDR["OrgUnit"] = " ";
oDR["WorkDays"] = oDRow["TotalWorkingDays"];
oDR["TotAttend"] = oDRow["TotalAttendedDays"];
oDR["TotAbsent"] = oDRow["TotalAbsentDays"];
oDR["TotLate"] = oDRow["TotalLateDays"];
oDR["TotLeave"] = oDRow["TotalLeaveDays"];
oDTable.Rows.Add(oDR);
serial++;
}
DataSet MonthlyAttendanceSummary = new DataSet();
oDTable.TableName = "AttendanceDataSet_MonthlyAttendanceSummary";
MonthlyAttendanceSummary.Tables.Add(oDTable);
return MonthlyAttendanceSummary;
}
public byte[] GetDailyAttnReport(DateTime fromDate, DateTime toDate, EnumAttendanceType attnType, int payrollTypeid, string fileFormate = "PDF", bool hideColumn = false)
{
ReportProcessor reportProcessor = new ReportProcessor();
string rdlcName = "HRM.Report.Attendence.RDLC.EmpDailyAttnReportForMailSender.rdlc"; // build action of this rdlc has to be embedded resource
string reportTitle = "Daily Attendance Report";
DataSet tempDataSet = RefreshDataSetForMailSender(fromDate, toDate, attnType, payrollTypeid);
return reportProcessor.ShowReportForSchedular(null, rdlcName, tempDataSet, null, true, reportTitle, fileFormate, hideColumn);
}
public byte[] GetWeeklyAttnReport(DateTime fromDate, DateTime toDate, EnumAttendanceType attnType, int payrollTypeid, string fileFormate = "PDF")
{
ReportProcessor reportProcessor = new ReportProcessor();
string rdlcName = "HRM.Report.Attendence.RDLC.EmpWeeklyAttnReportForMailSender.rdlc"; // build action of this rdlc has to be embedded resource
string reportTitle = "Weekly Attendance Report From " + fromDate.ToString("dd MMM yyyy") + " to " + toDate.ToString("dd MMM yyyy");
DataSet tempDataSet = RefreshDataSetForMailSender(fromDate, toDate, attnType, payrollTypeid);
return reportProcessor.ShowReportForSchedular(null, rdlcName, tempDataSet, null, true, reportTitle, fileFormate);
}
public byte[] GetMonthlyAttnReport(DateTime fromDate, DateTime toDate, EnumAttendanceType attnType, int payrollTypeid, string fileFormate = "PDF")
{
ReportProcessor reportProcessor = new ReportProcessor();
string rdlcName = "HRM.Report.Attendence.RDLC.EmpMonthlyAttnReportForMailSender.rdlc"; // build action of this rdlc has to be embedded resource
string reportTitle = "SPP Attendance Report: For the month of " + fromDate.ToString("MMMM yyyy");
DataSet tempDataSet = RefreshDataSetForMailSender(fromDate, toDate, attnType, payrollTypeid);
return reportProcessor.ShowReportForSchedular(null, rdlcName, tempDataSet, null, true, reportTitle, fileFormate);
}
public byte[] GetMonthlyAttendanceSummary(int id, DateTime fromDate, DateTime toDate, EnumAttendanceType attnType, int payrollTypeid, string fileFormate = "PDF")
{
ReportProcessor reportProcessor = new ReportProcessor();
string rdlcName = "HRM.Report.Attendence.RDLC.MonthlyAttendanceSummary.rdlc"; // build action of this rdlc has to be embedded resource
string reportTitle = "Monthly Attendance Summary: For the month of " + (fromDate.AddMonths(-1)).ToString("MMMM yyyy");
DataSet tempDataSet = RefreshDataSetForMonthlyAttendanceSummary(id, fromDate, toDate, attnType, payrollTypeid);
return reportProcessor.ShowReportForSchedular(null, rdlcName, tempDataSet, null, true, reportTitle, fileFormate);
}
public byte[] GetMonthlyAttendanceSummaryCordinator(int id, DateTime fromDate, DateTime toDate, EnumAttendanceType attnType, int payrollTypeid, string fileFormate = "PDF")
{
ReportProcessor reportProcessor = new ReportProcessor();
string rdlcName = "HRM.Report.Attendence.RDLC.MonthlyAttendanceSummary.rdlc"; // build action of this rdlc has to be embedded resource
string reportTitle = "Monthly Attendance Summary: For the month of " + (fromDate.AddMonths(-1)).ToString("MMMM yyyy");
DataSet tempDataSet = RefreshDataSetForMonthlyAttendanceSummaryCordinator(id, fromDate, toDate, attnType, payrollTypeid);
return reportProcessor.ShowReportForSchedular(null, rdlcName, tempDataSet, null, true, reportTitle, fileFormate);
}
#endregion
private DataSet calculateLeave(DataSet oMonthlyKPIDetail)
{
DataSet dsMonthlyKPIDetail = oMonthlyKPIDetail;
DataTable dtMonthlyKPIDetail = oMonthlyKPIDetail.Tables[0];
return dsMonthlyKPIDetail;
}
public byte[] ShowDateRangeJobCardMultiple(DateTime dFromDate, DateTime dToDate, string sEmpID, int payrollTypeId, string reportType)
{
if (dFromDate > dToDate)
{
var temp = dFromDate;
dFromDate = dToDate;
dToDate = temp;
}
List<Employee> oEmp = new EmployeeService().GetByEmpIDs(sEmpID, payrollTypeId);
List<Department> oDepartment = new DepartmentService().GetAll(payrollTypeId);
List<Designation> oDesignation = new DesignationService().GetAll(payrollTypeId);
String RDLC = string.Empty;
HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable oSubDataTable = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable();
HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnParentNewDataTable dTableParent = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnParentNewDataTable();
foreach (Employee emp in oEmp)
{
try
{
List<String> oTHours = new List<String>();
List<String> latehours = new List<String>();
Department tempDepartment = emp.DepartmentID != null ? oDepartment.Find(item => item.ID == emp.DepartmentID) : null;
Designation tempDesignation = emp.DesignationID != null ? oDesignation.Find(item => item.ID == emp.DesignationID) : null;
DataTable tempSub = GetEmpDailyAttn(emp.ID, dFromDate, dToDate, payrollTypeId);
foreach (DataRow dr in tempSub.Rows)
{
var dRowSub = oSubDataTable.NewRow();
dRowSub["EmpNo"] = emp.EmployeeNo;
dRowSub["Date"] = dr["Date"];
dRowSub["InTime"] = dr["InTime"];
dRowSub["OutTime"] = dr["OutTime"];
dRowSub["LateBy"] = dr["LateBy"];
dRowSub["OTHr"] = dr["OTHr"];
dRowSub["Status"] = dr["Status"];
dRowSub["Remarks"] = dr["Remarks"];
dRowSub["Shift"] = dr["Shift"];
dRowSub["AttnType"] = dr["AttnType"];
dRowSub["Description"] = dr["Description"];
dRowSub["Amount"] = dr["Amount"];
dRowSub["WorkPlanGroup"] = dr["WorkPlanGroup"];
dRowSub["AttnDate"] = dr["AttnDate"];
dRowSub["Day"] = dr["Day"];
dRowSub["WorkingHour"] = dr["WorkingHour"];
dRowSub["InTimeShow"] = dr["InTimeShow"];
oSubDataTable.Rows.Add(dRowSub);
string oTHour = Convert.ToString(dr["OTHr"]);
string latehour = Convert.ToString(dr["LateBy"]);
oTHours.Add(oTHour);
latehours.Add(latehour);
}
string totalOT = GlobalFunctions.GetHourMinutes(oTHours);
string totalLateHour = GlobalFunctions.GetHourMinutes(latehours);
var dRowParent = dTableParent.NewRow();
dRowParent["EmpNo"] = emp.EmployeeNo.ToString();
dRowParent["Name"] = emp.Name.ToString();
dRowParent["Designation"] = tempDesignation != null ? tempDesignation.Name : string.Empty;
dRowParent["Department"] = tempDepartment != null ? tempDepartment.Name : string.Empty;
//dRowParent["JoiningDate"] = emp.Grade == null ? "" : emp.JoiningDate.ToString("dd MMM yyyy");
dRowParent["JoiningDate"] = emp.JoiningDate != DateTime.MinValue ? emp.JoiningDate.ToString("dd MMM yyyy") : string.Empty;
dRowParent["FromDate"] = dFromDate.ToString("dd MMM yyyy");
dRowParent["ToDate"] = dToDate.ToString("dd MMM yyyy");
dRowParent["TotalLate"] = totalLateHour;
dRowParent["TotalOT"] = totalOT;
dTableParent.Rows.Add(dRowParent);
}
catch (Exception ex)
{
throw;
}
}
DataSet dSetSub = new DataSet();
oSubDataTable.TableName = "AttendenceDataSet_EmpDailyAttn";
dSetSub.Tables.Add(oSubDataTable);
DataSet dSetParent = new DataSet();
dTableParent.TableName = "AttendenceDataSet_EmpDailyAttnParentNew";
dSetParent.Tables.Add(dTableParent);
RDLC = "HRM.Report.Attendence.RDLC.DateRangeMultipleJobCardNew.rdlc";
return new ReportProcessor().CommonReportView(null, RDLC, dSetParent, dSetSub, null, true, payrollTypeId, reportType);
}
public byte[] ShowDateRangeJobCardMultipleForLiFung(DateTime fromDate, string sEmpID, int payrollTypeId, string reportType)
{
DateTime dFromDate = GlobalFunctions.FirstDateOfMonth(fromDate);
DateTime dToDate = GlobalFunctions.LastDateOfMonth(dFromDate);
if (dFromDate > dToDate)
{
var temp = dFromDate;
dFromDate = dToDate;
dToDate = temp;
}
List<Employee> oEmp = new EmployeeService().GetByEmpIDs(sEmpID, payrollTypeId);
List<Department> oDepartment = new DepartmentService().GetAll(payrollTypeId);
List<Designation> oDesignation = new DesignationService().GetAll(payrollTypeId);
String RDLC = string.Empty;
HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable oSubDataTable = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable();
HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnParentNewLiFungDataTable dTableParent = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnParentNewLiFungDataTable();
foreach (Employee emp in oEmp)
{
try
{
List<String> oTHours = new List<String>();
List<String> latehours = new List<String>();
Department tempDepartment = emp.DepartmentID != null ? oDepartment.Find(item => item.ID == emp.DepartmentID) : null;
Designation tempDesignation = emp.DesignationID != null ? oDesignation.Find(item => item.ID == emp.DesignationID) : null;
DataTable tempSub = GetEmpDailyAttn(emp.ID, dFromDate, dToDate, payrollTypeId);
foreach (DataRow dr in tempSub.Rows)
{
var dRowSub = oSubDataTable.NewRow();
dRowSub["EmpNo"] = emp.EmployeeNo;
dRowSub["Date"] = dr["Date"];
dRowSub["InTime"] = dr["InTime"];
dRowSub["OutTime"] = dr["OutTime"];
dRowSub["LateBy"] = dr["LateBy"];
dRowSub["OTHr"] = dr["OTHr"];
dRowSub["Status"] = dr["Status"];
dRowSub["Remarks"] = dr["Remarks"];
dRowSub["Shift"] = dr["Shift"];
dRowSub["AttnType"] = dr["AttnType"];
dRowSub["Description"] = dr["Description"];
dRowSub["Amount"] = dr["Amount"];
dRowSub["WorkPlanGroup"] = dr["WorkPlanGroup"];
dRowSub["AttnDate"] = dr["AttnDate"];
dRowSub["Day"] = dr["Day"];
dRowSub["WorkingHour"] = dr["WorkingHour"];
dRowSub["InTimeShow"] = dr["InTimeShow"];
oSubDataTable.Rows.Add(dRowSub);
string oTHour = Convert.ToString(dr["OTHr"]);
string latehour = Convert.ToString(dr["LateBy"]);
oTHours.Add(oTHour);
latehours.Add(latehour);
}
string totalOT = GlobalFunctions.GetHourMinutes(oTHours);
string totalLateHour = GlobalFunctions.GetHourMinutes(latehours);
var dRowParent = dTableParent.NewRow();
dRowParent["EmpNo"] = emp.EmployeeNo.ToString();
dRowParent["Name"] = emp.Name.ToString();
dRowParent["Designation"] = tempDesignation != null ? tempDesignation.Name : string.Empty;
dRowParent["Department"] = tempDepartment != null ? tempDepartment.Name : string.Empty;
dRowParent["Division"] = tempDepartment.ParentID==null?"": oDepartment.Find(item => item.ID == tempDepartment.ParentID).Name;
//dRowParent["JoiningDate"] = emp.Grade == null ? "" : emp.JoiningDate.ToString("dd MMM yyyy");
dRowParent["JoiningDate"] = emp.JoiningDate != DateTime.MinValue ? emp.JoiningDate.ToString("dd MMM yyyy") : string.Empty;
dRowParent["FromDate"] = dFromDate.ToString("dd MMM yyyy");
dRowParent["ToDate"] = dToDate.ToString("dd MMM yyyy");
dRowParent["TotalLate"] = totalLateHour;
dRowParent["TotalOT"] = totalOT;
dTableParent.Rows.Add(dRowParent);
}
catch (Exception ex)
{
throw;
}
}
DataSet dSetSub = new DataSet();
oSubDataTable.TableName = "AttendenceDataSet_EmpDailyAttn";
dSetSub.Tables.Add(oSubDataTable);
DataSet dSetParent = new DataSet();
dTableParent.TableName = "AttendenceDataSet_EmpDailyAttnParentNew";
dSetParent.Tables.Add(dTableParent);
RDLC = "HRM.Report.Attendence.RDLC.DateRangeMultipleJobCardNewLiFung.rdlc";
return new ReportProcessor().CommonReportView(null, RDLC, dSetParent, dSetSub, null, true, payrollTypeId, reportType);
//return new ReportProcessor().CommonReportViewer(null, RDLC, dSetParent, dSetSub, null, payrollTypeId);
}
public byte[] ShowDateRangeJobCardSingleForLiFung(DateTime fromDate, string sEmpID, int payrollTypeId, string reportType)
{
DateTime dFromDate = GlobalFunctions.FirstDateOfMonth(fromDate);
DateTime dToDate = GlobalFunctions.LastDateOfMonth(dFromDate);
if (dFromDate > dToDate)
{
var temp = dFromDate;
dFromDate = dToDate;
dToDate = temp;
}
List<Employee> oEmp = new EmployeeService().GetByEmpIDs(sEmpID, payrollTypeId);
List<Department> oDepartment = new DepartmentService().GetAll(payrollTypeId);
List<Designation> oDesignation = new DesignationService().GetAll(payrollTypeId);
String RDLC = string.Empty;
HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable oSubDataTable = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable();
HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnParentNewLiFungDataTable dTableParent = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnParentNewLiFungDataTable();
foreach (Employee emp in oEmp)
{
try
{
List<String> oTHours = new List<String>();
List<String> latehours = new List<String>();
Department tempDepartment = emp.DepartmentID != null ? oDepartment.Find(item => item.ID == emp.DepartmentID) : null;
Designation tempDesignation = emp.DesignationID != null ? oDesignation.Find(item => item.ID == emp.DesignationID) : null;
DataTable tempSub = GetEmpDailyAttn(emp.ID, dFromDate, dToDate, payrollTypeId);
foreach (DataRow dr in tempSub.Rows)
{
var dRowSub = oSubDataTable.NewRow();
dRowSub["EmpNo"] = emp.EmployeeNo;
dRowSub["Date"] = dr["Date"];
dRowSub["InTime"] = dr["InTime"];
dRowSub["OutTime"] = dr["OutTime"];
dRowSub["LateBy"] = dr["LateBy"];
dRowSub["OTHr"] = dr["OTHr"];
dRowSub["Status"] = dr["Status"];
dRowSub["Remarks"] = dr["Remarks"];
dRowSub["Shift"] = dr["Shift"];
dRowSub["AttnType"] = dr["AttnType"];
dRowSub["Description"] = dr["Description"];
dRowSub["Amount"] = dr["Amount"];
dRowSub["WorkPlanGroup"] = dr["WorkPlanGroup"];
dRowSub["AttnDate"] = dr["AttnDate"];
dRowSub["Day"] = dr["Day"];
dRowSub["WorkingHour"] = dr["WorkingHour"];
dRowSub["InTimeShow"] = dr["InTimeShow"];
oSubDataTable.Rows.Add(dRowSub);
string oTHour = Convert.ToString(dr["OTHr"]);
string latehour = Convert.ToString(dr["LateBy"]);
oTHours.Add(oTHour);
latehours.Add(latehour);
}
string totalOT = GlobalFunctions.GetHourMinutes(oTHours);
string totalLateHour = GlobalFunctions.GetHourMinutes(latehours);
var dRowParent = dTableParent.NewRow();
dRowParent["EmpNo"] = emp.EmployeeNo.ToString();
dRowParent["Name"] = emp.Name.ToString();
dRowParent["Designation"] = tempDesignation != null ? tempDesignation.Name : string.Empty;
dRowParent["Department"] = tempDepartment != null ? tempDepartment.Name : string.Empty;
dRowParent["Division"] = oDepartment.Find(item => item.ID == tempDepartment.ParentID).Name;
//dRowParent["JoiningDate"] = emp.Grade == null ? "" : emp.JoiningDate.ToString("dd MMM yyyy");
dRowParent["JoiningDate"] = emp.JoiningDate != DateTime.MinValue ? emp.JoiningDate.ToString("dd MMM yyyy") : string.Empty;
dRowParent["FromDate"] = dFromDate.ToString("dd MMM yyyy");
dRowParent["ToDate"] = dToDate.ToString("dd MMM yyyy");
dRowParent["TotalLate"] = totalLateHour;
dRowParent["TotalOT"] = totalOT;
dTableParent.Rows.Add(dRowParent);
}
catch (Exception ex)
{
throw;
}
}
DataSet dSetSub = new DataSet();
oSubDataTable.TableName = "AttendenceDataSet_EmpDailyAttn";
dSetSub.Tables.Add(oSubDataTable);
DataSet dSetParent = new DataSet();
dTableParent.TableName = "AttendenceDataSet_EmpDailyAttnParentNew";
dSetParent.Tables.Add(dTableParent);
RDLC = "HRM.Report.Attendence.RDLC.DateRangeMultipleJobCardNewLiFung.rdlc";
return new ReportProcessor().CommonReportView(null, RDLC, dSetParent, dSetSub, null, true, payrollTypeId, reportType);
//RDLC = "DateRangeMultipleJobCardNewLiFung.rdlc";
//return new ReportProcessor().CommonReportViewer(null, RDLC, dSetParent, dSetSub, null, payrollTypeId);
}
public byte[] GetAttendanceSummaryForLiFung(DateTime dFromDate, string sEmpID, string reportType, int payrollTypeID)
{
ReportProcessor reportProcessor = new ReportProcessor();
DataSet oAttendanceSummary = null;
oAttendanceSummary = new DailyAttnProcessService().GetMonthlyAttn(GlobalFunctions.FirstDateOfMonth(dFromDate), GlobalFunctions.LastDateOfMonth(dFromDate), sEmpID);
List<Department> oDepartment = new DepartmentService().GetAll(payrollTypeID);
//DataSet MonthlyKpiDetailsWithLeave = calculateLeave(oAttendanceSummary);
HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyAttnDataTable oAttendanceSummaryDTable = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyAttnDataTable();
#region Summary Parts
foreach (DataRow Dr in oAttendanceSummary.Tables[0].Rows)
{
DataRow dRow = oAttendanceSummaryDTable.NewRow();
Employee emp = new EmployeeService().GetFromAll(Dr["EMPLOYEENO"].ToString(), payrollTypeID);
Department tempDepartment = emp.DepartmentID != null ? oDepartment.Find(item => item.ID == emp.DepartmentID) : null;
dRow["EmpNo"] = Dr["EMPLOYEENO"];
dRow["Name"] = Dr["NAME"];
dRow["CardNo"] = Dr["CardNo"].ToString();
dRow["Designation"] = Dr["Designation"];
dRow["Grade"] = Dr["Grade"];
dRow["Division"] = tempDepartment.ParentID==null? "": oDepartment.Find(item => item.ID == tempDepartment.ParentID).Name;
dRow["JoinDate"] = Convert.ToDateTime(Dr["JOININGDATE"]).ToString("dd MMM yyyy");
dRow["GrossSalary"] = Convert.ToDouble(Dr["GROSSSALARY"]);
dRow["Present"] = Dr["Present"] is DBNull ? 0 : Dr["Present"];
dRow["Department"] = Dr["Department"].ToString();
dRow["Section"] = Dr["Section"].ToString();
dRow["Line"] = Dr["Line"].ToString();
dRow["Floor"] = Dr["Floor"].ToString();
dRow["Late"] = Dr["Late"] is DBNull ? 0 : Dr["Late"];
dRow["Absent"] = Dr["Absent"] is DBNull ? 0 : Dr["Absent"];
dRow["Holiday"] = Dr["Holiday"] is DBNull ? 0 : Dr["Holiday"];
dRow["Leave"] = Dr["Leave"] is DBNull ? 0 : Dr["Leave"];
dRow["TotalAttn"] = Dr["TotalAttn"];
dRow["TotalOT"] = Convert.ToDouble(Dr["TotalOT"]).ToString("0.00");
dRow["TotalOTDBL"] = Convert.ToDouble(Dr["TotalOT"]);
dRow["Remarks"] = "";
oAttendanceSummaryDTable.Rows.Add(dRow);
}
#endregion
oAttendanceSummaryDTable.TableName = "AttendenceDataSet_MonthlyAttn";
oAttendanceSummary.Tables.Add(oAttendanceSummaryDTable);
List<ReportParameter> _parameters = new List<ReportParameter>();
ReportParameter rParam = new ReportParameter("FromDate", GlobalFunctions.FirstDateOfMonth(dFromDate).ToString("dd MMM yyyy"));
_parameters.Add(rParam);
rParam = new ReportParameter("ToDate", GlobalFunctions.LastDateOfMonth(dFromDate).ToString("dd MMM yyyy"));
_parameters.Add(rParam);
string filePath = "HRM.Report.Attendence.RDLC.MonthlyAttnLiFung.rdlc";
//return new ReportProcessor().CommonReportView(null, oAttendanceSummary, null, filePath, _parameters, true, payrollTypeID, reportType);
return new ReportProcessor().CommonReportView(null, filePath, oAttendanceSummary, null, _parameters, true, payrollTypeID, reportType);
}
public byte[] DailyPresentForLiFung(DateTime dFromDate, string sEmpID, string reportType, int payrollTypeID)
{
ReportProcessor reportProcessor = new ReportProcessor();
DateTime attnDate = dFromDate;
//string sEmpID = sEmpID;
DataRow oDR = null;
DataSet oDailyInOut = null;
//new DailyAttnProcessService().GetDailyDataByStatus(attnDate, sEmpID, EnumAttendanceType.Present, EnumAttendanceType.Late, EnumAttendanceType.Early, EnumAttendanceType.Delay, EnumAttendanceType.On_Business_Travel, EnumAttendanceType.OutSideDuty);
//oDailyInOut = new DailyAttnProcessService().GetDailyDataByStatus(attnDate, sEmpID, EnumAttendanceType.Present, EnumAttendanceType.Late, EnumAttendanceType.Early, EnumAttendanceType.Delay, EnumAttendanceType.HalfDay, EnumAttendanceType.OutSideDuty);
oDailyInOut = new DailyAttnProcessService().GetDailyDataByStatus(attnDate, sEmpID, EnumAttendanceType.Present, EnumAttendanceType.Late, EnumAttendanceType.Early, EnumAttendanceType.Delay, EnumAttendanceType.OutSideDuty);
HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.DailyInOutDataTable dTable = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.DailyInOutDataTable();
foreach (DataRow Dr in oDailyInOut.Tables[0].Rows)
{
oDR = dTable.NewRow();
oDR["EmployeeNo"] = Dr["EMPLOYEENO"];
oDR["Name"] = Dr["Name"];
oDR["Designation"] = Dr["Designation"];
oDR["InTime"] = Dr["InTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["InTime"]).ToString("HH:mm");
oDR["OutTime"] = Dr["OutTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["OutTime"]).ToString("HH:mm");
oDR["EmpType"] = Dr["EmpType"].ToString();
oDR["Status"] = GlobalFunctions.GetShortAttnType((EnumAttendanceType)Convert.ToInt32(Dr["Status"]));
oDR["OTHour"] = GlobalFunctions.ConvertDoubleHourToHourMinute(Convert.ToDouble(Dr["OTHour"]));
oDR["OTHourDBL"] = Convert.ToDouble(Dr["OTHour"]);
oDR["DeptID"] = Convert.ToInt32(Dr["DeptID"].ToString());
oDR["DeptName"] = Dr["DeptName"].ToString();
oDR["Department"] = Dr["Department"].ToString();
oDR["Section"] = Dr["Section"].ToString();
oDR["Line"] = Dr["Line"].ToString();
oDR["Floor"] = Dr["Floor"].ToString();
oDR["Shift"] = Dr["Shift"].ToString();
oDR["CardNo"] = Dr["CardNo"].ToString();
dTable.Rows.Add(oDR);
}
DataSet dSet = new DataSet();
dTable.TableName = "AttendenceDataSet_DailyInOut";
dSet.Tables.Add(dTable);
//string RDLC = "HRM.Report.Attendence.RDLC.DailyPresent.rdlc";
string RDLC = "DailyPresentLiFung.rdlc";
List<ReportParameter> _reportParameters = new List<ReportParameter>();
ReportParameter rParam = new ReportParameter("AttnDate", attnDate.ToString("dd MMM yyyy"));
_reportParameters.Add(rParam);
//rParam = new ReportParameter("Fax", "");
//_reportParameters.Add(rParam);
//rParam = new ReportParameter("Email", systemInfo.email);
//_reportParameters.Add(rParam);
return new ReportProcessor().CommonReportViewer(null, RDLC, dSet, _reportParameters, payrollTypeID);
//return reportProcessor.AttendanceReportsView(null, dSet, null, RDLC, _reportParameters, true, payrollTypeID, reportType);
//AttendanceReportView(reportItem, dSet, dSubReportDataSet, reportName, parameters, defaultParameterNeeded, payrollTypeId, reportType)
}
public byte[] DailyAbsentForLiFung(DateTime dFromDate, string sEmpID, string reportType, int payrollTypeID)
{
ReportProcessor reportProcessor = new ReportProcessor();
DateTime attnDate = dFromDate;
DataSet oDailyInOut = null;
DataRow oDR = null;
oDailyInOut = new DailyAttnProcessService().GetDailyDataByStatus(attnDate, sEmpID, EnumAttendanceType.Absent);
HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.DailyInOutDataTable dTable = new Attendence.AttendenceDataSet.AttendenceDataSet.DailyInOutDataTable();
foreach (DataRow Dr in oDailyInOut.Tables[0].Rows)
{
oDR = dTable.NewRow();
oDR["EmployeeNo"] = Dr["EMPLOYEENO"];
oDR["Name"] = Dr["Name"];
oDR["Designation"] = Dr["Designation"];
oDR["InTime"] = Dr["InTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["InTime"]).ToString("HH:mm tt");
oDR["OutTime"] = Dr["OutTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["OutTime"]).ToString("HH:mm tt");
oDR["EmpType"] = Dr["EmpType"].ToString();
oDR["Status"] = GlobalFunctions.GetShortAttnType(((EnumAttendanceType)Convert.ToInt32(Dr["Status"])));
oDR["OTHour"] = GlobalFunctions.ConvertDoubleHourToHourMinute(Convert.ToDouble(Dr["OTHour"]));
oDR["OTHourDBL"] = Convert.ToDouble(Dr["OTHour"]);
oDR["DeptID"] = Convert.ToInt32(Dr["DeptID"].ToString());
oDR["DeptName"] = Dr["DeptName"].ToString();
oDR["Department"] = Dr["Department"].ToString();
oDR["Section"] = Dr["Section"].ToString();
oDR["Line"] = Dr["Line"].ToString();
oDR["Floor"] = Dr["Floor"].ToString();
oDR["Shift"] = Dr["Shift"].ToString();
oDR["CardNo"] = Dr["CardNo"].ToString();
dTable.Rows.Add(oDR);
}
DataSet dSet = new DataSet();
dTable.TableName = "AttendenceDataSet_DailyInOut";
dSet.Tables.Add(dTable);
string RDLC = "DailyAbsentLiFung.rdlc";
ReportParameter rParam;
List<ReportParameter> _reportParameters = new List<ReportParameter>();
rParam = new ReportParameter("AttnDate", attnDate.ToString("dd MMM yyyy"));
_reportParameters.Add(rParam);
//return reportProcessor.AttendanceReportsView(null, dSet, null, RDLC, _reportParameters, true, payrollTypeID, reportType);
return reportProcessor.CommonReportViewer(null, RDLC, dSet, _reportParameters, payrollTypeID);
}
public byte[] DailyOddForLiFung(DateTime dFromDate, string sEmpID, string reportType, int payrollTypeID)
{
ReportProcessor reportProcessor = new ReportProcessor();
//DateTime attnFromDate, attnToDate;
DateTime attnFromDate = dFromDate;
var sinMissingHour = new SystemConfigarationService().GetconfigValue(EnumConfigurationType.Logic, "overtime", "inmissinghour");
double inMissingHour = 0;
if (sinMissingHour != null) inMissingHour = Convert.ToDouble(sinMissingHour);
//if (dFromDate <= dToDate)
//{
// attnFromDate = dFromDate;
// attnToDate = dToDate.Date.AddDays(1).AddSeconds(-1);
//}
//else
//{
// attnFromDate = dToDate;
// attnToDate = dFromDate.Date.AddDays(1).AddSeconds(-1);
//}
List<Shift> shifts = new ShiftService().GetAllShift();
DataSet oDailyInOut = null;
DataRow oDR = null;
//oDailyInOut = new EchoTexExceptionReportService().GetDateRangeDataByStatus(attnFromDate, attnToDate, sEmpID, EnumAttendanceType.Present, EnumAttendanceType.Delay, EnumAttendanceType.Late, EnumAttendanceType.Early, EnumAttendanceType.OutSideDuty, EnumAttendanceType.HalfDay);
oDailyInOut = new DailyAttnProcessService().GetDailyOddDataByStatusReportDataset(dFromDate, sEmpID);
Attendence.AttendenceDataSet.AttendenceDataSet.InOutMissingDataTable dTable = new Attendence.AttendenceDataSet.AttendenceDataSet.InOutMissingDataTable();
DateTime Intime, OutTime, AttnDate, ShiftInTime, ShiftOutTime;
foreach (DataRow Dr in oDailyInOut.Tables[0].Rows)
{
Intime = DateTime.MinValue; OutTime = DateTime.MinValue;
oDR = dTable.NewRow();
oDR["EmployeeNo"] = Dr["EMPLOYEENO"];
oDR["Name"] = Dr["Name"];
oDR["Designation"] = Dr["Designation"];
//oDR["EmpType"] = Dr["EmpType"].ToString();
oDR["Status"] = GlobalFunctions.GetShortAttnType((EnumAttendanceType)Convert.ToInt32(Dr["Status"]));
oDR["OTHour"] = GlobalFunctions.ConvertDoubleHourToHourMinute(Convert.ToDouble(Dr["OTHour"]));
//oDR["OTHourDBL"] = Convert.ToDouble(Dr["OTHour"]);
//oDR["DeptID"] = Convert.ToInt32(Dr["DeptID"].ToString());
oDR["DeptName"] = Dr["DeptName"].ToString();
oDR["Shift"] = Dr["Shift"].ToString();
//oDR["CardNo"] = Dr["CardNo"].ToString();
oDR["AttnDate"] = Convert.ToDateTime(Dr["attndate"]).ToString("dd MMM yyyy");
if (Dr["OutTime"] is DBNull)
{
Intime = Convert.ToDateTime(Dr["InTime"]);
oDR["InTime"] = Intime.ToString("HH:mm");
oDR["OutTime"] = string.Empty;
//oDR["MissingStatus"] = "Out Time Missing";
}
else
{
OutTime = Convert.ToDateTime(Dr["OutTime"]);
oDR["InTime"] = string.Empty;
oDR["OutTime"] = OutTime.ToString("HH:mm");
//oDR["MissingStatus"] = "In Time Missing";
}
////oDR["Floor"] = Dr["Floor"].ToString();
////oDR["Section"] = Dr["Section"].ToString();
////oDR["Line"] = Dr["Line"].ToString();
//Shift shft = shifts.SingleOrDefault(x => x.ID == Convert.ToInt32(Dr["ShiftID"].ToString()));
//if (shft != null)
//{
// ShiftInTime = new DateTime(AttnDate.Year, AttnDate.Month, AttnDate.Day, shft.InTime.Hour, shft.InTime.Minute, shft.InTime.Second);
// ShiftOutTime = new DateTime(AttnDate.Year, AttnDate.Month, AttnDate.Day, shft.OutTime.Hour, shft.OutTime.Minute, shft.OutTime.Second);
// if (ShiftInTime > ShiftOutTime)
// ShiftOutTime = ShiftOutTime.AddDays(1);
// oDR["ShiftIn"] = ShiftInTime.ToString("HH:mm");
// oDR["ShiftOut"] = ShiftOutTime.ToString("HH:mm");
// if (Intime == DateTime.MinValue && ShiftInTime.AddHours(inMissingHour) < Intime)
// {
// oDR["OutTime"] = oDR["InTime"].ToString();
// oDR["InTime"] = string.Empty;
// oDR["MissingStatus"] = "In Time Missing";
// }
//}
dTable.Rows.Add(oDR);
}
DataSet dSet = new DataSet();
dTable.TableName = "AttendenceDataSet_InOutMissing";
dSet.Tables.Add(dTable);
string RDLC = "DailyOddStatusLiFung.rdlc";
ReportParameter rParam;
List<ReportParameter> _reportParameters = new List<ReportParameter>();
rParam = new ReportParameter("AttnFromDate", attnFromDate.ToString("dd MMM yyyy"));
_reportParameters.Add(rParam);
//rParam = new ReportParameter("AttnToDate", attnToDate.ToString("dd MMM yyyy"));
//_reportParameters.Add(rParam);
//return reportProcessor.AttendanceReportsView(null, dSet, null, RDLC, _reportParameters, true, payrollTypeID, reportType);
return reportProcessor.CommonReportViewer(null, RDLC, dSet, _reportParameters, payrollTypeID);
}
public byte[] DailyAttnForLiFung(DateTime dFromDate, string sEmpID, string reportType, int payrollTypeID)
{
//DateTime dFromDate = GlobalFunctions.FirstDateOfMonth(fromDate);
//DateTime dToDate = GlobalFunctions.LastDateOfMonth(dFromDate);
//if (dFromDate > dToDate)
//{
// var temp = dFromDate;
// dFromDate = dToDate;
// dToDate = temp;
//}
DataRow oDR = null;
DataSet oDailyInOut = null;
List<Employee> oEmp = new EmployeeService().GetByEmpIDs(sEmpID, payrollTypeID);
List<Department> oDepartment = new DepartmentService().GetAll(payrollTypeID);
List<Designation> oDesignation = new DesignationService().GetAll(payrollTypeID);
EnumAttendanceType[] statuses = { EnumAttendanceType.Present, EnumAttendanceType.Absent, EnumAttendanceType.Delay, EnumAttendanceType.Late, EnumAttendanceType.Early, EnumAttendanceType.OutSideDuty };
String status = string.Join(",", Array.ConvertAll(statuses, x => ((int)x).ToString()));
//oDailyInOut = new DailyAttnProcessService().GetDailyDataByStatus(dFromDate, sEmpID, EnumAttendanceType.Present, EnumAttendanceType.Late, EnumAttendanceType.Early, EnumAttendanceType.Delay, EnumAttendanceType.OutSideDuty);
oDailyInOut = new DailyAttnProcessService().GetDailyDataByStatusDateset(dFromDate, status, sEmpID);
HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable oSubDataTable = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable();
//HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnParentNewLiFungDataTable dTableParent = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnParentNewLiFungDataTable();
List<String> oTHours = new List<String>();
List<String> latehours = new List<String>();
HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.DailyInOutDataTable dTable = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.DailyInOutDataTable();
foreach (DataRow Dr in oDailyInOut.Tables[0].Rows)
{
oDR = dTable.NewRow();
oDR["EmployeeNo"] = Dr["EMPLOYEENO"];
oDR["Name"] = Dr["Name"];
oDR["Designation"] = Dr["Designation"];
oDR["InTime"] = Dr["InTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["InTime"]).ToString("HH:mm");
oDR["OutTime"] = Dr["OutTime"] is DBNull ? "00:00" : Convert.ToDateTime(Dr["OutTime"]).ToString("HH:mm");
oDR["EmpType"] = Dr["EmpType"].ToString();
oDR["Status"] = GlobalFunctions.GetShortAttnType((EnumAttendanceType)Convert.ToInt32(Dr["Status"]));
oDR["OTHour"] = GlobalFunctions.ConvertDoubleHourToHourMinute(Convert.ToDouble(Dr["OTHour"]));
oDR["OTHourDBL"] = Convert.ToDouble(Dr["OTHour"]);
oDR["DeptID"] = Convert.ToInt32(Dr["DeptID"].ToString());
oDR["DeptName"] = Dr["DeptName"].ToString();
oDR["Department"] = Dr["Department"].ToString();
oDR["Section"] = Dr["Section"].ToString();
oDR["Line"] = Dr["Line"].ToString();
oDR["Floor"] = Dr["Floor"].ToString();
oDR["Shift"] = Dr["Shift"].ToString();
oDR["CardNo"] = Dr["CardNo"].ToString();
dTable.Rows.Add(oDR);
}
DataSet dSet = new DataSet();
dTable.TableName = "AttendenceDataSet_DailyInOut";
dSet.Tables.Add(dTable);
//string RDLC = "HRM.Report.Attendence.RDLC.DailyPresent.rdlc";
string RDLC = "DailyAttendanceLiFung.rdlc";
List<ReportParameter> _reportParameters = new List<ReportParameter>();
ReportParameter rParam = new ReportParameter("AttnDate", dFromDate.ToString("dd MMM yyyy"));
_reportParameters.Add(rParam);
//rParam = new ReportParameter("Fax", "");
//_reportParameters.Add(rParam);
//rParam = new ReportParameter("Email", systemInfo.email);
//_reportParameters.Add(rParam);
return new ReportProcessor().CommonReportViewer(null, RDLC, dSet, _reportParameters, payrollTypeID);
//return reportProcessor.AttendanceReportsView(null, dSet, null, RDLC, _reportParameters, true, payrollTypeID, reportType);
//AttendanceReportView(reportItem, dSet, dSubReportDataSet, reportName, parameters, defaultParameterNeeded, payrollTypeId, reportType)
}
//public byte[] ShowDateRangeJobCardMultipleLiNFung(DateTime dFromDate, DateTime dToDate, string sEmpID, int payrollTypeId, string reportType)
//{
// if (dFromDate > dToDate)
// {
// var temp = dFromDate;
// dFromDate = dToDate;
// dToDate = temp;
// }
// List<Employee> oEmp = new EmployeeService().GetByEmpIDs(sEmpID, payrollTypeId);
// List<Department> oDepartment = new DepartmentService().GetAll(payrollTypeId);
// List<Designation> oDesignation = new DesignationService().GetAll(payrollTypeId);
// String RDLC = string.Empty;
// HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable oSubDataTable = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable();
// HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnParentNewDataTable dTableParent = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnParentNewDataTable();
// foreach (Employee emp in oEmp)
// {
// try
// {
// List<String> oTHours = new List<String>();
// List<String> latehours = new List<String>();
// Department tempDepartment = emp.DepartmentID != null ? oDepartment.Find(item => item.ID == emp.DepartmentID) : null;
// Designation tempDesignation = emp.DesignationID != null ? oDesignation.Find(item => item.ID == emp.DesignationID) : null;
// DataTable tempSub = GetEmpDailyAttn(emp.ID, dFromDate, dToDate, payrollTypeId);
// foreach (DataRow dr in tempSub.Rows)
// {
// var dRowSub = oSubDataTable.NewRow();
// dRowSub["EmployeeNo"] = emp.EmployeeNo;
// dRowSub["Date"] = dr["Date"];
// dRowSub["InTime"] = dr["InTime"];
// dRowSub["OutTime"] = dr["OutTime"];
// dRowSub["LateBy"] = dr["LateBy"];
// dRowSub["OTHr"] = dr["OTHr"];
// dRowSub["Status"] = dr["Status"];
// dRowSub["Remarks"] = dr["Remarks"];
// dRowSub["Shift"] = dr["Shift"];
// dRowSub["AttnType"] = dr["AttnType"];
// dRowSub["Description"] = dr["Description"];
// dRowSub["Amount"] = dr["Amount"];
// dRowSub["WorkPlanGroup"] = dr["WorkPlanGroup"];
// dRowSub["AttnDate"] = dr["AttnDate"];
// dRowSub["Day"] = dr["Day"];
// dRowSub["WorkingHour"] = dr["WorkingHour"];
// dRowSub["InTimeShow"] = dr["InTimeShow"];
// oSubDataTable.Rows.Add(dRowSub);
// string oTHour = Convert.ToString(dr["OTHr"]);
// string latehour = Convert.ToString(dr["LateBy"]);
// oTHours.Add(oTHour);
// latehours.Add(latehour);
// }
// string totalOT = GlobalFunctions.GetHourMinutes(oTHours);
// string totalLateHour = GlobalFunctions.GetHourMinutes(latehours);
// var dRowParent = dTableParent.NewRow();
// dRowParent["EmpNo"] = emp.EmployeeNo.ToString();
// dRowParent["Name"] = emp.Name.ToString();
// dRowParent["Designation"] = tempDesignation != null ? tempDesignation.Name : string.Empty;
// dRowParent["Department"] = tempDepartment != null ? tempDepartment.Name : string.Empty;
// //dRowParent["JoiningDate"] = emp.Grade == null ? "" : emp.JoiningDate.ToString("dd MMM yyyy");
// dRowParent["JoiningDate"] = emp.JoiningDate != DateTime.MinValue ? emp.JoiningDate.ToString("dd MMM yyyy") : string.Empty;
// dRowParent["FromDate"] = dFromDate.ToString("dd MMM yyyy");
// dRowParent["ToDate"] = dToDate.ToString("dd MMM yyyy");
// dRowParent["TotalLate"] = totalLateHour;
// dRowParent["TotalOT"] = totalOT;
// dTableParent.Rows.Add(dRowParent);
// }
// catch (Exception ex)
// {
// throw;
// }
// }
// DataSet dSetSub = new DataSet();
// oSubDataTable.TableName = "AttendenceDataSet_EmpDailyAttn";
// dSetSub.Tables.Add(oSubDataTable);
// DataSet dSetParent = new DataSet();
// dTableParent.TableName = "AttendenceDataSet_EmpDailyAttnParentNew";
// dSetParent.Tables.Add(dTableParent);
// RDLC = "HRM.Report.Attendence.RDLC.DateRangeMultipleJobCardNew.rdlc";
// return new ReportProcessor().CommonReportView(null, RDLC, dSetParent, dSetSub, null, true, payrollTypeId, reportType);
//}
public byte[] MonthlyJobCard(DateTime dFromDate, DateTime dToDate, string sEmpID, int payrollTypeId, string reportType)
{
if (dFromDate > dToDate)
{
var temp = dFromDate;
dFromDate = dToDate;
dToDate = temp;
}
ReportProcessor reportProcessor = new ReportProcessor();
AttendanceReport attnReport = new AttendanceReport();
DataSet dSet = new DataSet();
DataTable oDataTable = null;
double totalOTHour, totalLateHour;
oDataTable = attnReport.GetEmpDailyAttnNew(Convert.ToInt32(sEmpID), GlobalFunctions.FirstDateOfMonth(dFromDate), GlobalFunctions.LastDateOfMonth(dToDate), out totalOTHour, out totalLateHour, payrollTypeId);
DataSet dsEmp = new EmployeeService().GetAllEmpBasicInfo(sEmpID);
//DataSet MonthlyKpiDetailsWithLeave = calculateLeave(dSet);
string sDepartment = string.Empty, sSection = string.Empty, sFloor = string.Empty, sDesignation = string.Empty;
if (dsEmp.Tables[0].Rows.Count > 0)
{
var dRow = dsEmp.Tables[0].Rows[0];
sDepartment = dRow["Department"].ToString();
sSection = dRow["Section"].ToString();
sFloor = dRow["Floor"].ToString();
sDesignation = dRow["Designation"].ToString();
}
string totalOTHR = GlobalFunctions.ConvertDoubleHourToHourMinute(totalOTHour);
string totalLateHourString = GlobalFunctions.ConvertDoubleHourToHourMinute(totalLateHour);
Employee employee = new Employee();
employee = new EmployeeService().Get(Convert.ToInt32(sEmpID));
#region Parameter Addition
List<ReportParameter> parameters = new List<ReportParameter>();
ReportParameter _parameter = new ReportParameter("FromDate", GlobalFunctions.FirstDateOfMonth(dFromDate).ToString("dd MMM yyyy"));
parameters.Add(_parameter);
_parameter = new ReportParameter("ToDate", GlobalFunctions.LastDateOfMonth(dFromDate).ToString("dd MMM yyyy"));
parameters.Add(_parameter);
_parameter = new ReportParameter("EmpNo", employee.EmployeeNo);
parameters.Add(_parameter);
_parameter = new ReportParameter("EmpName", employee.Name);
parameters.Add(_parameter);
_parameter = new ReportParameter("EmpDesignation", sDesignation != null ? sDesignation : string.Empty);
parameters.Add(_parameter);
_parameter = new ReportParameter("EmpJoinDate", employee.JoiningDate.ToString("dd MMM yyyy"));
parameters.Add(_parameter);
_parameter = new ReportParameter("EmpDepartment", sDepartment);
parameters.Add(_parameter);
_parameter = new ReportParameter("EmpSection", sSection);
parameters.Add(_parameter);
_parameter = new ReportParameter("TotalOT", totalOTHR);
parameters.Add(_parameter);
_parameter = new ReportParameter("TotalLateHour", totalLateHourString);
parameters.Add(_parameter);
_parameter = new ReportParameter("EmpFloor", sFloor);
parameters.Add(_parameter);
#endregion
oDataTable.TableName = "AttendenceDataSet_EmpDailyAttn";
string filePath = "EmpDailyAttn.rdlc";
dSet.Tables.Add(oDataTable);
return new ReportProcessor().CommonReportView(null, dSet, null, filePath, parameters, true, payrollTypeId, reportType);
}
public byte[] GetAttendanceSummary(DateTime dFromDate, string sEmpID, string reportType, int payrollTypeID)
{
ReportProcessor reportProcessor = new ReportProcessor();
DataSet oAttendanceSummary = null;
oAttendanceSummary = new DailyAttnProcessService().GetMonthlyAttn(GlobalFunctions.FirstDateOfMonth(dFromDate), GlobalFunctions.LastDateOfMonth(dFromDate), sEmpID);
//DataSet MonthlyKpiDetailsWithLeave = calculateLeave(oAttendanceSummary);
HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyAttnDataTable oAttendanceSummaryDTable = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyAttnDataTable();
#region Summary Parts
foreach (DataRow Dr in oAttendanceSummary.Tables[0].Rows)
{
DataRow dRow = oAttendanceSummaryDTable.NewRow();
dRow["EmpNo"] = Dr["EMPLOYEENO"];
dRow["Name"] = Dr["NAME"];
dRow["CardNo"] = Dr["CardNo"].ToString();
dRow["Designation"] = Dr["Designation"];
dRow["Grade"] = Dr["Grade"];
dRow["JoinDate"] = Convert.ToDateTime(Dr["JOININGDATE"]).ToString("dd MMM yyyy");
dRow["GrossSalary"] = Convert.ToDouble(Dr["GROSSSALARY"]);
dRow["Present"] = Dr["Present"] is DBNull ? 0 : Dr["Present"];
dRow["Department"] = Dr["Department"].ToString();
dRow["Section"] = Dr["Section"].ToString();
dRow["Line"] = Dr["Line"].ToString();
dRow["Floor"] = Dr["Floor"].ToString();
dRow["Late"] = Dr["Late"] is DBNull ? 0 : Dr["Late"];
dRow["Absent"] = Dr["Absent"] is DBNull ? 0 : Dr["Absent"];
dRow["Holiday"] = Dr["Holiday"] is DBNull ? 0 : Dr["Holiday"];
dRow["Leave"] = Dr["Leave"] is DBNull ? 0 : Dr["Leave"];
dRow["TotalAttn"] = Dr["TotalAttn"];
dRow["TotalOT"] = GlobalFunctions.ConvertDoubleHourToHourMinute(Convert.ToDouble(Dr["TotalOT"]));
dRow["TotalOTDBL"] = Convert.ToDouble(Dr["TotalOT"]);
dRow["Remarks"] = "";
oAttendanceSummaryDTable.Rows.Add(dRow);
}
#endregion
oAttendanceSummaryDTable.TableName = "AttendenceDataSet_MonthlyAttn";
oAttendanceSummary.Tables.Add(oAttendanceSummaryDTable);
List<ReportParameter> _parameters = new List<ReportParameter>();
ReportParameter rParam = new ReportParameter("FromDate", GlobalFunctions.FirstDateOfMonth(dFromDate).ToString("dd MMM yyyy"));
_parameters.Add(rParam);
rParam = new ReportParameter("ToDate", GlobalFunctions.LastDateOfMonth(dFromDate).ToString("dd MMM yyyy"));
_parameters.Add(rParam);
string filePath = "MonthlyAttn.rdlc";
return new ReportProcessor().CommonReportView(null, oAttendanceSummary, null, filePath, _parameters, true, payrollTypeID, reportType);
}
public DataTable GetEmpDailyAttnNew(int EmpID, DateTime dFromDate, DateTime dToDate, out double totalOTHour, out double totalLateHour, int payrollTypeID)
{
List<AttnNationalHoliday> oNationalHolidays = new AttnNationalHolidayService().GetByMonth(PayrollGlobalFunctions.FirstDateOfYear(dFromDate), PayrollGlobalFunctions.LastDateOfYear(dToDate));
//dFromDate.FirstDateOfMonth(), dFromDate.FirstDateOfMonth());
totalOTHour = 0; totalLateHour = 0;
List<DailyAttnProcess> dAttnProcessess = new List<DailyAttnProcess>();
dAttnProcessess = new DailyAttnProcessService().Get(EmpID, dFromDate, dToDate);
List<ADParameter> _adps = new ADParameterService().Get(EnumStatus.Regardless, EnumAllowOrDeduct.Allowance, payrollTypeID);
List<AllowanceDeduction> oAllowanceDeduction = new AllowanceDeductionService().Get(EnumStatus.Regardless);
List<ADParameterEmployee> oADParameterEmployee = new ADParameterEmployeeService().Get(EnumADEmpType.NotApplicable);
List<ADParameter.ADParameterShift> oADParameterShift = new ADParameterService().GetAllShifts();
foreach (ADParameter item in _adps)
{
//item.AllowanceDeduction = new AllowanceDeductionService().Get(item.AllowDeductID);
//item.NotApplicable = new ADParameterEmployeeService().GetbyParameter(item.ID, EnumADEmpType.NotApplicable);
//item.ADParameterShifts = new ADParameterService().GetShifts(item.ID);
item.AllowanceDeduction = oAllowanceDeduction.Where(x=> x.ID == item.AllowDeductID).FirstOrDefault();
item.NotApplicable = oADParameterEmployee.Where(x => x.ADParameterID == item.ID && x.ADEmpType == EnumADEmpType.NotApplicable).ToList();
item.ADParameterShifts = oADParameterShift.Where(x => x.ADParameterID == item.ID).ToList();
}
oAllDeducts = new AllowanceDeductionService().Get(EnumStatus.Regardless);
AllowanceDeduction oAttnNightAllowance = oAllDeducts.FirstOrDefault(x => x.Code.Trim().ToUpper() == "023" && x.AllowOrDeductType == EnumAllowOrDeduct.Allowance);
AllowanceDeduction oAttnSpacialAllowance = oAllDeducts.FirstOrDefault(x => x.Code.Trim().ToUpper() == "022" && x.AllowOrDeductType == EnumAllowOrDeduct.Allowance);
List<int> oShiftIDs = (_adps != null && _adps.Count > 0) ? _adps.Where(y => y.AllowDeductID == oAttnNightAllowance.ID).SelectMany(z => z.ADParameterShifts).Select(a => Convert.ToInt32(a.ShiftID)).ToList() : null;
List<int> oShiftIDsSpecial = (_adps != null && _adps.Count > 0) ? _adps.Where(y => y.AllowDeductID == oAttnSpacialAllowance.ID).SelectMany(z => z.ADParameterShifts).Select(a => Convert.ToInt32(a.ShiftID)).ToList() : null;
List<Leave> oLeaves = new LeaveService().Get();
HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable dTable = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable();
List<Shift> oShifts = new ShiftService().GetAllShift();
//var tfshifts = oShifts.FindAll(x => x.NightAllowanceID != null);
//List<int> oShiftIDs = tfshifts.Select(a => a.ID).ToList();
//var tfshiftsSpecial = oShifts.FindAll(x => x.SpecialAllowanceID != null);
//List<int> oShiftIDsSpecial = tfshiftsSpecial.Select(a => a.ID).ToList();
string sLeaveName = string.Empty;
List<int> oOverlappingShiftIDs = oShifts.Where(x => x.IsOverlapingDay).Select(x => x.ID).ToList();
AllowanceDeduction oAttnLunchAssistanceAllowance = oAllDeducts.FirstOrDefault(x => x.Code.Trim().ToUpper() == "015" && x.AllowOrDeductType == EnumAllowOrDeduct.Allowance);
string lunchAllowDaysString = new SystemConfigarationService().GetconfigStringValue(EnumConfigurationType.Logic, "attendence", "lunchallowanceday");
////---------Added for Just manual testing-------
//lunchAllowDaysString = "Fryday";
////---------------------------------------------
DayOfWeek lunchAllowanceDOW;
if (!Enum.TryParse(lunchAllowDaysString, out lunchAllowanceDOW)) lunchAllowanceDOW = DayOfWeek.Friday;
////---------Added for Just manual testing-------
//tiffinAllowanceCodeString = "003,012,019";
////---------------------------------------------
string tiffinAllowanceCodeString = new SystemConfigarationService().GetconfigStringValue(EnumConfigurationType.Logic, "attendence", "nightshiftcodes");
List<string> tiffinAllowanceCodes = tiffinAllowanceCodeString.Trim().Split(',').ToList();
List<int> oNightShiftIDs = oShifts.Where(x => tiffinAllowanceCodes.Contains(x.Code.Trim())).Select(x => x.ID).ToList();
//AllowanceDeduction oAttnExtraAllowance = oAllDeducts.FirstOrDefault(x => x.Code.Trim().ToUpper() == "004" && x.AllowOrDeductType == EnumAllowOrDeduct.Allowance);
List <ADParameter> _Adparameters = new ADParameterService().Get(EnumStatus.Active, EnumAllowOrDeduct.Allowance, payrollTypeID).Where(x => x.AllowDeductID == 4).ToList(); // AllowDeductID = 4 is Extra Allowance in ALLOWANCEDEDUCTION table
//List<Grade> ogrades = new GradeService().Get(EnumStatus.Regardless);
List<Grade> ogrades = new GradeService().GetAllPayrollTypes(EnumStatus.Regardless);
Employee emp = new EmployeeService().Get(EmpID);
//string sExtraAllowanceHour = Ease.CoreV35.Utility.ConfigUtility.GetAppSettings("ExtraAllowanceHour");
double dExtraAllowanceHours = 13.5;
//if (!double.TryParse(sExtraAllowanceHour, out dExtraAllowanceHours))
//{
// dExtraAllowanceHours = 13.5; // Default if Hour not given
//}
DateTime? startTime;
DateTime? endTime;
string shortAttnType = "";
if (!(dAttnProcessess == null || dAttnProcessess.Count <= 0))
{
foreach (DailyAttnProcess dAttnProcess in dAttnProcessess)
{
sLeaveName = string.Empty;
StringBuilder sRemarks;
DataRow Rowbody = dTable.NewRow();
DailyAttnProcess dap = dAttnProcessess.Where(x => x.ShiftID != null &&
x.ShiftID != 0 &&
oShiftIDs.Contains(Convert.ToInt32(x.ShiftID)) &&
x.AttenType != EnumAttendanceType.Absent &&
x.AttenType != EnumAttendanceType.Holiday &&
x.AttenType != EnumAttendanceType.Leave &&
x.AttenType != EnumAttendanceType.WeeklyHoliday
&& x.AttnDate == dAttnProcess.AttnDate).FirstOrDefault();
Rowbody["NightShiftAllowance"] = dap != null ? 1 : 0;
DailyAttnProcess dapSpecial = dAttnProcessess.Where(x => x.ShiftID != null &&
x.ShiftID != 0 &&
oShiftIDsSpecial.Contains(Convert.ToInt32(x.ShiftID)) &&
x.AttenType != EnumAttendanceType.Absent &&
x.AttenType != EnumAttendanceType.Holiday &&
x.AttenType != EnumAttendanceType.Leave &&
x.AttenType != EnumAttendanceType.WeeklyHoliday && x.AttnDate == dAttnProcess.AttnDate).FirstOrDefault();
Rowbody["SpecialAllowance"] = dapSpecial != null ? 1 : 0;
Rowbody["Date"] = dAttnProcess.AttnDate.ToString("dd MMM yy");
Rowbody["Day"] = dAttnProcess.AttnDate.ToString("ddd");
if (dAttnProcess.InTime == DateTime.MinValue || dAttnProcess.InTime == null)
{
Rowbody["InTime"] = "00:00";
}
else
{
Rowbody["InTime"] = ((DateTime)dAttnProcess.InTime).ToString("HH:mm:ss");
}
if (dAttnProcess.OutTime == DateTime.MinValue || dAttnProcess.OutTime == null)
{
Rowbody["OutTime"] = "00:00";
}
else
{
Rowbody["OutTime"] = ((DateTime)dAttnProcess.OutTime).ToString("HH:mm:ss");
}
totalLateHour += dAttnProcess.LateHour;
Rowbody["LateBy"] = GlobalFunctions.ConvertDoubleHourToHourMinute(dAttnProcess.LateHour);
totalOTHour += dAttnProcess.OTHour;
Rowbody["OTHr"] = GlobalFunctions.ConvertDoubleHourToHourMinute(dAttnProcess.OTHour);
shortAttnType = GlobalFunctions.GetShortAttnType(dAttnProcess.AttenType);
Rowbody["Status"] = shortAttnType;
AttnNationalHoliday nh = oNationalHolidays.Find(x => dAttnProcess.AttnDate >= x.FromDate && dAttnProcess.AttnDate <= x.ToDate);
if (nh != null)
Rowbody["Status"] = "N";
Rowbody["Lunch"] = 0;
if (dAttnProcess.AttnDate.DayOfWeek == lunchAllowanceDOW &&
dAttnProcess.AttenType != EnumAttendanceType.Absent &&
dAttnProcess.AttenType != EnumAttendanceType.Holiday &&
dAttnProcess.AttenType != EnumAttendanceType.Leave &&
dAttnProcess.AttenType != EnumAttendanceType.WeeklyHoliday &&
!oOverlappingShiftIDs.Contains((dAttnProcess.ShiftID != null && dAttnProcess.ShiftID != 0) ? Convert.ToInt32(dAttnProcess.ShiftID) : 0))
{
Rowbody["Lunch"] = 1;
}
Rowbody["Tiffin"] = 0;
if (dAttnProcess.ShiftID != null &&
dAttnProcess.ShiftID != 0 &&
oNightShiftIDs.Contains(Convert.ToInt32(dAttnProcess.ShiftID)) &&
dAttnProcess.AttenType != EnumAttendanceType.Absent &&
dAttnProcess.AttenType != EnumAttendanceType.Holiday &&
dAttnProcess.AttenType != EnumAttendanceType.Leave &&
dAttnProcess.AttenType != EnumAttendanceType.WeeklyHoliday)
{
Rowbody["Tiffin"] = 1;
}
ADParameter ad = _adps.Where(x => x.AllowanceDeduction.Code == "016").FirstOrDefault();
if (ad != null && ad.NotApplicable != null && ad.NotApplicable.Count > 0)
{
ADParameterEmployee adpe = ad.NotApplicable.Where(x => x.EmployeeID == emp.ID).FirstOrDefault();
if (adpe != null)
{
Rowbody["Tiffin"] = 0;
}
}
Rowbody["ExtraAllowance"] = 0;
if (_Adparameters != null && emp != null)
{
foreach (ADParameter adparam in _Adparameters)
{
foreach (ADParameter.ADParameterGrade grn in adparam.ADParameterGrades)
{
//Grade gr = ogrades.GetItem(grn.GradeID);
Grade gr = ogrades.Where(x=> x.ID == grn.GradeID).FirstOrDefault();
if (gr != null && gr.ID == emp.GradeID)
{
if (/*dAttnProcess.InTime != DateTime.MinValue ||*/ dAttnProcess.InTime != null)
{
Shift sft = oShifts.FirstOrDefault(x => x.ID == dAttnProcess.ShiftID);
if(sft != null || dAttnProcess.ShiftID != null)
{
startTime = dAttnProcess.InTime.Value.Add(sft.InTime.TimeOfDay);
startTime = startTime.Value.AddMinutes(-15) > dAttnProcess.InTime ? startTime.Value.AddMinutes(-15) : dAttnProcess.InTime;
endTime = dAttnProcess.OutTime;
if (endTime != DateTime.MinValue)
{
if (endTime.Value.Subtract(startTime.Value).Add(TimeSpan.FromMinutes(1)).TotalHours >= dExtraAllowanceHours)
{
Rowbody["ExtraAllowance"] = 1;
}
}
}
}
}
}
}
}
//New
//Rowbody["ExtraAllowance"] = 0;
//if (dAttnProcess.InTime != null && dAttnProcess.InTime != DateTime.MinValue)
//{
// Shift sft = oShifts.FirstOrDefault(x => x.ID == dAttnProcess.ShiftID);
// startTime = ((DateTime)dAttnProcess.InTime).Date.Add(sft.InTime.TimeOfDay);
// startTime = ((DateTime)startTime).AddMinutes(-15) > (DateTime)dAttnProcess.InTime
// ? Convert.ToDateTime(startTime).AddMinutes(-15) : (DateTime)dAttnProcess.InTime;
// endTime = dAttnProcess.OutTime;
// if (endTime != null && endTime != DateTime.MinValue)
// {
// if (((DateTime)endTime).Subtract(startTime).Add(TimeSpan.FromMinutes(1)).TotalHours >= dExtraAllowanceHours)
// {
// Rowbody["ExtraAllowance"] = 1;
// }
// }
//}
if (dAttnProcess.AttenType == EnumAttendanceType.Leave)
{
var oLeave = oLeaves.FirstOrDefault(x => Convert.ToInt32(x.ID) == Convert.ToInt32(dAttnProcess.ReferenceID));
if (oLeave != null)
{
sLeaveName = oLeave.Description;
}
}
sRemarks = new StringBuilder();
sRemarks.AppendFormat("{0}.", sLeaveName);
sRemarks.AppendFormat("{0}.", dAttnProcess.Comments);
Rowbody["Remarks"] = sRemarks.ToString().Trim('.');
Shift oSft = oShifts.Where(o => Convert.ToInt32(o.ID) == Convert.ToInt32(dAttnProcess.ShiftID)).FirstOrDefault();
if (oSft != null)
{
Rowbody["Shift"] = oSft.ShortName;
}
else
{
Rowbody["Shift"] = string.Empty;
}
Rowbody["IsManualEntry"] = dAttnProcess.IsManualEntry;
dTable.Rows.Add(Rowbody);
}
}
DataView dv = dTable.DefaultView;
dv.Sort = "Date ASC";
DataTable sortedDT = dv.ToTable();
return sortedDT;
}
public DataTable GetEmpDailyAttn(int EmpID, DateTime dFromDate, DateTime dToDate, int PayrollTypeID)
{
List<EmployeeUnAuthorizeLeave> _unAuthorizedLeaves = new EmployeeUnAuthorizeLeaveService().GetByEmployeeID(EmpID);
_unAuthorizedLeaves = _unAuthorizedLeaves.Where(o => o.IsLateAttendanceRelated == false).ToList();
EmployeeUnAuthorizeLeave unAuthorizedLeave = null;
EmployeeUnAuthorizeLeave unAuthorizedLeaveHalfDay = null;
string workingHour = string.Empty;
List<Leave> oLeaves = new LeaveService().Get(EnumStatus.Active, PayrollTypeID);
List<AttnMonthlyBenefit> amBenefits = null;
DateTime fromSalaryMonth = dFromDate;
DateTime toSalaryMonth = dToDate;
fromSalaryMonth = GlobalFunctions.GetAttandaceSalaryMonth(dFromDate);
toSalaryMonth = new AttnMonthlyBenefitService().GetAttandaceSalaryMonth(dToDate);
amBenefits = new AttnMonthlyBenefitService().Get(EmpID, fromSalaryMonth, toSalaryMonth);
List<DailyAttnProcess> dAttnProcessess = new List<DailyAttnProcess>();
dAttnProcessess = new DailyAttnProcessService().Get(EmpID, dFromDate, dToDate);
HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable dTable = new HRM.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable();
//PayrollDataSet.PayrollDataSet.LaonPaymentDueDataTable dTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.LaonPaymentDueDataTable();
List<Shift> oShifts = new ShiftService().GetAllShift();
if (!(dAttnProcessess == null || dAttnProcessess.Count <= 0))
{
foreach (DailyAttnProcess dAttnProcess in dAttnProcessess)
{
DataRow Rowbody = dTable.NewRow();
Rowbody["Date"] = dAttnProcess.AttnDate.ToString("dd MMM yyyy");
Rowbody["Day"] = dAttnProcess.AttnDate.ToString("dddd");
if (dAttnProcess.InTime == DateTime.MinValue || dAttnProcess.InTime == null)
{
Rowbody["InTime"] = "00:00";
}
else
{
Rowbody["InTime"] = ((DateTime)dAttnProcess.InTime).ToString("hh:mm tt");
}
if (dAttnProcess.OutTime == DateTime.MinValue || dAttnProcess.OutTime == null)
{
Rowbody["OutTime"] = "00:00";
}
else
{
Rowbody["OutTime"] = ((DateTime)dAttnProcess.OutTime).ToString("hh:mm tt");
}
Rowbody["WorkingHour"] = dAttnProcess.WorkHour.ToString("0.00");
Rowbody["LateBy"] = dAttnProcess.LateHour.ToString("0.00");
Rowbody["OTHr"] = dAttnProcess.OTHour.ToString("0.00");
if (dAttnProcess.AttenType == EnumAttendanceType.Leave)
{
Rowbody["Status"] = GetLeaveType(dAttnProcess.ReferenceID == null ? 0 : dAttnProcess.ReferenceID.Value, oLeaves);
}
else
{
Rowbody["Status"] = GlobalFunctions.GetShortAttnType(dAttnProcess.AttenType, dAttnProcess.WorkDayType, dAttnProcess.LateHour);
}
unAuthorizedLeaveHalfDay = _unAuthorizedLeaves.Where(o => o.LeaveDays == 0.5 && o.FromDate.Date == dAttnProcess.AttnDate && o.ToDate.Date == dAttnProcess.AttnDate).FirstOrDefault();
unAuthorizedLeave = _unAuthorizedLeaves.Where(o => dAttnProcess.AttnDate >= o.FromDate && dAttnProcess.AttnDate <= o.ToDate).FirstOrDefault();
//oAttNHoliday = attNHolidays.Where(o => dDate.Date >= o.FromDate.Date && dDate.Date <= o.ToDate.Date).FirstOrDefault();
Rowbody["Remarks"] = unAuthorizedLeaveHalfDay == null ? dAttnProcess.Comments : "1/2 day";
if (unAuthorizedLeave != null)
Rowbody["Status"] = "LWP";
if (dAttnProcess.ShiftID != null)
{
Shift oSft = oShifts.Where(o => o.ID == dAttnProcess.ShiftID).FirstOrDefault();
if (oSft != null)
{
Rowbody["Shift"] = oSft.ShortName;
}
else
{
Rowbody["Shift"] = string.Empty;
}
}
dTable.Rows.Add(Rowbody);
}
}
return dTable;
}
private string GetLeaveType(int ReferenceID, List<Leave> _leaves)
{
string leaveType = string.Empty;
Leave leave = null;
if (ReferenceID != 0)
{
leave = new Leave();
leave = _leaves.Where(o => o.ID == ReferenceID).FirstOrDefault();
if (leave != null)
{
leaveType = leave.Code;
}
}
return leaveType;
}
public byte[] ShowEmpCardInfoPerPage(string EmpIDs, int authPersonID, string RDLC, bool IsAssignDateChecked, string ExpireYear, DateTime AssignmentDate, int reportCategory)
{
ReportProcessor reportProcessor = new ReportProcessor();
DataSet oCardInfo = null;
string signaturePath = string.Empty;
string folderPath = string.Empty;
if (authPersonID != 0)
{
AuthorizedPerson oAuthPerson = new AuthorizedPersonService().Get(authPersonID);
DataTable dtImage = new AuthorizedPersonService().GetImage(authPersonID);
if (dtImage != null && dtImage.Rows.Count > 0)
{
DataRow dRow = (DataRow)dtImage.Rows[0];
byte[] SignatureData = (byte[])dRow["SignatureData"];
folderPath = Path.Combine(Environment.CurrentDirectory + @"\ClientApp\src\assets\photos");
signaturePath = Path.Combine(folderPath, "AuthSign.jpg");
File.WriteAllBytes(signaturePath, SignatureData);
}
}
List<Employee> oEmployees = new EmployeeService().GetByEmpIDs(EmpIDs);
bool isDesigFromEmp = new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "designation", "desigfromdescriptiontext");
oCardInfo = new DailyAttnProcessService().GetEmpCardInfoPerPage(EmpIDs);
PhotoPath pPath = new PhotoPathService().Get().FirstOrDefault();
foreach (DataRow Dr in oCardInfo.Tables[0].Rows)
{
Employee oEmp = oEmployees.FirstOrDefault(x => x.EmployeeNo.Trim() == Dr["IDNo"].ToString().Trim());
Dr["Desig"] = (isDesigFromEmp && oEmp != null) ? oEmp.DescriptionText : Dr["Desig"];
Dr["EmpPhoto"] = Dr["EmpPhoto"].ToString();
Dr["EmpSign"] = Dr["EmpSign"].ToString();
Dr["IssueDate"] = DateTime.Today;
}
oCardInfo.Tables[0].TableName = "AttendenceDataSet_IDCard";
SystemInformation _systemInfo =new SystemInformationService().Get();
ReportParameter rParam;
List<ReportParameter> _reportParameters = new List<ReportParameter>();
string LogoPath = Path.Combine(folderPath, "Logo.png");
string EmpSignPath = Path.Combine(folderPath, "EmpSign.png");
string EmpPhotoPath = Path.Combine(folderPath, "EmpPhoto.jpg");
//_PATH = Application.StartupPath + @"\Resource\IDCardBanner.png";
rParam = new ReportParameter("EchoTextLogo", LogoPath);
_reportParameters.Add(rParam);
rParam = new ReportParameter("SignatureColor", "");
_reportParameters.Add(rParam);
rParam = new ReportParameter("CompanyNameBangla", "");
_reportParameters.Add(rParam);
rParam = new ReportParameter("CAddress", "");
_reportParameters.Add(rParam);
rParam = new ReportParameter("CPhone", "");
_reportParameters.Add(rParam);
rParam = new ReportParameter("Dhara", "");
_reportParameters.Add(rParam);
rParam = new ReportParameter("SignPath", signaturePath);
_reportParameters.Add(rParam);
if (reportCategory == 1)
{
rParam = new ReportParameter("EmpSignPath", EmpSignPath);
_reportParameters.Add(rParam);
rParam = new ReportParameter("EmpPhotoPath", EmpPhotoPath);
_reportParameters.Add(rParam);
}
return reportProcessor.CommonReportViewer(null, RDLC, oCardInfo, _reportParameters, false);
}
public byte[] ShowEmpCardInfoPerPageBangla(string EmpIDs, int authPersonID, string RDLC, bool IsAssignDateChecked, string ExpireYear, DateTime AssignmentDate)
{
ReportProcessor reportProcessor = new ReportProcessor();
DataSet oCardInfo = null;
string signaturePath = string.Empty;
string folderPath = string.Empty;
if (authPersonID != 0)
{
AuthorizedPerson oAuthPerson = new AuthorizedPersonService().Get(authPersonID);
DataTable dtImage = new AuthorizedPersonService().GetImage(authPersonID);
if (dtImage != null && dtImage.Rows.Count > 0)
{
DataRow dRow = (DataRow)dtImage.Rows[0];
byte[] SignatureData = (byte[])dRow["SignatureData"];
folderPath = Path.Combine(Environment.CurrentDirectory + @"\ClientApp\src\assets\photos");
signaturePath = Path.Combine(folderPath, "AuthSign.jpg");
File.WriteAllBytes(signaturePath, SignatureData);
}
}
List<Employee> oEmployees = new EmployeeService().GetByEmpIDs(EmpIDs);
bool isDesigFromEmp = new SystemConfigarationService().GetconfigBooleanValue(EnumConfigurationType.Logic, "designation", "desigfromdescriptiontext");
oCardInfo = new DailyAttnProcessService().GetEmpCardInfoPerPageBangla(EmpIDs);
//Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.IDCardDataTable dTable = new Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.IDCardDataTable();
//PayrollDataSet.PayrollDataSet.LaonPaymentDueDataTable dTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.LaonPaymentDueDataTable();
oCardInfo.Tables[0].Columns.Add("DOJBangla", typeof(string));
oCardInfo.Tables[0].Columns.Add("IssueDateBangla", typeof(string));
oCardInfo.Tables[0].Columns.Add("ExpireDateBangla", typeof(string));
foreach (DataRow Dr in oCardInfo.Tables[0].Rows)
{
Employee oEmp = oEmployees.FirstOrDefault(x => x.EmployeeNo.Trim() == Dr["IDNo"].ToString().Trim());
Dr["Desig"] = (isDesigFromEmp && oEmp != null) ? oEmp.DescriptionText : Dr["Desig"];
Dr["EmpPhoto"] = Dr["EmpPhoto"].ToString();
Dr["EmpSign"] = Dr["EmpSign"].ToString();
DateTime joiningDate = Convert.ToDateTime(Dr["DOJ"].ToString());
Dr["DOJBangla"] = joiningDate.Day.ToString() + " " + joiningDate.BanglaMonth() + " " + joiningDate.Year.ToString();
DateTime AssignDate;
string ExpireDate = string.Empty;
if (IsAssignDateChecked)
{
AssignDate = AssignmentDate;
ExpireDate = ExpireYear == "3" ? "3 eQi|" : "5 eQi|";
}
else
{
AssignDate = oEmp.JoiningDate;
ExpireDate = ExpireYear == "3" ? "3 eQi|" : "5 eQi|";
}
// DateTime IssueDate = Convert.ToDateTime(Dr["IssueDate"].ToString());
Dr["IssueDateBangla"] = AssignDate != DateTime.MinValue ? AssignDate.Day.ToString() + " " + AssignDate.BanglaMonth() + " " + AssignDate.Year.ToString() : "";
//DateTime ExpireDate = Convert.ToDateTime(Dr["ExpireDate"].ToString());
Dr["ExpireDateBangla"] = ExpireDate;
}
//DataSet dSet = new DataSet();
oCardInfo.Tables[0].TableName = "AttendenceDataSet_IDCard";
//dSet.Tables.Add(dTable);
//string RDLC = "Payroll.Report.RDLC.IDCardBothSidePrint.rdlc";// "Payroll.Report.RDLC.IDCardPrint.rdlc";
//SystemInformation _systemInfo = new SystemInformation().Get();
ReportParameter rParam;
List<ReportParameter> _reportParameters = new List<ReportParameter>();
string _PATH = string.Empty;
_PATH = string.Empty;
rParam = new ReportParameter("EchoTextLogo", _PATH);
_reportParameters.Add(rParam);
rParam = new ReportParameter("SignatureColor","");
_reportParameters.Add(rParam);
rParam = new ReportParameter("CompanyNameBangla", "");
_reportParameters.Add(rParam);
rParam = new ReportParameter("CAddress", "");
_reportParameters.Add(rParam);
rParam = new ReportParameter("CPhone", "");
_reportParameters.Add(rParam);
rParam = new ReportParameter("Dhara","");
_reportParameters.Add(rParam);
rParam = new ReportParameter("SignPath", signaturePath);
_reportParameters.Add(rParam);
return reportProcessor.CommonReportViewer(null, RDLC, oCardInfo, _reportParameters, false);
}
}
}