Query_Barcodeio.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. using DevExpress.Printing.Core.PdfExport.Metafile;
  2. using HslCommunication;
  3. using LabelManager2;
  4. using Seagull.BarTender.Print;
  5. using System;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Threading;
  9. using System.Windows.Forms;
  10. using UAS_MES_NEW.DataOperate;
  11. using UAS_MES_NEW.Entity;
  12. using UAS_MES_NEW.PublicForm;
  13. using UAS_MES_NEW.PublicMethod;
  14. using static System.Runtime.CompilerServices.RuntimeHelpers;
  15. namespace UAS_MES_NEW.Query
  16. {
  17. public partial class Query_Barcodeio : Form
  18. {
  19. DataHelper dh = SystemInf.dh;
  20. ApplicationClass lbl;
  21. Engine engine;
  22. Document doc;
  23. DataTable Dbfind;
  24. Thread InitPrint;
  25. public Query_Barcodeio()
  26. {
  27. InitializeComponent();
  28. try { UAS_MES_NEW.I18n.LanguageManager.Localize(this); } catch { }
  29. }
  30. private void Query_LoadMake_Load(object sender, EventArgs e)
  31. {
  32. pi_inoutno.TableName = "prodinout";
  33. pi_inoutno.SelectField = "pi_inoutno#单号";
  34. pi_inoutno.FormName = Name;
  35. pi_inoutno.SetValueField = new string[] { "pi_inoutno" };
  36. pi_inoutno.Condition = "1=1";
  37. pi_inoutno.DbChange += Ma_code_DbChange;
  38. InitPrint = new Thread(InPrint);
  39. SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
  40. BaseUtil.SetFormCenter(stw);
  41. stw.ShowDialog();
  42. LoadGridData();
  43. DataTable _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault,replace(LA_SOFTTYPE,';',',')LA_SOFTTYPE from label where la_prodcode='退料标签' and la_templatetype='自定义' and la_statuscode='AUDITED' order by la_isdefault", "select");
  44. if (_dt.Rows.Count == 0)
  45. {
  46. _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault,replace(LA_SOFTTYPE,';',',')LA_SOFTTYPE from label where la_prodcode is null and la_templatetype='自定义' and la_statuscode='AUDITED' order by la_isdefault", "select");
  47. }
  48. if (_dt.Rows.Count > 0)
  49. {
  50. string la_id = _dt.Rows[0]["la_id"].ToString();
  51. _dt = (DataTable)dh.ExecuteSql("select fp_name la_url,'" + la_id + "' la_id from FILEPATH where fp_id in (select * from table(select parsestring(LA_SOFTTYPE,';') from label where la_templatetype='自定义' and la_id='" + la_id + "') where COLUMN_VALUE is not null)", "select");
  52. PrintLabel.DataSource = _dt;
  53. PrintLabel.DisplayMember = "la_url";
  54. PrintLabel.ValueMember = "la_id";
  55. }
  56. }
  57. private void InPrint()
  58. {
  59. try
  60. {
  61. engine = new Engine(true);
  62. }
  63. catch (Exception)
  64. {
  65. MessageBox.Show(UAS_MES_NEW.I18n.LanguageManager.T("未正确安装BarTender软件"));
  66. }
  67. }
  68. private void Ma_code_DbChange(object sender, EventArgs e)
  69. {
  70. Dbfind = pi_inoutno.ReturnData;
  71. BaseUtil.SetFormValue(this.Controls, Dbfind);
  72. }
  73. private void UpLoadMake_Click(object sender, EventArgs e)
  74. {
  75. LoadGridData();
  76. }
  77. private void LoadGridData()
  78. {
  79. DataTable dt = (DataTable)dh.ExecuteSql("select * from barcodeio left join product on pr_code=bi_prodcode where bi_inoutno='" + pi_inoutno.Text + "'", "select");
  80. BaseUtil.FillDgvWithDataTable(DGV, dt);
  81. }
  82. private bool ifcheckrow()
  83. {
  84. for (int i = 0; i < DGV.Rows.Count; i++)
  85. {
  86. if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  87. {
  88. return true;
  89. }
  90. }
  91. return false;
  92. }
  93. private void Print_Click(object sender, EventArgs e)
  94. {
  95. if (!ifcheckrow())
  96. {
  97. MessageBox.Show(UAS_MES_NEW.I18n.LanguageManager.T("请勾选需要操作的行"));
  98. return;
  99. }
  100. for (int i = 0; i < DGV.Rows.Count; i++)
  101. {
  102. if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  103. {
  104. string barcode = DGV.Rows[i].Cells["bi_barcode"].Value.ToString();
  105. string prodcode = DGV.Rows[i].Cells["bi_prodcode"].Value.ToString();
  106. string ErrorMessage = "";
  107. if (Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, barcode, int.Parse("1"), pi_inoutno.Text, prodcode, "自定义", "0", out ErrorMessage))
  108. {
  109. }
  110. }
  111. }
  112. }
  113. private void pi_inoutno_UserControlTextChanged(object sender, EventArgs e)
  114. {
  115. LoadGridData();
  116. }
  117. private void PrintLabel_SelectedIndexChanged(object sender, EventArgs e)
  118. {
  119. }
  120. private void label3_Click(object sender, EventArgs e)
  121. {
  122. }
  123. }
  124. }