From 1a1c8e71fcd14858f595029f089b2d4a00202b32 Mon Sep 17 00:00:00 2001
From: ogi <Administrator@S-OGI-PC>
Date: Fri, 05 Dec 2025 09:24:16 +0900
Subject: [PATCH] プロジェクトファイルを追加。
---
HotelPms.Share.Windows/Report/ReportFactory.cs | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 107 insertions(+), 0 deletions(-)
diff --git a/HotelPms.Share.Windows/Report/ReportFactory.cs b/HotelPms.Share.Windows/Report/ReportFactory.cs
new file mode 100644
index 0000000..5e53786
--- /dev/null
+++ b/HotelPms.Share.Windows/Report/ReportFactory.cs
@@ -0,0 +1,107 @@
+using HotelPms.Share.Util;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Diagnostics;
+using System.Drawing;
+using System.Drawing.Printing;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace HotelPms.Share.Windows.Report
+{
+ public class ReportFactory
+ {
+ public static void OutputGrid(DataTable data, GridStyle style)
+ {
+ ReportType type = ReportType.Print;
+ using(FormTypeSelect form = new FormTypeSelect())
+ {
+ if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; }
+ type = form.ReportType;
+ }
+ OutputGrid(data, style, type);
+ }
+
+ public static string GetTempFileName()
+ {
+ string root = Application.StartupPath.TrimEnd(Path.DirectorySeparatorChar) + @"\Output\";
+ if(!Directory.Exists(root)) { Directory.CreateDirectory(root); }
+
+ return $"{root}{DateTime.Now.ToString("yyyyMMddHHmmssfff")}";
+ }
+
+ public static void OutputGrid(DataTable data, GridStyle style, ReportType type)
+ {
+ string path = string.Empty;
+ IReport report = null;
+ if (type == ReportType.Print) { report = new GridReport(data, style, string.Empty); }
+ else if (type == ReportType.Pdf)
+ {
+ path = GetTempFileName() + ".pdf";
+ report = new GridReport(data, style, path);
+ }
+ else if (type == ReportType.Xlsx) { report = new GridExcel(data, style, true, GetTempFileName()); }
+ else if (type == ReportType.Xls) { report = new GridExcel(data, style, false, GetTempFileName()); }
+ else if (type == ReportType.Csv) { report = new GridCsv(data, style); }
+ else if (type == ReportType.Xml) { report = new GridXml(data, style); }
+
+ if (report == null) { return; }
+ report.Output();
+ report.Dispose();
+
+ if (type == ReportType.Pdf) { CConvert.StartFile(path); }
+ }
+
+ public static void OutputForm(List<List<Cell>> rptList, Rectangle ownerArea, PaperKind paper, string titlem)
+ {
+ OutputForm(rptList, ownerArea, paper, titlem, -1);
+ }
+
+ public static void OutputForm(List<List<Cell>> rptList, Rectangle ownerArea, PaperKind paper, string title, int rptType)
+ {
+ ReportType type = ReportType.Print;
+ if (rptType == -1)
+ {
+ using (FormTypeSelect form = new FormTypeSelect())
+ {
+ form.btnItem2.Enabled = false;
+ form.btnItem3.Enabled = false;
+ form.btnItem6.Enabled = false;
+ form.btnItem7.Enabled = false;
+ if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; }
+ type = form.ReportType;
+ }
+ }
+ else
+ {
+ type = (ReportType)rptType;
+ }
+
+ IReport report = null;
+ if (type == ReportType.Print) { report = new FormReport(rptList, ownerArea, paper, title); }
+
+ if (report == null) { return; }
+ report.Output();
+ report.Dispose();
+ }
+
+ public static int SelectType()
+ {
+ ReportType type = ReportType.Print;
+ using (FormTypeSelect form = new FormTypeSelect())
+ {
+ form.btnItem2.Enabled = false;
+ form.btnItem3.Enabled = false;
+ form.btnItem6.Enabled = false;
+ form.btnItem7.Enabled = false;
+ if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return -1; }
+ type = form.ReportType;
+ }
+ return (int)type;
+ }
+
+ }
+}
--
Gitblit v1.10.0