using System; using System.Collections.Generic; using System.IO; using System.Linq; using ClosedXML.Excel; using FastReport; 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("สำหรับรายงานงบแผ่นดิน")] public class governmentBudget : Controller { readonly Setting _setting; public governmentBudget(Setting setting) { this._setting = setting; } [SwaggerOperation("รับเงินแผ่นดิน")] [HttpPost, Route("reports/receive_government/{type}")] //รับเงินแผ่นดิน [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetGovernmentBudgetReport([FromRoute] string type, [FromBody] receive_government receiveGovernments) { var governments = new List() { receiveGovernments }; Report report = new Report(); report.Load(_setting.report_path + "receive_government.frx"); report.RegisterData(governments, "receive_government"); 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", "receive_government_" + date + ".xlsx"); case "doc": case "docx": Word2007Export word = new Word2007Export(); report.Export(word, stream); stream.Seek(0, SeekOrigin.Begin); return File(stream, "appllication/vnd.ms-word"); } return Ok(); } [SwaggerOperation("การจัดสรรงบประมาณแผ่นดินรวมทุกแผนงาน, แผนงานบุคลากร, พื้นฐาน+ยุทธศาตร์")] [HttpPost, Route("reports/budget_government_allocate/{type}")] // (พื้นฐาน+ยุทธศาตร์) [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetInStrAllocateReport([FromRoute] string type, [FromBody] budget_government_allocate allocate) { var workbook = new XLWorkbook(); var ws = workbook.Worksheets.Add("การจัดสรรงบประมาณแผ่นดิน"); ws.Range("A1:S1").Merge().Value = "การจัดสรรงบประมาณแผ่นดิน ปีงบประมาณ พ.ศ. " + allocate.budget_year + " (" + allocate.report_name + ")"; //" (แผนงาน พื้นฐาน และ แผนงาน ยุทธศาสตร์ฯ)"; ws.Range("A1:S1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("A1:S1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("A1:S1").Style.Font.FontName = "TH SarabunPSK"; ws.Range("A1:S1").Style.Font.FontSize = 16; ws.Range("A1:S1").Style.Font.Bold = true; ws.Range("A2:S2").Merge().Value = "มหาวิทยาลัยเทคโนโลยีราชมงคลรัตนโกสินทร์"; ws.Range("A2:S2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("A2:S2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("A2:S2").Style.Font.FontName = "TH SarabunPSK"; ws.Range("A2:S2").Style.Font.FontSize = 16; ws.Range("A2:S2").Style.Font.Bold = true; ws.Column(1).Width = 40; ws.Column(2).Width = 15; ws.Column(3).Width = 15; ws.Column(4).Width = 15; ws.Column(5).Width = 15; ws.Column(6).Width = 15; ws.Column(7).Width = 15; ws.Column(8).Width = 15; ws.Column(9).Width = 15; ws.Column(10).Width = 15; ws.Column(11).Width = 15; ws.Column(12).Width = 15; ws.Column(13).Width = 15; ws.Column(14).Width = 15; ws.Column(15).Width = 15; ws.Column(16).Width = 15; ws.Column(17).Width = 15; ws.Column(18).Width = 15; ws.Column(19).Width = 15; int row = 8; //int no = 1; ws.Cell("A3").Value = "แผนงาน / ผลผลิต / กิจกรรม"; ws.Cell("A3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("A3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("A3").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("A3").Style.Font.SetBold().Font.FontSize = 16; //ws.Range("A3:A5").Style.Fill.BackgroundColor = XLColor.FromArgb(255, 153, 204); ws.Range("A3:A5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("A5").Value = "หน่วยงาน"; ws.Cell("A5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("A5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("A5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("A5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("A5").Style.Alignment.WrapText = true; ws.Range("B3:E4").Merge().Value = "งบบุคลากร"; ws.Range("B3:E4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("B3:E4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("B3:E4").Style.Font.FontName = "TH SarabunPSK"; ws.Range("B3:E4").Style.Font.SetBold().Font.FontSize = 16; ws.Range("B3:E4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("B5").Value = "เงินเดือน"; ws.Cell("B5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("B5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("B5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("B5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("B5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("C5").Value = "ค่าจ้างประจำ"; ws.Cell("C5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("C5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("C5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("C5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("C5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("D5").Value = "ค่าจ้างชั่วคราว"; ws.Cell("D5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("D5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("D5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("D5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("D5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("E5").Value = "พนักงานราชการ"; ws.Cell("E5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("E5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("E5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("E5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("E5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("F3:I4").Merge().Value = "งบดำเนินงาน"; ws.Range("F3:I4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("F3:I4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("F3:I4").Style.Font.FontName = "TH SarabunPSK"; ws.Range("F3:I4").Style.Font.SetBold().Font.FontSize = 16; ws.Range("F3:I4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("F5").Value = "ค่าตอบแทน"; ws.Cell("F5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("F5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("F5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("F5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("F5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("G5").Value = "ค่าใช้สอย"; ws.Cell("G5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("G5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("G5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("G5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("G5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("H5").Value = "ค่าวัสดุ"; ws.Cell("H5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("H5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("H5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("H5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("H5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("I5").Value = "ค่าสาธารณูปโภค"; ws.Cell("I5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("I5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("I5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("I5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("I5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("J3:K4").Merge().Value = "งบลงทุน"; ws.Range("J3:K4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("J3:K4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("J3:K4").Style.Font.FontName = "TH SarabunPSK"; ws.Range("J3:K4").Style.Font.SetBold().Font.FontSize = 16; ws.Range("J3:K4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("J5").Value = "ค่าครุภัณฑ์"; ws.Cell("J5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("J5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("J5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("J5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("J5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("K5").Value = "ที่ดิน สิ่งก่อสร้าง"; ws.Cell("K5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("K5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("K5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("K5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("K5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("L3:R3").Merge().Value = "งบเงินอุดหนุน"; ws.Range("L3:R3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("L3:R3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("L3:R3").Style.Font.FontName = "TH SarabunPSK"; ws.Range("L3:R3").Style.Font.SetBold().Font.FontSize = 16; ws.Range("L3:R3").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("L4:L5").Merge().Value = "เงินอุดหนุนค่าใช้จ่ายบุคลากร"; ws.Range("L4:L5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("L4:L5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("L4:L5").Style.Font.FontName = "TH SarabunPSK"; ws.Range("L4:L5").Style.Font.SetBold().Font.FontSize = 16; ws.Range("L4:L5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("M4:M5").Merge().Value = "เงินอุดหนุนค่าใช้จ่ายโครงการ"; ws.Range("M4:M5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("M4:M5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("M4:M5").Style.Font.FontName = "TH SarabunPSK"; ws.Range("M4:M5").Style.Font.SetBold().Font.FontSize = 16; ws.Range("M4:M5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("N4:R4").Merge().Value = "ค่าใช้จ่ายดำเนินงาน"; ws.Range("N4:R4").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("N4:R4").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("N4:R4").Style.Font.FontName = "TH SarabunPSK"; ws.Range("N4:R4").Style.Font.SetBold().Font.FontSize = 16; ws.Range("N4:R4").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("N5").Value = "ค่าตอบแทน"; ws.Cell("N5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("N5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("N5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("N5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("N5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("O5").Value = "ค่าใช้สอย"; ws.Cell("O5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("O5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("O5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("O5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("O5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("P5").Value = "ค่าวัสดุ"; ws.Cell("P5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("P5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("P5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("P5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("P5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("Q5").Value = "ค่าสาธารณูปโภค"; ws.Cell("Q5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("Q5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("Q5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("Q5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("Q5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("R5").Value = "ค่าใช้จ่ายดำเนินงานอื่นๆ"; ws.Cell("R5").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("R5").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("R5").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("R5").Style.Font.SetBold().Font.FontSize = 16; ws.Cell("R5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("S3").Value = "รวมทั้งสิ้น"; ws.Cell("S3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell("S3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Cell("S3").Style.Font.FontName = "TH SarabunPSK"; ws.Cell("S3").Style.Font.SetBold().Font.FontSize = 16; ws.Range("S3:S5").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("A6:A7").Merge().Value = "รวมทั้งสิ้น"; ws.Range("A6:A7").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range("A6:A7").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range("A6:A7").Style.Font.FontName = "TH SarabunPSK"; ws.Range("A6:A7").Style.Font.SetBold().Font.FontSize = 16; ws.Range("A6:A7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("B6:E6").Merge().Value = allocate.total_budget_personnel; ws.Range("F6:I6").Merge().Value = allocate.total_budget_operating; ws.Range("J6:K6").Merge().Value = allocate.total_budget_investment; ws.Cell("L6").Value = allocate.total_personnel_expense; ws.Cell("M6").Value = allocate.total_project_expense; ws.Range("N6:Q6").Merge().Value = allocate.total_operating_expenses; ws.Cell("R6").Value = allocate.total_other_operating_expenses; ws.Cell("S6").Value = allocate.total_budget; ws.Range("B6:E6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("F6:I6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("J6:K6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range("N6:Q6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("L6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("M6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("R6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("S6").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(6, 1), ws.Cell(7, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 204, 255); ws.Range(ws.Cell(6, 1), ws.Cell(7, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(6, 1), ws.Cell(7, 19)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(6, 1), ws.Cell(7, 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(6, 1), ws.Cell(7, 19)).Style.Font.SetBold().Font.FontSize = 16; //ws.Range(ws.Cell(5, 2), ws.Cell(5, 11)).Style.Font.FontColor = XLColor.Blue; ws.Range(ws.Cell(6, 1), ws.Cell(7, 19)).Style.NumberFormat.SetFormat("#,#"); ws.Cell("B7").Value = allocate.salary_person; ws.Cell("C7").Value = allocate.regular_wages_person; ws.Cell("D7").Value = allocate.temporary_wages_person; ws.Cell("E7").Value = allocate.government_employee; ws.Cell("F7").Value = allocate.compensation_operating_budget; ws.Cell("G7").Value = allocate.cost_operating_budget; ws.Cell("H7").Value = allocate.material_cost_operating_budget; ws.Cell("I7").Value = allocate.utility_bill_operating_budget; ws.Cell("J7").Value = allocate.cost_equipment; ws.Cell("K7").Value = allocate.land_building; ws.Cell("N7").Value = allocate.compensation_operating_expenses; ws.Cell("O7").Value = allocate.cost_operating_expenses; ws.Cell("P7").Value = allocate.material_cost_operating_expenses; ws.Cell("Q7").Value = allocate.utility_bill_operating_expenses; ws.Cell("B7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("C7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("D7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("E7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("F7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("G7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("H7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("I7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("J7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("K7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("N7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("O7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("P7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("Q7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell("S7").Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(3, 1), ws.Cell(5, 19)).Style.Alignment.WrapText = true; foreach (var detail in allocate.data_1) { if (detail.color == 1) // แผนงาน สีเหลือง { ws.Range(ws.Cell(row, 1), ws.Cell(row + 1, 1)).Merge().Value = detail.list; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Merge().Value = detail.total_budget_personnel; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Merge().Value = detail.total_budget_operating; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Merge().Value = detail.total_budget_investment; ws.Cell(row, 12).Value = detail.total_personnel_expense; ws.Cell(row, 13).Value = detail.total_project_expense; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Merge().Value = detail.total_operating_expenses; ws.Cell(row, 18).Value = detail.total_other_operating_expenses; ws.Cell(row, 19).Value = detail.total_budget; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 183); ws.Cell(row, 9).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 12).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (detail.color == 2) // โครงการ สีฟ้าอ่อน { ws.Cell(row, 1).Value = detail.list; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Merge().Value = detail.total_budget_personnel; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Merge().Value = detail.total_budget_operating; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Merge().Value = detail.total_budget_investment; ws.Cell(row, 12).Value = detail.total_personnel_expense; ws.Cell(row, 13).Value = detail.total_project_expense; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Merge().Value = detail.total_operating_expenses; ws.Cell(row, 18).Value = detail.total_other_operating_expenses; ws.Cell(row, 19).Value = detail.total_budget; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(218, 238, 243); ws.Cell(row, 9).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 12).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (detail.color == 3) // ชื่อคณะ สีแดงอ่อน { ws.Range(ws.Cell(row, 1), ws.Cell(row + 1, 1)).Merge().Value = detail.list; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Merge().Value = detail.total_budget_personnel; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Merge().Value = detail.total_budget_operating; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Merge().Value = detail.total_budget_investment; ws.Cell(row, 12).Value = detail.total_personnel_expense; ws.Cell(row, 13).Value = detail.total_project_expense; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Merge().Value = detail.total_operating_expenses; ws.Cell(row, 18).Value = detail.total_other_operating_expenses; ws.Cell(row, 19).Value = detail.total_budget; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 204, 204); ws.Cell(row, 9).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 12).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (detail.color == 5) // ชื่อคณะ สีขาว { ws.Cell(row, 1).Value = "'- " + detail.list; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Merge().Value = detail.total_budget_personnel; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Merge().Value = detail.total_budget_operating; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Merge().Value = detail.total_budget_investment; ws.Cell(row, 12).Value = detail.total_personnel_expense; ws.Cell(row, 13).Value = detail.total_project_expense; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Merge().Value = detail.total_operating_expenses; ws.Cell(row, 18).Value = detail.total_other_operating_expenses; ws.Cell(row, 19).Value = detail.total_budget; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 9).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 12).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.BottomBorder = XLBorderStyleValues.None; ws.Cell(row, 1).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } if (detail.color == 4) // ชื่อย่อยคณะ สีเทาอ่อน { ws.Range(ws.Cell(row, 1), ws.Cell(row + 1, 1)).Merge().Value = detail.list; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Merge().Value = detail.total_budget_personnel; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Merge().Value = detail.total_budget_operating; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Merge().Value = detail.total_budget_investment; ws.Cell(row, 12).Value = detail.total_personnel_expense; ws.Cell(row, 13).Value = detail.total_project_expense; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Merge().Value = detail.total_operating_expenses; ws.Cell(row, 18).Value = detail.total_other_operating_expenses; ws.Cell(row, 19).Value = detail.total_budget; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(237, 235, 249); ws.Cell(row, 9).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 12).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; row++; } if (detail.color == 6) // ชื่อย่อยคณะ+พื้นที่ สีขาว { ws.Cell(row, 1).Value = "'- " + detail.list; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Merge().Value = detail.total_budget_personnel; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Merge().Value = detail.total_budget_operating; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Merge().Value = detail.total_budget_investment; ws.Cell(row, 12).Value = detail.total_personnel_expense; ws.Cell(row, 13).Value = detail.total_project_expense; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Merge().Value = detail.total_operating_expenses; ws.Cell(row, 18).Value = detail.total_other_operating_expenses; ws.Cell(row, 19).Value = detail.total_budget; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Cell(row, 9).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 12).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.BottomBorder = XLBorderStyleValues.None; ws.Cell(row, 1).Style.Border.LeftBorder = XLBorderStyleValues.Thin; row++; } foreach (var detail2 in detail.data_2) { if (detail2.color == 1) //สีเหลือง { ws.Cell(row, 2).Value = detail2.salary_person; ws.Cell(row, 3).Value = detail2.regular_wages_person; ws.Cell(row, 4).Value = detail2.temporary_wages_person; ws.Cell(row, 5).Value = detail2.government_employee; ws.Cell(row, 6).Value = detail2.compensation_operating_budget; ws.Cell(row, 7).Value = detail2.cost_operating_budget; ws.Cell(row, 8).Value = detail2.material_cost_operating_budget; ws.Cell(row, 9).Value = detail2.utility_bill_operating_budget; ws.Cell(row, 10).Value = detail2.cost_equipment; ws.Cell(row, 11).Value = detail2.land_building; ws.Cell(row, 14).Value = detail2.compensation_operating_expenses; ws.Cell(row, 15).Value = detail2.cost_operating_expenses; ws.Cell(row, 16).Value = detail2.material_cost_operating_expenses; ws.Cell(row, 17).Value = detail2.utility_bill_operating_expenses; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 255, 183); ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (detail2.color == 2) // ชื่อกิจกรรม สีฟ้าอ่อน { ws.Cell(row, 1).Value = detail2.list; ws.Cell(row, 2).Value = detail2.salary_person; ws.Cell(row, 3).Value = detail2.regular_wages_person; ws.Cell(row, 4).Value = detail2.temporary_wages_person; ws.Cell(row, 5).Value = detail2.government_employee; ws.Cell(row, 6).Value = detail2.compensation_operating_budget; ws.Cell(row, 7).Value = detail2.cost_operating_budget; ws.Cell(row, 8).Value = detail2.material_cost_operating_budget; ws.Cell(row, 9).Value = detail2.utility_bill_operating_budget; ws.Cell(row, 10).Value = detail2.cost_equipment; ws.Cell(row, 11).Value = detail2.land_building; ws.Cell(row, 14).Value = detail2.compensation_operating_expenses; ws.Cell(row, 15).Value = detail2.cost_operating_expenses; ws.Cell(row, 16).Value = detail2.material_cost_operating_expenses; ws.Cell(row, 17).Value = detail2.utility_bill_operating_expenses; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(218, 238, 243); ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Font.FontColor = XLColor.Red; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (detail2.color == 3) // ชื่อคณะ สีแดงอ่อน { ws.Cell(row, 1).Value = null; ws.Cell(row, 2).Value = detail2.salary_person; ws.Cell(row, 3).Value = detail2.regular_wages_person; ws.Cell(row, 4).Value = detail2.temporary_wages_person; ws.Cell(row, 5).Value = detail2.government_employee; ws.Cell(row, 6).Value = detail2.compensation_operating_budget; ws.Cell(row, 7).Value = detail2.cost_operating_budget; ws.Cell(row, 8).Value = detail2.material_cost_operating_budget; ws.Cell(row, 9).Value = detail2.utility_bill_operating_budget; ws.Cell(row, 10).Value = detail2.cost_equipment; ws.Cell(row, 11).Value = detail2.land_building; ws.Cell(row, 14).Value = detail2.compensation_operating_expenses; ws.Cell(row, 15).Value = detail2.cost_operating_expenses; ws.Cell(row, 16).Value = detail2.material_cost_operating_expenses; ws.Cell(row, 17).Value = detail2.utility_bill_operating_expenses; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(255, 204, 204); ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (detail2.color == 5) // ชื่อคณะ สีขาว detail { ws.Cell(row, 1).Value = null; ws.Cell(row, 2).Value = detail2.salary_person; ws.Cell(row, 3).Value = detail2.regular_wages_person; ws.Cell(row, 4).Value = detail2.temporary_wages_person; ws.Cell(row, 5).Value = detail2.government_employee; ws.Cell(row, 6).Value = detail2.compensation_operating_budget; ws.Cell(row, 7).Value = detail2.cost_operating_budget; ws.Cell(row, 8).Value = detail2.material_cost_operating_budget; ws.Cell(row, 9).Value = detail2.utility_bill_operating_budget; ws.Cell(row, 10).Value = detail2.cost_equipment; ws.Cell(row, 11).Value = detail2.land_building; ws.Cell(row, 14).Value = detail2.compensation_operating_expenses; ws.Cell(row, 15).Value = detail2.cost_operating_expenses; ws.Cell(row, 16).Value = detail2.material_cost_operating_expenses; ws.Cell(row, 17).Value = detail2.utility_bill_operating_expenses; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.TopBorder = XLBorderStyleValues.None; ws.Cell(row, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (detail2.color == 4) // ชื่อย่อยคณะ สีเทาอ่อน { ws.Cell(row, 1).Value = null; ws.Cell(row, 2).Value = detail2.salary_person; ws.Cell(row, 3).Value = detail2.regular_wages_person; ws.Cell(row, 4).Value = detail2.temporary_wages_person; ws.Cell(row, 5).Value = detail2.government_employee; ws.Cell(row, 6).Value = detail2.compensation_operating_budget; ws.Cell(row, 7).Value = detail2.cost_operating_budget; ws.Cell(row, 8).Value = detail2.material_cost_operating_budget; ws.Cell(row, 9).Value = detail2.utility_bill_operating_budget; ws.Cell(row, 10).Value = detail2.cost_equipment; ws.Cell(row, 11).Value = detail2.land_building; ws.Cell(row, 14).Value = detail2.compensation_operating_expenses; ws.Cell(row, 15).Value = detail2.cost_operating_expenses; ws.Cell(row, 16).Value = detail2.material_cost_operating_expenses; ws.Cell(row, 17).Value = detail2.utility_bill_operating_expenses; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Fill.BackgroundColor = XLColor.FromArgb(237, 235, 249); ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } if (detail2.color == 6) // ชื่อย่อยคณะ+พื้นที่ สีขาว detail { ws.Cell(row, 1).Value = null; ws.Cell(row, 2).Value = detail2.salary_person; ws.Cell(row, 3).Value = detail2.regular_wages_person; ws.Cell(row, 4).Value = detail2.temporary_wages_person; ws.Cell(row, 5).Value = detail2.government_employee; ws.Cell(row, 6).Value = detail2.compensation_operating_budget; ws.Cell(row, 7).Value = detail2.cost_operating_budget; ws.Cell(row, 8).Value = detail2.material_cost_operating_budget; ws.Cell(row, 9).Value = detail2.utility_bill_operating_budget; ws.Cell(row, 10).Value = detail2.cost_equipment; ws.Cell(row, 11).Value = detail2.land_building; ws.Cell(row, 14).Value = detail2.compensation_operating_expenses; ws.Cell(row, 15).Value = detail2.cost_operating_expenses; ws.Cell(row, 16).Value = detail2.material_cost_operating_expenses; ws.Cell(row, 17).Value = detail2.utility_bill_operating_expenses; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = "TH SarabunPSK"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.SetBold().Font.FontSize = 16; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.WrapText = true; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.NumberFormat.SetFormat("#,#0"); ws.Range(ws.Cell(row, 2), ws.Cell(row, 19)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; ws.Range(ws.Cell(row, 2), ws.Cell(row, 5)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 6), ws.Cell(row, 9)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 10), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 2), ws.Cell(row, 11)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Range(ws.Cell(row, 14), ws.Cell(row, 17)).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 1).Style.Border.TopBorder = XLBorderStyleValues.None; ws.Cell(row, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thin; ws.Cell(row, 13).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 18).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 19).Style.Border.RightBorder = XLBorderStyleValues.Thin; ws.Cell(row, 2).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 3).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 4).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 5).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 6).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 7).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 8).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 9).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 10).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 11).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 14).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 15).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 16).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; ws.Cell(row, 17).Style.Border.OutsideBorder = XLBorderStyleValues.Thin; row++; } } } using (var stream1 = new MemoryStream()) { workbook.SaveAs(stream1); var content = stream1.ToArray(); return File( content, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "budget_government_allocate" + ".xlsx"); } } [SwaggerOperation("1 รายการวัสดุ 2 รายการค่าใช้สอย")] [HttpPost, Route("reports/national_budget_list/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetNationalBudgetListReport([FromRoute] string type, [FromBody] national_budget_list _nationalBudgetList) { string item = "รายการวัสดุ (คำของบประมาณรายจ่าย ปี "; string item2 = "รายการค่าใช้สอย (คำของบประมาณรายจ่าย ปี "; if (_nationalBudgetList.report_type == 1) { _nationalBudgetList.budget_year = item + _nationalBudgetList.budget_year + ")"; foreach (var detail in _nationalBudgetList.data) { if (detail != null) { detail.total_amount = (detail.quantity * detail.unit_price); } } } if (_nationalBudgetList.report_type == 2) { _nationalBudgetList.budget_year = item2 + _nationalBudgetList.budget_year + ")"; foreach (var detail in _nationalBudgetList.data) { if (detail != null) { detail.total_amount = (detail.quantity * detail.unit_price*detail.quantity_month); } } } var nationalBudgetLists = new List() { _nationalBudgetList }; Report report = new Report(); if (_nationalBudgetList.report_type == 2) { report.Load(_setting.report_path + "national_budget_list_type2.frx"); report.RegisterData(nationalBudgetLists, "national_budget_list"); report.Prepare(); MemoryStream stream1 = new MemoryStream(); switch (type) { case "pdf": PDFExport pdf = new PDFExport(); report.Export(pdf, stream1); stream1.Seek(0, SeekOrigin.Begin); return File(stream1, "application/pdf"); case "xls": case "xlsx": Excel2007Export excel = new Excel2007Export(); report.Export(excel, stream1); stream1.Seek(0, SeekOrigin.Begin); return File( stream1, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ค่าเช่าทรัพย์สิน" + ".xlsx"); } } if (_nationalBudgetList.report_type == 1) { report.Load(_setting.report_path + "national_budget_list.frx"); report.RegisterData(nationalBudgetLists, "national_budget_list"); 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.openxmlformats-officedocument.spreadsheetml.sheet", "ค่าคณะกรรมการตรวจสอบพัสดุในงานจ้างก่อสร้าง" + ".xlsx"); } } return Ok(); } [SwaggerOperation("ค่าประกันภัยรถยนต์ราชการ")] [HttpPost, Route("reports/budget_progress_insurances/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetInsurancesListReport([FromRoute] string type, [FromBody] budget_progress_insurances insurances) { foreach (var detail in insurances.data) { if (detail != null) { detail.total_amount = (detail.amount + detail.car_act); } switch (detail.month) { case 1: detail.month_th = "มกราคม"; break; case 2: detail.month_th = "กุมภาพันธ์"; break; case 3: detail.month_th = "มีนาคม"; break; case 4: detail.month_th = "เมษายน"; break; case 5: detail.month_th = "พฤษภาคม"; break; case 6: detail.month_th = "มิถุนายน"; break; case 7: detail.month_th = "กรกฎาคม"; break; case 8: detail.month_th = "สิงหาคม"; break; case 9: detail.month_th = "กันยายน"; break; case 10: detail.month_th = "ตุลาคม"; break; case 11: detail.month_th = "พฤศจิกายน"; break; case 12: detail.month_th = "ธันวาคม"; break; } } var _insurances = new List() { insurances }; Report report = new Report(); report.Load(_setting.report_path + "budget_progress_insurances.frx"); report.RegisterData(_insurances, "budget_progress_insurances"); 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.openxmlformats-officedocument.spreadsheetml.sheet", "ค่าประกันภัยรถยนต์ราชการ" + ".xlsx"); } return Ok(); } [SwaggerOperation("ค่าคณะกรรมการตรวจสอบพัสดุในงานจ้างก่อสร้าง,ค่าคณะกรรมการอื่น ๆ")] [HttpPost, Route("reports/parcel_inspection_committee/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetCommitteeReport([FromRoute] string type, [FromBody] parcel_inspection_committee committee) { int no = 1; foreach (var data in committee.data) { data.list = "รายการ " + no; no++; foreach (var detail in data.data_detail) { if (detail != null) { data.total_amount = (detail.quantity * detail.quantity_person * detail.quantity_work * detail.amount); } } var s = committee.data.Sum(d => d.total_amount); committee.total_all_amount = s; } var _committees = new List() { committee }; Report report = new Report(); report.Load(_setting.report_path + "other_committee_fee.frx"); report.RegisterData(_committees, "parcel_inspection_committee"); 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.openxmlformats-officedocument.spreadsheetml.sheet", "national_budget_list" + ".xlsx"); } return Ok(); } [SwaggerOperation("ค่าจ้างให้บริการงานจ้างออกแบบ")] [HttpPost, Route("reports/design_services/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetDesignServicesReport([FromRoute] string type, [FromBody] parcel_inspection_committee committee) { int no = 1; string per = "%"; foreach (var data in committee.data) { data.list = "รายการ " + no; no++; foreach (var detail in data.data_detail) { if (detail != null) { detail.unit = detail.quantity_work + per; detail.amount = (detail.quantity * detail.quantity_person * detail.quantity_work) / 100; } } var total = data.data_detail.Sum(d => d.amount); data.total_amount = total; var s = committee.data.Sum(d => d.total_amount); committee.total_all_amount = s; } var _committees = new List() { committee }; Report report = new Report(); report.Load(_setting.report_path + "design_services.frx"); report.RegisterData(_committees, "parcel_inspection_committee"); 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.openxmlformats-officedocument.spreadsheetml.sheet", "ค่าจ้างให้บริการงานจ้างออกแบบ" + ".xlsx"); } return Ok(); } [SwaggerOperation("ค่าอาหารทำการนอกเวลา 1 วันทำการปกติ 2 วันหยุดราชการ")] [HttpPost, Route("reports/meal_costs_outside/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetDesignServicesReport([FromRoute] string type, [FromBody] meal_costs_outside mealCostsOutsides) { var meals = mealCostsOutsides.data.ToList(); if (mealCostsOutsides.topic_type == 1) { mealCostsOutsides.topic = "วันทำการปกติ"; } if (mealCostsOutsides.topic_type == 2) { mealCostsOutsides.topic = "วันหยุดราชการ"; } foreach (var detail in mealCostsOutsides.data) { detail.total_amount = (detail.day * detail.person * detail.amount); } mealCostsOutsides.day = mealCostsOutsides.data.Sum(d => d.day); mealCostsOutsides.person = mealCostsOutsides.data.Sum(d => d.person); mealCostsOutsides.amount = mealCostsOutsides.data.Sum(d => d.amount); mealCostsOutsides.total_amount = meals.Sum(f => f.total_amount); var meal = new List() { mealCostsOutsides }; Report report = new Report(); report.Load(_setting.report_path + "meal_costs_outside.frx"); report.RegisterData(meal, "meal_costs_outside"); 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.openxmlformats-officedocument.spreadsheetml.sheet", "ค่าอาหารทำการนอกเวลา" + ".xlsx"); } return Ok(); } [SwaggerOperation("ค่าเบี้ยเลี้ยง ที่พัก พาหนะ")] [HttpPost, Route("reports/expense/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetExpenseReport([FromRoute] string type, [FromBody] expense _expense) { var meals = _expense.data.ToList(); if (_expense.topic_type == 1) { _expense.topic = "ค่าเบี้ยเลี้ยง"; _expense.text_1 = "จำนวนเงิน/วัน"; _expense.text_2 = "จำนวน (วัน)"; foreach (var detail in _expense.data) { detail.total_amount = (detail.quantity_1 * detail.quantity_2 * detail.quantity_3 * detail.quantity_4); } } if (_expense.topic_type == 2) { _expense.topic = "ค่าเช่าที่พัก"; _expense.text_1 = "จำนวนเงิน/คน/คืน"; _expense.text_2 = "จำนวนวัน"; foreach (var detail in _expense.data) { detail.total_amount = (detail.quantity_1 * detail.quantity_2 * detail.quantity_3); } } if (_expense.topic_type == 3) { _expense.topic = "ค่าพาหนะ"; _expense.text_1 = "จำนวนเงิน"; _expense.text_2 = "จำนวนครั้ง"; foreach (var detail in _expense.data) { detail.total_amount = (detail.quantity_1 * detail.quantity_2 * detail.quantity_3); } } _expense.quantity_1 = _expense.data.Sum(d => d.quantity_1); _expense.quantity_2 = _expense.data.Sum(d => d.quantity_2); _expense.quantity_3 = _expense.data.Sum(d => d.quantity_3); _expense.quantity_4 = _expense.data.Sum(d => d.quantity_4); _expense.total_amount = meals.Sum(f => f.total_amount); var expenses = new List() { _expense }; Report report = new Report(); if (_expense.topic_type == 1) { report.Load(_setting.report_path + "expense_allowance.frx"); report.RegisterData(expenses, "expense"); report.Prepare(); MemoryStream stream1 = new MemoryStream(); switch (type) { case "pdf": PDFExport pdf = new PDFExport(); report.Export(pdf, stream1); stream1.Seek(0, SeekOrigin.Begin); return File(stream1, "application/pdf"); case "xls": case "xlsx": Excel2007Export excel = new Excel2007Export(); report.Export(excel, stream1); stream1.Seek(0, SeekOrigin.Begin); return File( stream1, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ค่าเบี้ยเลี้ยง" + ".xlsx"); } } if (_expense.topic_type != 1) { report.Load(_setting.report_path + "expense.frx"); report.RegisterData(expenses, "expense"); 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.openxmlformats-officedocument.spreadsheetml.sheet", "ค่าใช้สอย" + ".xlsx"); } } return Ok(); } [SwaggerOperation("แบบคำนวณค่าวัสดุการศึกษา")] [HttpPost, Route("reports/material_edu_cal_form/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetCalFormReport([FromRoute] string type, [FromBody] material_edu_cal_form calForm) { foreach (var data in calForm.data) { int row_no = 1; var total = data.data_detail.ToList(); foreach (var detail2 in data.data_detail) { if (detail2.topic_type == 2) { detail2.no = row_no.ToString(); row_no++; // detail2.total_amount_1 = detail2.amount_1*detail2.rate_1; // detail2.total_amount_2 = detail2.amount_2*detail2.rate_2; // detail2.total_all_amount = detail2.total_amount_1 + detail2.total_amount_2; } calForm.total_amount = calForm.data.Sum(d => d.amount); } } var _cal = new List() { calForm }; Report report = new Report(); report.Load(_setting.report_path + "material_edu_cal_form.frx"); report.RegisterData(_cal, "material_edu_cal_form"); 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.openxmlformats-officedocument.spreadsheetml.sheet", "แบบคำนวณค่าวัสดุการศึกษา" + ".xlsx"); } return Ok(); } [SwaggerOperation("ค่าควบคุมงานก่อสร้าง")] [HttpPost, Route("reports/control_cost_construction/{type}")] [ApiExplorerSettings(GroupName = "reports")] public IActionResult GetConstructionReport([FromRoute] string type, [FromBody] control_cost_construction _expense) { if (_expense.topic_type == 1) { _expense.topic = "ค่าควบคุมงานก่อสร้าง (หัวหน้าควบคุมงานก่อสร้าง)"; } if (_expense.topic_type == 2) { _expense.topic = "ค่าควบคุมงานก่อสร้าง (ผู้ปฏิบัติการ)"; } foreach (var detail in _expense.data) { detail.total_amount = (detail.quantity_day * detail.quantity_person * detail.amount); } var expenses = new List() { _expense }; Report report = new Report(); report.Load(_setting.report_path + "control_cost_construction.frx"); report.RegisterData(expenses, "control_cost_construction"); 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.openxmlformats-officedocument.spreadsheetml.sheet", "ค่าควบคุมงานก่อสร้าง" + ".xlsx"); } return Ok(); } } }