20251202-1870 Issue with Payslip Mail Exception Fixed

This commit is contained in:
Shahadat Hossain 2025-12-03 12:15:03 +06:00
parent 367b1ae98e
commit d25b979d2f
4 changed files with 60 additions and 23 deletions

View File

@ -7,7 +7,8 @@
<section name="InformationForReportTool" type="Ease.SearchTools.Objects.InformationForReportToolConfigHandler, Ease.SearchTools.Objects"/> <section name="InformationForReportTool" type="Ease.SearchTools.Objects.InformationForReportToolConfigHandler, Ease.SearchTools.Objects"/>
</configSections> </configSections>
<dbSettings> <dbSettings>
<connection name="conn" provider="sql" connectionString="server=103.197.204.164,1718;Database=CELPayrol;User ID=DBuser;Password=E@se2@24" sqlSyntax="SQL"/> <connection name="conn" provider="sql" connectionString="server=cel80;Database=CELPayroll;User ID=CELPayroll;password=4B06094270245E4D5B63" sqlSyntax="SQL"/>
<!--<connection name="conn" provider="sql" connectionString="server=103.197.204.164,1718;Database=CELPayrol;User ID=DBuser;Password=E@se2@24" sqlSyntax="SQL"/>-->
<!--<connection name="conn" provider="sql" connectionString="server=WIN-D48IJC70V70;Database=GPPayroll;integrated security=yes;" sqlSyntax="SQL"/>--> <!--<connection name="conn" provider="sql" connectionString="server=WIN-D48IJC70V70;Database=GPPayroll;integrated security=yes;" sqlSyntax="SQL"/>-->
</dbSettings> </dbSettings>
@ -20,13 +21,13 @@
<add key="GratuityParam" value="Grade"/> <add key="GratuityParam" value="Grade"/>
<!--<add key="FSSLeaveOnlyBasic" value="no"/>--> <!--<add key="FSSLeaveOnlyBasic" value="no"/>-->
<add key="EERS" value="123456"/> <add key="EERS" value="123456"/>
<add key="WebAddress" value="http://www.celimited.com"/> <add key="WebAddress" value="http://www.celimited.com"/>
<add key="mailGateway" value="SMTP" /> <add key="mailGateway" value="SMTP" />
<add key="SendMethod" value="SMTP" /> <add key="SendMethod" value="SMTP" />
<add key="EmailServer" value="mail.celimited.com" /> <add key="EmailServer" value="mail.celimited.com" />
<add key="FromAddress" value="fkanak@celimited.com" /> <add key="FromAddress" value="fkanak@celimited.com" />
<add key="UserID" value="fkanak@celimited.com" /> <add key="UserID" value="fkanak@celimited.com" />
<add key="Password" value="4823074F2F0506582E704159" /> <add key="Password" value="4823074F2F0506582E704159" />
<add key="EnableSSL" value="No" /> <add key="EnableSSL" value="No" />
<add key="PortNumber" value="25" /> <add key="PortNumber" value="25" />
<add key="handleAuditTrail" value="No"/> <add key="handleAuditTrail" value="No"/>

View File

@ -3504,6 +3504,7 @@
<Content Include="Resource\GStat.png" /> <Content Include="Resource\GStat.png" />
<Content Include="Resource\HeadBack.jpg" /> <Content Include="Resource\HeadBack.jpg" />
<Content Include="Resource\Help_48x48.png" /> <Content Include="Resource\Help_48x48.png" />
<Content Include="Resource\home_pano.jpg" />
<Content Include="Resource\Huge.gif" /> <Content Include="Resource\Huge.gif" />
<Content Include="Resource\Huge.ico" /> <Content Include="Resource\Huge.ico" />
<Content Include="Resource\icon_people.jpg" /> <Content Include="Resource\icon_people.jpg" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -11,6 +11,7 @@ using Payroll.BO;
using Payroll.Controls; using Payroll.Controls;
using Payroll.Controls.CustomControls; using Payroll.Controls.CustomControls;
using Payroll.Report; using Payroll.Report;
using System.Net.Mail;
namespace Payroll.UI namespace Payroll.UI
{ {
@ -385,7 +386,7 @@ namespace Payroll.UI
return MS.SendMail(); return MS.SendMail();
} }
#endregion #endregion
#region Events #region Events
@ -483,40 +484,74 @@ namespace Payroll.UI
lblSelected.Text = "0"; 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) private void btnSendMail_Click(object sender, EventArgs e)
{ {
DirectoryInfo dirInfo = null; DirectoryInfo dirInfo = null;
string reportPath = Application.StartupPath + @"\Report";
try try
{ {
dirInfo = new DirectoryInfo(Application.StartupPath + @"\Report"); dirInfo = new DirectoryInfo(reportPath);
if (!Directory.Exists(Application.StartupPath + @"\Report"))
if (!dirInfo.Exists)
{ {
dirInfo.Create(); dirInfo.Create();
} }
else // For Fail Safe Check. Do not remove this 'else' block else
{ {
// Clean contents, not directory
dirInfo.Delete(true); foreach (FileInfo file in dirInfo.GetFiles()) file.Delete();
dirInfo.Create(); foreach (DirectoryInfo subDir in dirInfo.GetDirectories()) subDir.Delete(true);
} }
if (Validation()) 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) catch (Exception exp)
{ {
throw new Exception(exp.Message); MessageBox.Show(exp.Message);
} }
finally
{
if (dirInfo != null)
dirInfo.Delete(true);
}
} }
#endregion #endregion
} }