From 8af686e634c3cf5bc530342fe28845a17e002427 Mon Sep 17 00:00:00 2001 From: Shahadat Hossain Date: Mon, 5 Jan 2026 15:42:08 +0600 Subject: [PATCH] 20260105-1985 CEL-Payroll - Payslip Generate and Download Option Needed - Done --- Payroll.UI/Payroll.UI/App.config | 2 +- Payroll.UI/Payroll.UI/Payroll.UI.csproj | 2 + .../Salary/fPayslipSendMail.Designer.cs | 346 ++++++++++-------- .../Payroll.UI/Salary/fPayslipSendMail.cs | 333 +++++++++++++++++ .../Payroll.UI/Salary/fPayslipSendMail.resx | 4 +- 5 files changed, 524 insertions(+), 163 deletions(-) diff --git a/Payroll.UI/Payroll.UI/App.config b/Payroll.UI/Payroll.UI/App.config index 2371d6c..9127a5b 100644 --- a/Payroll.UI/Payroll.UI/App.config +++ b/Payroll.UI/Payroll.UI/App.config @@ -8,7 +8,7 @@ - + diff --git a/Payroll.UI/Payroll.UI/Payroll.UI.csproj b/Payroll.UI/Payroll.UI/Payroll.UI.csproj index 21cceae..801f6f9 100644 --- a/Payroll.UI/Payroll.UI/Payroll.UI.csproj +++ b/Payroll.UI/Payroll.UI/Payroll.UI.csproj @@ -160,6 +160,8 @@ + + 3.5 diff --git a/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.Designer.cs b/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.Designer.cs index 0ec34e8..52c28fa 100644 --- a/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.Designer.cs +++ b/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.cs b/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.cs index 05ded4c..5fe5b82 100644 --- a/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.cs +++ b/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.cs @@ -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 employees = new List(); + + 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 employees = new List(); + + // // 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 } diff --git a/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.resx b/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.resx index 19dc0dd..d58980a 100644 --- a/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.resx +++ b/Payroll.UI/Payroll.UI/Salary/fPayslipSendMail.resx @@ -112,9 +112,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file