Merge pull request '20260105-1985 CEL-Payroll - Payslip Generate and Download Option Needed - Done' (#4) from dev_shahadat into devqc

Reviewed-on: http://103.197.204.162:3025/CelHRTeam/CEL_Payroll/pulls/4
This commit is contained in:
shamim 2026-01-05 15:44:15 +06:00
commit b306501b70
5 changed files with 524 additions and 163 deletions

View File

@ -8,7 +8,7 @@
</configSections>
<dbSettings>
<!--<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=103.197.204.164,1718;Database=CELPayrol;User ID=Easeuser;Password=EaSeuSeR2025" sqlSyntax="SQL"/>
<!--<connection name="conn" provider="sql" connectionString="server=WIN-D48IJC70V70;Database=GPPayroll;integrated security=yes;" sqlSyntax="SQL"/>-->
</dbSettings>

View File

@ -160,6 +160,8 @@
</Reference>
<Reference Include="System.Design" />
<Reference Include="System.DirectoryServices" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Web.Extensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>

View File

@ -32,14 +32,11 @@ namespace Payroll.UI
this.btnSearch = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.ctlDesignation = new Payroll.Controls.ctlCustomControl();
this.ctlCostCenter = new Payroll.Controls.ctlCustomControl();
this.lblCostCenters = new System.Windows.Forms.Label();
this.lblDesignation = new System.Windows.Forms.Label();
this.cboBranch = new System.Windows.Forms.ComboBox();
this.cboBank = new System.Windows.Forms.ComboBox();
this.label19 = new System.Windows.Forms.Label();
this.ctlEmployee = new Payroll.Controls.CustomControls.ctlEmployee();
this.label12 = new System.Windows.Forms.Label();
this.dtpfromDate = new System.Windows.Forms.DateTimePicker();
this.lblFromDate = new System.Windows.Forms.Label();
@ -47,31 +44,36 @@ namespace Payroll.UI
this.label22 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.ctlGrade = new Payroll.Controls.ctlCustomControl();
this.cboGender = new System.Windows.Forms.ComboBox();
this.ctlLocation = new Payroll.Controls.ctlCustomControl();
this.ctlReligion = new Payroll.Controls.ctlCustomControl();
this.ctlCategory = new Payroll.Controls.ctlCustomControl();
this.label9 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.ctlDepartment = new Payroll.Controls.ctlCustomControl();
this.lblSelected = new System.Windows.Forms.Label();
this.lblTotal = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.lsvEmployee = new System.Windows.Forms.ListView();
this.colName = new System.Windows.Forms.ColumnHeader();
this.colEmpNo = new System.Windows.Forms.ColumnHeader();
this.colEmpEmail = new System.Windows.Forms.ColumnHeader();
this.colName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colEmpNo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colEmpEmail = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.btnSelectAll = new System.Windows.Forms.Button();
this.btnCLose = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.btnSendMail = new System.Windows.Forms.Button();
this.lblEmployee = new System.Windows.Forms.Label();
this.btnSendMail = new System.Windows.Forms.Button();
this.btnGenerate = new System.Windows.Forms.Button();
this.ctlDesignation = new Payroll.Controls.ctlCustomControl();
this.ctlCostCenter = new Payroll.Controls.ctlCustomControl();
this.ctlEmployee = new Payroll.Controls.CustomControls.ctlEmployee();
this.ctlGrade = new Payroll.Controls.ctlCustomControl();
this.ctlLocation = new Payroll.Controls.ctlCustomControl();
this.ctlReligion = new Payroll.Controls.ctlCustomControl();
this.ctlCategory = new Payroll.Controls.ctlCustomControl();
this.ctlDepartment = new Payroll.Controls.ctlCustomControl();
this.btnDownload = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox3.SuspendLayout();
@ -91,6 +93,7 @@ namespace Payroll.UI
//
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel1.Controls.Add(this.groupBox1);
this.panel1.Controls.Add(this.lblEmployee);
this.panel1.Controls.Add(this.lblSelected);
this.panel1.Controls.Add(this.lblTotal);
this.panel1.Controls.Add(this.label14);
@ -139,42 +142,6 @@ namespace Payroll.UI
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Search Condition";
//
// ctlDesignation
//
this.ctlDesignation.BackColor = System.Drawing.Color.Transparent;
this.ctlDesignation.ChildPropertyName = null;
this.ctlDesignation.ControlType = Payroll.BO.EnumCustomBasicControlType.ListView;
this.ctlDesignation.CustomSearchString = null;
this.ctlDesignation.LastLevel = -1;
this.ctlDesignation.Location = new System.Drawing.Point(101, 221);
this.ctlDesignation.MHTire = 0;
this.ctlDesignation.MultipleSelection = true;
this.ctlDesignation.Name = "ctlDesignation";
this.ctlDesignation.OutputType = Payroll.BO.EnumCustomBasicControl.Designation;
this.ctlDesignation.PickerCaption = "Designation";
this.ctlDesignation.PickerHeadLine = "";
this.ctlDesignation.SelectedIDs = null;
this.ctlDesignation.Size = new System.Drawing.Size(229, 24);
this.ctlDesignation.TabIndex = 46;
//
// ctlCostCenter
//
this.ctlCostCenter.BackColor = System.Drawing.Color.Transparent;
this.ctlCostCenter.ChildPropertyName = "PickerChilds";
this.ctlCostCenter.ControlType = Payroll.BO.EnumCustomBasicControlType.TreeView;
this.ctlCostCenter.CustomSearchString = null;
this.ctlCostCenter.LastLevel = -1;
this.ctlCostCenter.Location = new System.Drawing.Point(402, 221);
this.ctlCostCenter.MHTire = 0;
this.ctlCostCenter.MultipleSelection = true;
this.ctlCostCenter.Name = "ctlCostCenter";
this.ctlCostCenter.OutputType = Payroll.BO.EnumCustomBasicControl.CostCenter;
this.ctlCostCenter.PickerCaption = "Cost-Center";
this.ctlCostCenter.PickerHeadLine = "";
this.ctlCostCenter.SelectedIDs = null;
this.ctlCostCenter.Size = new System.Drawing.Size(211, 24);
this.ctlCostCenter.TabIndex = 45;
//
// lblCostCenters
//
this.lblCostCenters.AutoSize = true;
@ -229,16 +196,6 @@ namespace Payroll.UI
this.label19.TabIndex = 30;
this.label19.Text = "Employee";
//
// ctlEmployee
//
this.ctlEmployee.EmployeeNo = "";
this.ctlEmployee.Grades = null;
this.ctlEmployee.Location = new System.Drawing.Point(101, 264);
this.ctlEmployee.Name = "ctlEmployee";
this.ctlEmployee.SelectedEmployee = null;
this.ctlEmployee.Size = new System.Drawing.Size(507, 27);
this.ctlEmployee.TabIndex = 28;
//
// label12
//
this.label12.AutoSize = true;
@ -247,7 +204,7 @@ namespace Payroll.UI
this.label12.Size = new System.Drawing.Size(595, 13);
this.label12.TabIndex = 27;
this.label12.Text = "_________________________________________________________________________________" +
"_________________";
"_________________";
//
// dtpfromDate
//
@ -302,25 +259,7 @@ namespace Payroll.UI
this.label11.Size = new System.Drawing.Size(595, 13);
this.label11.TabIndex = 21;
this.label11.Text = "_________________________________________________________________________________" +
"_________________";
//
// ctlGrade
//
this.ctlGrade.BackColor = System.Drawing.Color.Transparent;
this.ctlGrade.ChildPropertyName = null;
this.ctlGrade.ControlType = Payroll.BO.EnumCustomBasicControlType.ListView;
this.ctlGrade.CustomSearchString = null;
this.ctlGrade.LastLevel = -1;
this.ctlGrade.Location = new System.Drawing.Point(402, 189);
this.ctlGrade.MHTire = 0;
this.ctlGrade.MultipleSelection = true;
this.ctlGrade.Name = "ctlGrade";
this.ctlGrade.OutputType = Payroll.BO.EnumCustomBasicControl.Grade;
this.ctlGrade.PickerCaption = "Grade";
this.ctlGrade.PickerHeadLine = "";
this.ctlGrade.SelectedIDs = null;
this.ctlGrade.Size = new System.Drawing.Size(211, 24);
this.ctlGrade.TabIndex = 19;
"_________________";
//
// cboGender
//
@ -335,60 +274,6 @@ namespace Payroll.UI
this.cboGender.Size = new System.Drawing.Size(229, 21);
this.cboGender.TabIndex = 18;
//
// ctlLocation
//
this.ctlLocation.BackColor = System.Drawing.Color.Transparent;
this.ctlLocation.ChildPropertyName = "PickerChilds";
this.ctlLocation.ControlType = Payroll.BO.EnumCustomBasicControlType.TreeView;
this.ctlLocation.CustomSearchString = null;
this.ctlLocation.LastLevel = -1;
this.ctlLocation.Location = new System.Drawing.Point(402, 158);
this.ctlLocation.MHTire = 0;
this.ctlLocation.MultipleSelection = false;
this.ctlLocation.Name = "ctlLocation";
this.ctlLocation.OutputType = Payroll.BO.EnumCustomBasicControl.Location;
this.ctlLocation.PickerCaption = "Location";
this.ctlLocation.PickerHeadLine = "";
this.ctlLocation.SelectedIDs = null;
this.ctlLocation.Size = new System.Drawing.Size(211, 21);
this.ctlLocation.TabIndex = 17;
//
// ctlReligion
//
this.ctlReligion.BackColor = System.Drawing.Color.Transparent;
this.ctlReligion.ChildPropertyName = null;
this.ctlReligion.ControlType = Payroll.BO.EnumCustomBasicControlType.ListView;
this.ctlReligion.CustomSearchString = null;
this.ctlReligion.LastLevel = -1;
this.ctlReligion.Location = new System.Drawing.Point(101, 156);
this.ctlReligion.MHTire = 0;
this.ctlReligion.MultipleSelection = true;
this.ctlReligion.Name = "ctlReligion";
this.ctlReligion.OutputType = Payroll.BO.EnumCustomBasicControl.Religion;
this.ctlReligion.PickerCaption = "Religion";
this.ctlReligion.PickerHeadLine = "";
this.ctlReligion.SelectedIDs = null;
this.ctlReligion.Size = new System.Drawing.Size(229, 24);
this.ctlReligion.TabIndex = 12;
//
// ctlCategory
//
this.ctlCategory.BackColor = System.Drawing.Color.Transparent;
this.ctlCategory.ChildPropertyName = null;
this.ctlCategory.ControlType = Payroll.BO.EnumCustomBasicControlType.ListView;
this.ctlCategory.CustomSearchString = null;
this.ctlCategory.LastLevel = -1;
this.ctlCategory.Location = new System.Drawing.Point(101, 100);
this.ctlCategory.MHTire = 0;
this.ctlCategory.MultipleSelection = true;
this.ctlCategory.Name = "ctlCategory";
this.ctlCategory.OutputType = Payroll.BO.EnumCustomBasicControl.Category;
this.ctlCategory.PickerCaption = "Category";
this.ctlCategory.PickerHeadLine = "";
this.ctlCategory.SelectedIDs = null;
this.ctlCategory.Size = new System.Drawing.Size(229, 22);
this.ctlCategory.TabIndex = 11;
//
// label9
//
this.label9.AutoSize = true;
@ -443,24 +328,6 @@ namespace Payroll.UI
this.label1.TabIndex = 2;
this.label1.Text = "Department";
//
// ctlDepartment
//
this.ctlDepartment.BackColor = System.Drawing.Color.Transparent;
this.ctlDepartment.ChildPropertyName = "PickerChilds";
this.ctlDepartment.ControlType = Payroll.BO.EnumCustomBasicControlType.TreeView;
this.ctlDepartment.CustomSearchString = null;
this.ctlDepartment.LastLevel = -1;
this.ctlDepartment.Location = new System.Drawing.Point(101, 129);
this.ctlDepartment.MHTire = 0;
this.ctlDepartment.MultipleSelection = true;
this.ctlDepartment.Name = "ctlDepartment";
this.ctlDepartment.OutputType = Payroll.BO.EnumCustomBasicControl.Department;
this.ctlDepartment.PickerCaption = "Department";
this.ctlDepartment.PickerHeadLine = "";
this.ctlDepartment.SelectedIDs = null;
this.ctlDepartment.Size = new System.Drawing.Size(229, 22);
this.ctlDepartment.TabIndex = 0;
//
// lblSelected
//
this.lblSelected.AutoSize = true;
@ -508,6 +375,7 @@ namespace Payroll.UI
this.colEmpEmail});
this.lsvEmployee.FullRowSelect = true;
this.lsvEmployee.GridLines = true;
this.lsvEmployee.HideSelection = false;
this.lsvEmployee.Location = new System.Drawing.Point(661, 3);
this.lsvEmployee.Name = "lsvEmployee";
this.lsvEmployee.Size = new System.Drawing.Size(245, 391);
@ -552,7 +420,8 @@ namespace Payroll.UI
//
// groupBox3
//
this.groupBox3.Controls.Add(this.lblEmployee);
this.groupBox3.Controls.Add(this.btnDownload);
this.groupBox3.Controls.Add(this.btnGenerate);
this.groupBox3.Controls.Add(this.btnCLose);
this.groupBox3.Controls.Add(this.btnSendMail);
this.groupBox3.Location = new System.Drawing.Point(9, 457);
@ -561,6 +430,15 @@ namespace Payroll.UI
this.groupBox3.TabIndex = 28;
this.groupBox3.TabStop = false;
//
// lblEmployee
//
this.lblEmployee.AutoSize = true;
this.lblEmployee.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblEmployee.Location = new System.Drawing.Point(18, 411);
this.lblEmployee.Name = "lblEmployee";
this.lblEmployee.Size = new System.Drawing.Size(0, 13);
this.lblEmployee.TabIndex = 11;
//
// btnSendMail
//
this.btnSendMail.Location = new System.Drawing.Point(15, 14);
@ -571,14 +449,162 @@ namespace Payroll.UI
this.btnSendMail.UseVisualStyleBackColor = true;
this.btnSendMail.Click += new System.EventHandler(this.btnSendMail_Click);
//
// lblEmployee
// btnGenerate
//
this.lblEmployee.AutoSize = true;
this.lblEmployee.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblEmployee.Location = new System.Drawing.Point(125, 21);
this.lblEmployee.Name = "lblEmployee";
this.lblEmployee.Size = new System.Drawing.Size(0, 13);
this.lblEmployee.TabIndex = 11;
this.btnGenerate.Location = new System.Drawing.Point(96, 14);
this.btnGenerate.Name = "btnGenerate";
this.btnGenerate.Size = new System.Drawing.Size(75, 27);
this.btnGenerate.TabIndex = 12;
this.btnGenerate.Text = "Generate";
this.btnGenerate.UseVisualStyleBackColor = true;
this.btnGenerate.Click += new System.EventHandler(this.btnGenerate_Click);
//
// ctlDesignation
//
this.ctlDesignation.BackColor = System.Drawing.Color.Transparent;
this.ctlDesignation.ChildPropertyName = null;
this.ctlDesignation.ControlType = Payroll.BO.EnumCustomBasicControlType.ListView;
this.ctlDesignation.CustomSearchString = null;
this.ctlDesignation.LastLevel = -1;
this.ctlDesignation.Location = new System.Drawing.Point(101, 221);
this.ctlDesignation.MHTire = 0;
this.ctlDesignation.MultipleSelection = true;
this.ctlDesignation.Name = "ctlDesignation";
this.ctlDesignation.OutputType = Payroll.BO.EnumCustomBasicControl.Designation;
this.ctlDesignation.PickerCaption = "Designation";
this.ctlDesignation.PickerHeadLine = "";
this.ctlDesignation.SelectedIDs = null;
this.ctlDesignation.Size = new System.Drawing.Size(229, 24);
this.ctlDesignation.TabIndex = 46;
//
// ctlCostCenter
//
this.ctlCostCenter.BackColor = System.Drawing.Color.Transparent;
this.ctlCostCenter.ChildPropertyName = "PickerChilds";
this.ctlCostCenter.ControlType = Payroll.BO.EnumCustomBasicControlType.TreeView;
this.ctlCostCenter.CustomSearchString = null;
this.ctlCostCenter.LastLevel = -1;
this.ctlCostCenter.Location = new System.Drawing.Point(402, 221);
this.ctlCostCenter.MHTire = 0;
this.ctlCostCenter.MultipleSelection = true;
this.ctlCostCenter.Name = "ctlCostCenter";
this.ctlCostCenter.OutputType = Payroll.BO.EnumCustomBasicControl.CostCenter;
this.ctlCostCenter.PickerCaption = "Cost-Center";
this.ctlCostCenter.PickerHeadLine = "";
this.ctlCostCenter.SelectedIDs = null;
this.ctlCostCenter.Size = new System.Drawing.Size(211, 24);
this.ctlCostCenter.TabIndex = 45;
//
// ctlEmployee
//
this.ctlEmployee.EmployeeNo = "";
this.ctlEmployee.Grades = null;
this.ctlEmployee.Location = new System.Drawing.Point(101, 264);
this.ctlEmployee.Name = "ctlEmployee";
this.ctlEmployee.SelectedEmployee = null;
this.ctlEmployee.Size = new System.Drawing.Size(507, 27);
this.ctlEmployee.TabIndex = 28;
//
// ctlGrade
//
this.ctlGrade.BackColor = System.Drawing.Color.Transparent;
this.ctlGrade.ChildPropertyName = null;
this.ctlGrade.ControlType = Payroll.BO.EnumCustomBasicControlType.ListView;
this.ctlGrade.CustomSearchString = null;
this.ctlGrade.LastLevel = -1;
this.ctlGrade.Location = new System.Drawing.Point(402, 189);
this.ctlGrade.MHTire = 0;
this.ctlGrade.MultipleSelection = true;
this.ctlGrade.Name = "ctlGrade";
this.ctlGrade.OutputType = Payroll.BO.EnumCustomBasicControl.Grade;
this.ctlGrade.PickerCaption = "Grade";
this.ctlGrade.PickerHeadLine = "";
this.ctlGrade.SelectedIDs = null;
this.ctlGrade.Size = new System.Drawing.Size(211, 24);
this.ctlGrade.TabIndex = 19;
//
// ctlLocation
//
this.ctlLocation.BackColor = System.Drawing.Color.Transparent;
this.ctlLocation.ChildPropertyName = "PickerChilds";
this.ctlLocation.ControlType = Payroll.BO.EnumCustomBasicControlType.TreeView;
this.ctlLocation.CustomSearchString = null;
this.ctlLocation.LastLevel = -1;
this.ctlLocation.Location = new System.Drawing.Point(402, 158);
this.ctlLocation.MHTire = 0;
this.ctlLocation.MultipleSelection = false;
this.ctlLocation.Name = "ctlLocation";
this.ctlLocation.OutputType = Payroll.BO.EnumCustomBasicControl.Location;
this.ctlLocation.PickerCaption = "Location";
this.ctlLocation.PickerHeadLine = "";
this.ctlLocation.SelectedIDs = null;
this.ctlLocation.Size = new System.Drawing.Size(211, 21);
this.ctlLocation.TabIndex = 17;
//
// ctlReligion
//
this.ctlReligion.BackColor = System.Drawing.Color.Transparent;
this.ctlReligion.ChildPropertyName = null;
this.ctlReligion.ControlType = Payroll.BO.EnumCustomBasicControlType.ListView;
this.ctlReligion.CustomSearchString = null;
this.ctlReligion.LastLevel = -1;
this.ctlReligion.Location = new System.Drawing.Point(101, 156);
this.ctlReligion.MHTire = 0;
this.ctlReligion.MultipleSelection = true;
this.ctlReligion.Name = "ctlReligion";
this.ctlReligion.OutputType = Payroll.BO.EnumCustomBasicControl.Religion;
this.ctlReligion.PickerCaption = "Religion";
this.ctlReligion.PickerHeadLine = "";
this.ctlReligion.SelectedIDs = null;
this.ctlReligion.Size = new System.Drawing.Size(229, 24);
this.ctlReligion.TabIndex = 12;
//
// ctlCategory
//
this.ctlCategory.BackColor = System.Drawing.Color.Transparent;
this.ctlCategory.ChildPropertyName = null;
this.ctlCategory.ControlType = Payroll.BO.EnumCustomBasicControlType.ListView;
this.ctlCategory.CustomSearchString = null;
this.ctlCategory.LastLevel = -1;
this.ctlCategory.Location = new System.Drawing.Point(101, 100);
this.ctlCategory.MHTire = 0;
this.ctlCategory.MultipleSelection = true;
this.ctlCategory.Name = "ctlCategory";
this.ctlCategory.OutputType = Payroll.BO.EnumCustomBasicControl.Category;
this.ctlCategory.PickerCaption = "Category";
this.ctlCategory.PickerHeadLine = "";
this.ctlCategory.SelectedIDs = null;
this.ctlCategory.Size = new System.Drawing.Size(229, 22);
this.ctlCategory.TabIndex = 11;
//
// ctlDepartment
//
this.ctlDepartment.BackColor = System.Drawing.Color.Transparent;
this.ctlDepartment.ChildPropertyName = "PickerChilds";
this.ctlDepartment.ControlType = Payroll.BO.EnumCustomBasicControlType.TreeView;
this.ctlDepartment.CustomSearchString = null;
this.ctlDepartment.LastLevel = -1;
this.ctlDepartment.Location = new System.Drawing.Point(101, 129);
this.ctlDepartment.MHTire = 0;
this.ctlDepartment.MultipleSelection = true;
this.ctlDepartment.Name = "ctlDepartment";
this.ctlDepartment.OutputType = Payroll.BO.EnumCustomBasicControl.Department;
this.ctlDepartment.PickerCaption = "Department";
this.ctlDepartment.PickerHeadLine = "";
this.ctlDepartment.SelectedIDs = null;
this.ctlDepartment.Size = new System.Drawing.Size(229, 22);
this.ctlDepartment.TabIndex = 0;
//
// btnDownload
//
this.btnDownload.Location = new System.Drawing.Point(177, 14);
this.btnDownload.Name = "btnDownload";
this.btnDownload.Size = new System.Drawing.Size(75, 27);
this.btnDownload.TabIndex = 13;
this.btnDownload.Text = "Download";
this.btnDownload.UseVisualStyleBackColor = true;
this.btnDownload.Visible = false;
this.btnDownload.Click += new System.EventHandler(this.btnDownload_Click);
//
// fPayslipSendMail
//
@ -601,7 +627,6 @@ namespace Payroll.UI
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.ResumeLayout(false);
}
@ -651,6 +676,7 @@ namespace Payroll.UI
private System.Windows.Forms.Button btnSendMail;
private System.Windows.Forms.ColumnHeader colEmpEmail;
private System.Windows.Forms.Label lblEmployee;
private System.Windows.Forms.Button btnGenerate;
private System.Windows.Forms.Button btnDownload;
}
}

View File

@ -12,6 +12,8 @@ using Payroll.Controls;
using Payroll.Controls.CustomControls;
using Payroll.Report;
using System.Net.Mail;
using System.IO.Compression;
namespace Payroll.UI
{
@ -554,6 +556,337 @@ namespace Payroll.UI
#endregion
private void btnGenerate_Click(object sender, EventArgs e)
{
try
{
using (FolderBrowserDialog folderDialog = new FolderBrowserDialog())
{
folderDialog.Description = "Select folder to generate payslips";
folderDialog.ShowNewFolderButton = true;
if (folderDialog.ShowDialog() != DialogResult.OK)
return;
Cursor = Cursors.WaitCursor;
string basePath = folderDialog.SelectedPath;
int year = dtpfromDate.Value.Year;
int month = dtpfromDate.Value.Month;
PaySlip paySlip = new PaySlip();
List<SearchEmployee> employees = new List<SearchEmployee>();
if ((ObjectTemplate)(object)ctlEmployee.SelectedEmployee != null)
{
employees.Add(ctlEmployee.SelectedEmployee);
}
else if (lsvEmployee.CheckedItems.Count > 0)
{
foreach (ListViewItem item in lsvEmployee.CheckedItems)
{
employees.Add((SearchEmployee)item.Tag);
}
}
if (employees.Count == 0)
{
MessageBox.Show("No employee selected.", "Generate Payslip",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
int count = 0;
foreach (SearchEmployee emp in employees)
{
lblEmployee.Text = $"Generating Payslip : {++count}/{employees.Count}";
lblEmployee.Refresh();
byte[] pdfBytes = (_Type != 1)
? paySlip.SKFExpencesPaySlip1(dtpfromDate.Value, emp.EmployeeID.Integer.ToString())
: paySlip.MailReportWithAccountNoMask(dtpfromDate.Value, emp.EmployeeID.Integer.ToString());
if (pdfBytes == null)
continue;
// ✅ FILE NAME: ID-Year-Month.pdf
string fileName = string.Format(
"{0}-{1}-{2}.pdf",
emp.Employee.EmployeeNo,
year,
month.ToString("00")
);
string filePath = Path.Combine(basePath, fileName);
string phoneNo = emp.Employee.MobileNo ?? "";
string password = phoneNo.Length >= 4
? phoneNo.Substring(phoneNo.Length - 4)
: phoneNo.PadLeft(4, '0');
using (MemoryStream ms = new MemoryStream(pdfBytes))
using (PdfReader reader = new PdfReader(ms))
using (FileStream fs = new FileStream(filePath, FileMode.Create))
{
PdfEncryptor.Encrypt(
reader,
fs,
true,
password,
null,
2052
);
}
}
lblEmployee.Text = string.Empty;
MessageBox.Show("Payslips generated successfully.", "Payslip",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error Generating Payslip",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
Cursor = Cursors.Default;
}
//try
//{
// Cursor = Cursors.WaitCursor;
// // Salary month/year from date picker
// int year = dtpfromDate.Value.Year;
// int month = dtpfromDate.Value.Month;
// // Base report path
// string basePath = Path.Combine(Application.StartupPath, "PaySlipReport");
// string yearPath = Path.Combine(basePath, year.ToString());
// string monthPath = Path.Combine(yearPath, month.ToString("00"));
// // Create directories if not exists
// Directory.CreateDirectory(monthPath);
// PaySlip paySlip = new PaySlip();
// List<SearchEmployee> employees = new List<SearchEmployee>();
// // Selected employee
// if ((ObjectTemplate)(object)ctlEmployee.SelectedEmployee != null)
// {
// employees.Add(ctlEmployee.SelectedEmployee);
// }
// // Checked employees
// else if (lsvEmployee.CheckedItems.Count > 0)
// {
// foreach (ListViewItem item in lsvEmployee.CheckedItems)
// {
// employees.Add((SearchEmployee)item.Tag);
// }
// }
// if (employees.Count == 0)
// {
// MessageBox.Show("No employee selected.", "Generate Payslip",
// MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
// }
// int count = 0;
// foreach (SearchEmployee emp in employees)
// {
// lblEmployee.Text = $"Generating Payslip : {++count}/{employees.Count}";
// lblEmployee.Refresh();
// byte[] pdfBytes = (_Type != 1)
// ? paySlip.SKFExpencesPaySlip1(dtpfromDate.Value, emp.EmployeeID.Integer.ToString())
// : paySlip.MailReportWithAccountNoMask(dtpfromDate.Value, emp.EmployeeID.Integer.ToString());
// if (pdfBytes == null)
// continue;
// string filePath = Path.Combine(
// monthPath,
// emp.Employee.EmployeeNo + ".pdf"
// );
// // Encrypt PDF using last 4 digits of mobile
// string phoneNo = emp.Employee.MobileNo ?? "";
// string password = phoneNo.Length >= 4
// ? phoneNo.Substring(phoneNo.Length - 4)
// : phoneNo.PadLeft(4, '0');
// using (MemoryStream ms = new MemoryStream(pdfBytes))
// using (PdfReader reader = new PdfReader(ms))
// using (FileStream fs = new FileStream(filePath, FileMode.Create))
// {
// PdfEncryptor.Encrypt(
// reader,
// fs,
// true,
// password,
// null,
// 2052
// );
// }
// }
// lblEmployee.Text = string.Empty;
// MessageBox.Show("Payslips generated successfully.", "Payslip",
// MessageBoxButtons.OK, MessageBoxIcon.Information);
//}
//catch (Exception ex)
//{
// MessageBox.Show(ex.Message, "Error Generating Payslip",
// MessageBoxButtons.OK, MessageBoxIcon.Error);
//}
//finally
//{
// Cursor = Cursors.Default;
//}
}
//private void btnDownload_Click(object sender, EventArgs e)
//{
// try
// {
// // 1⃣ Select source folder
// using (FolderBrowserDialog folderDialog = new FolderBrowserDialog())
// {
// folderDialog.Description = "Select folder where payslips are stored";
// folderDialog.ShowNewFolderButton = false;
// if (folderDialog.ShowDialog() != DialogResult.OK)
// return;
// string sourceFolder = folderDialog.SelectedPath;
// // 2⃣ Select files from source folder
// using (OpenFileDialog fileDialog = new OpenFileDialog())
// {
// fileDialog.InitialDirectory = sourceFolder;
// fileDialog.Filter = "PDF files (*.pdf)|*.pdf";
// fileDialog.Multiselect = true;
// fileDialog.Title = "Select payslip(s) to download";
// if (fileDialog.ShowDialog() != DialogResult.OK)
// return;
// string[] selectedFiles = fileDialog.FileNames;
// // 3⃣ Select destination folder
// using (FolderBrowserDialog destDialog = new FolderBrowserDialog())
// {
// destDialog.Description = "Select destination folder to download files";
// destDialog.ShowNewFolderButton = true;
// if (destDialog.ShowDialog() != DialogResult.OK)
// return;
// string destFolder = destDialog.SelectedPath;
// // 4⃣ Copy selected files to destination
// foreach (string file in selectedFiles)
// {
// string fileName = Path.GetFileName(file);
// string destPath = Path.Combine(destFolder, fileName);
// // Overwrite if exists
// File.Copy(file, destPath, true);
// }
// MessageBox.Show("Selected files downloaded successfully!",
// "Download Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
// }
// }
// }
// }
// catch (Exception ex)
// {
// MessageBox.Show(ex.Message, "Error Downloading Files",
// MessageBoxButtons.OK, MessageBoxIcon.Error);
// }
//}
private void btnDownload_Click(object sender, EventArgs e)
{
try
{
// 1⃣ Select source folder
using (FolderBrowserDialog folderDialog = new FolderBrowserDialog())
{
folderDialog.Description = "Select folder where payslips are stored";
folderDialog.ShowNewFolderButton = false;
if (folderDialog.ShowDialog() != DialogResult.OK)
return;
string sourceFolder = folderDialog.SelectedPath;
// 2⃣ Select files from source folder
using (OpenFileDialog fileDialog = new OpenFileDialog())
{
fileDialog.InitialDirectory = sourceFolder;
fileDialog.Filter = "PDF files (*.pdf)|*.pdf";
fileDialog.Multiselect = true;
fileDialog.Title = "Select payslip(s) to download";
if (fileDialog.ShowDialog() != DialogResult.OK)
return;
string[] selectedFiles = fileDialog.FileNames;
if (selectedFiles.Length == 0)
{
MessageBox.Show("No files selected.", "Download", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
// 3⃣ Select destination folder for ZIP
using (FolderBrowserDialog destDialog = new FolderBrowserDialog())
{
destDialog.Description = "Select destination folder to save ZIP";
destDialog.ShowNewFolderButton = true;
if (destDialog.ShowDialog() != DialogResult.OK)
return;
string destFolder = destDialog.SelectedPath;
// 4⃣ Create ZIP file
string zipFileName = "SelectedPayslips_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".zip";
string zipFilePath = Path.Combine(destFolder, zipFileName);
if (File.Exists(zipFilePath))
File.Delete(zipFilePath); // overwrite if exists
// 5⃣ Add selected files to ZIP
using (ZipArchive zip = ZipFile.Open(zipFilePath, ZipArchiveMode.Create))
{
foreach (string filePath in selectedFiles)
{
string fileName = Path.GetFileName(filePath);
zip.CreateEntryFromFile(filePath, fileName, CompressionLevel.Optimal);
}
}
MessageBox.Show($"Selected files have been zipped successfully!\n\nSaved as:\n{zipFilePath}",
"Download Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error Downloading Files", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
#endregion
}

View File

@ -112,9 +112,9 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>