CEL_Payroll/Payroll.Report/Attendence/UI/fEmpDailyAttnReport.cs
2024-09-17 14:30:13 +06:00

242 lines
9.1 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
using Ease.CoreV35.Model;
using Payroll.BO;
using Payroll.Report;
namespace Payroll.Report
{
public partial class fEmpDailyAttnReport : Form
{
#region Declaration and constructor
ReportParameter _parameter = null;
public fEmpDailyAttnReport()
{
InitializeComponent();
}
private void fEmpDailyAttnReport_Load(object sender, EventArgs e)
{
btnDailyAbsent.Visible = false;
btnDailyInOut.Visible = false;
btnEmpAttenInfo.Visible = false;
btnMonthlyAttnReport.Visible = false;
btnMonthlyDetail.Visible = false;
}
#endregion
#region Private function
private List<ReportParameter> GetReportParameters(ID empID, DateTime fromDate, DateTime toDate, string totalOT, string totalLateHour)
{
Employee employee = new Employee();
employee = Employee.Get(empID);
List<ReportParameter> parameters = new List<ReportParameter>();
_parameter = new ReportParameter("FromDate", fromDate.ToString("dd MMM yyyy"));
parameters.Add(_parameter);
_parameter = new ReportParameter("ToDate", toDate.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", employee.Designation.Name);
parameters.Add(_parameter);
_parameter = new ReportParameter("EmpJoinDate", employee.JoiningDate.ToString("dd MMM yyyy"));
parameters.Add(_parameter);
_parameter = new ReportParameter("EmpDepartment", employee.Department.Name);
parameters.Add(_parameter);
_parameter = new ReportParameter("EmpSection", "");
parameters.Add(_parameter);
_parameter = new ReportParameter("TotalOT", totalOT);
parameters.Add(_parameter);
_parameter = new ReportParameter("TotalLateHour", totalLateHour);
parameters.Add(_parameter);
return parameters;
}
#endregion
#region Events
// Working Attendence Report :
private void btnMonthlyAttnReport_Click(object sender, EventArgs e)
{
DataSet dSet = new DataSet();
String RDLC = string.Empty;
DataTable oDataTable = null;
AttendanceReport attnReport = new AttendanceReport();
// oDataTable = attnReport.GetMonthlyAttn(dtpFromDate.Value, dtpToDate.Value);
oDataTable.TableName = "AttendenceDataSet_MonthlyAttn";
RDLC = "Payroll.Report.Attendence.RDLC.MonthlyAttn.rdlc";
dSet.Tables.Add(oDataTable);
List<ReportParameter> parameters = new List<ReportParameter>();
_parameter = new ReportParameter("FromDate", dtpFromDate.Value.ToString("dd MMM yyyy"));
parameters.Add(_parameter);
_parameter = new ReportParameter("ToDate", dtpToDate.Value.ToString("dd MMM yyyy"));
parameters.Add(_parameter);
fReportViewer form = new fReportViewer();
form.CommonReportViewer(null, RDLC, dSet, parameters);
}
private void btnPreview_Click(object sender, EventArgs e)
{
if (ctlEmployee.SelectedEmployee == null)
{
MessageBox.Show("Please Select an Employee", "Select Employee", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
DataSet dSet = new DataSet();
String RDLC = string.Empty;
DataTable oDataTable = null;
AttendanceReport attnReport = new AttendanceReport();
oDataTable = attnReport.GetEmpDailyAttn(ctlEmployee.SelectedEmployee.EmployeeID, dtpFromDate.Value, dtpToDate.Value);
List<String> oTHours = new List<String>();
List<String> latehours = new List<String>();
foreach (DataRow dr in oDataTable.Rows)
{
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);
List<ReportParameter> parameters = new List<ReportParameter>();
parameters = GetReportParameters(ctlEmployee.SelectedEmployee.EmployeeID, dtpFromDate.Value, dtpToDate.Value, totalOT, totalLateHour);
oDataTable.TableName = "AttendenceDataSet_EmpDailyAttn";
RDLC = "Payroll.Report.Attendence.RDLC.EmpDailyAttn.rdlc";
dSet.Tables.Add(oDataTable);
fReportViewer form = new fReportViewer();
form.CommonReportViewer(null, RDLC, dSet, parameters);
}
private void btnDailyInOut_Click(object sender, EventArgs e)
{
DataSet dSet = new DataSet();
String RDLC = string.Empty;
DataTable oDataTable = null;
AttendanceReport attnReport = new AttendanceReport();
//oDataTable = attnReport.GetDailyInOut(dtpFromDate.Value);
oDataTable.TableName = "AttendenceDataSet_DailyInOut";
RDLC = "Payroll.Report.Attendence.RDLC.DailyInOut.rdlc";
dSet.Tables.Add(oDataTable);
List<ReportParameter> parameters = new List<ReportParameter>();
_parameter = new ReportParameter("AttnDate", dtpFromDate.Value.ToString("dd MMM yyyy"));
parameters.Add(_parameter);
fReportViewer form = new fReportViewer();
form.CommonReportViewer(null, RDLC, dSet, parameters);
}
private void btnDailyAbsent_Click(object sender, EventArgs e)
{
DataSet dSet = new DataSet();
String RDLC = string.Empty;
DataTable oDataTable = null;
AttendanceReport attnReport = new AttendanceReport();
// oDataTable = attnReport.GetDailyAbsent(dtpFromDate.Value);
oDataTable.TableName = "AttendenceDataSet_DailyAbsent";
RDLC = "Payroll.Report.Attendence.RDLC.DailyAbsent.rdlc";
dSet.Tables.Add(oDataTable);
List<ReportParameter> parameters = new List<ReportParameter>();
_parameter = new ReportParameter("AttnDate", dtpFromDate.Value.ToString("dd MMM yyyy"));
parameters.Add(_parameter);
fReportViewer form = new fReportViewer();
form.CommonReportViewer(null, RDLC, dSet, parameters);
}
private void btnMonthlyDetail_Click(object sender, EventArgs e)
{
DataSet dSet = new DataSet();
String RDLC = string.Empty;
DataTable oDataTable = null;
AttendanceReport attnReport = new AttendanceReport();
//oDataTable = attnReport.GetMonthlyDetail(dtpFromDate.Value, dtpToDate.Value);
oDataTable.TableName = "AttendenceDataSet_MonthlyDetail";
RDLC = "Payroll.Report.Attendence.RDLC.MontjlyDetail.rdlc";
dSet.Tables.Add(oDataTable);
List<ReportParameter> parameters = new List<ReportParameter>();
_parameter = new ReportParameter("Fromdate", dtpFromDate.Value.ToString("dd MMM yyyy"));
parameters.Add(_parameter);
_parameter = new ReportParameter("ToDate", dtpToDate.Value.ToString("dd MMM yyyy"));
parameters.Add(_parameter);
fReportViewer form = new fReportViewer();
form.CommonReportViewer(null, RDLC, dSet, parameters);
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnEmpAttenInfo_Click(object sender, EventArgs e)
{
DataSet dSet = new DataSet();
String RDLC = string.Empty;
DataTable oDataTable = null;
AttendanceReport attnReport = new AttendanceReport();
//oDataTable = attnReport.GetEmpAttenInfo();
oDataTable.TableName = "AttendenceDataSet_EmpAttenInfo";
RDLC = "Payroll.Report.Attendence.RDLC.EmpAttenInfo.rdlc";
dSet.Tables.Add(oDataTable);
//List<ReportParameter> parameters = new List<ReportParameter>();
//_parameter = new ReportParameter("Fromdate", dtpFromDate.Value.ToString("dd MMM yyyy"));
//parameters.Add(_parameter);
//_parameter = new ReportParameter("ToDate", dtpToDate.Value.ToString("dd MMM yyyy"));
//parameters.Add(_parameter);
fReportViewer form = new fReportViewer();
form.CommonReportViewer(null, RDLC, dSet);
}
#endregion
}
}