private void Btn_ExportExcel_Click(object sender, EventArgs e) { System.Windows.Forms.SaveFileDialog saveFileDialog = new SaveFileDialog(); string pathsave = ""; saveFileDialog.Title = "Browse Excel Files"; saveFileDialog.DefaultExt = "Excel"; saveFileDialog.Filter = "Excel files (*.xlsx)|*.xlsx"; saveFileDialog.CheckPathExists = true; if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { GetAttendanceHR getAttendance = new GetAttendanceHR(); List <AttendanceDept> attendanceDepts = getAttendance.GetAttendanceDeptsNew(dtpk_choose.Value); HRReport hRReport = new HRReport(); pathsave = saveFileDialog.FileName; saveFileDialog.RestoreDirectory = true; hRReport.ExportExcelHRAttendaceReport(pathsave, attendanceDepts, dtpk_choose.Value); var resultMessage = MessageBox.Show("Attendance Daily Report export to excel sucessful ! \n\r Do you want to open this file ?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (resultMessage == DialogResult.Yes) { FileInfo fi = new FileInfo(pathsave); if (fi.Exists) { System.Diagnostics.Process.Start(pathsave); } else { MessageBox.Show("File doestn't exist !", "warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }
private void Btn_absenceList_Click(object sender, EventArgs e) { System.Windows.Input.Cursor oldCursor = Mouse.OverrideCursor; try { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; //pic_loader.Visible = true; //pic_loader.Image = global::WindowsFormsApplication1.Properties.Resources.loader; System.Windows.Forms.SaveFileDialog saveFileDialog = new SaveFileDialog(); string pathsave = ""; saveFileDialog.Title = "Browse Excel Files"; saveFileDialog.DefaultExt = "Excel"; saveFileDialog.Filter = "Excel files (*.xlsx)|*.xlsx"; saveFileDialog.CheckPathExists = true; if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { GetdataInout getdataInout = new GetdataInout(); List <EmployeeAbsence> employeeAbsences = new List <EmployeeAbsence>(); int IDSession = GetSessionID.GetsessionID(dtpk_choose.Value); List <EmployeeAbsence> employeeAbsencesDay = getdataInout.GetEmployeeAbsencesDayShift(dtpk_choose.Value, IDSession); List <EmployeeAbsence> employeeAbsencesDayNotPaiPan = getdataInout.GetEmployeeAbsencesDayShiftNotPaipan(dtpk_choose.Value, IDSession); List <EmployeeAbsence> employeeAbsencesNightShift = getdataInout.GetEmployeeAbsencesNightShift(dtpk_choose.Value, IDSession); employeeAbsences.AddRange(employeeAbsencesDay); employeeAbsences.AddRange(employeeAbsencesDayNotPaiPan); employeeAbsences.AddRange(employeeAbsencesNightShift); HRReport hRReport = new HRReport(); pathsave = saveFileDialog.FileName; saveFileDialog.RestoreDirectory = true; hRReport.ExportExcelAbsenceReport(pathsave, employeeAbsences, dtpk_choose.Value); var resultMessage = MessageBox.Show("Absence Daily Report export to excel sucessful ! \n\r Do you want to open this file ?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (resultMessage == DialogResult.Yes) { FileInfo fi = new FileInfo(pathsave); if (fi.Exists) { System.Diagnostics.Process.Start(pathsave); } else { MessageBox.Show("File doestn't exist !", "warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } // WindowAbsenceList windowAbsenceList = new WindowAbsenceList(employeeAbsences); //windowAbsenceList.Show(); } catch (Exception) { throw; } finally { Mouse.OverrideCursor = oldCursor; } }