diff --git a/Library/BouncyCastle.Crypto.dll b/Library/BouncyCastle.Crypto.dll
index 8531f7f..9059e64 100644
Binary files a/Library/BouncyCastle.Crypto.dll and b/Library/BouncyCastle.Crypto.dll differ
diff --git a/Library/itextsharp.dll b/Library/itextsharp.dll
new file mode 100644
index 0000000..d9f1d58
Binary files /dev/null and b/Library/itextsharp.dll differ
diff --git a/Payroll.BO/Global/GlobalFunctions.cs b/Payroll.BO/Global/GlobalFunctions.cs
index b3a910a..4ae42c8 100644
--- a/Payroll.BO/Global/GlobalFunctions.cs
+++ b/Payroll.BO/Global/GlobalFunctions.cs
@@ -12,7 +12,7 @@ using ClosedXML.Excel;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Collections;
-using DocumentFormat.OpenXml.Spreadsheet;
+//using DocumentFormat.OpenXml.Spreadsheet;
namespace Payroll.BO
{
diff --git a/Payroll.BO/Payroll.BO.csproj b/Payroll.BO/Payroll.BO.csproj
index 800f73e..07b52ca 100644
--- a/Payroll.BO/Payroll.BO.csproj
+++ b/Payroll.BO/Payroll.BO.csproj
@@ -49,7 +49,8 @@
false
-
+
+ False
..\Library\BouncyCastle.Crypto.dll
diff --git a/Payroll.BO/SAPLookUp/SAPInterface.cs b/Payroll.BO/SAPLookUp/SAPInterface.cs
index 9392c34..d770675 100644
--- a/Payroll.BO/SAPLookUp/SAPInterface.cs
+++ b/Payroll.BO/SAPLookUp/SAPInterface.cs
@@ -3067,7 +3067,11 @@ namespace Payroll.BO
enc = (PgpEncryptedDataList)pgpObjF.NextPgpObject();
}
- var akp = new Org.BouncyCastle.Crypto.AsymmetricKeyParameter(true);
+ // Replace the following line:
+ // var akp = new Org.BouncyCastle.Crypto.AsymmetricKeyParameter(true);
+
+ // With the following corrected code:
+ Org.BouncyCastle.Crypto.AsymmetricKeyParameter akp = new Org.BouncyCastle.Crypto.Parameters.RsaKeyParameters(true, null, null);
diff --git a/Payroll.Report/Class/PaySlip.cs b/Payroll.Report/Class/PaySlip.cs
index 794fe62..1a669b5 100644
--- a/Payroll.Report/Class/PaySlip.cs
+++ b/Payroll.Report/Class/PaySlip.cs
@@ -3395,6 +3395,286 @@ namespace Payroll.Report
}
form.ShowDlgForPaySlipOverAllSummary(_selectedParameter.ReportItem, PayslipData);
}
+
+ public byte[] MailReportWithAccountNoMask(DateTime salaryMonth2, string sEmpID2)
+ {
+ DataSet dataSet = null;
+ DataSet dataSet2 = new DataSet();
+ _oGratuityParams = ESBDefinition.Get();
+ Employee employee = null;
+ ObjectsTemplate val = new ObjectsTemplate();
+ val = Employee.Get();
+ List source = (List)(object)Designation.Get(EnumStatus.Regardless);
+ DataRow dataRow = null;
+ fReportViewer fReportViewer2 = new fReportViewer();
+ DateTime dateTime = salaryMonth2;
+ ObjectsTemplate val2 = new ObjectsTemplate();
+ val2 = SalaryProcess.Get(GlobalFunctions.LastDateOfMonth(dateTime));
+ dataSet = Employee.GetEmpBasicInfoForPSlipNew(sEmpID2, GlobalFunctions.LastDateOfMonth(dateTime));
+ if (dataSet != null && dataSet.Tables.Count > 0)
+ {
+ DataTable dataTable = dataSet.Tables[0];
+ foreach (DataRow row2 in dataTable.Rows)
+ {
+ string text = row2["AccountNo"].ToString().Trim();
+ if (text.Length >= 6)
+ {
+ string text2 = text.Substring(0, 3);
+ string text3 = text.Substring(text.Length - 3);
+ row2["AccountNo"] = text2 + "******" + text3;
+ }
+ else
+ {
+ row2["AccountNo"] = text;
+ }
+ }
+ }
+
+ //PayrollDataSet.PayrollDataSet.PayslipDataTable PayslipData = new Payroll.Report.PayrollDataSet.PayrollDataSet.PayslipDataTable();
+ //PayrollDataSet.PayrollDataSet.LoanDataDataTable loanDT = new Payroll.Report.PayrollDataSet.PayrollDataSet.LoanDataDataTable();
+ ////bool IsApproved = oSaProcess.GetBySMonth(GlobalFunctions.LastDateOfMonth(salaryMonth));
+ //DataTable basicInfo = new PayrollDataSet.PayrollDataSet.PayslipBasicInfoDataTable();
+
+ DataSet empPaySlipGrossForOthers = SalaryMonthly.GetEmpPaySlipGrossForOthers(GlobalFunctions.LastDateOfMonth(dateTime), sEmpID2);
+ DataSet empPaySlipDeductForOthers = SalaryMonthly.GetEmpPaySlipDeductForOthers(GlobalFunctions.LastDateOfMonth(dateTime), sEmpID2);
+ PayrollDataSet.PayrollDataSet.PayslipDataTable payslipDataTable = new PayrollDataSet.PayrollDataSet.PayslipDataTable();
+ PayrollDataSet.PayrollDataSet.LoanDataDataTable loanDataDataTable = new PayrollDataSet.PayrollDataSet.LoanDataDataTable();
+ DataTable dataTable2 = new PayrollDataSet.PayrollDataSet.PayslipBasicInfoDataTable();
+ _dSalaryMonth = GlobalFunctions.LastDateOfMonth(dateTime);
+ if (val2 != null && ((List)(object)val2).Count > 0 && empPaySlipGrossForOthers.Tables[0].Rows.Count > 0)
+ {
+ if (((List)(object)val2)[0].PaymentDate != DateTime.MinValue)
+ {
+ _dMonthEndDate = Convert.ToDateTime(((List)(object)val2)[0].PaymentDate);
+ }
+ else
+ {
+ _dMonthEndDate = DateTime.MinValue;
+ }
+ }
+ foreach (DataRow row3 in empPaySlipGrossForOthers.Tables[0].Rows)
+ {
+ double num = Convert.ToDouble(row3["CHANGEDAMOUNT"].ToString());
+ if (num == 0.0)
+ {
+ continue;
+ }
+ dataRow = ((Convert.ToInt32(row3["ItemCode"]) != -103) ? GetItem(payslipDataTable, Convert.ToString(row3["EMPLOYEENO"]), (EnumSalaryGroup)Convert.ToInt32(row3["ITEMGROUP"]), (EnumSalaryItemCode)Convert.ToInt32(row3["ItemCode"]), Convert.ToInt32(row3["ItemID"])) : GetItem2(payslipDataTable, Convert.ToString(row3["EMPLOYEENO"]), (EnumSalaryGroup)Convert.ToInt32(row3["ITEMGROUP"]), (EnumSalaryItemCode)Convert.ToInt32(row3["ItemCode"]), Convert.ToInt32(row3["ItemID"]), row3["Description"].ToString().Trim()));
+ if (dataRow == null)
+ {
+ dataRow = payslipDataTable.NewRow();
+ dataRow = GrossMerge(dataRow, row3);
+ payslipDataTable.Rows.Add(dataRow);
+ }
+ if (Convert.ToInt32(row3["ItemCode"]) == -103)
+ {
+ DataRow item = GetItem2(empPaySlipGrossForOthers.Tables[1], Convert.ToString(row3["EMPLOYEENO"]), EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Over_Time_Hours, Convert.ToInt32(row3["ItemID"]), row3["Description"].ToString().Replace(" hour", "").Trim());
+ if (item != null && dataRow["Description"].ToString().IndexOf('[') < 0)
+ {
+ DataRow dataRow4 = dataRow;
+ dataRow4["Description"] = dataRow4["Description"]?.ToString() + " [" + Convert.ToDouble(item["CHANGEDAMOUNT"]).ToString("#") + " Hours]";
+ }
+ }
+ if (Convert.ToInt32(row3["ITEMGROUP"]) == 1)
+ {
+ if (dataRow["Earning"].ToString() != "" && Convert.ToInt32(row3["ItemCode"]) != -103)
+ {
+ dataRow["Earning"] = Convert.ToDouble(dataRow["Earning"]) + Convert.ToDouble(row3["CHANGEDAMOUNT"]);
+ }
+ else
+ {
+ dataRow["Earning"] = row3["CHANGEDAMOUNT"];
+ }
+ }
+ if (Convert.ToInt32(row3["ITEMGROUP"]) == 3 && Convert.ToInt32(row3["ITEMID"]) == -128)
+ {
+ if (dataRow["Earning"].ToString() != "")
+ {
+ dataRow["Earning"] = Convert.ToDouble(dataRow["Earning"]) + Convert.ToDouble(row3["CHANGEDAMOUNT"]);
+ dataRow["Description"] = "Company PF Contribution";
+ }
+ else
+ {
+ dataRow["Earning"] = Convert.ToDouble(row3["CHANGEDAMOUNT"]);
+ dataRow["Description"] = "Company PF Contribution";
+ }
+ }
+ else if (Convert.ToInt32(row3["ITEMGROUP"]) == 8)
+ {
+ double num2 = Convert.ToDouble(row3["CHANGEDAMOUNT"].ToString());
+ dataRow["Arrear"] = num2;
+ }
+ else if (Convert.ToInt32(row3["ITEMGROUP"]) == 2)
+ {
+ dataRow["unAuthLeave"] = row3["CHANGEDAMOUNT"];
+ }
+ }
+ int num3 = 0;
+ string text4 = "";
+ DataRow[] array = null;
+ if (empPaySlipDeductForOthers.Tables[0].Rows.Count > 0)
+ {
+ text4 = empPaySlipDeductForOthers.Tables[0].Rows[0]["EMPLOYEENO"].ToString();
+ array = payslipDataTable.Select(" EmployeeNo='" + empPaySlipDeductForOthers.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'");
+ }
+ double num4 = 0.0;
+ double num5 = 0.0;
+ string text5 = "";
+ double num6 = 0.0;
+ foreach (DataRow odRow in empPaySlipDeductForOthers.Tables[0].Rows)
+ {
+ double num7 = Convert.ToDouble(odRow["CHANGEDAMOUNT"].ToString());
+ if (num7 == 0.0)
+ {
+ continue;
+ }
+ dataRow = null;
+ if (text4 != odRow["EMPLOYEENO"].ToString())
+ {
+ array = payslipDataTable.Select(" EmployeeNo='" + odRow["EMPLOYEENO"].ToString() + "'");
+ num3 = 0;
+ }
+ if (array.Length <= num3)
+ {
+ dataRow = payslipDataTable.NewRow();
+ dataRow = GrossMerge(dataRow, odRow);
+ payslipDataTable.Rows.Add(dataRow);
+ }
+ else
+ {
+ dataRow = array[num3];
+ }
+ dataRow["DeducDescription"] = odRow["Description"];
+ if (Convert.ToInt32(odRow["ITEMGROUP"]) == 3)
+ {
+ if (dataRow["DeducDescription"].ToString().ToLower() == "pf contribution")
+ {
+ dataRow["DeducAmount"] = Convert.ToDouble(odRow["CHANGEDAMOUNT"]) * 2.0;
+ }
+ else
+ {
+ dataRow["DeducAmount"] = odRow["CHANGEDAMOUNT"];
+ }
+ }
+ dataRow["DeducDescription"] = odRow["Description"];
+ if (text5 == "" || text5 != odRow["EMPLOYEENO"].ToString())
+ {
+ num6 = 0.0;
+ num5 = 0.0;
+ employee = ((List)(object)val).Find((Predicate)((Employee oEmpItem) => oEmpItem.EmployeeNo == odRow["EMPLOYEENO"].ToString().Trim()));
+ DataRow[] array2 = empPaySlipDeductForOthers.Tables[0].Select(" ItemCode='" + -128 + "' AND EMPLOYEENO='" + odRow["EMPLOYEENO"].ToString() + "'");
+ if (array2.Length != 0)
+ {
+ DataRow dataRow5 = array2[0];
+ num6 = Convert.ToDouble(dataRow5["CHANGEDAMOUNT"]) * 2.0;
+ }
+ if ((ObjectTemplate)(object)employee != (ObjectTemplate)null)
+ {
+ num4 = ((((List)(object)_oGratuityParams).Count <= 0 || _oGratuityParams == null) ? 0.0 : GetGratuityAmount(_oGratuityParams, employee, dateTime));
+ num5 = GetPFAmount(employee, dateTime);
+ }
+ }
+ dataRow["Gratuity"] = num4;
+ double num8 = 0.0;
+ if ((ObjectTemplate)(object)employee != (ObjectTemplate)null)
+ {
+ num8 = ServiceYears(GlobalFunctions.LastDateOfMonth(dateTime), employee);
+ }
+ if (num8 > 5.0)
+ {
+ dataRow["PF"] = num5 + num6;
+ }
+ else
+ {
+ dataRow["PF"] = num5 + num6;
+ }
+ num3++;
+ text4 = odRow["EMPLOYEENO"].ToString();
+ text5 = odRow["EMPLOYEENO"].ToString();
+ }
+ num3 = 0;
+ DataSet empPaySlipIncomeTaxAmountForOthers = SalaryMonthly.GetEmpPaySlipIncomeTaxAmountForOthers(GlobalFunctions.LastDateOfMonth(dateTime), sEmpID2);
+ string text6 = "";
+ DataRow[] array3 = null;
+ if (empPaySlipIncomeTaxAmountForOthers.Tables[0].Rows.Count > 0)
+ {
+ text6 = empPaySlipIncomeTaxAmountForOthers.Tables[0].Rows[0]["EMPLOYEENO"].ToString();
+ array3 = payslipDataTable.Select(" EmployeeNo='" + empPaySlipIncomeTaxAmountForOthers.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'");
+ }
+ foreach (DataRow row4 in empPaySlipIncomeTaxAmountForOthers.Tables[0].Rows)
+ {
+ dataRow = null;
+ if (text6 != row4["EMPLOYEENO"].ToString())
+ {
+ array3 = payslipDataTable.Select(" EmployeeNo='" + row4["EMPLOYEENO"].ToString() + "'");
+ num3 = 0;
+ }
+ if (array3.Length > num3)
+ {
+ dataRow = array3[num3];
+ if (Convert.ToInt32(row4["ITEMGROUP"]) == 5 && Convert.ToInt32(row4["ItemCode"]) == -129)
+ {
+ dataRow["IncomTaxAmount"] = row4["CHANGEDAMOUNT"];
+ }
+ num3++;
+ text6 = row4["EMPLOYEENO"].ToString();
+ }
+ }
+ num3 = 0;
+ DataSet empPaySlipDeductForLR = SalaryMonthly.GetEmpPaySlipDeductForLR(GlobalFunctions.LastDateOfMonth(dateTime), sEmpID2);
+ string text7 = "";
+ DataRow[] array4 = null;
+ if (empPaySlipDeductForLR.Tables[0].Rows.Count > 0)
+ {
+ text7 = empPaySlipDeductForLR.Tables[0].Rows[0]["EMPLOYEENO"].ToString();
+ array4 = payslipDataTable.Select(" EmployeeNo='" + empPaySlipDeductForLR.Tables[0].Rows[0]["EMPLOYEENO"].ToString() + "'");
+ }
+ foreach (DataRow row5 in empPaySlipDeductForLR.Tables[0].Rows)
+ {
+ dataRow = null;
+ if (text7 != row5["EMPLOYEENO"].ToString())
+ {
+ array4 = payslipDataTable.Select(" EmployeeNo='" + row5["EMPLOYEENO"].ToString() + "'");
+ num3 = 0;
+ }
+ if (array4.Length > num3)
+ {
+ dataRow = array4[num3];
+ if (Convert.ToInt32(row5["ITEMGROUP"]) == 4 && Convert.ToInt32(row5["ItemCode"]) == -126)
+ {
+ dataRow["LoanDescription"] = row5["Description"];
+ dataRow["LoanAmount"] = row5["CHANGEDAMOUNT"];
+ }
+ num3++;
+ text7 = row5["EMPLOYEENO"].ToString();
+ }
+ }
+ bool boolValue = ConfigurationManager.GetBoolValue("designation", "desigfromdescriptiontext", EnumConfigurationType.Logic);
+ foreach (DataRow row in payslipDataTable.Rows)
+ {
+ Employee oEmp = ((IEnumerable)val).Where((Employee o) => o.EmployeeNo.ToUpper().Trim() == row["EMPLOYEENO"].ToString().ToUpper().Trim()).SingleOrDefault();
+ if (!((ObjectTemplate)(object)oEmp != (ObjectTemplate)null))
+ {
+ continue;
+ }
+ if (boolValue)
+ {
+ row["Designation"] = oEmp.DescriptionText;
+ continue;
+ }
+ Designation designation = source.Where((Designation o) => ((ObjectTemplate)o).ID == oEmp.DesignationID).SingleOrDefault();
+ if ((ObjectTemplate)(object)designation != (ObjectTemplate)null)
+ {
+ row["Designation"] = designation.Name;
+ }
+ }
+ dataTable2 = dataSet.Tables[0];
+ dataTable2.TableName = "BasicInfo";
+ DataSet dataSet3 = new DataSet();
+ payslipDataTable.TableName = "SalaryMonthlysGross";
+ dataSet3.Tables.Add(payslipDataTable);
+ return fReportViewer2.MailNewPaySlip(null, dataTable2, dataSet3, dateTime.ToString("MMMM yyyy"));
+ }
}
}
diff --git a/Payroll.UI/Payroll.UI/App.config b/Payroll.UI/Payroll.UI/App.config
index 258ccdc..1a7e864 100644
--- a/Payroll.UI/Payroll.UI/App.config
+++ b/Payroll.UI/Payroll.UI/App.config
@@ -7,7 +7,7 @@
-
+
diff --git a/Payroll.UI/Payroll.UI/Payroll.UI.csproj b/Payroll.UI/Payroll.UI/Payroll.UI.csproj
index 6058802..e873de2 100644
--- a/Payroll.UI/Payroll.UI/Payroll.UI.csproj
+++ b/Payroll.UI/Payroll.UI/Payroll.UI.csproj
@@ -64,6 +64,10 @@
false
+
+ False
+ ..\..\Library\BouncyCastle.Crypto.dll
+
False
..\..\Library\ClosedXML.dll
@@ -113,6 +117,9 @@
False
..\..\Library\ExtendedRichTextBox.dll
+
+ ..\..\Library\itextsharp.dll
+
..\..\packages\Microsoft.Exchange.WebServices.2.2\lib\40\Microsoft.Exchange.WebServices.dll
True
diff --git a/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.cs b/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.cs
index a14282f..e16b206 100644
--- a/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.cs
+++ b/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.cs
@@ -1,19 +1,16 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
-using System.Data;
using System.Drawing;
-using System.Linq;
+using System.IO;
using System.Text;
using System.Windows.Forms;
-//using Ease.CoreV35.Utility;
-using Payroll.BO;
using Ease.CoreV35.Model;
+using iTextSharp.text.pdf;
+using Payroll.BO;
using Payroll.Controls;
+using Payroll.Controls.CustomControls;
using Payroll.Report;
-using System.Reflection;
-using System.Net.Mail;
-using System.IO;
namespace Payroll.UI
{
@@ -95,118 +92,241 @@ namespace Payroll.UI
}
return true;
}
-
private void PrepareReport()
{
- MailSender oMailSender = new MailSender();
+ MailSender mailSender = new MailSender();
_ToSendEmps = new ObjectsTemplate();
-
lblEmployee.Text = "";
lblEmployee.Refresh();
- PaySlip _payslip = new PaySlip();
-
- if (ctlEmployee.SelectedEmployee != null)
+ PaySlip paySlip = new PaySlip();
+ if ((ObjectTemplate)(object)ctlEmployee.SelectedEmployee != (ObjectTemplate)null)
{
- _ToSendEmps.Add((SearchEmployee)ctlEmployee.SelectedEmployee);
+ ((List)(object)_ToSendEmps).Add(ctlEmployee.SelectedEmployee);
}
else if (lsvEmployee.CheckedItems.Count > 0)
{
- int index = 0;
- foreach (ListViewItem item in lsvEmployee.CheckedItems)
+ int num = 0;
+ foreach (ListViewItem checkedItem in lsvEmployee.CheckedItems)
{
- _ToSendEmps.Add((SearchEmployee)lsvEmployee.CheckedItems[index++].Tag);
+ ((List)(object)_ToSendEmps).Add((SearchEmployee)lsvEmployee.CheckedItems[num++].Tag);
}
}
-
-
- if (_ToSendEmps.Count > 0)
+ if (((List)(object)_ToSendEmps).Count <= 0)
{
- string path = string.Empty;
- string filename = string.Empty;
- byte[] filetoSendBytes = null;
- int count = 0;
- try
+ return;
+ }
+ string empty = string.Empty;
+ string empty2 = string.Empty;
+ byte[] array = null;
+ int num2 = 0;
+ try
+ {
+ Cursor = Cursors.WaitCursor;
+ EnumSendMail enumSendMail = EnumSendMail.None;
+ foreach (SearchEmployee item in (List)(object)_ToSendEmps)
{
- this.Cursor = Cursors.WaitCursor;
- EnumSendMail sendMail = EnumSendMail.None;
- foreach (SearchEmployee item in _ToSendEmps)
+ if (string.IsNullOrWhiteSpace(item.Employee.MobileNo))
{
- lblEmployee.Text = "Sending Mail :" + (++count).ToString() + "/" + _ToSendEmps.Count;
- lblEmployee.Refresh();
- if(_Type==1)
- filetoSendBytes = _payslip.MailReport(dtpfromDate.Value, item.EmployeeID.Integer.ToString());
- else
- filetoSendBytes = _payslip.SKFExpencesPaySlip1(dtpfromDate.Value, item.EmployeeID.Integer.ToString());
+ MessageBox.Show($"{item.Employee.Name} ({item.Employee.EmployeeNo}) does not have a phone number. Email sending was skipped.");
+ continue;
+ }
+ Label label = lblEmployee;
+ int num3 = ++num2;
+ label.Text = "Sending Mail :" + num3 + "/" + ((List)(object)_ToSendEmps).Count;
+ lblEmployee.Refresh();
+ array = ((_Type != 1) ? paySlip.SKFExpencesPaySlip1(dtpfromDate.Value, item.EmployeeID.Integer.ToString()) : paySlip.MailReportWithAccountNoMask(dtpfromDate.Value, item.EmployeeID.Integer.ToString()));
+ if (array == null)
+ {
+ continue;
+ }
+ if (!Directory.Exists(Application.StartupPath + "\\Report"))
+ {
+ DirectoryInfo directoryInfo = new DirectoryInfo(Application.StartupPath + "\\Report");
+ directoryInfo.Create();
+ }
+ empty = string.Concat(str2: (_Type != 1) ? ("Expense_" + item.EmployeeNo + "-" + dtpfromDate.Value.Month + "-" + dtpfromDate.Value.Year + "_" + DateTime.Now.ToString("hh_mm_ss") + ".pdf") : ("Payslip_" + item.EmployeeNo + "-" + dtpfromDate.Value.Month + "-" + dtpfromDate.Value.Year + "_" + DateTime.Now.ToString("hh_mm_ss") + ".pdf"), str0: Application.StartupPath, str1: "\\Report\\");
+ using (FileStream fileStream = new FileStream(empty, FileMode.Create))
+ {
+ fileStream.Write(array, 0, array.Length);
+ fileStream.Dispose();
+ }
- if (filetoSendBytes != null)
+ //string employeeNo = item.Employee.EmployeeNo;
+ //string text = ((employeeNo.Length >= 3) ? employeeNo.Substring(employeeNo.Length - 3) : employeeNo.PadLeft(3, '0'));
+
+ //Encrypt PDF with last 4 digit of mobile no
+ string phoneNo = item.Employee.MobileNo;
+ string text = ((phoneNo.Length >= 4) ? phoneNo.Substring(phoneNo.Length - 4) : phoneNo.PadLeft(4, '0'));
+
+ using (MemoryStream memoryStream = new MemoryStream(array))
+ {
+ PdfReader val = new PdfReader((Stream)memoryStream);
+ try
{
- if (!Directory.Exists(Application.StartupPath + @"\Report"))
+ // Replace the following line:
+ //using FileStream fileStream2 = new FileStream(empty, FileMode.Create);
+ using (FileStream fileStream2 = new FileStream(empty, FileMode.Create))
{
- DirectoryInfo dirInfo = new DirectoryInfo(Application.StartupPath + @"\Report");
- dirInfo.Create();
+ PdfEncryptor.Encrypt(val, (Stream)fileStream2, 2, text, (string)null, 2052);
}
- if (_Type == 1)
- filename = "Payslip_"+item.EmployeeNo + "-" + dtpfromDate.Value.Month + "-" + dtpfromDate.Value.Year+"_"+DateTime.Now.ToString("hh_mm_ss") + ".pdf";
- else
- filename = "Expense_" + item.EmployeeNo + "-" + dtpfromDate.Value.Month + "-" + dtpfromDate.Value.Year + "_" + DateTime.Now.ToString("hh_mm_ss") + ".pdf";
- path = Application.StartupPath + @"\Report\" + filename;
-
- using (FileStream fs = new FileStream(path, FileMode.Create))
- {
- fs.Write(filetoSendBytes, 0, filetoSendBytes.Length);
- fs.Dispose();
- }
- item.Email = item.Employee.EmailAddress;
- sendMail = SendMail(item, path,_Type);
-
- switch (sendMail)
- {
- case EnumSendMail.ToMissing:
- MessageBox.Show("Employee mail address is missing", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Error);
- break;
- case EnumSendMail.FromMissing:
- MessageBox.Show("Missing from address", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Error);
- break;
- case EnumSendMail.BodyMissing:
- MessageBox.Show("Missing mail body", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Error);
- break;
- case EnumSendMail.SubjectMissing:
- MessageBox.Show("Mail subject is missing", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Error);
- break;
- case EnumSendMail.ServerNotFound:
- MessageBox.Show("Server not found", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Error);
- break;
- case EnumSendMail.SendError:
- MessageBox.Show("Sending Mail Error", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Error);
- break;
-
- default:
- break;
- }
-
-
+ //PdfEncryptor.Encrypt(val, (Stream)fileStream2, 2, text, (string)null, 2052);
+ }
+ finally
+ {
+ ((IDisposable)val)?.Dispose();
}
}
-
- if (sendMail == EnumSendMail.SuccessFullySend)
+ item.Email = item.Employee.EmailAddress;
+ enumSendMail = SendMail(item, empty, _Type);
+ switch (enumSendMail)
{
- lblEmployee.Text = string.Empty;
- lblEmployee.Refresh();
- MessageBox.Show("Mail Sent Successfully", "Payslip", MessageBoxButtons.OK, MessageBoxIcon.Information);
-
+ case EnumSendMail.ToMissing:
+ MessageBox.Show("Employee mail address is missing", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Hand);
+ break;
+ case EnumSendMail.FromMissing:
+ MessageBox.Show("Missing from address", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Hand);
+ break;
+ case EnumSendMail.BodyMissing:
+ MessageBox.Show("Missing mail body", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Hand);
+ break;
+ case EnumSendMail.SubjectMissing:
+ MessageBox.Show("Mail subject is missing", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Hand);
+ break;
+ case EnumSendMail.ServerNotFound:
+ MessageBox.Show("Server not found", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Hand);
+ break;
+ case EnumSendMail.SendError:
+ MessageBox.Show("Sending Mail Error", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Hand);
+ break;
}
- this.Cursor = Cursors.Default;
}
- catch (Exception ex)
+ if (enumSendMail == EnumSendMail.SuccessFullySend)
{
- MessageBox.Show(this, ex.Message, "Error Sending Mail", MessageBoxButtons.OK, MessageBoxIcon.Error);
lblEmployee.Text = string.Empty;
lblEmployee.Refresh();
- this.Cursor = Cursors.Default;
+ MessageBox.Show("Mail Sent Successfully", "Payslip", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
-
+ Cursor = Cursors.Default;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(this, ex.Message, "Error Sending Mail", MessageBoxButtons.OK, MessageBoxIcon.Hand);
+ lblEmployee.Text = string.Empty;
+ lblEmployee.Refresh();
+ Cursor = Cursors.Default;
}
}
+ //private void PrepareReport()
+ //{
+ // MailSender oMailSender = new MailSender();
+ // _ToSendEmps = new ObjectsTemplate();
+
+ // lblEmployee.Text = "";
+ // lblEmployee.Refresh();
+ // PaySlip _payslip = new PaySlip();
+
+ // if (ctlEmployee.SelectedEmployee != null)
+ // {
+ // _ToSendEmps.Add((SearchEmployee)ctlEmployee.SelectedEmployee);
+ // }
+ // else if (lsvEmployee.CheckedItems.Count > 0)
+ // {
+ // int index = 0;
+ // foreach (ListViewItem item in lsvEmployee.CheckedItems)
+ // {
+ // _ToSendEmps.Add((SearchEmployee)lsvEmployee.CheckedItems[index++].Tag);
+ // }
+ // }
+
+
+ // if (_ToSendEmps.Count > 0)
+ // {
+ // string path = string.Empty;
+ // string filename = string.Empty;
+ // byte[] filetoSendBytes = null;
+ // int count = 0;
+ // try
+ // {
+ // this.Cursor = Cursors.WaitCursor;
+ // EnumSendMail sendMail = EnumSendMail.None;
+ // foreach (SearchEmployee item in _ToSendEmps)
+ // {
+ // lblEmployee.Text = "Sending Mail :" + (++count).ToString() + "/" + _ToSendEmps.Count;
+ // lblEmployee.Refresh();
+ // if(_Type==1)
+ // filetoSendBytes = _payslip.MailReport(dtpfromDate.Value, item.EmployeeID.Integer.ToString());
+ // else
+ // filetoSendBytes = _payslip.SKFExpencesPaySlip1(dtpfromDate.Value, item.EmployeeID.Integer.ToString());
+
+ // if (filetoSendBytes != null)
+ // {
+ // if (!Directory.Exists(Application.StartupPath + @"\Report"))
+ // {
+ // DirectoryInfo dirInfo = new DirectoryInfo(Application.StartupPath + @"\Report");
+ // dirInfo.Create();
+ // }
+ // if (_Type == 1)
+ // filename = "Payslip_"+item.EmployeeNo + "-" + dtpfromDate.Value.Month + "-" + dtpfromDate.Value.Year+"_"+DateTime.Now.ToString("hh_mm_ss") + ".pdf";
+ // else
+ // filename = "Expense_" + item.EmployeeNo + "-" + dtpfromDate.Value.Month + "-" + dtpfromDate.Value.Year + "_" + DateTime.Now.ToString("hh_mm_ss") + ".pdf";
+ // path = Application.StartupPath + @"\Report\" + filename;
+
+ // using (FileStream fs = new FileStream(path, FileMode.Create))
+ // {
+ // fs.Write(filetoSendBytes, 0, filetoSendBytes.Length);
+ // fs.Dispose();
+ // }
+ // item.Email = item.Employee.EmailAddress;
+ // sendMail = SendMail(item, path,_Type);
+
+ // switch (sendMail)
+ // {
+ // case EnumSendMail.ToMissing:
+ // MessageBox.Show("Employee mail address is missing", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ // break;
+ // case EnumSendMail.FromMissing:
+ // MessageBox.Show("Missing from address", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ // break;
+ // case EnumSendMail.BodyMissing:
+ // MessageBox.Show("Missing mail body", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ // break;
+ // case EnumSendMail.SubjectMissing:
+ // MessageBox.Show("Mail subject is missing", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ // break;
+ // case EnumSendMail.ServerNotFound:
+ // MessageBox.Show("Server not found", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ // break;
+ // case EnumSendMail.SendError:
+ // MessageBox.Show("Sending Mail Error", item.EmployeeNo, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ // break;
+
+ // default:
+ // break;
+ // }
+
+
+ // }
+ // }
+
+ // if (sendMail == EnumSendMail.SuccessFullySend)
+ // {
+ // lblEmployee.Text = string.Empty;
+ // lblEmployee.Refresh();
+ // MessageBox.Show("Mail Sent Successfully", "Payslip", MessageBoxButtons.OK, MessageBoxIcon.Information);
+
+ // }
+ // this.Cursor = Cursors.Default;
+ // }
+ // catch (Exception ex)
+ // {
+ // MessageBox.Show(this, ex.Message, "Error Sending Mail", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ // lblEmployee.Text = string.Empty;
+ // lblEmployee.Refresh();
+ // this.Cursor = Cursors.Default;
+ // }
+
+ // }
+ //}
private EnumSendMail SendMail(SearchEmployee item, string sPath,int nType)
{