SystemSetting_PrinterTestRadium.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using Seagull.BarTender.Print;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Drawing.Printing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. using UAS_MES_NEW.DataOperate;
  12. using UAS_MES_NEW.Entity;
  13. using UAS_MES_NEW.PublicMethod;
  14. using static System.Runtime.CompilerServices.RuntimeHelpers;
  15. namespace UAS_MES_NEW.SystemSetting
  16. {
  17. public partial class SystemSetting_PrinterTestRadium : Form
  18. {
  19. Engine engine = new Engine();
  20. LabelFormatDocument format;
  21. DataHelper dh = SystemInf.dh;
  22. DataTable Dbfind;
  23. public SystemSetting_PrinterTestRadium()
  24. {
  25. InitializeComponent();
  26. try { UAS_MES_NEW.I18n.LanguageManager.Localize(this); } catch { }
  27. }
  28. private void PrintTest_Click(object sender, EventArgs e)
  29. {
  30. PrintDocument print = new PrintDocument();
  31. print.PrintPage += Print_PrintPage;
  32. print.Print();
  33. }
  34. private void Print_PrintPage(object sender, PrintPageEventArgs e)
  35. {
  36. Graphics g = e.Graphics;
  37. float leftMargin = 10f; //左边距
  38. SolidBrush myBrush = new SolidBrush(System.Drawing.Color.Black);//刷子
  39. float yPosition = 5f;//行定位
  40. Font printFont = new Font("微软雅黑", 20f, FontStyle.Bold);//设置字体
  41. yPosition += printFont.GetHeight(g);//另起一行
  42. g.DrawString("成功连接此打印机", printFont, myBrush, leftMargin, yPosition, new StringFormat());
  43. }
  44. private void Setting_Click(object sender, EventArgs e)
  45. {
  46. PrintDialog printd = new PrintDialog();
  47. printd.ShowDialog();
  48. }
  49. private void Export_Click(object sender, EventArgs e)
  50. {
  51. if (!dh.CheckExist("make", "ma_code='" + ma_code.Text + "'"))
  52. {
  53. MessageBox.Show(UAS_MES_NEW.I18n.LanguageManager.T("工单号不存在"));
  54. return;
  55. }
  56. /*DataTable dt = (DataTable)dh.ExecuteSql("select pr_machinetype from make left join product on ma_prodcode=pr_code where ma_code='" + ma_code.Text + "'", "select");
  57. if (dt.Rows.Count > 0)
  58. {
  59. string pr_machinetype = dt.Rows[0]["pr_machinetype"].ToString();
  60. if (pr_machinetype != Prefix.Text)
  61. {
  62. MessageBox.Show(UAS_MES_NEW.I18n.LanguageManager.T("前缀和产品机型") + pr_machinetype + UAS_MES_NEW.I18n.LanguageManager.T("不匹配"));
  63. return;
  64. }
  65. }*/
  66. format = engine.Documents.Open(Application.StartupPath + "/单排.btw");
  67. for (int i = int.Parse(Rn.Text); i < (int.Parse(Num.Text) + int.Parse(Rn.Text)); i = i + 1)
  68. {
  69. int temp = i;
  70. for (int j = 0; j < format.SubStrings.Count; j++)
  71. {
  72. switch (format.SubStrings[j].Name)
  73. {
  74. case "SN":
  75. format.SubStrings[j].Value = (PreFix.Text + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp).ToString()));
  76. if (!dh.CheckExist("makesnlist_radium", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  77. dh.ExecuteSql("insert into makesnlist_radium(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  78. break;
  79. }
  80. }
  81. DataTable dt = (DataTable)dh.ExecuteSql("select ma_qty,ma_prodcode,pr_detail,ma_printnum from make left join product on ma_prodcode=pr_code left join (select count(1)ma_printnum,msl_makecode from makesnlist where msl_printstatus=-1 group by msl_makecode) on msl_makecode=ma_code where ma_code='" + ma_code.Text + "'", "select");
  82. if (dt.Rows.Count > 0)
  83. {
  84. pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString();
  85. ma_qty.Text = dt.Rows[0]["ma_qty"].ToString();
  86. pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
  87. }
  88. }
  89. }
  90. private static string lpad(int length, string number)
  91. {
  92. while (number.Length < length)
  93. {
  94. number = "0" + number;
  95. }
  96. number = number.Substring(number.Length - length, length);
  97. return number;
  98. }
  99. private void SystemSetting_PrinterTest_Load(object sender, EventArgs e)
  100. {
  101. engine.Start();
  102. ma_code.TableName = " make left join product on ma_prodcode=pr_code";
  103. ma_code.SelectField = "ma_code # 工单编号,pr_code # 产品编号,pr_spec # 型号";
  104. ma_code.FormName = Name;
  105. ma_code.SetValueField = new string[] { "ma_code" };
  106. ma_code.Condition = "ma_statuscode='STARTED'";
  107. ma_code.DbChange += pr_code_DbChange;
  108. }
  109. private void pr_code_DbChange(object sender, EventArgs e)
  110. {
  111. Dbfind = ma_code.ReturnData;
  112. BaseUtil.SetFormValue(this.Controls, Dbfind);
  113. DataTable dt = (DataTable)dh.ExecuteSql("select ma_submodel,ma_color,ma_qty,ma_prodcode,pr_detail,ma_printnum from make left join product on ma_prodcode=pr_code left join (select count(1)ma_printnum,mil_makecode from makeimeilist where mil_printstatus=-1 group by mil_makecode) on mil_makecode=ma_code where ma_code='" + ma_code.Text + "'", "select");
  114. if (dt.Rows.Count > 0)
  115. {
  116. pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString();
  117. ma_qty.Text = dt.Rows[0]["ma_qty"].ToString();
  118. pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
  119. }
  120. }
  121. }
  122. }