From 86f899fa91e811415614dff1a699141144bfc802 Mon Sep 17 00:00:00 2001
From: quanzhou <quan.zhou@broconcentric.com>
Date: 星期五, 12 十二月 2025 13:25:37 +0800
Subject: [PATCH] S5上传mes逻辑修改及打印机逻辑修改和数据库存储数据增加
---
src/Bro.M141.Process/UI/UIPrinter.cs | 130 ++++++++++++++++++++++++++++++++++++-------
1 files changed, 108 insertions(+), 22 deletions(-)
diff --git a/src/Bro.M141.Process/UI/UIPrinter.cs b/src/Bro.M141.Process/UI/UIPrinter.cs
index c6e1de0..0278d89 100644
--- a/src/Bro.M141.Process/UI/UIPrinter.cs
+++ b/src/Bro.M141.Process/UI/UIPrinter.cs
@@ -45,24 +45,22 @@
{
base.OnProcessUpdated();
printDocument1.PrintPage += new PrintPageEventHandler(printDocument_Print);
-
- Process141.StartPrinter += StartPrint;
textBox1.Text = "C229M2508250500002";
}
PrintDocument printDocument1 = new PrintDocument();
- int ttwith = (int)(80 * 4);
- int ttheigh = (int)(40 * 4);
+ int ttwith = (int)(60 * 4);
+ int ttheigh = (int)(20 * 4);
string message = "";
public void StartPrint(string str)
{
try
{
- ttwith = 320;
- ttheigh = 160;
+ ttwith = 240;
+ ttheigh = 80;
message = str;
if (string.IsNullOrEmpty(message))
@@ -76,6 +74,14 @@
this.printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
this.printDocument1.Print();
+ this.printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)1";
+ this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Custum", ttwith, ttheigh);
+
+ this.printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
+ this.printDocument1.Print();
+
+
+
}
catch
{
@@ -86,8 +92,15 @@
string status = GetPrinterStatusMessage(statuscode);
//Config141
- Process141.PlcwritePrinter(1520, 0);
- Process141.PlcwritePrinter(1510, 1);
+ try
+ {
+ Process141.PlcwritePrinter(1520, 0);
+ Process141.PlcwritePrinter(1510, 1);
+ }
+ catch(Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
}
@@ -123,14 +136,14 @@
{
DisableECI = true,//璁剧疆鍐呭缂栫爜
CharacterSet = "UTF-8", //璁剧疆浜岀淮鐮佺殑瀹藉害鍜岄珮搴�
- Width = 123,
- Height = 123,
+ Width = 60,
+ Height = 60,
Margin = 1//璁剧疆浜岀淮鐮佺殑杈硅窛,鍗曚綅涓嶆槸鍥哄畾鍍忕礌
};
writer.Options = options;
Bitmap map = writer.Write(numvalue);
- e.Graphics.DrawImage(map, new System.Drawing.Point(90,10));
+ e.Graphics.DrawImage(map, new System.Drawing.Point(90,4));
// 鍦ㄤ簩缁寸爜涓嬫柟鐢诲唴瀹规枃瀛�
@@ -140,7 +153,7 @@
// 璁╂枃瀛楀眳涓埌浜岀淮鐮佷笅鏂�
SizeF textSize = e.Graphics.MeasureString(numvalue, font);
float textX = 90 + (map.Width - textSize.Width) / 2;
- float textY = 10 + map.Height;
+ float textY = 1 + map.Height;
e.Graphics.DrawString(numvalue, font, brush3, textX, textY);
}
@@ -151,6 +164,16 @@
//g.DrawString("鍘傚晢", font, brush, (startX + 20) * Scale, (startY + 5) * Scale);//
//g.DrawString("鍢夊桨绉戞妧", font2, brush, (startX + 140) * Scale, (startY + 4) * Scale);
+ //BarcodeWriter writer = new BarcodeWriter();
+ //writer.Format = BarcodeFormat.QR_CODE;
+ //QrCodeEncodingOptions options = new QrCodeEncodingOptions()
+ //{
+ // DisableECI = true,//璁剧疆鍐呭缂栫爜
+ // CharacterSet = "UTF-8", //璁剧疆浜岀淮鐮佺殑瀹藉害鍜岄珮搴�
+ // Width = 123,
+ // Height = 123,
+ // Margin = 1//璁剧疆浜岀淮鐮佺殑杈硅窛,鍗曚綅涓嶆槸鍥哄畾鍍忕礌
+ //};
////绗簩琛屾暟鎹�
//g.DrawRectangle(p, startX * Scale, (startY + 20) * Scale, 70 * Scale, 20 * Scale);
@@ -193,6 +216,79 @@
MessageBox.Show(ee.Message);
}
}
+
+
+ //private void printDocument_Print(object sender, PrintPageEventArgs e)
+ //{
+ // Font fntTxt = new Font("榛戜綋", 15, System.Drawing.FontStyle.Bold);//姝f枃鏂囧瓧
+ // System.Drawing.Brush brush = new SolidBrush(System.Drawing.Color.Black);//鐢诲埛
+ // try
+ // {
+ // string numvalue = message;
+
+ // float Scale = (float)0.95;
+ // int startX = 10;
+ // int startY = 25;
+
+ // //int length = 320 * Scale;
+ // //int height = 160 * Scale;
+ // var g = e.Graphics;
+
+ // Font font = new Font("Arial", 8 * Scale);//璁剧疆瀛椾綋棰滆壊
+ // Font font2 = new Font("Arial", 11 * Scale);//璁剧疆瀛椾綋棰滆壊
+ // Font font3 = new Font("Arial", 36 * Scale);//璁剧疆瀛椾綋棰滆壊
+ // Font font4 = new Font("Arial", 12 * Scale);//璁剧疆瀛椾綋棰滆壊
+
+
+ // Pen p = new Pen(Color.Black, Scale);//瀹氫箟浜嗕竴涓粦鑹�,瀹藉害涓�1鐨勭敾绗�
+ // g.Clear(Color.White);
+ // g.DrawRectangle(p, startX * Scale, startY * Scale, 70 * Scale, 20 * Scale);//鍦ㄧ敾鏉夸笂鐢荤煩褰�,璧峰鍧愭爣涓�(10,10),瀹戒负80,楂樹负20
+ // g.DrawRectangle(p, startX * Scale, startY * Scale, 280 * Scale, 20 * Scale);//鍦ㄧ敾鏉夸笂鐢荤煩褰�,璧峰鍧愭爣涓�(90,10),瀹戒负80,楂樹负20
+ // g.DrawString("鍘傚晢", font, brush, (startX + 20) * Scale, (startY + 5) * Scale);//
+ // g.DrawString("鍢夊桨绉戞妧", font2, brush, (startX + 140) * Scale, (startY + 4) * Scale);
+
+
+ // //绗簩琛屾暟鎹�
+ // g.DrawRectangle(p, startX * Scale, (startY + 20) * Scale, 70 * Scale, 20 * Scale);
+ // g.DrawRectangle(p, startX * Scale, (startY + 20) * Scale, 280 * Scale, 20 * Scale);
+ // g.DrawString("鍝佸悕", font, brush, (startX + 20) * Scale, (startY + 25) * Scale);
+ // g.DrawString(@"COVER LG208H-RC100 #2", font4, brush, (startX + 71) * Scale, (startY + 22) * Scale);
+
+ // //绗笁琛屾暟鎹�
+ // g.DrawRectangle(p, startX * Scale, (startY + 40) * Scale, 70 * Scale, 20 * Scale);
+ // g.DrawRectangle(p, startX * Scale, (startY + 40) * Scale, 280 * Scale, 20 * Scale);
+ // g.DrawString("鏂欏彿", font, brush, (startX + 20) * Scale, (startY + 45) * Scale);
+ // g.DrawString(@"436LG208I000", font2, brush, (startX + 130) * Scale, (startY + 43) * Scale);
+
+ // //绗洓琛屾暟鎹�
+ // g.DrawRectangle(p, startX * Scale, (startY + 60) * Scale, 70 * Scale, 20 * Scale);
+ // g.DrawRectangle(p, startX * Scale, (startY + 60) * Scale, 210 * Scale, 20 * Scale);
+ // g.DrawString("鏁伴噺", font, brush, (startX + 20) * Scale, (startY + 65) * Scale);
+ // g.DrawString(@"50PCS", font2, brush, (startX + 120) * Scale, (startY + 62) * Scale);
+
+ // //绗簲琛屾暟鎹�
+ // g.DrawRectangle(p, startX * Scale, (startY + 80) * Scale, 70 * Scale, 20 * Scale);
+ // g.DrawRectangle(p, startX * Scale, (startY + 80) * Scale, 210 * Scale, 20 * Scale);
+ // g.DrawString("鐢熶骇鏃ユ湡", font, brush, (startX + 10) * Scale, (startY + 85) * Scale);
+ // g.DrawString($"{DateTime.Now.ToString("yyyy.MM.dd")}", font2, brush, (startX + 105) * Scale, (startY + 82) * Scale);
+
+ // //绗叚琛屾暟鎹�
+ // g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 70 * Scale, 20 * Scale);
+ // g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 140 * Scale, 20 * Scale);
+ // g.DrawRectangle(p, startX * Scale, (startY + 100) * Scale, 210 * Scale, 20 * Scale);
+ // g.DrawString("MARK1", font, brush, (startX + 15) * Scale, (startY + 104) * Scale);
+ // g.DrawString("MARK2", font, brush, (startX + 155) * Scale, (startY + 104) * Scale);
+
+
+ // //渚ч潰
+ // g.DrawRectangle(p, (startX + 210) * Scale, (startY + 60) * Scale, 70 * Scale, 60 * Scale);
+ // g.DrawString(@"#2", font3, brush, (startX + 210) * Scale, (startY + 62) * Scale);
+ // }
+ // catch (Exception ee)
+ // {
+ // MessageBox.Show(ee.Message);
+ // }
+ //}
private void printDocument_Print222(object sender, PrintPageEventArgs e)
{
@@ -437,16 +533,6 @@
return bmp;
}
-
-
-
-
-
-
-
-
-
-
#region
--
Gitblit v1.8.0