using Payroll.BO; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Payroll.Report { public partial class frmRCAssignedReport : Form { private enum RCAssignEnum { RCAssigned, RCNotAssigned } public frmRCAssignedReport() { InitializeComponent(); } private void frmRCAssignedReport_Load(object sender, EventArgs e) { List oEnums = Enum.GetValues(typeof(RCAssignEnum)).Cast().ToList(); List oLVItems = new List(); foreach (RCAssignEnum ENM in oEnums) { ListViewItem oItem = new ListViewItem(ENM.ToString()); oItem.Tag = ENM; oLVItems.Add(oItem); } lvwRCReport.Items.AddRange(oLVItems.ToArray()); } private void btnPreview_Click(object sender, EventArgs e) { if (lvwRCReport.SelectedItems.Count > 0) { rptEmployee oEmpReports = new rptEmployee(); switch ((RCAssignEnum)lvwRCReport.SelectedItems.Cast().ToList()[0].Tag) { case RCAssignEnum.RCAssigned: oEmpReports.ShowEmpRCAssigned(); break; case RCAssignEnum.RCNotAssigned: oEmpReports.ShowEmpRCNotAssigned(); break; default: break; } } else { MessageBox.Show("Select an item.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } private void btnExport_Click(object sender, EventArgs e) { SaveFileDialog savefile = new SaveFileDialog(); // set a default file name savefile.FileName = "Employee RC Information"; // set filters - this can be done in properties as well savefile.Filter = "Excel files (*.xlsx)|*.xlsx"; if ((RCAssignEnum)lvwRCReport.SelectedItems.Count == 0) { MessageBox.Show("Select an item.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { switch ((RCAssignEnum)lvwRCReport.SelectedItems.Cast().ToList()[0].Tag) { case RCAssignEnum.RCAssigned: savefile.FileName = "RC Assigned Employee's Information"; break; case RCAssignEnum.RCNotAssigned: savefile.FileName = "RC Not Assigned Employee's Information"; break; default: break; } if (savefile.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; switch ((RCAssignEnum)lvwRCReport.SelectedItems.Cast().ToList()[0].Tag) { case RCAssignEnum.RCAssigned: GlobalFunctions.ExportToExcel(new rptEmployee().ExportEmpRCAssignedInfo(), savefile.FileName, "RC Assigned"); break; case RCAssignEnum.RCNotAssigned: GlobalFunctions.ExportToExcel(new rptEmployee().ExportEmpRCNotAssignedInfo(), savefile.FileName, "RC Not Assigned"); break; default: break; } Cursor.Current = Cursors.Default; MessageBox.Show("File saved successfully at " + savefile.FileName, "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } private void btnClose_Click(object sender, EventArgs e) { this.Close(); } } }