using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using Payroll.BO; using Ease.CoreV35.Model; using System.Windows.Forms; using Payroll.BO; using Payroll.Report.PayrollDataSet; using Microsoft.Reporting.WinForms; using System.IO; namespace Payroll.Report { public class AttendanceReport { #region Declaration & Construction private EnumAttendanceType _attnType; private string _localPhotLocationName = "LocalFolder"; private PhotoPath _oPhotopath; private FileAccessWithImpersonation fAccessImpersonation; private ReportSetup _selectedParameter; public ReportSetup SelectedParameter { set { _selectedParameter = value; } } public AttendanceReport() { _oPhotopath = PhotoPath.Get().FirstOrDefault(); fAccessImpersonation = new FileAccessWithImpersonation(); } #endregion #region Private Functions private string GetShortAttnType(EnumAttendanceType attnType) { string type = string.Empty; switch (attnType) { case EnumAttendanceType.Absent: type = "A"; break; case EnumAttendanceType.Delay: type = "L"; break; case EnumAttendanceType.Holiday: type = "H"; break; case EnumAttendanceType.Late: type = "L"; break; case EnumAttendanceType.Leave: type = "Lv"; break; case EnumAttendanceType.Present: type = "P"; break; case EnumAttendanceType.OutSideDuty: type = "OD"; break; case EnumAttendanceType.Early: type = "E"; break; case EnumAttendanceType.WeeklyHoliday: type = "W"; break; } return type; } private string GetLeaveType(ID ReferenceID) { string leaveType = "Lv"; Leave leave = null; if (ReferenceID.Integer != 0) { leave = new Leave(); leave = leave.Get(ReferenceID); if (leave != null) { leaveType = leave.Code; } } return leaveType; } private string GetEmployeePicture(string databasePhotoPath) { string newPhotoPath = string.Empty; try { string currDir = Directory.GetCurrentDirectory(); currDir = currDir.Trim('\\') + "\\" + _localPhotLocationName + "\\"; if (!Directory.Exists(currDir)) { Directory.CreateDirectory(currDir); } byte[] bytes = fAccessImpersonation.GetFileInBytes(_oPhotopath.EmployeePhoto, databasePhotoPath); newPhotoPath = currDir + databasePhotoPath; File.WriteAllBytes(newPhotoPath, bytes); } catch (Exception) { newPhotoPath = string.Empty; } return newPhotoPath; } private void RemoveTempPicturePath() { string currDir = Directory.GetCurrentDirectory(); currDir = currDir.Trim('\\') + "\\" + _localPhotLocationName + "\\"; if (Directory.Exists(currDir)) { Directory.Delete(currDir,true); } } #endregion #region Report Functions public void GetDailyInOut() { fReportViewer form = new fReportViewer(); DateTime attnDate = _selectedParameter.FromDate.Value; string sEmpID = _selectedParameter.ReportItem.INSQL; DataSet oDailyInOut = null; DataRow oDR = null; oDailyInOut = DailyAttnProcess.GetDailyInOut(attnDate, sEmpID); Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.DailyInOutDataTable dTable = new Payroll.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"] = GetShortAttnType((EnumAttendanceType)(Convert.ToInt32(Dr["Status"]))); oDR["OTHour"] = Convert.ToDouble(Dr["OTHour"]).ToString("00.00"); oDR["DeptID"] = Convert.ToInt32(Dr["DeptID"].ToString()); oDR["DeptName"] = Dr["DeptName"].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 = "Payroll.Report.Attendence.RDLC.DailyInOut.rdlc"; ReportParameter rParam; List _reportParameters = new List(); rParam = new ReportParameter("AttnDate", attnDate.ToString("dd MMM yyyy")); _reportParameters.Add(rParam); form.CommonReportViewer(_selectedParameter.ReportItem, RDLC, dSet, _reportParameters); } public void GetDailyAbsent() { fReportViewer form = new fReportViewer(); DateTime attnDate = _selectedParameter.FromDate.Value; string sEmpID = _selectedParameter.ReportItem.INSQL; DataSet oDailyInOut = null; DataRow oDR = null; oDailyInOut = DailyAttnProcess.GetDailyDataByStatus(attnDate, sEmpID,EnumAttendanceType.Absent); Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.DailyInOutDataTable dTable = new Payroll.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"] = GetShortAttnType((EnumAttendanceType)(Convert.ToInt32(Dr["Status"]))); oDR["OTHour"] = Convert.ToDouble(Dr["OTHour"]).ToString("00.00"); oDR["DeptID"] = Convert.ToInt32(Dr["DeptID"].ToString()); oDR["DeptName"] = Dr["DeptName"].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 = "Payroll.Report.Attendence.RDLC.DailyAbsent.rdlc"; ReportParameter rParam; List _reportParameters = new List(); rParam = new ReportParameter("AttnDate", attnDate.ToString("dd MMM yyyy")); _reportParameters.Add(rParam); form.CommonReportViewer(_selectedParameter.ReportItem, RDLC, dSet, _reportParameters); } public void GetDailyPresent() { fReportViewer form = new fReportViewer(); DateTime attnDate = _selectedParameter.FromDate.Value; string sEmpID = _selectedParameter.ReportItem.INSQL; DataSet oDailyInOut = null; DataRow oDR = null; oDailyInOut = DailyAttnProcess.GetDailyDataByStatus(attnDate, sEmpID, EnumAttendanceType.Present); Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.DailyInOutDataTable dTable = new Payroll.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"] = GetShortAttnType((EnumAttendanceType)(Convert.ToInt32(Dr["Status"]))); oDR["OTHour"] = Convert.ToDouble(Dr["OTHour"]).ToString("00.00"); oDR["DeptID"] = Convert.ToInt32(Dr["DeptID"].ToString()); oDR["DeptName"] = Dr["DeptName"].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 = "Payroll.Report.Attendence.RDLC.DailyPresent.rdlc"; ReportParameter rParam; List _reportParameters = new List(); rParam = new ReportParameter("AttnDate", attnDate.ToString("dd MMM yyyy")); _reportParameters.Add(rParam); form.CommonReportViewer(_selectedParameter.ReportItem, RDLC, dSet, _reportParameters); } public void GetDailyLeave() { fReportViewer form = new fReportViewer(); DateTime attnDate = _selectedParameter.FromDate.Value; string sEmpID = _selectedParameter.ReportItem.INSQL; DataSet oDailyInOut = null; DataRow oDR = null; oDailyInOut = DailyAttnProcess.GetDailyDataByStatus(attnDate, sEmpID, EnumAttendanceType.Leave); List oLeaves = Leave.Get(); Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.DailyInOutDataTable dTable = new Payroll.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["OTHour"] = Convert.ToDouble(Dr["OTHour"]).ToString("00.00"); oDR["DeptID"] = Convert.ToInt32(Dr["DeptID"].ToString()); oDR["DeptName"] = Dr["DeptName"].ToString(); oDR["Shift"] = string.Empty; // Dr["Shift"].ToString(); oDR["CardNo"] = Dr["CardNo"].ToString(); // We know it is Leave // We get what type of leave from ReferenceID if (Dr["ReferenceID"] != DBNull.Value) { Leave oLeave = oLeaves.Where(l => l.ID.Integer == Convert.ToInt32(Dr["ReferenceID"].ToString())).FirstOrDefault(); if (oLeave != null) oDR["Status"] = oLeave.Code; else oDR["Status"] = string.Empty; } else { oDR["Status"] = string.Empty; } dTable.Rows.Add(oDR); } DataSet dSet = new DataSet(); dTable.TableName = "AttendenceDataSet_DailyInOut"; dSet.Tables.Add(dTable); string RDLC = "Payroll.Report.Attendence.RDLC.DailyLeave.rdlc"; ReportParameter rParam; List _reportParameters = new List(); rParam = new ReportParameter("AttnDate", attnDate.ToString("dd MMM yyyy")); _reportParameters.Add(rParam); form.CommonReportViewer(_selectedParameter.ReportItem, RDLC, dSet, _reportParameters); } public void GetEmpAttenInfo() { fReportViewer form = new fReportViewer(); string sEmpID = _selectedParameter.ReportItem.INSQL; DataSet oEmpAttenInfo = null; DataRow oDR = null; oEmpAttenInfo = DailyAttnProcess.GetEmpAttenInfo(sEmpID); Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpAttenInfoDataTable dTable = new Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpAttenInfoDataTable(); //int serial = 1; foreach (DataRow Dr in oEmpAttenInfo.Tables[0].Rows) { oDR = dTable.NewRow(); //oDR["Serial"] = serial.ToString(); oDR["EmpNo"] = Dr["EMPLOYEENO"]; oDR["EmpName"] = Dr["Name"]; oDR["AccessCardID"] = Dr["CardNumber"]; oDR["Shift"] = Dr["ShortName"]; oDR["WorkPlanGroup"] = Dr["Name1"]; dTable.Rows.Add(oDR); //serial++; } DataSet dSet = new DataSet(); dTable.TableName = "AttendenceDataSet_EmpAttenInfo"; string RDLC = "Payroll.Report.Attendence.RDLC.EmpAttenInfo.rdlc"; dSet.Tables.Add(dTable); form.CommonReportViewer(_selectedParameter.ReportItem, RDLC, dSet); } public void GetMonthlyAttn() { fReportViewer form = new fReportViewer(); DateTime dFromDate = _selectedParameter.FromDate.Value; // DateTime dToDate = _selectedParameter.ToDate.Value; string sEmpID = _selectedParameter.ReportItem.INSQL; DataSet oMonthlyAttn = null; DataRow oDR = null; oMonthlyAttn = DailyAttnProcess.GetMonthlyAttn(GlobalFunctions.FirstDateOfMonth(dFromDate), GlobalFunctions.LastDateOfMonth(dFromDate), sEmpID); Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyAttnDataTable dTable = new Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyAttnDataTable(); foreach (DataRow Dr in oMonthlyAttn.Tables[0].Rows) { oDR = dTable.NewRow(); oDR["EmpNo"] = Dr["EMPLOYEENO"]; oDR["Name"] = Dr["NAME"]; oDR["CardNo"] = Dr["CardNo"].ToString(); oDR["Designation"] = Dr["Designation"]; oDR["Grade"] = Dr["Grade"]; oDR["JoinDate"] = Convert.ToDateTime(Dr["JOININGDATE"]).ToString("dd MMM yyyy"); oDR["GrossSalary"] = Convert.ToDouble(Dr["GROSSSALARY"]); oDR["Present"] = Dr["Present"] is DBNull ? 0 : Dr["Present"]; oDR["Late"] = Dr["Late"] is DBNull ? 0 : Dr["Late"]; oDR["Absent"] = Dr["Absent"] is DBNull ? 0 : Dr["Absent"]; oDR["Holiday"] = Dr["Holiday"] is DBNull ? 0 : Dr["Holiday"]; oDR["Leave"] = Dr["Leave"] is DBNull ? 0 : Dr["Leave"]; oDR["TotalAttn"] = Dr["TotalAttn"]; string TotalOT = Convert.ToDouble(Dr["TotalOT"]).ToString("00.00"); oDR["TotalOT"] = TotalOT.Replace('.', ':'); oDR["Remarks"] = ""; dTable.Rows.Add(oDR); } DataSet dSet = new DataSet(); dTable.TableName = "AttendenceDataSet_MonthlyAttn"; string RDLC = "Payroll.Report.Attendence.RDLC.MonthlyAttn.rdlc"; dSet.Tables.Add(dTable); List _parameters = new List(); 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); form.CommonReportViewer(_selectedParameter.ReportItem, RDLC, dSet, _parameters); } public void GetMonthlyDetail() { fReportViewer form = new fReportViewer(); DateTime dFromDate = _selectedParameter.FromDate.Value; //DateTime dToDate = _selectedParameter.ToDate.Value; string sEmpID = _selectedParameter.ReportItem.INSQL; DataSet oMonthlyDetail = null; DataRow oDR = null; oMonthlyDetail = DailyAttnProcess.GetMonthlyDetail(GlobalFunctions.FirstDateOfMonth(dFromDate), GlobalFunctions.LastDateOfMonth(dFromDate), sEmpID); Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyDetailDataTable dTable = new Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyDetailDataTable(); //int serial = 1; foreach (DataRow Dr in oMonthlyDetail.Tables[0].Rows) { oDR = dTable.NewRow(); //oDR["Serial"] = serial.ToString(); oDR["EmployeeNo"] = Dr["EMPLOYEENO"]; oDR["Name"] = Dr["Name"]; oDR["CardNo"] = Dr["CardNo"].ToString(); oDR["Designation"] = Dr["Designation"]; oDR["JoinDate"] = Convert.ToDateTime(Dr["JOININGDATE"]).ToString("dd MMM yyyy"); oDR["Gross"] = Convert.ToDouble(Dr["GROSSSALARY"]); oDR["AttnDate"] = Convert.ToDateTime(Dr["AttnDate"]).ToString("dd/MM/yy"); oDR["AttnType"] = GetShortAttnType((EnumAttendanceType)(Convert.ToInt32(Dr["AttnType"]))); dTable.Rows.Add(oDR); //serial++; } DataSet dSet = new DataSet(); dTable.TableName = "AttendenceDataSet_MonthlyDetail"; string RDLC = "Payroll.Report.Attendence.RDLC.MonthlyDetailAttn.rdlc"; dSet.Tables.Add(dTable); List _parameters = new List(); 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); form.CommonReportViewer(_selectedParameter.ReportItem, RDLC, dSet, _parameters); } public DataTable GetEmpDailyAttn(ID EmpID, DateTime dFromDate, DateTime dToDate) { ObjectsTemplate dAttnProcessess = new ObjectsTemplate(); dAttnProcessess = DailyAttnProcess.Get(EmpID, dFromDate, dToDate); Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable dTable = new Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpDailyAttnDataTable(); //PayrollDataSet.PayrollDataSet.LaonPaymentDueDataTable dTable = new Payroll.Report.PayrollDataSet.PayrollDataSet.LaonPaymentDueDataTable(); List oShifts = Shift.Get(); if (!(dAttnProcessess == null || dAttnProcessess.Count <= 0)) { foreach (DailyAttnProcess dAttnProcess in dAttnProcessess) { DataRow Rowbody = dTable.NewRow(); Rowbody["Date"] = dAttnProcess.AttnDate.ToString("dd MMM yyyy"); if (dAttnProcess.InTime == DateTime.MinValue) { Rowbody["InTime"] = "00:00"; } else { Rowbody["InTime"] = dAttnProcess.InTime.ToString("HH:mm"); } if (dAttnProcess.OutTime == DateTime.MinValue) { Rowbody["OutTime"] = "00:00"; } else { Rowbody["OutTime"] = dAttnProcess.OutTime.ToString("HH:mm"); } string LateBy = dAttnProcess.LateHour.ToString("f"); Rowbody["LateBy"] = LateBy.Replace('.', ':'); string OTHr = dAttnProcess.OTHour.ToString("f"); Rowbody["OTHr"] = OTHr.Replace('.', ':'); //if (dAttnProcess.AttenType == EnumAttendanceType.Leave) //{ // Rowbody["Status"] = GetLeaveType(dAttnProcess.ReferenceID); //} //else //{ // Rowbody["Status"] = GetShortAttnType(dAttnProcess.AttenType); //} Rowbody["Status"] = GetShortAttnType(dAttnProcess.AttenType); Rowbody["Remarks"] = dAttnProcess.Comments; Shift oSft = oShifts.Where(o => o.ID.Integer == dAttnProcess.ShiftID.Integer).FirstOrDefault(); if (oSft != null) { Rowbody["Shift"] = oSft.ShortName; } else { Rowbody["Shift"] = string.Empty; } dTable.Rows.Add(Rowbody); } } return dTable; } public void ShowEmpCardInfo(string EmpIDs) { fReportViewer form = new fReportViewer(); DataSet oCardInfo = null; DataRow oDR = null; List oEmployees = Employee.GetByEmpIDs(EmpIDs); bool isDesigFromEmp = ConfigurationManager.GetBoolValue("designation", "desigfromdescriptiontext", EnumConfigurationType.Logic); oCardInfo = DailyAttnProcess.GetEmpCardInfo(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(); 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"] = string.IsNullOrEmpty(Dr["EmpPhoto"].ToString()) ? Dr["EmpPhoto"].ToString() : GetEmployeePicture(Dr["EmpPhoto"].ToString()); } //DataSet dSet = new DataSet(); oCardInfo.Tables[0].TableName = "AttendenceDataSet_IDCard"; //dSet.Tables.Add(dTable); string RDLC = "Payroll.Report.RDLC.IDCard.rdlc"; Payroll.BO.SystemInformation _systemInfo = Payroll.BO.SystemInformation.Get(); ReportParameter rParam; List _reportParameters = new List(); string _PATH = Application.StartupPath + @"\Resource\IDCardBanner.png"; if (!File.Exists(_PATH)) { _PATH = Application.StartupPath + @"\Logo.jpg"; } rParam = new ReportParameter("EchoTextLogo", _PATH); _reportParameters.Add(rParam); rParam = new ReportParameter("CompanyInfo", _systemInfo.name); _reportParameters.Add(rParam); rParam = new ReportParameter("SignatureLogo", Application.StartupPath + @"\BhugiSign.jpg"); _reportParameters.Add(rParam); form.CommonReportViewer(null, RDLC, oCardInfo, _reportParameters,false); } public void ShowEmpCardInfoPerPage(string EmpIDs) { fReportViewer form = new fReportViewer(); DataSet oCardInfo = null; DataRow oDR = null; List oEmployees = Employee.GetByEmpIDs(EmpIDs); bool isDesigFromEmp = ConfigurationManager.GetBoolValue("designation", "desigfromdescriptiontext", EnumConfigurationType.Logic); oCardInfo = DailyAttnProcess.GetEmpCardInfoPerPage(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(); PhotoPath pPath = PhotoPath.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"] = string.IsNullOrEmpty(Dr["EmpPhoto"].ToString()) ? Dr["EmpPhoto"].ToString() : GetEmployeePicture(Dr["EmpPhoto"].ToString()); } //DataSet dSet = new DataSet(); oCardInfo.Tables[0].TableName = "AttendenceDataSet_IDCard"; //dSet.Tables.Add(dTable); string RDLC = "Payroll.Report.RDLC.IDCardPrint.rdlc"; Payroll.BO.SystemInformation _systemInfo = Payroll.BO.SystemInformation.Get(); ReportParameter rParam; List _reportParameters = new List(); string _PATH = Application.StartupPath + @"\Resource\IDCardBanner.png"; if (!File.Exists(_PATH)) { _PATH = Application.StartupPath + @"\Logo.jpg"; } rParam = new ReportParameter("EchoTextLogo", _PATH); _reportParameters.Add(rParam); rParam = new ReportParameter("CAddress", Ease.CoreV35.Utility.ConfigUtility.GetAppSettings("CAddress")); _reportParameters.Add(rParam); rParam = new ReportParameter("CPhone", Ease.CoreV35.Utility.ConfigUtility.GetAppSettings("CPhone")); _reportParameters.Add(rParam); rParam = new ReportParameter("Dhara", Ease.CoreV35.Utility.ConfigUtility.GetAppSettings("Dhara")); _reportParameters.Add(rParam); //rParam = new ReportParameter("SignatureLogo", Application.StartupPath + @"\BhugiSign.jpg"); //_reportParameters.Add(rParam); form.CommonReportViewer(null, RDLC, oCardInfo, _reportParameters, false); RemoveTempPicturePath(); } public void GetInOutMissing() { fReportViewer form = new fReportViewer(); DateTime attnFromDate, attnToDate; if (_selectedParameter.FromDate <= _selectedParameter.ToDate) { attnFromDate = _selectedParameter.FromDate.Value.Date; attnToDate = _selectedParameter.ToDate.Value.Date.AddDays(1).AddSeconds(-1); } else { attnFromDate = _selectedParameter.ToDate.Value.Date; attnToDate = _selectedParameter.FromDate.Value.Date.AddDays(1).AddSeconds(-1); } List shifts = Shift.Get(); string sEmpID = _selectedParameter.ReportItem.INSQL; DataSet oDailyInOut = null; DataRow oDR = null; oDailyInOut = DailyAttnProcess.GetDateRangeDataByStatus(attnFromDate, attnToDate, sEmpID, EnumAttendanceType.Present, EnumAttendanceType.Delay, EnumAttendanceType.Late); Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.InOutMissingDataTable dTable = new Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.InOutMissingDataTable(); DateTime Intime, ShiftInTime, ShiftOutTime; foreach (DataRow Dr in oDailyInOut.Tables[0].AsEnumerable().Where(x => x["OutTime"] is DBNull)) { oDR = dTable.NewRow(); if (Dr["InTime"] is DBNull) continue; oDR["EmployeeNo"] = Dr["EMPLOYEENO"]; oDR["Name"] = Dr["Name"]; oDR["Designation"] = Dr["Designation"]; oDR["EmpType"] = Dr["EmpType"].ToString(); oDR["Status"] = GetShortAttnType((EnumAttendanceType)(Convert.ToInt32(Dr["Status"]))); oDR["OTHour"] = Convert.ToDouble(Dr["OTHour"]).ToString("00.00"); 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"]); Intime = Convert.ToDateTime(Dr["InTime"]); oDR["InTime"] = Intime.ToString("HH:mm"); oDR["OutTime"] = string.Empty; oDR["MissingStatus"] = "Out Missing"; Shift shft = shifts.SingleOrDefault(x => x.ID.Integer == Convert.ToInt32(Dr["ShiftID"].ToString())); if (shft != null) { ShiftInTime = new DateTime(Intime.Year, Intime.Month, Intime.Day, shft.InTime.Hour, shft.InTime.Minute, shft.InTime.Second); ShiftOutTime = new DateTime(Intime.Year, Intime.Month, Intime.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 (ShiftInTime.AddHours(3) < Intime) { oDR["InTime"] = string.Empty; oDR["OutTime"] = Intime.ToString("HH:mm"); oDR["MissingStatus"] = "In Missing"; } } dTable.Rows.Add(oDR); } DataSet dSet = new DataSet(); dTable.TableName = "AttendenceDataSet_InOutMissing"; dSet.Tables.Add(dTable); string RDLC = "Payroll.Report.Attendence.RDLC.InOutMissing.rdlc"; ReportParameter rParam; List _reportParameters = new List(); rParam = new ReportParameter("AttnFromDate", attnFromDate.ToString("dd MMM yyyy")); _reportParameters.Add(rParam); rParam = new ReportParameter("AttnToDate", attnToDate.ToString("dd MMM yyyy")); _reportParameters.Add(rParam); form.CommonReportViewer(_selectedParameter.ReportItem, RDLC, dSet, _reportParameters); } #region Un-used Report public void GetDailyInOutAndAbsent() { fReportViewer form = new fReportViewer(); DateTime attnDate = _selectedParameter.FromDate.Value; string sEmpID = _selectedParameter.ReportItem.INSQL; DataSet oDailyInOutAndAbsent = null; DataRow oDR = null; oDailyInOutAndAbsent = DailyAttnProcess.GetDailyInOutAndAbsent(attnDate, sEmpID); Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.DailyInOutDataTable dTable = new Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.DailyInOutDataTable(); foreach (DataRow Dr in oDailyInOutAndAbsent.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"); string LateHour = Convert.ToDouble(Dr["LateHour"]).ToString("00.00"); oDR["LateBy"] = LateHour.Replace('.', ':'); //string OTHour = Convert.ToDouble(Dr["OTHour"]).ToString("00.00"); //oDR["OTHour"] = OTHour.Replace('.', ':'); oDR["Status"] = GetShortAttnType((EnumAttendanceType)(Convert.ToInt32(Dr["AttnType"]))); oDR["Remarks"] = Dr["Comments"]; oDR["ShiftName"] = Dr["ShortName"]; //oDR["DepartmentName"] = Dr["DepartmentName"]; //oDR["DepartmentID"] = Dr["DEPARTMENTID"]; if (!(oDR["InTime"].ToString() == "00:00" && oDR["Status"].ToString() == GetShortAttnType(EnumAttendanceType.WeeklyHoliday))) dTable.Rows.Add(oDR); } //form.ShowDlgForDailyInOutAndAbsent(_selectedParameter.ReportItem, dTable, attnDate); } public void GetMonthlyLongAbsent(int absentDays, DateTime FromDate) { fReportViewer form = new fReportViewer(); DateTime dFromDate = FromDate; //DateTime dToDate = _selectedParameter.ToDate.Value; //string sEmpID = _selectedParameter.ReportItem.INSQL; DataSet oMonthlyDetail = null; DataRow oDR = null; oMonthlyDetail = DailyAttnProcess.GetMonthlyLongAbsent(GlobalFunctions.FirstDateOfMonth(dFromDate), GlobalFunctions.LastDateOfMonth(dFromDate), absentDays); Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyDetailDataTable dTable = new Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.MonthlyDetailDataTable(); //int serial = 1; foreach (DataRow Dr in oMonthlyDetail.Tables[0].Rows) { oDR = dTable.NewRow(); //oDR["Serial"] = serial.ToString(); oDR["EmployeeNo"] = Dr["EMPLOYEENO"]; oDR["Name"] = Dr["Name"]; oDR["Designation"] = Dr["Designation"]; oDR["JoinDate"] = Convert.ToDateTime(Dr["JOININGDATE"]).ToString("dd MMM yyyy"); oDR["Gross"] = Convert.ToDouble(Dr["GROSSSALARY"]); oDR["AttnDate"] = Convert.ToDateTime(Dr["AttnDate"]).ToString("dd/MM/yy"); oDR["AttnType"] = GetShortAttnType((EnumAttendanceType)(Convert.ToInt32(Dr["AttnType"]))); dTable.Rows.Add(oDR); //serial++; } // form.ShowDlgForMonthlyLongAbsent(dTable, GlobalFunctions.FirstDateOfMonth(dFromDate), GlobalFunctions.LastDateOfMonth(dFromDate), absentDays); //return dTable; } public DataTable GetEmpInfo() { DataSet oEmpInfo = null; DataRow oDR = null; oEmpInfo = EmployeeWorkPlanSetup.GetEmpNotInWorkPlan(); Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpInfoDataTable dTable = new Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpInfoDataTable(); foreach (DataRow Dr in oEmpInfo.Tables[0].Rows) { oDR = dTable.NewRow(); //oDR["Serial"] = serial.ToString(); oDR["EmpNo"] = Dr["EMPLOYEENO"]; oDR["EmpName"] = Dr["Name"]; oDR["Grade"] = Dr["description"]; dTable.Rows.Add(oDR); //serial++; } return dTable; } public DataTable GetMissingMonthlyWPEmpsInfo(DateTime assignDate) { DataSet oEmpInfo = null; DataRow oDR = null; oEmpInfo = MonthlyWorkPlan.GetEmpNotInMonthlyWorkPlan(assignDate); Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpInfoDataTable dTable = new Payroll.Report.Attendence.AttendenceDataSet.AttendenceDataSet.EmpInfoDataTable(); foreach (DataRow Dr in oEmpInfo.Tables[0].Rows) { oDR = dTable.NewRow(); //oDR["Serial"] = serial.ToString(); oDR["EmpNo"] = Dr["EMPLOYEENO"]; oDR["EmpName"] = Dr["Name"]; oDR["Grade"] = Dr["description"]; dTable.Rows.Add(oDR); //serial++; } return dTable; } #endregion #endregion } }