649 lines
26 KiB
C#
649 lines
26 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Linq;
|
|
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 rmutr_report.Models.RoThree;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
|
|
namespace rmutr_report.Controllers
|
|
{
|
|
[SwaggerTag("สำหรับรายงาน ร.(คำของบประมาณรายจ่ายจากเงินรายได้)")]
|
|
public class Ro : Controller
|
|
{
|
|
readonly Setting _setting;
|
|
|
|
public Ro(Setting setting)
|
|
{
|
|
this._setting = setting;
|
|
}
|
|
|
|
[HttpPost, Route("reports/ro_five/{type}")]
|
|
[ApiExplorerSettings(GroupName = "reports")]
|
|
public IActionResult GetRoFiveReport([FromRoute] string type, [FromBody] ro_five building_fours)
|
|
{
|
|
foreach (var a in building_fours.building_type)
|
|
{
|
|
if (a.usage_per_target != null)
|
|
{
|
|
var a1 = a.usage_per_target.Where(d => d.used_year == d.used_year)
|
|
.Sum(o => o.used_year);
|
|
building_fours.sum_year1 = a1;
|
|
var a2 = a.usage_per_target.Where(d => d.year1 == d.year1)
|
|
.Sum(o => o.year1);
|
|
building_fours.sum_year2 = a2;
|
|
var a3 = a.usage_per_target.Where(d => d.year2 == d.year2)
|
|
.Sum(o => o.year2);
|
|
building_fours.sum_year3 = a3;
|
|
var a4 = a.usage_per_target.Where(d => d.year3 == d.year3)
|
|
.Sum(o => o.year3);
|
|
building_fours.sum_year4 = a4;
|
|
var a5 = a.usage_per_target.Where(d => d.year4 == d.year4)
|
|
.Sum(o => o.year4);
|
|
building_fours.sum_year5 = a5;
|
|
var a6 = a.usage_per_target.Where(d => d.year5 == d.year5)
|
|
.Sum(o => o.year5);
|
|
building_fours.sum_year6 = a6;
|
|
}
|
|
}
|
|
|
|
// foreach (var bb in building_fours.material_construction_labor1)
|
|
// {
|
|
// if (bb != null)
|
|
// {
|
|
// bb.total_amount = bb.material_cost + bb.labor_unit;
|
|
// var f = building_fours.material_construction_labor1.Where(d => d.total_amount == d.total_amount)
|
|
// .Sum(o => o.total_amount);
|
|
// building_fours.material_total_amount1 = f;
|
|
// }
|
|
// }
|
|
// foreach (var bb in building_fours.material_construction_labor2)
|
|
// {
|
|
// if (bb != null)
|
|
// {
|
|
// bb.total_amount = bb.material_cost + bb.labor_unit;
|
|
// var f = building_fours.material_construction_labor2.Where(d => d.total_amount == d.total_amount)
|
|
// .Sum(o => o.total_amount);
|
|
// building_fours.material_total_amount2 = f;
|
|
// }
|
|
// }
|
|
// foreach (var bb in building_fours.material_construction_labor3)
|
|
// {
|
|
// if (bb != null)
|
|
// {
|
|
// bb.total_amount = bb.material_cost + bb.labor_unit;
|
|
// var f = building_fours.material_construction_labor3.Where(d => d.total_amount == d.total_amount)
|
|
// .Sum(o => o.total_amount);
|
|
// building_fours.material_total_amount3 = f;
|
|
// }
|
|
// }
|
|
foreach (var cc in building_fours.budget_limit)
|
|
{
|
|
if (cc != null)
|
|
{
|
|
var a = building_fours.budget_limit.Where(d => d.amount == d.amount)
|
|
.Sum(o => o.amount);
|
|
building_fours.amount = a;
|
|
if (cc.outside_amount != null)
|
|
{
|
|
var b = building_fours.budget_limit.Where(d => d.outside_amount == d.outside_amount)
|
|
.Sum(o => o.outside_amount);
|
|
building_fours.outside_amount = b;
|
|
}
|
|
|
|
if (cc.outside_amount == null)
|
|
{
|
|
building_fours.outside_amount = null;
|
|
}
|
|
|
|
if (cc.amount != null && cc.outside_amount != null)
|
|
{
|
|
cc.total_amount = cc.amount + cc.outside_amount;
|
|
}
|
|
|
|
var c = building_fours.budget_limit.Where(d => d.total_amount == d.total_amount)
|
|
.Sum(o => o.total_amount);
|
|
building_fours.total_amount = c;
|
|
}
|
|
}
|
|
|
|
foreach (var boqPrice in building_fours.basic_information)
|
|
{
|
|
if (boqPrice.list != null)
|
|
{
|
|
string str = boqPrice.list;
|
|
string num = String.Concat(str.Where(c => c >= '0' && c <= '9'));
|
|
|
|
if (num.Length == 4)
|
|
{
|
|
for (int i = 1; i <= num.Length - 1; i += 4)
|
|
{
|
|
boqPrice.list = num.Insert(i, ",");
|
|
}
|
|
}
|
|
else if (num.Length == 5)
|
|
{
|
|
for (int i = 2; i <= num.Length - 1; i += 5)
|
|
{
|
|
boqPrice.list = num.Insert(i, ",");
|
|
}
|
|
}
|
|
else if (num.Length == 6)
|
|
{
|
|
for (int i = 3; i <= num.Length - 1; i += 6)
|
|
{
|
|
boqPrice.list = num.Insert(i, ",");
|
|
}
|
|
}
|
|
else if (num.Length == 7)
|
|
{
|
|
for (int i = 1, j = 5; i <= num.Length - 1; i += 7, j += 7)
|
|
{
|
|
boqPrice.list = num.Insert(i, ",").Insert(j, ",");
|
|
}
|
|
}
|
|
else if (num.Length == 8)
|
|
{
|
|
for (int i = 2, j = 6; i <= num.Length - 1; i += 8, j += 8)
|
|
{
|
|
boqPrice.list = num.Insert(i, ",").Insert(j, ",");
|
|
}
|
|
}
|
|
|
|
if (boqPrice.list == "20000000.0000")
|
|
{
|
|
boqPrice.list = "20,000,000";
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach (var boqPrice in building_fours.boq)
|
|
{
|
|
if (boqPrice.is_data == "1")
|
|
{
|
|
string str = boqPrice.have;
|
|
if (str.Length == 4)
|
|
{
|
|
for (int i = 1; i <= str.Length - 1; i += 4)
|
|
{
|
|
boqPrice.have = str.Insert(i, ",");
|
|
}
|
|
}
|
|
else if (str.Length == 5)
|
|
{
|
|
for (int i = 2; i <= str.Length - 1; i += 5)
|
|
{
|
|
boqPrice.have = str.Insert(i, ",");
|
|
}
|
|
}
|
|
else if (str.Length == 6)
|
|
{
|
|
for (int i = 3; i <= str.Length - 1; i += 6)
|
|
{
|
|
boqPrice.have = str.Insert(i, ",");
|
|
}
|
|
}
|
|
else if (str.Length == 7)
|
|
{
|
|
for (int i = 1, j = 5; i <= str.Length - 1; i += 7, j += 7)
|
|
{
|
|
boqPrice.have = str.Insert(i, ",").Insert(j, ",");
|
|
}
|
|
}
|
|
else if (str.Length == 8)
|
|
{
|
|
for (int i = 2, j = 6; i <= str.Length - 1; i += 8, j += 8)
|
|
{
|
|
boqPrice.have = str.Insert(i, ",").Insert(j, ",");
|
|
}
|
|
}
|
|
|
|
// if (boqPrice.have == "10000000")
|
|
// {
|
|
// boqPrice.have = "10,000,000";
|
|
// }
|
|
boqPrice.text1 = "- มี วงเงิน " + boqPrice.have + " บาท";
|
|
boqPrice.text2 = "- ดำเนินการจัดทำ BOQ เดือน " + boqPrice.pending_boq_month;
|
|
boqPrice.text3 = "- BOQ แล้วเสร็จเดือน " + boqPrice.done_boq_month;
|
|
boqPrice.text4 = "- ขออนุมัติ BOQ เดือน " + boqPrice.approval_month;
|
|
boqPrice.text5 = "- ทำสัญญาก่อสร้าง เดือน " + boqPrice.construction_contract_month;
|
|
}
|
|
|
|
if (boqPrice.is_data == "2")
|
|
{
|
|
boqPrice.text1 = "- ไม่มี";
|
|
boqPrice.text2 = "- กรณีไม่มีคาดว่าจะแล้วเสร็จ เดือน " + boqPrice.months + " ปี " +
|
|
boqPrice.years;
|
|
boqPrice.text3 = "- ขณะนี้อยูในขั้นตอน " + boqPrice.step;
|
|
}
|
|
}
|
|
|
|
|
|
var _budget_summary_report = new List<ro_five>() { building_fours };
|
|
|
|
Report report = new Report();
|
|
report.Load(_setting.report_path + "ro_five.frx");
|
|
report.RegisterData(_budget_summary_report, "ro_five");
|
|
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",
|
|
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();
|
|
}
|
|
|
|
[HttpPost, Route("reports/external_research/{type}")]
|
|
[ApiExplorerSettings(GroupName = "reports")]
|
|
public IActionResult GetExReport([FromRoute] string type, [FromBody] external_research external)
|
|
{
|
|
var s1 = external.data.Sum(g => g.budget_1);
|
|
var s2 = external.data.Sum(g => g.budget_2);
|
|
var s3 = external.data.Sum(g => g.budget_3);
|
|
var s4 = external.data.Sum(g => g.budget_4);
|
|
var s5 = external.data.Sum(g => g.budget_5);
|
|
var s6 = external.data.Sum(g => g.budget_received);
|
|
var s7 = external.data.Sum(g => g.total_budget);
|
|
var s8 = external.data.Sum(g => g.expenses);
|
|
if (s1 != null && s2 != null && s3 != null && s4 != null && s5 != null)
|
|
{
|
|
external.project_amount = s6;
|
|
external.total_1 = s6;
|
|
//external.total_8 = s7;
|
|
external.total_2 = s8;
|
|
external.total_3 = s1;
|
|
external.total_4 = s2;
|
|
external.total_5 = s3;
|
|
external.total_6 = s4;
|
|
external.total_7 = s5;
|
|
}
|
|
|
|
CultureInfo culture = new CultureInfo("th-TH");
|
|
|
|
if (external.data_date != null)
|
|
{
|
|
external.data_day = external.data_date.Value.ToString("dd", culture);
|
|
external.data_month = external.data_date.Value.ToString("MMMM", culture);
|
|
external.data_year = external.data_date.Value.ToString("yyyy", culture);
|
|
}
|
|
|
|
if (external.data_date == null)
|
|
{
|
|
external.data_day = "";
|
|
external.data_month = "";
|
|
external.data_year = "";
|
|
}
|
|
|
|
if (external.data != null)
|
|
{
|
|
foreach (var data in external.data)
|
|
{
|
|
data.total_budget = data.budget_1 + data.budget_2 + data.budget_3 + data.budget_4 +
|
|
data.budget_5;
|
|
var ss = external.data.Sum(y => y.total_budget);
|
|
external.institutional_subsidy_fee = ss;
|
|
external.total_8 = external.institutional_subsidy_fee;
|
|
}
|
|
}
|
|
|
|
|
|
var _budget_summary_report = new List<external_research>() { external };
|
|
|
|
Report report = new Report();
|
|
report.Load(_setting.report_path + "external_research.frx");
|
|
report.RegisterData(_budget_summary_report, "external_research");
|
|
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;
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost, Route("reports/ro_nine/{type}")]
|
|
[ApiExplorerSettings(GroupName = "reports")]
|
|
public IActionResult GetNineReport([FromRoute] string type, [FromBody] ro_nine external)
|
|
{
|
|
var s1 = external.data.Sum(g => g.budget_1);
|
|
var s2 = external.data.Sum(g => g.budget_2);
|
|
var s3 = external.data.Sum(g => g.budget_3);
|
|
var s4 = external.data.Sum(g => g.budget_4);
|
|
var s5 = external.data.Sum(g => g.budget_5);
|
|
var s6 = external.data.Sum(g => g.budget_received);
|
|
var s7 = external.data.Sum(g => g.total_budget);
|
|
var s8 = external.data.Sum(g => g.expenses);
|
|
if (s1 != null && s2 != null && s3 != null && s4 != null && s5 != null)
|
|
{
|
|
external.total_1 = s6;
|
|
//external.total_8 = s7;
|
|
external.total_2 = s8;
|
|
external.total_3 = s1;
|
|
external.total_4 = s2;
|
|
external.total_5 = s3;
|
|
external.total_6 = s4;
|
|
external.total_7 = s5;
|
|
}
|
|
|
|
CultureInfo culture = new CultureInfo("th-TH");
|
|
|
|
if (external.data_date != null)
|
|
{
|
|
external.data_day = external.data_date.Value.ToString("dd", culture);
|
|
external.data_month = external.data_date.Value.ToString("MMMM", culture);
|
|
external.data_year = external.data_date.Value.ToString("yyyy", culture);
|
|
}
|
|
|
|
if (external.data_date == null)
|
|
{
|
|
external.data_day = "";
|
|
external.data_month = "";
|
|
external.data_year = "";
|
|
}
|
|
|
|
if (external.data != null)
|
|
{
|
|
foreach (var data in external.data)
|
|
{
|
|
data.total_budget = data.budget_1 + data.budget_2 + data.budget_3 + data.budget_4 + data.budget_5;
|
|
var ss = external.data.Sum(y => y.total_budget);
|
|
external.total_8 = ss;
|
|
}
|
|
}
|
|
|
|
var _budget_summary_report = new List<ro_nine>() { external };
|
|
|
|
Report report = new Report();
|
|
report.Load(_setting.report_path + "ro_nine.frx");
|
|
report.RegisterData(_budget_summary_report, "ro_nine");
|
|
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;
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
[HttpPost, Route("reports/ro_ten/{type}")]
|
|
[ApiExplorerSettings(GroupName = "reports")]
|
|
public IActionResult GetTenReport([FromRoute] string type, [FromBody] ro_ten ten)
|
|
{
|
|
var t_ten = ten.data.ToArray();
|
|
if (t_ten != null)
|
|
{
|
|
// var t1 = ten.data.Sum(g => g.amount_1);
|
|
// var t2 = ten.data.Sum(g => g.amount_2);
|
|
// var t3 = ten.data.Sum(g => g.amount_3);
|
|
// var t2 = t_ten.Sum(g => g.amount_2);
|
|
// var t3 = t_ten.Sum(g => g.amount_3);
|
|
|
|
|
|
foreach (var detail in t_ten)
|
|
{
|
|
var s1 = detail.data_detail.Sum(g => g.amount_1);
|
|
var s2 = detail.data_detail.Sum(g => g.amount_2);
|
|
var s3 = detail.data_detail.Sum(g => g.amount_3);
|
|
// var s4 = t_ten.Sum(g => g.amount_1);
|
|
// var s5 = t_ten.Sum(g => g.amount_2);
|
|
// var s6 = t_ten.Sum(g => g.amount_3);
|
|
detail.amount_1 = s1;
|
|
detail.amount_2 = s2;
|
|
detail.amount_3 = s3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var _budget_summary_report = new List<ro_ten>() { ten };
|
|
|
|
Report report = new Report();
|
|
report.Load(_setting.report_path + "ro_ten.frx");
|
|
report.RegisterData(_budget_summary_report, "ro_ten");
|
|
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",
|
|
date + ".xlsx");
|
|
break;
|
|
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
[HttpPost, Route("reports/ro_eleven/{type}")]
|
|
[ApiExplorerSettings(GroupName = "reports")]
|
|
public IActionResult GetEleReport([FromRoute] string type, [FromBody] ro_eleven eleven)
|
|
{
|
|
var t_eleven = eleven.data.ToArray();
|
|
if (t_eleven != null)
|
|
{
|
|
var t1 = eleven.data.Sum(g => g.amount_1);
|
|
var t2 = eleven.data.Sum(g => g.amount_2);
|
|
var t3 = eleven.data.Sum(g => g.amount_3);
|
|
eleven.total_amount_1 = t1;
|
|
eleven.total_amount_2 = t2;
|
|
eleven.total_amount_3 = t3;
|
|
|
|
|
|
}
|
|
|
|
var ele = new List<ro_eleven>() { eleven };
|
|
|
|
Report report = new Report();
|
|
report.Load(_setting.report_path + "ro_eleven.frx");
|
|
report.RegisterData(ele, "ro_eleven");
|
|
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",
|
|
date + ".xlsx");
|
|
break;
|
|
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
[HttpPost, Route("reports/revenue_estimate_income_summary/{type}")]
|
|
[ApiExplorerSettings(GroupName = "reports")]
|
|
public IActionResult GetEstimateIncomeReport([FromRoute] string type, [FromBody] revenue_estimate_income_summary estimate)
|
|
{
|
|
var s1 = estimate.data.Sum(d => d.science_1);
|
|
var s2 = estimate.data.Sum(d => d.social_1);
|
|
var s3 = estimate.data.Sum(d => d.science_2);
|
|
var s4 = estimate.data.Sum(d => d.social_2);
|
|
var s5 = estimate.data.Sum(d => d.total_register_fee);
|
|
var s6 = estimate.data.Sum(d => d.science_3);
|
|
var s7 = estimate.data.Sum(d => d.social_3);
|
|
var s8 = estimate.data.Sum(d => d.science_4);
|
|
var s9 = estimate.data.Sum(d => d.social_4);
|
|
var s10 = estimate.data.Sum(d => d.total_education_fee);
|
|
var s11 = estimate.data.Sum(d => d.total_science);
|
|
var s12 = estimate.data.Sum(d => d.total_social);
|
|
var s13 = estimate.data.Sum(d => d.total_science_social);
|
|
|
|
estimate.sum_1 = s1;
|
|
estimate.sum_2 = s2;
|
|
estimate.sum_3 = s3;
|
|
estimate.sum_4 = s4;
|
|
estimate.sum_5 = s5;
|
|
estimate.sum_6 = s6;
|
|
estimate.sum_7 = s7;
|
|
estimate.sum_8 = s8;
|
|
estimate.sum_9 = s9;
|
|
estimate.sum_10 = s10;
|
|
estimate.sum_11 = s11;
|
|
estimate.sum_12 = s12;
|
|
estimate.sum_13 = s13;
|
|
var estimateEducation = new List<revenue_estimate_income_summary>() { estimate };
|
|
|
|
Report report = new Report();
|
|
report.Load(_setting.report_path + "revenue_estimate_income_summary.frx");
|
|
report.RegisterData(estimateEducation, "revenue_estimate_income_summary");
|
|
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",
|
|
"estimateincome_" + ".xlsx");
|
|
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
[HttpPost, Route("reports/revenue_estimate_education_fee/{type}")]
|
|
[ApiExplorerSettings(GroupName = "reports")]
|
|
public IActionResult GetEstimateReport([FromRoute] string type, [FromBody] revenue_estimate_education_fee estimate)
|
|
{
|
|
|
|
var estimateEducation = new List<revenue_estimate_education_fee>() { estimate };
|
|
|
|
Report report = new Report();
|
|
report.Load(_setting.report_path + "revenue_estimate_education_fee.frx");
|
|
report.RegisterData(estimateEducation, "revenue_estimate_education_fee");
|
|
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",
|
|
"estimateEducation" + ".xlsx");
|
|
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
}
|
|
} |