diff --git a/Payroll.UI/Payroll.UI/App.config b/Payroll.UI/Payroll.UI/App.config index 1a7e864..3c94861 100644 --- a/Payroll.UI/Payroll.UI/App.config +++ b/Payroll.UI/Payroll.UI/App.config @@ -7,7 +7,8 @@
- + + @@ -20,13 +21,13 @@ - - - - - - - + + + + + + + diff --git a/Payroll.UI/Payroll.UI/Payroll.UI.csproj b/Payroll.UI/Payroll.UI/Payroll.UI.csproj index e873de2..21cceae 100644 --- a/Payroll.UI/Payroll.UI/Payroll.UI.csproj +++ b/Payroll.UI/Payroll.UI/Payroll.UI.csproj @@ -3504,6 +3504,7 @@ + diff --git a/Payroll.UI/Payroll.UI/Resource/home_pano.jpg b/Payroll.UI/Payroll.UI/Resource/home_pano.jpg new file mode 100644 index 0000000..8e025f1 Binary files /dev/null and b/Payroll.UI/Payroll.UI/Resource/home_pano.jpg differ diff --git a/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.cs b/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.cs index acf1369..05ded4c 100644 --- a/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.cs +++ b/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.cs @@ -11,6 +11,7 @@ using Payroll.BO; using Payroll.Controls; using Payroll.Controls.CustomControls; using Payroll.Report; +using System.Net.Mail; namespace Payroll.UI { @@ -385,7 +386,7 @@ namespace Payroll.UI return MS.SendMail(); } - + #endregion #region Events @@ -483,40 +484,74 @@ namespace Payroll.UI lblSelected.Text = "0"; } + //private void btnSendMail_Click(object sender, EventArgs e) + //{ + // DirectoryInfo dirInfo = null; + // try + // { + // dirInfo = new DirectoryInfo(Application.StartupPath + @"\Report"); + // if (!Directory.Exists(Application.StartupPath + @"\Report")) + // { + // dirInfo.Create(); + // } + // else // For Fail Safe Check. Do not remove this 'else' block + // { + + // dirInfo.Delete(true); + // dirInfo.Create(); + // } + + // if (Validation()) + // { + // PrepareReport(); + // } + // } + // catch (Exception exp) + // { + // throw new Exception(exp.Message); + // } + // finally + // { + // if (dirInfo != null) + // dirInfo.Delete(true); + // } + + //} private void btnSendMail_Click(object sender, EventArgs e) { DirectoryInfo dirInfo = null; + string reportPath = Application.StartupPath + @"\Report"; + try { - dirInfo = new DirectoryInfo(Application.StartupPath + @"\Report"); - if (!Directory.Exists(Application.StartupPath + @"\Report")) + dirInfo = new DirectoryInfo(reportPath); + + if (!dirInfo.Exists) { dirInfo.Create(); } - else // For Fail Safe Check. Do not remove this 'else' block + else { - - dirInfo.Delete(true); - dirInfo.Create(); + // Clean contents, not directory + foreach (FileInfo file in dirInfo.GetFiles()) file.Delete(); + foreach (DirectoryInfo subDir in dirInfo.GetDirectories()) subDir.Delete(true); } if (Validation()) { - PrepareReport(); + PrepareReport(); // <-- Generate PDF and Send Mail } + + // IMPORTANT: Delete only after everything is closed + foreach (FileInfo file in dirInfo.GetFiles()) file.Delete(); } catch (Exception exp) { - throw new Exception(exp.Message); + MessageBox.Show(exp.Message); } - finally - { - if (dirInfo != null) - dirInfo.Delete(true); - } - } + #endregion }