인쇄 기능 추가 업데이트
실제 인쇄 기능 추가
This commit is contained in:
@@ -3,9 +3,12 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
using System.Drawing.Printing;
|
using System.Drawing.Printing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Windows.Documents;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using HSUCO_Cargo_Garage_Operation_Program.Properties;
|
||||||
|
|
||||||
namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
|
namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
|
||||||
{
|
{
|
||||||
@@ -173,12 +176,19 @@ namespace HSUCO_Cargo_Garage_Operation_Program.CustomUserControl
|
|||||||
//if (allCount == 0) return;
|
//if (allCount == 0) return;
|
||||||
// TODO: 증명서 인쇄
|
// TODO: 증명서 인쇄
|
||||||
// PRINT
|
// PRINT
|
||||||
|
List<PrintCertificateData> all = new List<PrintCertificateData>();
|
||||||
Print print = new Print();
|
all.Add(new PrintCertificateData());
|
||||||
|
all.Add(new PrintCertificateData());
|
||||||
|
all.Add(new PrintCertificateData());
|
||||||
|
PrintCertificate print = new PrintCertificate(all);
|
||||||
PrintDocument printDocument = new PrintDocument();
|
PrintDocument printDocument = new PrintDocument();
|
||||||
printDocument.PrintPage += new PrintPageEventHandler(print.PrintPage);
|
printDocument.DocumentName = "차고지 이용 증명서";
|
||||||
|
|
||||||
|
printDocument.PrintPage += print.PrintPage;
|
||||||
|
|
||||||
PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
|
PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
|
||||||
|
printPreviewDialog.Icon = Resources.free_icon_trucks_8552082;
|
||||||
|
printPreviewDialog.WindowState = FormWindowState.Maximized;
|
||||||
printPreviewDialog.Document = printDocument;
|
printPreviewDialog.Document = printDocument;
|
||||||
printPreviewDialog.ShowDialog();
|
printPreviewDialog.ShowDialog();
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ApplicationIcon>free-icon-trucks-8552082.ico</ApplicationIcon>
|
<ApplicationIcon>Resources\free-icon-trucks-8552082.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||||
@@ -162,7 +162,7 @@
|
|||||||
<Compile Include="Master.Designer.cs">
|
<Compile Include="Master.Designer.cs">
|
||||||
<DependentUpon>Master.cs</DependentUpon>
|
<DependentUpon>Master.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Print.cs" />
|
<Compile Include="PrintCertificate.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<EmbeddedResource Include="CustomForm\Promotion.resx">
|
<EmbeddedResource Include="CustomForm\Promotion.resx">
|
||||||
@@ -226,7 +226,7 @@
|
|||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="free-icon-trucks-8552082.ico" />
|
<Content Include="Resources\free-icon-trucks-8552082.ico" />
|
||||||
<None Include="Resources\file_type_excel_icon_130611.png" />
|
<None Include="Resources\file_type_excel_icon_130611.png" />
|
||||||
<Content Include="TextFile1.txt" />
|
<Content Include="TextFile1.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@@ -1,52 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Drawing.Printing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace HSUCO_Cargo_Garage_Operation_Program
|
|
||||||
{
|
|
||||||
internal class Print
|
|
||||||
{
|
|
||||||
public void PrintPage(object sender, PrintPageEventArgs e)
|
|
||||||
{
|
|
||||||
// 테두리?
|
|
||||||
e.Graphics.DrawRectangle(new Pen(Brushes.Black, 3), e.MarginBounds.Top, e.MarginBounds.Left, e.MarginBounds.Width, e.MarginBounds.Height);
|
|
||||||
|
|
||||||
string text = "화물차고지 사용신고확인서";
|
|
||||||
Font font = new Font("맑은 고딕", 30, FontStyle.Bold);
|
|
||||||
|
|
||||||
int totalWidth = (int)e.PageBounds.Width;
|
|
||||||
int totalHeight = (int)e.PageBounds.Height;
|
|
||||||
|
|
||||||
|
|
||||||
e.Graphics.DrawString("제 2023-01호", new Font("맑은 고딕", 12), Brushes.Black, e.MarginBounds.Left + 10, e.MarginBounds.Top + 10);
|
|
||||||
|
|
||||||
SizeF textSize = e.Graphics.MeasureString(text, font);
|
|
||||||
float textX = (totalWidth - textSize.Width) / 2;
|
|
||||||
|
|
||||||
e.Graphics.DrawString(text, font, Brushes.Black, textX, e.MarginBounds.Top + 150);
|
|
||||||
|
|
||||||
e.Graphics.DrawString("사용자 성명 : ", new Font("맑은 고딕", 12), Brushes.Black, e.MarginBounds.Left + 50, e.MarginBounds.Top + 300);
|
|
||||||
e.Graphics.DrawString("주소 : ", new Font("맑은 고딕", 12), Brushes.Black, e.MarginBounds.Left + 50, e.MarginBounds.Top + 350);
|
|
||||||
e.Graphics.DrawString("차량번호 : ", new Font("맑은 고딕", 12), Brushes.Black, e.MarginBounds.Left + 50, e.MarginBounds.Top + 400);
|
|
||||||
e.Graphics.DrawString("사용기한 : 2023-01-01 ~ 2023-12-31", new Font("맑은 고딕", 12), Brushes.Black, e.MarginBounds.Left + 50, e.MarginBounds.Top + 450);
|
|
||||||
|
|
||||||
e.Graphics.DrawString("내용", new Font("맑은 고딕", 12), Brushes.Black, e.MarginBounds.Left + 50, e.MarginBounds.Top + 500);
|
|
||||||
|
|
||||||
text = "2023년 01월 01일";
|
|
||||||
font = new Font("맑은 고딕", 15);
|
|
||||||
textSize = e.Graphics.MeasureString(text, font);
|
|
||||||
textX = (totalWidth - textSize.Width) / 2;
|
|
||||||
e.Graphics.DrawString(text, font, Brushes.Black, textX, e.MarginBounds.Top + 700);
|
|
||||||
|
|
||||||
text = "화성도시공사 화물차주차장 담당자";
|
|
||||||
font = new Font("맑은 고딕", 20);
|
|
||||||
textSize = e.Graphics.MeasureString(text, font);
|
|
||||||
textX = (totalWidth - textSize.Width) / 2;
|
|
||||||
e.Graphics.DrawString("화성도시공사 화물차주차장 담당자", font, Brushes.Black, textX, e.MarginBounds.Top + 800);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
77
HSUCO_Cargo_Garage_Operation_Program/PrintCertificate.cs
Normal file
77
HSUCO_Cargo_Garage_Operation_Program/PrintCertificate.cs
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Printing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Office.Interop.Excel;
|
||||||
|
using Font = System.Drawing.Font;
|
||||||
|
|
||||||
|
namespace HSUCO_Cargo_Garage_Operation_Program
|
||||||
|
{
|
||||||
|
struct PrintCertificateData
|
||||||
|
{
|
||||||
|
public string IssueNumber;
|
||||||
|
public string Name;
|
||||||
|
public string RegistrationNumberTruck;
|
||||||
|
public string RegistrationNumberPassenger;
|
||||||
|
public DateTime StartDate;
|
||||||
|
public DateTime EndDate;
|
||||||
|
public DateTime IssueDate;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class PrintCertificate
|
||||||
|
{
|
||||||
|
private List<PrintCertificateData> _printCertificateDatas;
|
||||||
|
private int _count;
|
||||||
|
public PrintCertificate(List<PrintCertificateData> printCertificateDatas)
|
||||||
|
{
|
||||||
|
_printCertificateDatas = printCertificateDatas;
|
||||||
|
_count = 0;
|
||||||
|
}
|
||||||
|
public void PrintPage(object sender, PrintPageEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
e.Graphics.DrawRectangle(new Pen(Brushes.Black, 3), e.MarginBounds.Top, e.MarginBounds.Left, e.MarginBounds.Width, e.MarginBounds.Height);
|
||||||
|
|
||||||
|
string text = "화물차고지 사용신고확인서";
|
||||||
|
Font font = new Font("맑은 고딕", 30, FontStyle.Bold);
|
||||||
|
|
||||||
|
int totalWidth = (int)e.PageBounds.Width;
|
||||||
|
int totalHeight = (int)e.PageBounds.Height;
|
||||||
|
|
||||||
|
|
||||||
|
e.Graphics.DrawString($"제 {_printCertificateDatas[_count].IssueNumber}호", new Font("맑은 고딕", 12), Brushes.Black, e.MarginBounds.Left + 10, e.MarginBounds.Top + 10);
|
||||||
|
|
||||||
|
SizeF textSize = e.Graphics.MeasureString(text, font);
|
||||||
|
float textX = (totalWidth - textSize.Width) / 2;
|
||||||
|
|
||||||
|
e.Graphics.DrawString(text, font, Brushes.Black, textX, e.MarginBounds.Top + 150);
|
||||||
|
|
||||||
|
e.Graphics.DrawString($"사용자 성명 : {_printCertificateDatas[_count].Name}", new Font("맑은 고딕", 12), Brushes.Black, e.MarginBounds.Left + 50, e.MarginBounds.Top + 300);
|
||||||
|
e.Graphics.DrawString($"주소 : {_printCertificateDatas[_count].Name}", new Font("맑은 고딕", 12), Brushes.Black, e.MarginBounds.Left + 50, e.MarginBounds.Top + 350);
|
||||||
|
e.Graphics.DrawString($"차량번호(화물) : {_printCertificateDatas[_count].RegistrationNumberTruck}", new Font("맑은 고딕", 12), Brushes.Black, e.MarginBounds.Left + 50, e.MarginBounds.Top + 400);
|
||||||
|
e.Graphics.DrawString($"차량번호(승용) : {_printCertificateDatas[_count].RegistrationNumberPassenger}", new Font("맑은 고딕", 12), Brushes.Black, e.MarginBounds.Left + 50, e.MarginBounds.Top + 450);
|
||||||
|
e.Graphics.DrawString($"사용기한 : {_printCertificateDatas[_count].StartDate.ToString("yyyy-mm-dd")} ~ {_printCertificateDatas[_count].EndDate.ToString("yyyy-mm-dd")}", new Font("맑은 고딕", 12), Brushes.Black, e.MarginBounds.Left + 50, e.MarginBounds.Top + 500);
|
||||||
|
|
||||||
|
e.Graphics.DrawString("상기 차량은 위 사용기한에 차고지 사용을 승인합니다.", new Font("맑은 고딕", 12), Brushes.Black, e.MarginBounds.Left + 50, e.MarginBounds.Top + 600);
|
||||||
|
|
||||||
|
text = $"{_printCertificateDatas[_count].IssueDate.ToString("yyyy년 mm월 dd일")}";
|
||||||
|
font = new Font("맑은 고딕", 15);
|
||||||
|
textSize = e.Graphics.MeasureString(text, font);
|
||||||
|
textX = (totalWidth - textSize.Width) / 2;
|
||||||
|
e.Graphics.DrawString(text, font, Brushes.Black, textX, e.MarginBounds.Top + 700);
|
||||||
|
|
||||||
|
text = "화성도시공사 화물차주차장 담당자";
|
||||||
|
font = new Font("맑은 고딕", 20);
|
||||||
|
textSize = e.Graphics.MeasureString(text, font);
|
||||||
|
textX = (totalWidth - textSize.Width) / 2;
|
||||||
|
e.Graphics.DrawString(text, font, Brushes.Black, textX, e.MarginBounds.Top + 800);
|
||||||
|
_count++;
|
||||||
|
e.HasMorePages = _printCertificateDatas.Count > _count;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -69,5 +69,15 @@ namespace HSUCO_Cargo_Garage_Operation_Program.Properties {
|
|||||||
return ((System.Drawing.Bitmap)(obj));
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// (아이콘)과(와) 유사한 System.Drawing.Icon 형식의 지역화된 리소스를 찾습니다.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Icon free_icon_trucks_8552082 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("free_icon_trucks_8552082", resourceCulture);
|
||||||
|
return ((System.Drawing.Icon)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -121,4 +121,7 @@
|
|||||||
<data name="file_type_excel_icon_130611" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="file_type_excel_icon_130611" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\file_type_excel_icon_130611.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\file_type_excel_icon_130611.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="free_icon_trucks_8552082" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\free-icon-trucks-8552082.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Reference in New Issue
Block a user