Query_Barcodeio.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. }
  29. private void Query_LoadMake_Load(object sender, EventArgs e)
  30. {
  31. pi_inoutno.TableName = "prodinout";
  32. pi_inoutno.SelectField = "pi_inoutno#单号";
  33. pi_inoutno.FormName = Name;
  34. pi_inoutno.SetValueField = new string[] { "pi_inoutno" };
  35. pi_inoutno.Condition = "1=1";
  36. pi_inoutno.DbChange += Ma_code_DbChange;
  37. InitPrint = new Thread(InPrint);
  38. SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
  39. BaseUtil.SetFormCenter(stw);
  40. stw.ShowDialog();
  41. LoadGridData();
  42. 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");
  43. if (_dt.Rows.Count == 0)
  44. {
  45. _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");
  46. }
  47. if (_dt.Rows.Count > 0)
  48. {
  49. string la_id = _dt.Rows[0]["la_id"].ToString();
  50. _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");
  51. PrintLabel.DataSource = _dt;
  52. PrintLabel.DisplayMember = "la_url";
  53. PrintLabel.ValueMember = "la_id";
  54. }
  55. }
  56. private void InPrint()
  57. {
  58. try
  59. {
  60. engine = new Engine(true);
  61. }
  62. catch (Exception)
  63. {
  64. MessageBox.Show("未正确安装BarTender软件");
  65. }
  66. }
  67. private void Ma_code_DbChange(object sender, EventArgs e)
  68. {
  69. Dbfind = pi_inoutno.ReturnData;
  70. BaseUtil.SetFormValue(this.Controls, Dbfind);
  71. }
  72. private void UpLoadMake_Click(object sender, EventArgs e)
  73. {
  74. LoadGridData();
  75. }
  76. private void LoadGridData()
  77. {
  78. DataTable dt = (DataTable)dh.ExecuteSql("select * from barcodeio left join product on pr_code=bi_prodcode where bi_inoutno='" + pi_inoutno.Text + "'", "select");
  79. BaseUtil.FillDgvWithDataTable(DGV, dt);
  80. }
  81. private bool ifcheckrow()
  82. {
  83. for (int i = 0; i < DGV.Rows.Count; i++)
  84. {
  85. if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  86. {
  87. return true;
  88. }
  89. }
  90. return false;
  91. }
  92. private void Print_Click(object sender, EventArgs e)
  93. {
  94. if (!ifcheckrow())
  95. {
  96. MessageBox.Show("请勾选需要操作的行");
  97. return;
  98. }
  99. for (int i = 0; i < DGV.Rows.Count; i++)
  100. {
  101. if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  102. {
  103. string barcode = DGV.Rows[i].Cells["bi_barcode"].Value.ToString();
  104. string prodcode = DGV.Rows[i].Cells["bi_prodcode"].Value.ToString();
  105. string ErrorMessage = "";
  106. 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))
  107. {
  108. }
  109. }
  110. }
  111. }
  112. private void pi_inoutno_UserControlTextChanged(object sender, EventArgs e)
  113. {
  114. LoadGridData();
  115. }
  116. private void PrintLabel_SelectedIndexChanged(object sender, EventArgs e)
  117. {
  118. }
  119. private void label3_Click(object sender, EventArgs e)
  120. {
  121. }
  122. }
  123. }