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 frmChangedReport : Form { public frmChangedReport() { InitializeComponent(); } DateTime toDate, fromDate; string value = ""; rptEmployee rpt = new rptEmployee(); private void frmChangedReport_Load(object sender, EventArgs e) { rbtnBasicSalary.Checked = true; } private void btnPreview_Click(object sender, EventArgs e) { toDate = dtpToDate.Value; fromDate = dtpFromDate.Value; bool isChecked = rbtnBasicSalary.Checked; if(isChecked ) value=rbtnBasicSalary.Text; else value=rbtnBankAccount.Text; rpt.ChangedReport(fromDate, toDate,value); } private void btnExcelExport_Click(object sender, EventArgs e) { toDate = dtpToDate.Value; fromDate = dtpFromDate.Value; bool isChecked = rbtnBasicSalary.Checked; if (isChecked) value = rbtnBasicSalary.Text; else value = rbtnBankAccount.Text; try { SaveFileDialog savefile = new SaveFileDialog(); savefile.Filter = "Excel files (*.xlsx)|*.xlsx"; savefile.FileName =value+" Changed Report"; if (savefile.ShowDialog() == DialogResult.OK) { GlobalFunctions.ExportToExcel(rpt.ChangedReportExcel(fromDate, toDate, value).Tables[0], savefile.FileName, value+" Changed Report"); } Cursor.Current = Cursors.Default; MessageBox.Show("Excel created at " + savefile.FileName); } catch ( Exception ex) { throw new Exception(ex.Message); } } } }