diff --git a/Controllers/Personnel.Controller.cs b/Controllers/Personnel.Controller.cs index 5a00cd5..e0bcc61 100644 --- a/Controllers/Personnel.Controller.cs +++ b/Controllers/Personnel.Controller.cs @@ -3093,7 +3093,7 @@ namespace rmutr_report.Controllers XLAlignmentHorizontalValues.Left; ws.Range(ws.Cell(row, 7), ws.Cell(row, 20)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; - ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Fill.BackgroundColor = XLColor.LightYellow; + ws.Range(ws.Cell(row, 1), ws.Cell(row, 20)).Style.Fill.BackgroundColor = XLColor.FromArgb(255,230,153); ws.Range(ws.Cell(row, 7), ws.Cell(row, 20)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 2), ws.Cell(row, 6)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; diff --git a/Controllers/RoTwo.Controller.cs b/Controllers/RoTwo.Controller.cs new file mode 100644 index 0000000..5f4fa44 --- /dev/null +++ b/Controllers/RoTwo.Controller.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using FastReport; +using FastReport.Export.OoXML; +using FastReport.Export.Pdf; +using Microsoft.AspNetCore.Mvc; +using rmutr_report.Models; +using rmutr_report.Models.Personnel; +using rmutr_report.Models.RoThree; +using Swashbuckle.AspNetCore.Annotations; + +namespace rmutr_report.Controllers +{ + [SwaggerTag("สำหรับรายงาน ร.2 คำขอชี้แจงงบบุคลากร")] + + public class RoTwo : Controller + { + readonly Setting _setting; + + public RoTwo(Setting setting) + { + this._setting = setting; + } + + [HttpPost, Route("reports/personnel_statement/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetRoThreeReport([FromRoute] string type, [FromBody] personnel_statement personnel_statements) + { + int no = 1; + int no_2 = 1; + foreach (var personnelStatementDetail in personnel_statements.personnel_statement_details) + { + personnelStatementDetail.start_dates = + personnelStatementDetail.start_date.Value.ToString("dd/MM/yyyy", + CultureInfo.CreateSpecificCulture("th-TH")); + if (personnelStatementDetail.topic_type == 2) + { + personnelStatementDetail.row_no = no; + no++; + } + } + foreach (var personnelStatementDetail2 in personnel_statements.personnel_statement_details_2) + { + personnelStatementDetail2.start_dates = + personnelStatementDetail2.start_date.Value.ToString("dd/MM/yyyy", + CultureInfo.CreateSpecificCulture("th-TH")); + if (personnelStatementDetail2.topic_type == 2) + { + personnelStatementDetail2.row_no = no_2; + no_2++; + } + } + var personnelstatements = new List() { personnel_statements }; + + Report report = new Report(); + report.Load(_setting.report_path + "personnel_statement.frx"); + report.RegisterData(personnelstatements, "personnel_statement"); + report.Prepare(); + + MemoryStream stream = new MemoryStream(); + switch (type) + { + case "pdf": + PDFExport pdf = new PDFExport(); + report.Export(pdf, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "application/pdf"); + case "xls": + case "xlsx": + Excel2007Export excel = new Excel2007Export(); + report.Export(excel, stream); + stream.Seek(0, SeekOrigin.Begin); + //return File(stream, "application/vnd.ms-excel"); + string date = DateTime.Now.ToString("yyyyMMddHHmmss"); + return File( + stream, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "personnel_statement_"+date + ".xlsx"); + break; + case "doc": + case "docx": + Word2007Export word = new Word2007Export(); + report.Export(word, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "appllication/vnd.ms-word"); + break; + } + + return Ok(); + } + } +} \ No newline at end of file diff --git a/Models/Personnel/personnel_statement.cs b/Models/Personnel/personnel_statement.cs index af3e28e..dc4bcb8 100644 --- a/Models/Personnel/personnel_statement.cs +++ b/Models/Personnel/personnel_statement.cs @@ -36,6 +36,7 @@ namespace rmutr_report.Models.Personnel public string major { get; set; } public string qualification { get; set; } public DateTime? start_date { get; set; } + public string start_dates { get; set; } public decimal? salary_rate { get; set; } public decimal? increase_cost_of_living { get; set; } public decimal? social_security { get; set; } @@ -44,6 +45,10 @@ namespace rmutr_report.Models.Personnel public decimal? total_expenses_per_year { get; set; } public string department { get; set; } + public int? row_no { get; set; } + public int? topic_type { get; set; } + + } public class t_personnel_statement_detail_2 @@ -57,6 +62,7 @@ namespace rmutr_report.Models.Personnel public string major { get; set; } public string qualification { get; set; } public DateTime? start_date { get; set; } + public string start_dates { get; set; } public decimal? salary_rate { get; set; } public decimal? increase_cost_of_living { get; set; } public decimal? social_security { get; set; } @@ -66,5 +72,8 @@ namespace rmutr_report.Models.Personnel public string department { get; set; } public int? row { get; set; } + public int? row_no { get; set; } + public int? topic_type { get; set; } + } } \ No newline at end of file diff --git a/bin/Debug/netcoreapp3.1/rmutr_report.dll b/bin/Debug/netcoreapp3.1/rmutr_report.dll index c08051c..ad73ed7 100644 Binary files a/bin/Debug/netcoreapp3.1/rmutr_report.dll and b/bin/Debug/netcoreapp3.1/rmutr_report.dll differ diff --git a/bin/Debug/netcoreapp3.1/rmutr_report.pdb b/bin/Debug/netcoreapp3.1/rmutr_report.pdb index a1844a4..5047d1b 100644 Binary files a/bin/Debug/netcoreapp3.1/rmutr_report.pdb and b/bin/Debug/netcoreapp3.1/rmutr_report.pdb differ diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache b/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache index 5c40ad4..a201456 100644 --- a/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache +++ b/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -fbfa60e7aec45c4984e6c01a01c1f94c28233dde +6b38d80c42c7701c621aeb86361ccf2c1087d190 diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.dll b/obj/Debug/netcoreapp3.1/rmutr_report.dll index c08051c..ad73ed7 100644 Binary files a/obj/Debug/netcoreapp3.1/rmutr_report.dll and b/obj/Debug/netcoreapp3.1/rmutr_report.dll differ diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.pdb b/obj/Debug/netcoreapp3.1/rmutr_report.pdb index a1844a4..5047d1b 100644 Binary files a/obj/Debug/netcoreapp3.1/rmutr_report.pdb and b/obj/Debug/netcoreapp3.1/rmutr_report.pdb differ diff --git a/wwwroot/reports/personnel_statement.frx b/wwwroot/reports/personnel_statement.frx new file mode 100644 index 0000000..970b190 --- /dev/null +++ b/wwwroot/reports/personnel_statement.frx @@ -0,0 +1,437 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +