Query_SOP.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using UAS_MES_NEW.DataOperate;
  11. using UAS_MES_NEW.Entity;
  12. using UAS_MES_NEW.PublicMethod;
  13. namespace UAS_MES_NEW.Query
  14. {
  15. public partial class Query_SOP : Form
  16. {
  17. DataHelper dh = SystemInf.dh;
  18. Engine engine;
  19. public Query_SOP()
  20. {
  21. InitializeComponent();
  22. }
  23. private void Export_Click(object sender, EventArgs e)
  24. {
  25. }
  26. //选择导出Excel时是选择导出数据的还是模板
  27. private void ExcelExport(string DataOrTemplet)
  28. {
  29. }
  30. DataTable _dt;
  31. private void Query_SpecialReport_Load(object sender, EventArgs e)
  32. {
  33. try
  34. {
  35. engine = new Engine(true);
  36. }
  37. catch (Exception)
  38. {
  39. MessageBox.Show("未正确安装Bartender软件");
  40. }
  41. _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault from label where la_prodcode='BQDY' and la_templatetype='卡通箱标' and la_statuscode='AUDITED' order by la_isdefault", "select");
  42. PrintLabel.DataSource = _dt;
  43. PrintLabel.DisplayMember = "la_url";
  44. PrintLabel.ValueMember = "la_id";
  45. }
  46. private void Sn_KeyDown(object sender, KeyEventArgs e)
  47. {
  48. if (e.KeyData == Keys.Enter)
  49. {
  50. }
  51. }
  52. private void Print_Click(object sender, EventArgs e)
  53. {
  54. string makecode = dh.getFieldDataByCondition("package_view", "pa_makecode", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString();
  55. if (makecode != "")
  56. {
  57. ma_code.Text = makecode;
  58. }
  59. DataTable dt = (DataTable)dh.ExecuteSql("select * from package_view where pa_makecode='" + ma_code.Text + "'", "select");
  60. string ErrorMessage = "";
  61. string outboxcode = "";
  62. if (dt.Rows.Count == 0)
  63. {
  64. OperateResult.AppendText(">>工单" + ma_code.Text + "不存在装箱记录\n", Color.Black);
  65. return;
  66. }
  67. if (pa_outboxcode.Text != "")
  68. {
  69. dt = (DataTable)dh.ExecuteSql("select * from package_view where pa_makecode='" + ma_code.Text + "' and pa_outboxcode='" + pa_outboxcode.Text + "'", "select");
  70. if (dt.Rows.Count == 0)
  71. {
  72. OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "不存在装箱记录\n", Color.Black);
  73. return;
  74. }
  75. }
  76. for (int i = 0; i < dt.Rows.Count; i++)
  77. {
  78. outboxcode = dt.Rows[i]["pa_outboxcode"].ToString();
  79. if (Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, outboxcode, 1, "", "", "卡通箱标", "0", out ErrorMessage))
  80. {
  81. OperateResult.AppendText(">>开始打印箱号" + outboxcode + "\n", Color.Black);
  82. LogicHandler.DoCommandLog("LabelPrint", User.UserCode, makecode, User.UserLineCode, User.UserSourceCode, "包装标签打印", "打印成功", outboxcode, "");
  83. }
  84. }
  85. }
  86. }
  87. }