diff --git a/Controllers/RequestProjectBudget.Controller.cs b/Controllers/RequestProjectBudget.Controller.cs new file mode 100644 index 0000000..e9227ea --- /dev/null +++ b/Controllers/RequestProjectBudget.Controller.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using ClosedXML.Excel; +using FastReport; +using FastReport.Export.Csv; +using FastReport.Export.Mht; +using FastReport.Export.OoXML; +using FastReport.Export.Pdf; +using Microsoft.AspNetCore.Mvc; +using rmutr_report.Models; +using Swashbuckle.AspNetCore.Annotations; + +namespace rmutr_report.Controllers +{ + [SwaggerTag("สำหรับรายงาน ง.5-1")] + public class RequestProjectBudget: Controller + { + readonly Setting _setting; + + public RequestProjectBudget(Setting setting) + { + this._setting = setting; + } + [HttpPost, Route("reports/request_project_budget/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetRequestProjectBudgetReport([FromRoute] string type, [FromBody] request_project_budget project) + { + + // foreach (var v in project.five) + // { + // string na = "ประเด็นยุทธศาสตร์ที่ " ; + // v.strategic_issues = na + v.strategic_issues; + // string na2 = "กลยุทธ์ที่ " ; + // v.measure = na2 + v.measure; + // } + // foreach (var v in project.eleventh) + // { + // foreach (var vv in v.elevenths) + // { + // string na = "ครั้งที่ "; + // vv.the_time = na + vv.the_time; + // } + // } + + var _project = new List() {project}; + + Report report = new Report(); + report.Load(_setting.report_path + "request_project_budget.frx"); + report.RegisterData(_project, "request_project_budget"); + 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"); + break; + 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", + 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/budget/request_project_budget.cs b/Models/budget/request_project_budget.cs new file mode 100644 index 0000000..a3d9338 --- /dev/null +++ b/Models/budget/request_project_budget.cs @@ -0,0 +1,146 @@ +using System.Collections.Generic; + +namespace rmutr_report.Models +{ + public class request_project_budget + { + public string budget_year { get; set; } + public string allocate_year { get; set; } + public string request_year { get; set; } + public List data_1 { get; set; } + } + + public class request_project_budget1 + { + public string faculty_name_th { get; set; } + public decimal? compensation { get; set; } + public decimal? cost { get; set; } + public decimal? material_cost { get; set; } + public decimal? total_amount { get; set; } + public decimal? project_amount { get; set; } + public decimal? allocate_amount { get; set; } + public decimal? request_amount { get; set; } + public decimal? online { get; set; } + public decimal? onsite { get; set; } + public List data_2 { get; set; } + } + public class request_project_budget2{ + public string list { get; set; } + public string project_objectives { get; set; } + public string target_group { get; set; } + public string kpi { get; set; } + public string target_sdg { get; set; } + public decimal? compensation { get; set; } + public decimal? cost { get; set; } + public decimal? material_cost { get; set; } + public decimal? total_amount { get; set; } + public string period { get; set; } + public decimal? project_amount { get; set; } + public string target_1 { get; set; } + public string target_2 { get; set; } + public string target_3 { get; set; } + public string target_4 { get; set; } + public string target_5 { get; set; } + public string target_6 { get; set; } + public string unit { get; set; } + public decimal? unit_amount { get; set; } + public decimal? allocate_amount { get; set; } + public decimal? request_amount { get; set; } + public decimal? online { get; set; } + public decimal? onsite { get; set; } + public string budget_source { get; set; } + public string remark { get; set; } + public List data_3 { get; set; } + + } + + public class request_project_budget3 + { + public string list { get; set; } + public string project_objectives { get; set; } + public string target_group { get; set; } + public string kpi { get; set; } + public string target_sdg { get; set; } + public decimal? compensation { get; set; } + public decimal? cost { get; set; } + public decimal? material_cost { get; set; } + public decimal? total_amount { get; set; } + public string period { get; set; } + public decimal? project_amount { get; set; } + public string target_1 { get; set; } + public string target_2 { get; set; } + public string target_3 { get; set; } + public string target_4 { get; set; } + public string target_5 { get; set; } + public string target_6 { get; set; } + public string unit { get; set; } + public decimal? unit_amount { get; set; } + public decimal? allocate_amount { get; set; } + public decimal? request_amount { get; set; } + public decimal? online { get; set; } + public decimal? onsite { get; set; } + public string budget_source { get; set; } + public string remark { get; set; } + public List data_4 { get; set; } + + } + + public class request_project_budget4 + { + public string list { get; set; } + public string project_objectives { get; set; } + public string target_group { get; set; } + public string kpi { get; set; } + public string target_sdg { get; set; } + public decimal? compensation { get; set; } + public decimal? cost { get; set; } + public decimal? material_cost { get; set; } + public decimal? total_amount { get; set; } + public string period { get; set; } + public decimal? project_amount { get; set; } + public string target_1 { get; set; } + public string target_2 { get; set; } + public string target_3 { get; set; } + public string target_4 { get; set; } + public string target_5 { get; set; } + public string target_6 { get; set; } + public string unit { get; set; } + public decimal? unit_amount { get; set; } + public decimal? allocate_amount { get; set; } + public decimal? request_amount { get; set; } + public decimal? online { get; set; } + public decimal? onsite { get; set; } + public string budget_source { get; set; } + public string remark { get; set; } + public List data_5 { get; set; } + } + + public class request_project_budget5 + { + public string list { get; set; } + public string project_objectives { get; set; } + public string target_group { get; set; } + public string kpi { get; set; } + public string target_sdg { get; set; } + public decimal? compensation { get; set; } + public decimal? cost { get; set; } + public decimal? material_cost { get; set; } + public decimal? total_amount { get; set; } + public string period { get; set; } + public decimal? project_amount { get; set; } + public string target_1 { get; set; } + public string target_2 { get; set; } + public string target_3 { get; set; } + public string target_4 { get; set; } + public string target_5 { get; set; } + public string target_6 { get; set; } + public string unit { get; set; } + public decimal? unit_amount { get; set; } + public decimal? allocate_amount { get; set; } + public decimal? request_amount { get; set; } + public decimal? online { get; set; } + public decimal? onsite { get; set; } + public string budget_source { get; set; } + public string remark { 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 c059bce..f3ce322 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 9e3f3a1..e979931 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 1a94141..3d71ee0 100644 --- a/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache +++ b/obj/Debug/netcoreapp3.1/rmutr_report.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -c72c85eb313e56d69a393160878d05d03a62510b +159b9fce7386fddadb57d3e23712e888757a9066 diff --git a/obj/Debug/netcoreapp3.1/rmutr_report.dll b/obj/Debug/netcoreapp3.1/rmutr_report.dll index c059bce..f3ce322 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 9e3f3a1..e979931 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/request_project_budget.frx b/wwwroot/reports/request_project_budget.frx new file mode 100644 index 0000000..19ba0e8 --- /dev/null +++ b/wwwroot/reports/request_project_budget.frx @@ -0,0 +1,571 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +