├── BlackcatShippingOrderPrintHelper.Test
├── xxx.txt
├── test.jpg
├── xxx.jpg
├── sample.jpg
├── Web.config
├── index.aspx
├── Web.Debug.config
├── Web.Release.config
├── Properties
│ └── AssemblyInfo.cs
├── index.aspx.designer.cs
├── index.aspx.cs
└── BlackcatShippingOrderPrintHelper.Test.csproj
├── sh0571111.jpg
├── README.md
├── BlackcatShippingOrderPrintHelper
├── Properties
│ └── AssemblyInfo.cs
├── OrderInfo.cs
├── BlackcatShippingOrderPrintHelper.csproj
└── Agent.cs
├── BlackcatShippingOrderPrintHelper.sln
├── .gitattributes
└── .gitignore
/BlackcatShippingOrderPrintHelper.Test/xxx.txt:
--------------------------------------------------------------------------------
1 | 11120
--------------------------------------------------------------------------------
/sh0571111.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/donma/BlackcatShippingOrderPrinter/HEAD/sh0571111.jpg
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper.Test/test.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/donma/BlackcatShippingOrderPrinter/HEAD/BlackcatShippingOrderPrintHelper.Test/test.jpg
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper.Test/xxx.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/donma/BlackcatShippingOrderPrinter/HEAD/BlackcatShippingOrderPrintHelper.Test/xxx.jpg
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper.Test/sample.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/donma/BlackcatShippingOrderPrinter/HEAD/BlackcatShippingOrderPrintHelper.Test/sample.jpg
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 黑貓託運單列印幫手
2 |
3 |
4 | 
5 |
6 | 黑貓託運的小幫手
7 |
8 | C# 使用,簡簡單單
9 |
10 | 資料參考:
11 | http://no2don.blogspot.com/2016/07/c_19.html
12 |
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper.Test/Web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper.Test/index.aspx:
--------------------------------------------------------------------------------
1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="BlackcatShippingOrderPrintHelper.Test.index" %>
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper.Test/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper.Test/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper.Test/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("BlackcatShippingOrderPrintHelper.Test")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("BlackcatShippingOrderPrintHelper.Test")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("8e8879fa-2723-40f6-8df7-dbab03279d73")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper.Test/index.aspx.designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | //
5 | // Changes to this file may cause incorrect behavior and will be lost if
6 | // the code is regenerated.
7 | //
8 | //------------------------------------------------------------------------------
9 |
10 | namespace BlackcatShippingOrderPrintHelper.Test {
11 |
12 |
13 | public partial class index {
14 |
15 | ///
16 | /// form1 control.
17 | ///
18 | ///
19 | /// Auto-generated field.
20 | /// To modify move field declaration from designer file to code-behind file.
21 | ///
22 | protected global::System.Web.UI.HtmlControls.HtmlForm form1;
23 |
24 | ///
25 | /// Button1 control.
26 | ///
27 | ///
28 | /// Auto-generated field.
29 | /// To modify move field declaration from designer file to code-behind file.
30 | ///
31 | protected global::System.Web.UI.WebControls.Button Button1;
32 |
33 | ///
34 | /// Image1 control.
35 | ///
36 | ///
37 | /// Auto-generated field.
38 | /// To modify move field declaration from designer file to code-behind file.
39 | ///
40 | protected global::System.Web.UI.WebControls.Image Image1;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("BlackcatShippingOrderPrintHelper")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("BlackcatShippingOrderPrintHelper")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("bd9dc9f4-072d-492f-a9fd-8258e0d3ce95")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlackcatShippingOrderPrintHelper", "BlackcatShippingOrderPrintHelper\BlackcatShippingOrderPrintHelper.csproj", "{BD9DC9F4-072D-492F-A9FD-8258E0D3CE95}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlackcatShippingOrderPrintHelper.Test", "BlackcatShippingOrderPrintHelper.Test\BlackcatShippingOrderPrintHelper.Test.csproj", "{8E8879FA-2723-40F6-8DF7-DBAB03279D73}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {BD9DC9F4-072D-492F-A9FD-8258E0D3CE95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {BD9DC9F4-072D-492F-A9FD-8258E0D3CE95}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {BD9DC9F4-072D-492F-A9FD-8258E0D3CE95}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {BD9DC9F4-072D-492F-A9FD-8258E0D3CE95}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {8E8879FA-2723-40F6-8DF7-DBAB03279D73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {8E8879FA-2723-40F6-8DF7-DBAB03279D73}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {8E8879FA-2723-40F6-8DF7-DBAB03279D73}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {8E8879FA-2723-40F6-8DF7-DBAB03279D73}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper/OrderInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace BlackcatShippingOrderPrintHelper
7 | {
8 | public class 包裹查詢號碼
9 | {
10 | public string 轉運站代號 { get; set; }
11 | public string 轉運單號 { get; set; }
12 | }
13 |
14 | public class 配送資訊
15 | {
16 | public DateTime 收貨日 { get; set; }
17 | public DateTime 預定配達日 { get; set; }
18 | public string 指定時段 { get; set; }
19 | public string 發貨所 { get; set; }
20 | }
21 |
22 | public class 收件人資訊
23 | {
24 | public string 郵遞區號 { get; set; }
25 | public string 地址 { get; set; }
26 | public string 姓名 { get; set; }
27 | public string 電話1 { get; set; }
28 | public string 電話2 { get; set; }
29 | }
30 |
31 | public class 寄件人資訊
32 | {
33 | // public string 郵遞區號 { get; set; }
34 | public string 地址 { get; set; }
35 | public string 姓名 { get; set; }
36 | public string 電話1 { get; set; }
37 | public string 電話2 { get; set; }
38 | }
39 |
40 | public class OrderInfo
41 | {
42 | public 包裹查詢號碼 包裹查詢號碼 { get; set; }
43 |
44 | public 配送資訊 配送資訊 { get; set; }
45 |
46 |
47 | public 收件人資訊 收件人資訊 { get; set; }
48 |
49 | public 寄件人資訊 寄件人資訊 { get; set; }
50 |
51 | public string 備註 { get; set; }
52 |
53 | public string 品名 { get; set; }
54 |
55 | public string 訂單編號 { get; set; }
56 |
57 | public string 客戶代號 { get; set; }
58 |
59 | public decimal 代收金額 { get; set; }
60 |
61 | public string 尺寸 { get; set; }
62 |
63 | ///
64 | /// 請含 - 符號
65 | /// ex: 32-331-02
66 | ///
67 | public string 郵號條碼 { get; set; }
68 |
69 | public OrderInfo()
70 | {
71 | 包裹查詢號碼 = new 包裹查詢號碼();
72 | 配送資訊 = new 配送資訊();
73 | 收件人資訊 = new 收件人資訊();
74 | 寄件人資訊 = new 寄件人資訊();
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper/BlackcatShippingOrderPrintHelper.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {BD9DC9F4-072D-492F-A9FD-8258E0D3CE95}
8 | Library
9 | Properties
10 | BlackcatShippingOrderPrintHelper
11 | BlackcatShippingOrderPrintHelper
12 | v4.0
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
55 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper.Test/index.aspx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Drawing.Imaging;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Web;
8 | using System.Web.UI;
9 | using System.Web.UI.WebControls;
10 |
11 | namespace BlackcatShippingOrderPrintHelper.Test
12 | {
13 | public partial class index : System.Web.UI.Page
14 | {
15 | protected void Page_Load(object sender, EventArgs e)
16 | {
17 |
18 | }
19 |
20 |
21 |
22 |
23 | protected void Button1_Click(object sender, EventArgs e)
24 | {
25 | BlackcatShippingOrderPrintHelper.Agent.CearAllOrderInfo();
26 | //載入表格圖片
27 | BlackcatShippingOrderPrintHelper.Agent.LoadSampleImage(AppDomain.CurrentDomain.BaseDirectory + "sample.jpg");
28 |
29 |
30 | //第一聯的資料
31 | BlackcatShippingOrderPrintHelper.OrderInfo o1 = new OrderInfo();
32 | o1.包裹查詢號碼.轉運站代號 = "32";
33 | o1.包裹查詢號碼.轉運單號 = "7770000011";
34 |
35 | o1.配送資訊.指定時段 = "17-20時";
36 | o1.配送資訊.收貨日 = new DateTime(2016, 12, 21);
37 | o1.配送資訊.預定配達日 = new DateTime(2016, 12, 31);
38 | o1.配送資訊.發貨所 = "南港所";
39 |
40 | o1.收件人資訊.郵遞區號 = "12345";
41 | o1.收件人資訊.地址 = "台北市松江路yyy號yyy樓";
42 | o1.收件人資訊.姓名 = "許當麻1";
43 | o1.收件人資訊.電話1 = "02-25711956";
44 | o1.收件人資訊.電話2 = "0975543220";
45 |
46 |
47 | o1.寄件人資訊.地址 = "屏東縣恆春鎮海角六號";
48 | o1.寄件人資訊.姓名 = "潘蜥";
49 | o1.寄件人資訊.電話1 = "02-25711956";
50 | o1.寄件人資訊.電話2 = "0975543220";
51 |
52 | o1.備註 = "不可以自己寄給自己";
53 | o1.品名 = "北海道豬肉螃蟹鍋 x (2) 件";
54 | o1.訂單編號 = "T1213121543220";
55 |
56 | o1.客戶代號 = "273637101";
57 | o1.代收金額 = 199;
58 | o1.郵號條碼 = "11-115-34";
59 | o1.尺寸 = "150 cm";
60 | BlackcatShippingOrderPrintHelper.Agent.AddOrderInfo(o1);
61 |
62 |
63 |
64 | //第二聯的資料
65 | BlackcatShippingOrderPrintHelper.OrderInfo o2 = new OrderInfo();
66 | o2.包裹查詢號碼.轉運站代號 = "32";
67 | o2.包裹查詢號碼.轉運單號 = "7770000011";
68 |
69 | o2.配送資訊.指定時段 = "17-20時";
70 | o2.配送資訊.收貨日 = new DateTime(2016, 12, 21);
71 | o2.配送資訊.預定配達日 = new DateTime(2016, 12, 31);
72 | o2.配送資訊.發貨所 = "南港所";
73 |
74 | o2.收件人資訊.郵遞區號 = "12345";
75 | o2.收件人資訊.地址 = "台北市松江路xxx號xxx樓";
76 | o2.收件人資訊.姓名 = "許當麻2";
77 | o2.收件人資訊.電話1 = "02-25711956";
78 | o2.收件人資訊.電話2 = "0975543220";
79 |
80 |
81 | o2.寄件人資訊.地址 = "屏東縣恆春鎮海角六號";
82 | o2.寄件人資訊.姓名 = "潘蜥";
83 | o2.寄件人資訊.電話1 = "02-25711956";
84 | o2.寄件人資訊.電話2 = "0975543220";
85 |
86 | o2.備註 = "不可以自己寄給自己";
87 | o2.品名 = "北海道豬肉螃蟹鍋 x (2) 件";
88 | o2.訂單編號 = "T1213121543220";
89 |
90 | o2.客戶代號 = "273637101";
91 | o2.代收金額 = 199;
92 | o2.郵號條碼 = "32-331-02";
93 | o2.尺寸 = "150 cm";
94 | BlackcatShippingOrderPrintHelper.Agent.AddOrderInfo(o2);
95 |
96 |
97 |
98 | //第三聯的資料
99 | BlackcatShippingOrderPrintHelper.OrderInfo o3 = new OrderInfo();
100 | o3.包裹查詢號碼.轉運站代號 = "32";
101 | o3.包裹查詢號碼.轉運單號 = "7770000011";
102 |
103 | o3.配送資訊.指定時段 = "17-20時";
104 | o3.配送資訊.收貨日 = new DateTime(2016, 12, 21);
105 | o3.配送資訊.預定配達日 = new DateTime(2016, 12, 31);
106 | o3.配送資訊.發貨所 = "南港所";
107 |
108 | o3.收件人資訊.郵遞區號 = "12345";
109 | o3.收件人資訊.地址 = "台北市松江路zzz號zzz樓";
110 | o3.收件人資訊.姓名 = "許當麻3";
111 | o3.收件人資訊.電話1 = "02-25711956";
112 | o3.收件人資訊.電話2 = "0975543220";
113 |
114 |
115 | o3.寄件人資訊.地址 = "屏東縣恆春鎮海角六號";
116 | o3.寄件人資訊.姓名 = "潘蜥";
117 | o3.寄件人資訊.電話1 = "02-25711956";
118 | o3.寄件人資訊.電話2 = "0975543220";
119 |
120 | o3.備註 = "不可以自己寄給自己";
121 | o3.品名 = "北海道豬肉螃蟹鍋 x (2) 件";
122 | o3.訂單編號 = "T1213121543220";
123 |
124 | o3.客戶代號 = "273637101";
125 | o3.代收金額 = 199;
126 | o3.郵號條碼 = "32-331-02";
127 | o3.尺寸 = "150 cm";
128 | BlackcatShippingOrderPrintHelper.Agent.AddOrderInfo(o3);
129 |
130 | BlackcatShippingOrderPrintHelper.Agent.ExportToJPG(AppDomain.CurrentDomain.BaseDirectory + "test.jpg");
131 |
132 | Image1.ImageUrl = "test.jpg?" + Guid.NewGuid().ToString("N");
133 |
134 | //回收
135 | BlackcatShippingOrderPrintHelper.Agent.Dispose();
136 |
137 |
138 |
139 | }
140 | }
141 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | [Xx]64/
19 | [Xx]86/
20 | [Bb]uild/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 |
85 | # Visual Studio profiler
86 | *.psess
87 | *.vsp
88 | *.vspx
89 | *.sap
90 |
91 | # TFS 2012 Local Workspace
92 | $tf/
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 | *.DotSettings.user
101 |
102 | # JustCode is a .NET coding add-in
103 | .JustCode
104 |
105 | # TeamCity is a build add-in
106 | _TeamCity*
107 |
108 | # DotCover is a Code Coverage Tool
109 | *.dotCover
110 |
111 | # NCrunch
112 | _NCrunch_*
113 | .*crunch*.local.xml
114 | nCrunchTemp_*
115 |
116 | # MightyMoose
117 | *.mm.*
118 | AutoTest.Net/
119 |
120 | # Web workbench (sass)
121 | .sass-cache/
122 |
123 | # Installshield output folder
124 | [Ee]xpress/
125 |
126 | # DocProject is a documentation generator add-in
127 | DocProject/buildhelp/
128 | DocProject/Help/*.HxT
129 | DocProject/Help/*.HxC
130 | DocProject/Help/*.hhc
131 | DocProject/Help/*.hhk
132 | DocProject/Help/*.hhp
133 | DocProject/Help/Html2
134 | DocProject/Help/html
135 |
136 | # Click-Once directory
137 | publish/
138 |
139 | # Publish Web Output
140 | *.[Pp]ublish.xml
141 | *.azurePubxml
142 |
143 | # TODO: Un-comment the next line if you do not want to checkin
144 | # your web deploy settings because they may include unencrypted
145 | # passwords
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # NuGet Packages
150 | *.nupkg
151 | # The packages folder can be ignored because of Package Restore
152 | **/packages/*
153 | # except build/, which is used as an MSBuild target.
154 | !**/packages/build/
155 | # Uncomment if necessary however generally it will be regenerated when needed
156 | #!**/packages/repositories.config
157 | # NuGet v3's project.json files produces more ignoreable files
158 | *.nuget.props
159 | *.nuget.targets
160 |
161 | # Microsoft Azure Build Output
162 | csx/
163 | *.build.csdef
164 |
165 | # Microsoft Azure Emulator
166 | ecf/
167 | rcf/
168 |
169 | # Microsoft Azure ApplicationInsights config file
170 | ApplicationInsights.config
171 |
172 | # Windows Store app package directory
173 | AppPackages/
174 | BundleArtifacts/
175 |
176 | # Visual Studio cache files
177 | # files ending in .cache can be ignored
178 | *.[Cc]ache
179 | # but keep track of directories ending in .cache
180 | !*.[Cc]ache/
181 |
182 | # Others
183 | ClientBin/
184 | [Ss]tyle[Cc]op.*
185 | ~$*
186 | *~
187 | *.dbmdl
188 | *.dbproj.schemaview
189 | *.pfx
190 | *.publishsettings
191 | node_modules/
192 | orleans.codegen.cs
193 |
194 | # RIA/Silverlight projects
195 | Generated_Code/
196 |
197 | # Backup & report files from converting an old project file
198 | # to a newer Visual Studio version. Backup files are not needed,
199 | # because we have git ;-)
200 | _UpgradeReport_Files/
201 | Backup*/
202 | UpgradeLog*.XML
203 | UpgradeLog*.htm
204 |
205 | # SQL Server files
206 | *.mdf
207 | *.ldf
208 |
209 | # Business Intelligence projects
210 | *.rdl.data
211 | *.bim.layout
212 | *.bim_*.settings
213 |
214 | # Microsoft Fakes
215 | FakesAssemblies/
216 |
217 | # GhostDoc plugin setting file
218 | *.GhostDoc.xml
219 |
220 | # Node.js Tools for Visual Studio
221 | .ntvs_analysis.dat
222 |
223 | # Visual Studio 6 build log
224 | *.plg
225 |
226 | # Visual Studio 6 workspace options file
227 | *.opt
228 |
229 | # Visual Studio LightSwitch build output
230 | **/*.HTMLClient/GeneratedArtifacts
231 | **/*.DesktopClient/GeneratedArtifacts
232 | **/*.DesktopClient/ModelManifest.xml
233 | **/*.Server/GeneratedArtifacts
234 | **/*.Server/ModelManifest.xml
235 | _Pvt_Extensions
236 |
237 | # LightSwitch generated files
238 | GeneratedArtifacts/
239 | ModelManifest.xml
240 |
241 | # Paket dependency manager
242 | .paket/paket.exe
243 |
244 | # FAKE - F# Make
245 | .fake/
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper.Test/BlackcatShippingOrderPrintHelper.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 |
8 |
9 | 2.0
10 | {8E8879FA-2723-40F6-8DF7-DBAB03279D73}
11 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
12 | Library
13 | Properties
14 | BlackcatShippingOrderPrintHelper.Test
15 | BlackcatShippingOrderPrintHelper.Test
16 | v4.0
17 | true
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | true
26 | full
27 | false
28 | bin\
29 | DEBUG;TRACE
30 | prompt
31 | 4
32 |
33 |
34 | pdbonly
35 | true
36 | bin\
37 | TRACE
38 | prompt
39 | 4
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | index.aspx
68 | ASPXCodeBehind
69 |
70 |
71 | index.aspx
72 |
73 |
74 |
75 |
76 |
77 | Web.config
78 |
79 |
80 | Web.config
81 |
82 |
83 |
84 |
85 | {bd9dc9f4-072d-492f-a9fd-8258e0d3ce95}
86 | BlackcatShippingOrderPrintHelper
87 |
88 |
89 |
90 | 10.0
91 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 | True
101 | True
102 | 64634
103 | /
104 | http://localhost:64634/
105 | False
106 | False
107 |
108 |
109 | False
110 |
111 |
112 |
113 |
114 |
121 |
--------------------------------------------------------------------------------
/BlackcatShippingOrderPrintHelper/Agent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Drawing.Imaging;
5 | using System.Drawing.Text;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Runtime.InteropServices;
9 | using System.Text;
10 |
11 | namespace BlackcatShippingOrderPrintHelper
12 | {
13 | public static class Agent
14 | {
15 |
16 | private static List _OrderPool { get; set; }
17 | private static string _SamplePath { get; set; }
18 |
19 | private static Graphics _Graphics;
20 |
21 | public static void CearAllOrderInfo()
22 | {
23 | _OrderPool.Clear();
24 | }
25 |
26 | public static void AddOrderInfo(OrderInfo o)
27 | {
28 | if (_OrderPool.Count >= 3)
29 | {
30 | throw new Exception("超過三個囉");
31 | }
32 |
33 | _OrderPool.Add(o);
34 | }
35 |
36 | public static void LoadSampleImage(string filepath)
37 | {
38 | _SamplePath = filepath;
39 |
40 | }
41 |
42 | private static Bitmap GetCode39Bitmap(string strSource)
43 | {
44 | int x = 5;
45 | int y = 0;
46 | int wideLength = 16;
47 | int narrowLength = 8;
48 | int BarCodeHeight = 192;
49 | int intSourceLength = strSource.Length;
50 | string strEncode = "010010100"; //編碼字串 初值為 起始符號 *
51 |
52 | string AlphaBet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*"; //Code39的字母
53 |
54 | string[] Code39 = //Code39的各字母對應碼
55 | {
56 | /**//* 0 */ "000110100",
57 | /**//* 1 */ "100100001",
58 | /**//* 2 */ "001100001",
59 | /**//* 3 */ "101100000",
60 | /**//* 4 */ "000110001",
61 | /**//* 5 */ "100110000",
62 | /**//* 6 */ "001110000",
63 | /**//* 7 */ "000100101",
64 | /**//* 8 */ "100100100",
65 | /**//* 9 */ "001100100",
66 | /**//* A */ "100001001",
67 | /**//* B */ "001001001",
68 | /**//* C */ "101001000",
69 | /**//* D */ "000011001",
70 | /**//* E */ "100011000",
71 | /**//* F */ "001011000",
72 | /**//* G */ "000001101",
73 | /**//* H */ "100001100",
74 | /**//* I */ "001001100",
75 | /**//* J */ "000011100",
76 | /**//* K */ "100000011",
77 | /**//* L */ "001000011",
78 | /**//* M */ "101000010",
79 | /**//* N */ "000010011",
80 | /**//* O */ "100010010",
81 | /**//* P */ "001010010",
82 | /**//* Q */ "000000111",
83 | /**//* R */ "100000110",
84 | /**//* S */ "001000110",
85 | /**//* T */ "000010110",
86 | /**//* U */ "110000001",
87 | /**//* V */ "011000001",
88 | /**//* W */ "111000000",
89 | /**//* X */ "010010001",
90 | /**//* Y */ "110010000",
91 | /**//* Z */ "011010000",
92 | /**//* - */ "010000101",
93 | /**//* . */ "110000100",
94 | /**//*' '*/ "011000100",
95 | /**//* $ */ "010101000",
96 | /**//* / */ "010100010",
97 | /**//* + */ "010001010",
98 | /**//* % */ "000101010",
99 | /**//* * */ "010010100"
100 | };
101 | strSource = strSource.ToUpper();
102 | //實作圖片
103 | Bitmap objBitmap = new Bitmap(
104 | ((wideLength * 3 + narrowLength * 7) * (intSourceLength + 2)) + (x * 2),
105 | BarCodeHeight + (y * 2));
106 | Graphics objGraphics = Graphics.FromImage(objBitmap); //宣告GDI+繪圖介面
107 | //填上底色
108 | objGraphics.FillRectangle(Brushes.White, 0, 0, objBitmap.Width, objBitmap.Height);
109 |
110 | for (int i = 0; i < intSourceLength; i++)
111 | {
112 | //檢查是否有非法字元
113 | if (AlphaBet.IndexOf(strSource[i]) == -1 || strSource[i] == '*')
114 | {
115 | objGraphics.DrawString("含有非法字元",
116 | SystemFonts.DefaultFont, Brushes.Red, x, y);
117 | return objBitmap;
118 | }
119 | //查表編碼
120 | strEncode = string.Format("{0}0{1}", strEncode,
121 | Code39[AlphaBet.IndexOf(strSource[i])]);
122 | }
123 |
124 | strEncode = string.Format("{0}0010010100", strEncode); //補上結束符號 *
125 |
126 | int intEncodeLength = strEncode.Length; //編碼後長度
127 | int intBarWidth;
128 |
129 | for (int i = 0; i < intEncodeLength; i++) //依碼畫出Code39 BarCode
130 | {
131 | intBarWidth = strEncode[i] == '1' ? wideLength : narrowLength;
132 | objGraphics.FillRectangle(i % 2 == 0 ? Brushes.Black : Brushes.White,
133 | x, y, intBarWidth, BarCodeHeight);
134 | x += intBarWidth;
135 | }
136 | return objBitmap;
137 | }
138 |
139 |
140 | static Agent()
141 | {
142 | _OrderPool = new List();
143 | }
144 |
145 | public static void Dispose()
146 | {
147 | _OrderPool = new List();
148 | }
149 |
150 | public static void ExportToJPG(string targetFilePath)
151 | {
152 | var rBitmap = (Bitmap)Image.FromFile(_SamplePath);
153 | _Graphics = Graphics.FromImage(rBitmap);
154 |
155 | #region 第一個
156 | if (_OrderPool.Count >= 1)
157 | {
158 | Brush br = new SolidBrush(Color.Black);
159 |
160 | _Graphics.DrawString(_OrderPool[0].包裹查詢號碼.轉運站代號, new Font(new FontFamily("Arial"), 12), br, new PointF(366, 125));
161 | _Graphics.DrawString(_OrderPool[0].包裹查詢號碼.轉運單號, new Font(new FontFamily("Arial"), 18), br, new PointF(546, 115));
162 |
163 | //配送資訊
164 | _Graphics.DrawString(_OrderPool[0].配送資訊.收貨日.ToString("yyyy-MM-dd"), new Font(new FontFamily("Arial"), 10), br, new PointF(95, 280));
165 | _Graphics.DrawString(_OrderPool[0].配送資訊.預定配達日.ToString("yyyy-MM-dd"), new Font(new FontFamily("Arial"), 10), br, new PointF(355, 280));
166 | _Graphics.DrawString(_OrderPool[0].配送資訊.指定時段, new Font(new FontFamily("Arial"), 9), br, new PointF(650, 280));
167 |
168 | if (_OrderPool[0].配送資訊.發貨所.Length <= 5)
169 | {
170 | var tmpPlace = _OrderPool[0].配送資訊.發貨所;
171 | for (int i = 0; i < 5 - _OrderPool[0].配送資訊.發貨所.Length; i++)
172 | {
173 | tmpPlace = " " + tmpPlace;
174 | }
175 | _Graphics.DrawString(tmpPlace, new Font(new FontFamily("Arial"), 9), br, new PointF(885, 280));
176 |
177 | }
178 |
179 | //收件人
180 | _Graphics.DrawString(_OrderPool[0].收件人資訊.郵遞區號, new Font(new FontFamily("Arial"), 9), br, new PointF(150, 340));
181 | _Graphics.DrawString(_OrderPool[0].收件人資訊.地址, new Font(new FontFamily("Arial"), 10), br, new PointF(315, 340));
182 | _Graphics.DrawString(_OrderPool[0].收件人資訊.姓名, new Font(new FontFamily("Arial"), 10), br, new PointF(150, 410));
183 | _Graphics.DrawString(_OrderPool[0].收件人資訊.電話1, new Font(new FontFamily("Arial"), 10), br, new PointF(150, 480));
184 | _Graphics.DrawString(_OrderPool[0].收件人資訊.電話2, new Font(new FontFamily("Arial"), 10), br, new PointF(600, 480));
185 |
186 |
187 | //寄件人
188 | _Graphics.DrawString(_OrderPool[0].寄件人資訊.地址, new Font(new FontFamily("Arial"), 9), br, new PointF(150, 565));
189 | _Graphics.DrawString(_OrderPool[0].寄件人資訊.姓名, new Font(new FontFamily("Arial"), 8), br, new PointF(150, 620));
190 | _Graphics.DrawString(_OrderPool[0].寄件人資訊.電話1, new Font(new FontFamily("Arial"), 9), br, new PointF(150, 670));
191 | _Graphics.DrawString(_OrderPool[0].寄件人資訊.電話2, new Font(new FontFamily("Arial"), 9), br, new PointF(600, 670));
192 |
193 | //備註
194 | _Graphics.DrawString(_OrderPool[0].備註, new Font(new FontFamily("Arial"), 9), br, new PointF(180, 740));
195 |
196 | //品名
197 | _Graphics.DrawString(_OrderPool[0].品名, new Font(new FontFamily("Arial"), 9), br, new PointF(180, 810));
198 |
199 |
200 | //訂單編號
201 | _Graphics.DrawString(_OrderPool[0].訂單編號, new Font(new FontFamily("Arial"), 10), br, new PointF(260, 890));
202 |
203 |
204 | //客戶代號
205 | //BarCode
206 | var bmp1 = GetCode39Bitmap(_OrderPool[0].客戶代號);
207 | _Graphics.DrawImage(bmp1, new Rectangle(205, 990, 520, 50));
208 |
209 |
210 | //代號
211 | _Graphics.DrawString(_OrderPool[0].客戶代號, new Font(new FontFamily("Arial"), 10), br, new PointF(350, 1050));
212 |
213 | //金額
214 | _Graphics.DrawString(_OrderPool[0].代收金額.ToString("#"), new Font(new FontFamily("Arial"), 12), br, new PointF(920, 1010));
215 |
216 | //郵號條碼
217 | //Barcode
218 | var bmp2 = GetCode39Bitmap("+" + _OrderPool[0].郵號條碼.Replace("-", ""));
219 | _Graphics.DrawImage(bmp2, new Rectangle(1195, 60 , 510, 150));
220 |
221 | bmp2.Dispose();
222 |
223 | //Char
224 | _Graphics.DrawString(_OrderPool[0].郵號條碼, new Font(new FontFamily("Arial"), 28), br, new PointF(1695, 75));
225 |
226 |
227 | //收件人- 右
228 | _Graphics.DrawString(_OrderPool[0].收件人資訊.地址, new Font(new FontFamily("Arial"), 9), br, new PointF(1260, 260));
229 | _Graphics.DrawString(_OrderPool[0].收件人資訊.姓名, new Font(new FontFamily("Arial"), 10), br, new PointF(1260, 350));
230 | _Graphics.DrawString(_OrderPool[0].收件人資訊.電話1, new Font(new FontFamily("Arial"), 10), br, new PointF(1260, 410));
231 | _Graphics.DrawString(_OrderPool[0].收件人資訊.電話2, new Font(new FontFamily("Arial"), 10), br, new PointF(1660, 410));
232 |
233 | //寄件人- 右
234 | _Graphics.DrawString(_OrderPool[0].寄件人資訊.地址, new Font(new FontFamily("Arial"), 9), br, new PointF(1260, 490));
235 | _Graphics.DrawString(_OrderPool[0].寄件人資訊.姓名, new Font(new FontFamily("Arial"), 9), br, new PointF(1260, 540));
236 | _Graphics.DrawString(_OrderPool[0].寄件人資訊.電話1, new Font(new FontFamily("Arial"), 10), br, new PointF(1260, 600));
237 | _Graphics.DrawString(_OrderPool[0].寄件人資訊.電話2, new Font(new FontFamily("Arial"), 10), br, new PointF(1660, 600));
238 |
239 | //備註- 右
240 | _Graphics.DrawString(_OrderPool[0].備註, new Font(new FontFamily("Arial"), 9), br, new PointF(1315, 660));
241 |
242 | //品名- 右
243 | _Graphics.DrawString(_OrderPool[0].品名, new Font(new FontFamily("Arial"), 8), br, new PointF(1315, 715));
244 |
245 |
246 | //訂單編號- 右
247 | _Graphics.DrawString(_OrderPool[0].訂單編號, new Font(new FontFamily("Arial"), 8), br, new PointF(1420, 780));
248 |
249 |
250 | //收貨日- 右
251 | _Graphics.DrawString(_OrderPool[0].配送資訊.收貨日.ToString("yyyy-MM-dd"), new Font(new FontFamily("Arial"), 10), br, new PointF(1320, 835));
252 |
253 | //金額- 右
254 | _Graphics.DrawString(_OrderPool[0].代收金額.ToString("#"), new Font(new FontFamily("Arial"), 12), br, new PointF(1230, 1005));
255 |
256 |
257 | //客戶代號 -右
258 | _Graphics.DrawString(_OrderPool[0].客戶代號, new Font(new FontFamily("Arial"), 10), br, new PointF(1765, 835));
259 |
260 |
261 | //轉運單號 - 右
262 | //Barcode
263 | var bmp3 = GetCode39Bitmap(_OrderPool[0].包裹查詢號碼.轉運單號);
264 | _Graphics.DrawImage(bmp3, new Rectangle(1725, 910, 465, 170));
265 | bmp3.Dispose();
266 |
267 |
268 | //文字
269 | _Graphics.DrawString(_OrderPool[0].包裹查詢號碼.轉運單號, new Font(new FontFamily("Arial"), 10), br, new PointF(1849, 1080));
270 |
271 | //預定配達日- 右
272 | _Graphics.DrawString(_OrderPool[0].配送資訊.預定配達日.ToString("MM"), new Font(new FontFamily("Arial"), 10), br, new PointF(2120, 315));
273 | _Graphics.DrawString(_OrderPool[0].配送資訊.預定配達日.ToString("dd"), new Font(new FontFamily("Arial"), 10), br, new PointF(2160, 395));
274 |
275 |
276 | //指定送達時段- 右
277 | _Graphics.DrawString(_OrderPool[0].配送資訊.指定時段, new Font(new FontFamily("Arial"), 8), br, new PointF(2115, 540));
278 |
279 | //尺寸
280 | _Graphics.DrawString(_OrderPool[0].尺寸, new Font(new FontFamily("Arial"), 9), br, new PointF(2110, 730));
281 |
282 |
283 | _Graphics.Save();
284 | }
285 | #endregion
286 |
287 | #region 第二個
288 |
289 | var diff1 = 1170;
290 | if (_OrderPool.Count >= 2)
291 | {
292 | Brush br = new SolidBrush(Color.Black);
293 |
294 | _Graphics.DrawString(_OrderPool[1].包裹查詢號碼.轉運站代號, new Font(new FontFamily("Arial"), 12), br, new PointF(366, 125 + diff1));
295 | _Graphics.DrawString(_OrderPool[1].包裹查詢號碼.轉運單號, new Font(new FontFamily("Arial"), 18), br, new PointF(546, 115 + diff1));
296 |
297 | //配送資訊
298 | _Graphics.DrawString(_OrderPool[1].配送資訊.收貨日.ToString("yyyy-MM-dd"), new Font(new FontFamily("Arial"), 10), br, new PointF(95, 280 + diff1));
299 | _Graphics.DrawString(_OrderPool[1].配送資訊.預定配達日.ToString("yyyy-MM-dd"), new Font(new FontFamily("Arial"), 10), br, new PointF(355, 280 + diff1));
300 | _Graphics.DrawString(_OrderPool[1].配送資訊.指定時段, new Font(new FontFamily("Arial"), 9), br, new PointF(650, 280 + diff1));
301 |
302 | if (_OrderPool[1].配送資訊.發貨所.Length <= 5)
303 | {
304 | var tmpPlace = _OrderPool[1].配送資訊.發貨所;
305 | for (int i = 0; i < 5 - _OrderPool[1].配送資訊.發貨所.Length; i++)
306 | {
307 | tmpPlace = " " + tmpPlace;
308 | }
309 | _Graphics.DrawString(tmpPlace, new Font(new FontFamily("Arial"), 9), br, new PointF(885, 280 + diff1));
310 |
311 | }
312 |
313 | //收件人
314 | _Graphics.DrawString(_OrderPool[1].收件人資訊.郵遞區號, new Font(new FontFamily("Arial"), 9), br, new PointF(150, 340 + diff1));
315 | _Graphics.DrawString(_OrderPool[1].收件人資訊.地址, new Font(new FontFamily("Arial"), 10), br, new PointF(315, 340 + diff1));
316 | _Graphics.DrawString(_OrderPool[1].收件人資訊.姓名, new Font(new FontFamily("Arial"), 10), br, new PointF(150, 410 + diff1));
317 | _Graphics.DrawString(_OrderPool[1].收件人資訊.電話1, new Font(new FontFamily("Arial"), 10), br, new PointF(150, 480 + diff1));
318 | _Graphics.DrawString(_OrderPool[1].收件人資訊.電話2, new Font(new FontFamily("Arial"), 10), br, new PointF(600, 480 + diff1));
319 |
320 |
321 | //寄件人
322 | _Graphics.DrawString(_OrderPool[1].寄件人資訊.地址, new Font(new FontFamily("Arial"), 9), br, new PointF(150, 565 + diff1));
323 | _Graphics.DrawString(_OrderPool[1].寄件人資訊.姓名, new Font(new FontFamily("Arial"), 8), br, new PointF(150, 620 + diff1));
324 | _Graphics.DrawString(_OrderPool[1].寄件人資訊.電話1, new Font(new FontFamily("Arial"), 9), br, new PointF(150, 670 + diff1));
325 | _Graphics.DrawString(_OrderPool[1].寄件人資訊.電話2, new Font(new FontFamily("Arial"), 9), br, new PointF(600, 670 + diff1));
326 |
327 | //備註
328 | _Graphics.DrawString(_OrderPool[1].備註, new Font(new FontFamily("Arial"), 9), br, new PointF(180, 740 + diff1));
329 |
330 | //品名
331 | _Graphics.DrawString(_OrderPool[1].品名, new Font(new FontFamily("Arial"), 9), br, new PointF(180, 810 + diff1));
332 |
333 |
334 | //訂單編號
335 | _Graphics.DrawString(_OrderPool[1].訂單編號, new Font(new FontFamily("Arial"), 10), br, new PointF(260, 890 + diff1));
336 |
337 |
338 | //客戶代號
339 | //BarCode
340 | var bmp1 = GetCode39Bitmap(_OrderPool[1].客戶代號);
341 | _Graphics.DrawImage(bmp1, new Rectangle(205, 990 + diff1, 520, 50));
342 |
343 | //代號
344 | _Graphics.DrawString(_OrderPool[1].客戶代號, new Font(new FontFamily("Arial"), 10), br, new PointF(350, 1050 + diff1));
345 |
346 | //金額
347 | _Graphics.DrawString(_OrderPool[1].代收金額.ToString("#"), new Font(new FontFamily("Arial"), 12), br, new PointF(920, 1010 + diff1));
348 |
349 | //郵號條碼
350 | //Barcode
351 | var bmp2 = GetCode39Bitmap("+" + _OrderPool[1].郵號條碼.Replace("-", ""));
352 | _Graphics.DrawImage(bmp2, new Rectangle(1195, 60+diff1, 510, 150));
353 |
354 | //Char
355 | _Graphics.DrawString(_OrderPool[1].郵號條碼, new Font(new FontFamily("Arial"), 28), br, new PointF(1695, 75+diff1));
356 |
357 |
358 | //收件人- 右
359 | _Graphics.DrawString(_OrderPool[1].收件人資訊.地址, new Font(new FontFamily("Arial"), 9), br, new PointF(1260, 260 + diff1));
360 | _Graphics.DrawString(_OrderPool[1].收件人資訊.姓名, new Font(new FontFamily("Arial"), 10), br, new PointF(1260, 350 + diff1));
361 | _Graphics.DrawString(_OrderPool[1].收件人資訊.電話1, new Font(new FontFamily("Arial"), 10), br, new PointF(1260, 410 + diff1));
362 | _Graphics.DrawString(_OrderPool[1].收件人資訊.電話2, new Font(new FontFamily("Arial"), 10), br, new PointF(1660, 410 + diff1));
363 |
364 | //寄件人- 右
365 | _Graphics.DrawString(_OrderPool[1].寄件人資訊.地址, new Font(new FontFamily("Arial"), 9), br, new PointF(1260, 490 + diff1));
366 | _Graphics.DrawString(_OrderPool[1].寄件人資訊.姓名, new Font(new FontFamily("Arial"), 9), br, new PointF(1260, 540 + diff1));
367 | _Graphics.DrawString(_OrderPool[1].寄件人資訊.電話1, new Font(new FontFamily("Arial"), 10), br, new PointF(1260, 600 + diff1));
368 | _Graphics.DrawString(_OrderPool[1].寄件人資訊.電話2, new Font(new FontFamily("Arial"), 10), br, new PointF(1660, 600 + diff1));
369 |
370 | //備註- 右
371 | _Graphics.DrawString(_OrderPool[1].備註, new Font(new FontFamily("Arial"), 9), br, new PointF(1315, 660 + diff1));
372 |
373 | //品名- 右
374 | _Graphics.DrawString(_OrderPool[1].品名, new Font(new FontFamily("Arial"), 8), br, new PointF(1315, 715 + diff1));
375 |
376 |
377 | //訂單編號- 右
378 | _Graphics.DrawString(_OrderPool[1].訂單編號, new Font(new FontFamily("Arial"), 8), br, new PointF(1420, 780 + diff1));
379 |
380 |
381 | //收貨日- 右
382 | _Graphics.DrawString(_OrderPool[1].配送資訊.收貨日.ToString("yyyy-MM-dd"), new Font(new FontFamily("Arial"), 10), br, new PointF(1320, 835 + diff1));
383 |
384 | //金額- 右
385 | _Graphics.DrawString(_OrderPool[1].代收金額.ToString("#"), new Font(new FontFamily("Arial"), 12), br, new PointF(1230, 1005 + diff1));
386 |
387 |
388 | //客戶代號 -右
389 | _Graphics.DrawString(_OrderPool[1].客戶代號, new Font(new FontFamily("Arial"), 10), br, new PointF(1765, 835 + diff1));
390 |
391 |
392 | //轉運單號 - 右
393 | //Barcode
394 | //轉運單號 - 右
395 | //Barcode
396 | var bmp3 = GetCode39Bitmap(_OrderPool[1].包裹查詢號碼.轉運單號);
397 | _Graphics.DrawImage(bmp3, new Rectangle(1725, 910+diff1, 465, 170));
398 | bmp3.Dispose();
399 |
400 | //文字
401 | _Graphics.DrawString(_OrderPool[1].包裹查詢號碼.轉運單號, new Font(new FontFamily("Arial"), 10), br, new PointF(1849, 1080 + diff1));
402 |
403 | //預定配達日- 右
404 | _Graphics.DrawString(_OrderPool[1].配送資訊.預定配達日.ToString("MM"), new Font(new FontFamily("Arial"), 10), br, new PointF(2120, 315 + diff1));
405 | _Graphics.DrawString(_OrderPool[1].配送資訊.預定配達日.ToString("dd"), new Font(new FontFamily("Arial"), 10), br, new PointF(2160, 395 + diff1));
406 |
407 |
408 | //指定送達時段- 右
409 | _Graphics.DrawString(_OrderPool[1].配送資訊.指定時段, new Font(new FontFamily("Arial"), 8), br, new PointF(2115, 540 + diff1));
410 |
411 | //尺寸
412 | _Graphics.DrawString(_OrderPool[1].尺寸, new Font(new FontFamily("Arial"), 9), br, new PointF(2110, 730 + diff1));
413 |
414 |
415 | _Graphics.Save();
416 | }
417 | #endregion
418 |
419 | #region 第三個
420 |
421 | var diff2 = 2340;
422 | if (_OrderPool.Count >= 3)
423 | {
424 | Brush br = new SolidBrush(Color.Black);
425 |
426 | _Graphics.DrawString(_OrderPool[2].包裹查詢號碼.轉運站代號, new Font(new FontFamily("Arial"), 12), br, new PointF(366, 125 + diff2));
427 | _Graphics.DrawString(_OrderPool[2].包裹查詢號碼.轉運單號, new Font(new FontFamily("Arial"), 18), br, new PointF(546, 115 + diff2));
428 |
429 | //配送資訊
430 | _Graphics.DrawString(_OrderPool[2].配送資訊.收貨日.ToString("yyyy-MM-dd"), new Font(new FontFamily("Arial"), 10), br, new PointF(95, 280 + diff2));
431 | _Graphics.DrawString(_OrderPool[2].配送資訊.預定配達日.ToString("yyyy-MM-dd"), new Font(new FontFamily("Arial"), 10), br, new PointF(355, 280 + diff2));
432 | _Graphics.DrawString(_OrderPool[2].配送資訊.指定時段, new Font(new FontFamily("Arial"), 9), br, new PointF(650, 280 + diff2));
433 |
434 | if (_OrderPool[2].配送資訊.發貨所.Length <= 5)
435 | {
436 | var tmpPlace = _OrderPool[2].配送資訊.發貨所;
437 | for (int i = 0; i < 5 - _OrderPool[2].配送資訊.發貨所.Length; i++)
438 | {
439 | tmpPlace = " " + tmpPlace;
440 | }
441 | _Graphics.DrawString(tmpPlace, new Font(new FontFamily("Arial"), 9), br, new PointF(885, 280 + diff2));
442 |
443 | }
444 |
445 | //收件人
446 | _Graphics.DrawString(_OrderPool[2].收件人資訊.郵遞區號, new Font(new FontFamily("Arial"), 9), br, new PointF(150, 340 + diff2));
447 | _Graphics.DrawString(_OrderPool[2].收件人資訊.地址, new Font(new FontFamily("Arial"), 10), br, new PointF(315, 340 + diff2));
448 | _Graphics.DrawString(_OrderPool[2].收件人資訊.姓名, new Font(new FontFamily("Arial"), 10), br, new PointF(150, 410 + diff2));
449 | _Graphics.DrawString(_OrderPool[2].收件人資訊.電話1, new Font(new FontFamily("Arial"), 10), br, new PointF(150, 480 + diff2));
450 | _Graphics.DrawString(_OrderPool[2].收件人資訊.電話2, new Font(new FontFamily("Arial"), 10), br, new PointF(600, 480 + diff2));
451 |
452 |
453 | //寄件人
454 | _Graphics.DrawString(_OrderPool[2].寄件人資訊.地址, new Font(new FontFamily("Arial"), 9), br, new PointF(150, 565 + diff2));
455 | _Graphics.DrawString(_OrderPool[2].寄件人資訊.姓名, new Font(new FontFamily("Arial"), 8), br, new PointF(150, 620 + diff2));
456 | _Graphics.DrawString(_OrderPool[2].寄件人資訊.電話1, new Font(new FontFamily("Arial"), 9), br, new PointF(150, 670 + diff2));
457 | _Graphics.DrawString(_OrderPool[2].寄件人資訊.電話2, new Font(new FontFamily("Arial"), 9), br, new PointF(600, 670 + diff2));
458 |
459 | //備註
460 | _Graphics.DrawString(_OrderPool[2].備註, new Font(new FontFamily("Arial"), 9), br, new PointF(180, 740 + diff2));
461 |
462 | //品名
463 | _Graphics.DrawString(_OrderPool[2].品名, new Font(new FontFamily("Arial"), 9), br, new PointF(180, 810 + diff2));
464 |
465 |
466 | //訂單編號
467 | _Graphics.DrawString(_OrderPool[2].訂單編號, new Font(new FontFamily("Arial"), 10), br, new PointF(260, 890 + diff2));
468 |
469 |
470 | //客戶代號
471 | //BarCode
472 | var bmp1 = GetCode39Bitmap(_OrderPool[2].客戶代號);
473 |
474 | _Graphics.DrawImage(bmp1, new Rectangle(205, 990 + diff2, 520, 50));
475 |
476 |
477 | //代號
478 | _Graphics.DrawString(_OrderPool[2].客戶代號, new Font(new FontFamily("Arial"), 10), br, new PointF(350, 1050 + diff2));
479 |
480 | //金額
481 | _Graphics.DrawString(_OrderPool[2].代收金額.ToString("#"), new Font(new FontFamily("Arial"), 12), br, new PointF(920, 1010 + diff2));
482 |
483 | //郵號條碼
484 | //Barcode
485 | var bmp2 = GetCode39Bitmap("+" + _OrderPool[2].郵號條碼.Replace("-", ""));
486 |
487 | _Graphics.DrawImage(bmp2, new Rectangle(1195, 60 + diff2, 510, 150));
488 |
489 | //Char
490 | _Graphics.DrawString(_OrderPool[2].郵號條碼, new Font(new FontFamily("Arial"), 28), br, new PointF(1695, 75 + diff2));
491 |
492 |
493 | //收件人- 右
494 | _Graphics.DrawString(_OrderPool[2].收件人資訊.地址, new Font(new FontFamily("Arial"), 9), br, new PointF(1260, 260 + diff2));
495 | _Graphics.DrawString(_OrderPool[2].收件人資訊.姓名, new Font(new FontFamily("Arial"), 10), br, new PointF(1260, 350 + diff2));
496 | _Graphics.DrawString(_OrderPool[2].收件人資訊.電話1, new Font(new FontFamily("Arial"), 10), br, new PointF(1260, 410 + diff2));
497 | _Graphics.DrawString(_OrderPool[2].收件人資訊.電話2, new Font(new FontFamily("Arial"), 10), br, new PointF(1660, 410 + diff2));
498 |
499 | //寄件人- 右
500 | _Graphics.DrawString(_OrderPool[2].寄件人資訊.地址, new Font(new FontFamily("Arial"), 9), br, new PointF(1260, 490 + diff2));
501 | _Graphics.DrawString(_OrderPool[2].寄件人資訊.姓名, new Font(new FontFamily("Arial"), 9), br, new PointF(1260, 540 + diff2));
502 | _Graphics.DrawString(_OrderPool[2].寄件人資訊.電話1, new Font(new FontFamily("Arial"), 10), br, new PointF(1260, 600 + diff2));
503 | _Graphics.DrawString(_OrderPool[2].寄件人資訊.電話2, new Font(new FontFamily("Arial"), 10), br, new PointF(1660, 600 + diff2));
504 |
505 | //備註- 右
506 | _Graphics.DrawString(_OrderPool[2].備註, new Font(new FontFamily("Arial"), 9), br, new PointF(1315, 660 + diff2));
507 |
508 | //品名- 右
509 | _Graphics.DrawString(_OrderPool[2].品名, new Font(new FontFamily("Arial"), 8), br, new PointF(1315, 715 + diff2));
510 |
511 |
512 | //訂單編號- 右
513 | _Graphics.DrawString(_OrderPool[2].訂單編號, new Font(new FontFamily("Arial"), 8), br, new PointF(1420, 780 + diff2));
514 |
515 |
516 | //收貨日- 右
517 | _Graphics.DrawString(_OrderPool[2].配送資訊.收貨日.ToString("yyyy-MM-dd"), new Font(new FontFamily("Arial"), 10), br, new PointF(1320, 835 + diff2));
518 |
519 | //金額- 右
520 | _Graphics.DrawString(_OrderPool[2].代收金額.ToString("#"), new Font(new FontFamily("Arial"), 12), br, new PointF(1230, 1005 + diff2));
521 |
522 |
523 | //客戶代號 -右
524 | _Graphics.DrawString(_OrderPool[2].客戶代號, new Font(new FontFamily("Arial"), 10), br, new PointF(1765, 835 + diff2));
525 |
526 |
527 | //轉運單號 - 右
528 | //Barcode
529 | //轉運單號 - 右
530 | //Barcode
531 | var bmp3 = GetCode39Bitmap(_OrderPool[2].包裹查詢號碼.轉運單號);
532 | _Graphics.DrawImage(bmp3, new Rectangle(1725, 910+diff2, 465, 170));
533 | bmp3.Dispose();
534 |
535 | //文字
536 | _Graphics.DrawString(_OrderPool[2].包裹查詢號碼.轉運單號, new Font(new FontFamily("Arial"), 10), br, new PointF(1849, 1080 + diff2));
537 |
538 | //預定配達日- 右
539 | _Graphics.DrawString(_OrderPool[2].配送資訊.預定配達日.ToString("MM"), new Font(new FontFamily("Arial"), 10), br, new PointF(2120, 315 + diff2));
540 | _Graphics.DrawString(_OrderPool[2].配送資訊.預定配達日.ToString("dd"), new Font(new FontFamily("Arial"), 10), br, new PointF(2160, 395 + diff2));
541 |
542 |
543 | //指定送達時段- 右
544 | _Graphics.DrawString(_OrderPool[2].配送資訊.指定時段, new Font(new FontFamily("Arial"), 8), br, new PointF(2115, 540 + diff2));
545 |
546 | //尺寸
547 | _Graphics.DrawString(_OrderPool[2].尺寸, new Font(new FontFamily("Arial"), 9), br, new PointF(2110, 730 + diff2));
548 |
549 |
550 | _Graphics.Save();
551 | }
552 | #endregion
553 |
554 | ExportToFile(targetFilePath, rBitmap);
555 |
556 | }
557 |
558 |
559 |
560 | private static void ExportToFile(string path, Bitmap bitmap)
561 | {
562 | using (MemoryStream oMemoryStream = new MemoryStream())
563 | {
564 |
565 | //儲存圖片到 MemoryStream 物件,並且指定儲存影像之格式
566 | //Save image to MemoryStream and set it to jpeg format.
567 | bitmap.Save(oMemoryStream, ImageFormat.Jpeg);
568 | //設定資料流位置
569 | //Set stream position start from zero
570 | oMemoryStream.Position = 0;
571 | //設定 buffer 長度
572 | //Set buffer length
573 | var data = new byte[oMemoryStream.Length];
574 | //將資料寫入 buffer
575 | //Wrire data to buffer
576 | oMemoryStream.Read(data, 0, Convert.ToInt32(oMemoryStream.Length));
577 | //將所有緩衝區的資料寫入資料流
578 | //Flush memory.
579 | oMemoryStream.Flush();
580 | File.WriteAllBytes(path, data);
581 | }
582 |
583 | }
584 | }
585 | }
586 |
--------------------------------------------------------------------------------