add material_construction_labor
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using ClosedXML.Excel;
|
||||
using FastReport;
|
||||
using FastReport.Export.Csv;
|
||||
using FastReport.Export.Mht;
|
||||
@@ -156,6 +158,240 @@ namespace rmutr_report.Controllers
|
||||
|
||||
return Ok();
|
||||
}
|
||||
[HttpPost, Route("reports/materials_construction_labor/{type}")]
|
||||
[ApiExplorerSettings(GroupName = "reports")]
|
||||
public IActionResult GetConstructionReport([FromRoute] string type,
|
||||
[FromBody] building_four building_fours) {
|
||||
{
|
||||
var workbook = new XLWorkbook();
|
||||
var ws = workbook.Worksheets.Add("Page1");
|
||||
ws.Range("A1:J1").Merge().Value = "13. บัญชีแสดงปริมาณวัสดุและแรงงานค่าก่อสร้าง";
|
||||
ws.Range("A1:J1").Style.Alignment.WrapText = true;
|
||||
ws.Range("A1:J1").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
|
||||
ws.Range("A1:J1").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Cell("A1").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("A1").Style.Font.FontSize = 16;
|
||||
ws.Range("A1:D1").Style.Font.Bold = true;
|
||||
ws.Range("A2:A3").Merge().Value = "ลำดับที่";
|
||||
ws.Range("A2:A3").Style.Border.OutsideBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Range("A2:A3").Style.Alignment.WrapText = true;
|
||||
ws.Range("A2:A3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Range("A2:A3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Cell("A2").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("A2").Style.Font.FontSize = 14;
|
||||
ws.Range("A2:D2").Style.Font.Bold = true;
|
||||
ws.Range("B2:B3").Merge().Value = "กิจกรรมการดำเนินงาน";
|
||||
ws.Range("B2:B3").Style.Border.OutsideBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Cell("B2").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("B2").Style.Font.FontSize = 14;
|
||||
ws.Cell("B2").Style.Font.Bold = true;
|
||||
ws.Cell("B2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell("B2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Range("C2:C3").Merge().Value = "ปริมาณ";
|
||||
ws.Cell("C2").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("C2").Style.Font.FontSize = 14;
|
||||
ws.Cell("C2").Style.Font.Bold = true;
|
||||
ws.Cell("C2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell("C2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Range("D2:D3").Merge().Value = "หน่วย";
|
||||
ws.Range("D2:D3").Style.Border.OutsideBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Cell("D2").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("D2").Style.Font.FontSize = 14;
|
||||
ws.Cell("D2").Style.Font.Bold = true;
|
||||
ws.Cell("D2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell("D2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Range("E2:F2").Merge().Value = "ค่าวัสดุ";
|
||||
ws.Range("E2:F2").Style.Border.OutsideBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Cell("E2").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("E2").Style.Font.FontSize = 14;
|
||||
ws.Cell("E2").Style.Font.Bold = true;
|
||||
ws.Cell("E2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell("E2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Cell("E3").Value = "หน่วยละ";
|
||||
ws.Cell("E3").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("E3").Style.Font.FontSize = 14;
|
||||
ws.Cell("E3").Style.Font.Bold = true;
|
||||
ws.Cell("E3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell("E3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Cell("E3").Style.Border.RightBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Cell("F3").Value = "รวมเงิน";
|
||||
ws.Cell("F3").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("F3").Style.Font.FontSize = 14;
|
||||
ws.Cell("F3").Style.Font.Bold = true;
|
||||
ws.Cell("F3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell("F3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Cell("F3").Style.Border.RightBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Range("G2:H2").Merge().Value = "ค่าแรงงาน";
|
||||
ws.Range("G2:H2").Style.Border.OutsideBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Cell("G2").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("G2").Style.Font.FontSize = 14;
|
||||
ws.Cell("G2").Style.Font.Bold = true;
|
||||
ws.Cell("G2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell("G2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Cell("G3").Value = "หน่วยละ";
|
||||
ws.Cell("G3").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("G3").Style.Font.FontSize = 14;
|
||||
ws.Cell("G3").Style.Font.Bold = true;
|
||||
ws.Cell("G3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell("G3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Cell("G3").Style.Border.RightBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Cell("H3").Value = "รวมเงิน";
|
||||
ws.Cell("H3").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("H3").Style.Font.FontSize = 14;
|
||||
ws.Cell("H3").Style.Font.Bold = true;
|
||||
ws.Cell("H3").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell("H3").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Cell("H3").Style.Border.RightBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Range("I2:I3").Merge().Value = "ราคารวม";
|
||||
ws.Cell("I2").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("I2").Style.Font.FontSize = 14;
|
||||
ws.Cell("I2").Style.Font.Bold = true;
|
||||
ws.Cell("I2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell("I2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Range("J2:J3").Merge().Value = "หมายเหตุ";
|
||||
ws.Range("J2:J3").Style.Border.OutsideBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Cell("J2").Style.Font.FontName = "TH SarabunPSK";
|
||||
ws.Cell("J2").Style.Font.FontSize = 14;
|
||||
ws.Cell("J2").Style.Font.Bold = true;
|
||||
ws.Cell("J2").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell("J2").Style.Alignment.Vertical = XLAlignmentVerticalValues.Center;
|
||||
ws.Range("A2:J3").Style.Border.OutsideBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Row(1).Height = 20;
|
||||
ws.Column(1).Width = 10;
|
||||
ws.Column(2).Width = 30;
|
||||
ws.Column(3).Width = 10;
|
||||
ws.Column(4).Width = 10;
|
||||
ws.Column(5).Width = 10;
|
||||
ws.Column(6).Width = 10;
|
||||
ws.Column(7).Width = 10;
|
||||
ws.Column(8).Width = 10;
|
||||
ws.Column(9).Width = 10;
|
||||
ws.Column(10).Width = 30;
|
||||
int row = 4;
|
||||
int no = 1;
|
||||
ws.Range(ws.Cell(row, 5), ws.Cell(row, 9)).SetDataType(XLDataType.Number);
|
||||
if (building_fours.material_construction_labor != null)
|
||||
{
|
||||
var sumall = building_fours.material_construction_labor.Where(d => d.total_amount == d.total_amount)
|
||||
.Sum(o => o.total_amount);
|
||||
foreach (var fours in building_fours.material_construction_labor)
|
||||
{
|
||||
|
||||
if (fours.operational_activities != "รวมทั้งสิ้น")
|
||||
{
|
||||
|
||||
ws.Cell(row, 1).Value = no;
|
||||
no++;
|
||||
ws.Cell(row, 2).Value = fours.operational_activities;
|
||||
ws.Cell(row, 3).Value = fours.amount;
|
||||
ws.Cell(row, 4).Value = fours.unit;
|
||||
ws.Cell(row, 5).Value = fours.material_cost;
|
||||
ws.Cell(row, 6).Value = fours.material_cost;
|
||||
ws.Cell(row, 7).Value = fours.labor_unit;
|
||||
ws.Cell(row, 8).Value = fours.labor_cost;
|
||||
ws.Cell(row, 9).Value = fours.total_amount;
|
||||
ws.Cell(row, 10).Value = fours.note;
|
||||
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Font.FontName =
|
||||
"TH SarabunPSK";
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Font.FontSize = 14;
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Alignment.WrapText = true;
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Alignment.Vertical =
|
||||
XLAlignmentVerticalValues.Center;
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Border.OutsideBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Border.RightBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
|
||||
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
|
||||
//ws.Range(ws.Cell(5, 1), ws.Cell(5, 4)).Style.Font.Bold = true;
|
||||
//ws.Range(ws.Cell(6, 1), ws.Cell(6, 4)).Style.Border.BottomBorder = XLBorderStyleValues.Double;
|
||||
//ws.Range(ws.Cell(6, 1), ws.Cell(6, 4)).Style.Font.Bold = true;
|
||||
//ws.Cell(row, 3).Style.NumberFormat.NumberFormatId = 2;
|
||||
//ws.Cell(row, 3).DataType = XLDataType.Number;
|
||||
//ws.Cell(row,3).SetDataType(XLDataType.Number);
|
||||
ws.Range(ws.Cell(row, 5), ws.Cell(row, 9)).Style.NumberFormat.SetFormat("#,#");
|
||||
|
||||
row++;
|
||||
}
|
||||
if (fours.operational_activities == "รวมทั้งสิ้น")
|
||||
{
|
||||
|
||||
ws.Cell(row, 1).Value = null;
|
||||
ws.Cell(row, 2).Value = fours.operational_activities;
|
||||
ws.Cell(row, 3).Value = null;
|
||||
ws.Cell(row, 4).Value = null;
|
||||
ws.Cell(row, 5).Value = null;
|
||||
ws.Cell(row, 6).Value = null;
|
||||
ws.Cell(row, 7).Value = null;
|
||||
ws.Cell(row, 8).Value = null;
|
||||
ws.Cell(row, 9).Value = sumall;
|
||||
ws.Cell(row, 10).Value = null;
|
||||
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Font.FontName =
|
||||
"TH SarabunPSK";
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Font.FontSize = 14;
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Alignment.WrapText = true;
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Alignment.Vertical =
|
||||
XLAlignmentVerticalValues.Center;
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Border.OutsideBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Range(ws.Cell(row, 1), ws.Cell(row, 10)).Style.Border.RightBorder =
|
||||
XLBorderStyleValues.Thin;
|
||||
ws.Cell(row, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 2).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 3).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 4).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 5).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 6).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 7).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 8).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 9).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
ws.Cell(row, 10).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
|
||||
ws.Cell(row, 2).Style.Font.Bold = true;
|
||||
ws.Cell(row, 9).Style.Font.Bold = true;
|
||||
//ws.Range(ws.Cell(6, 1), ws.Cell(6, 4)).Style.Border.BottomBorder = XLBorderStyleValues.Double;
|
||||
//ws.Range(ws.Cell(6, 1), ws.Cell(6, 4)).Style.Font.Bold = true;
|
||||
//ws.Cell(row, 3).Style.NumberFormat.NumberFormatId = 2;
|
||||
//ws.Cell(row, 3).DataType = XLDataType.Number;
|
||||
//ws.Cell(row,3).SetDataType(XLDataType.Number);
|
||||
ws.Range(ws.Cell(row, 5), ws.Cell(row, 9)).Style.NumberFormat.SetFormat("#,#");
|
||||
|
||||
row++;
|
||||
}
|
||||
}
|
||||
}
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
workbook.SaveAs(stream);
|
||||
var content = stream.ToArray();
|
||||
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
return File(
|
||||
content,
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
"materials_construction_" + date + ".xlsx");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user