Query_SOP.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. DataTable dt = dh.getFieldsDataByCondition("package_view", new string[] { "pa_makecode", "pa_prodcode" }, "pa_outboxcode='" + pa_outboxcode.Text + "'");
  55. string pr_code = "";
  56. if (dt.Rows.Count > 0)
  57. {
  58. ma_code.Text = dt.Rows[0]["pa_makecode"].ToString();
  59. pr_code = dt.Rows[0]["pa_prodcode"].ToString();
  60. }
  61. dt = (DataTable)dh.ExecuteSql("select * from package_view where pa_makecode='" + ma_code.Text + "'", "select");
  62. string ErrorMessage = "";
  63. string outboxcode = "";
  64. if (dt.Rows.Count == 0)
  65. {
  66. OperateResult.AppendText(">>工单" + ma_code.Text + "不存在装箱记录\n", Color.Black);
  67. return;
  68. }
  69. if (pa_outboxcode.Text != "")
  70. {
  71. dt = (DataTable)dh.ExecuteSql("select * from package_view where pa_makecode='" + ma_code.Text + "' and pa_outboxcode='" + pa_outboxcode.Text + "'", "select");
  72. if (dt.Rows.Count == 0)
  73. {
  74. OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "不存在装箱记录\n", Color.Black);
  75. return;
  76. }
  77. }
  78. if (pa_outboxcode.Text != "")
  79. {
  80. string WorkProcess = dh.getFieldDataByCondition("configs", "data", "CODE='WorkProcess' and caller='MESSetting'").ToString();
  81. if (WorkProcess == "1")
  82. {
  83. string Err = "";
  84. if (!LogicHandler.CheckSNInfo(pa_outboxcode.Text, pr_code, ma_code.Text.Replace("-1", ""), "客户端", out Err))
  85. {
  86. OperateResult.AppendText(">>" + Err + "\n", Color.Black);
  87. return;
  88. }
  89. }
  90. }
  91. for (int i = 0; i < dt.Rows.Count; i++)
  92. {
  93. outboxcode = dt.Rows[i]["pa_outboxcode"].ToString();
  94. if (Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrintList.Text, outboxcode, 1, "", "", "卡通箱标", "0", out ErrorMessage))
  95. {
  96. OperateResult.AppendText(">>开始打印箱号" + outboxcode + "\n", Color.Black);
  97. LogicHandler.DoCommandLog("LabelPrint", User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "包装标签打印", "打印成功", outboxcode, "");
  98. }
  99. }
  100. }
  101. }
  102. }