Print.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using LabelManager2;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using UAS_LabelMachine.Entity;
  8. namespace UAS_LabelMachine.PublicMethod
  9. {
  10. class Print
  11. {
  12. public class CodeSoft
  13. {
  14. public static void SinglePrint(Document SingleDoc, string[] arg, string pib_id)
  15. {
  16. DataRow[] dr = UAS_出货标签打印.SingleBoxCacheData.Select("pib_id=" + pib_id);
  17. for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
  18. {
  19. if (arg.Contains(SingleDoc.Variables.FreeVariables.Item(j + 1).Name))
  20. SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][SingleDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
  21. if (SingleDoc.Variables.FreeVariables.Item(j + 1).Value == "")
  22. {
  23. DataRow[] dr1 = UAS_出货标签打印.Attach.Select("lp_name='" + SingleDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
  24. if (dr1.Length > 0)
  25. {
  26. SingleDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
  27. }
  28. }
  29. }
  30. SingleDoc.PrintDocument();
  31. }
  32. public static void MidPrint(Document MidDoc, DataTable MidLabelParam, string[] arg, string pib_id, string pib_outboxcode1)
  33. {
  34. for (int j = 0; j < MidDoc.Variables.FreeVariables.Count; j++)
  35. {
  36. //将维护的模板参数和模板本身的参数名称进行比对
  37. for (int k = 0; k < MidLabelParam.Rows.Count; k++)
  38. {
  39. //名称相等的时候,取SQL进行值的查询
  40. if (MidDoc.Variables.FreeVariables.Item(j + 1).Name == MidLabelParam.Rows[k]["lp_name"].ToString())
  41. {
  42. //获取对应行的pib_id
  43. //获取打印执行的SQL
  44. string sql = MidLabelParam.Rows[k]["lp_sql"].ToString();
  45. try
  46. {
  47. //获取打印执行的SQL
  48. if (sql.IndexOf("{") == 0)
  49. {
  50. MidDoc.Variables.FreeVariables.Item(j + 1).Value = SystemInf.dh.GetLabelParam(sql).ToString();
  51. }
  52. else
  53. {
  54. DataRow[] dr = UAS_出货标签打印.MidBoxCacheData.Select("pib_outboxcode1='" + pib_outboxcode1 + "'");
  55. if (arg.Contains(MidDoc.Variables.FreeVariables.Item(j + 1).Name))
  56. {
  57. if (dr.Length > 0)
  58. {
  59. MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr[0][MidDoc.Variables.FreeVariables.Item(j + 1).Name].ToString();
  60. }
  61. }
  62. if (MidDoc.Variables.FreeVariables.Item(j + 1).Value == "")
  63. {
  64. DataRow[] dr1 = UAS_出货标签打印.Attach.Select("lp_name='" + MidDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
  65. if (dr1.Length > 0)
  66. {
  67. MidDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
  68. }
  69. }
  70. }
  71. }
  72. catch (Exception)
  73. {
  74. return;
  75. }
  76. }
  77. }
  78. }
  79. MidDoc.PrintDocument();
  80. }
  81. public static void OutPrint(Document OutBoxDoc, DataTable OutLabelParam, string pib_id, string pib_outboxcode2)
  82. {
  83. for (int j = 0; j < OutBoxDoc.Variables.FreeVariables.Count; j++)
  84. {
  85. //将维护的模板参数和模板本身的参数名称进行比对
  86. for (int k = 0; k < OutLabelParam.Rows.Count; k++)
  87. {
  88. //名称相等的时候,取SQL进行值的查询
  89. if (OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name == OutLabelParam.Rows[k]["lp_name"].ToString())
  90. {
  91. //获取对应行的pib_id
  92. //获取打印执行的SQL
  93. string sql = OutLabelParam.Rows[k]["lp_sql"].ToString();
  94. //select * from productiobarcode where pib_id={pib_id} and pib_outboxcode1={pib_outboxcode1}
  95. try
  96. {
  97. string ExeSQL = "";
  98. ExeSQL = sql.ToLower().Replace("{pib_id}", "'" + pib_id + "'");
  99. ExeSQL = ExeSQL.Replace("{pib_outboxcode2}", "'" + pib_outboxcode2 + "'");
  100. OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = SystemInf.dh.GetLabelParam(ExeSQL).ToString();
  101. if (OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value == "")
  102. {
  103. DataRow[] dr1 = UAS_出货标签打印.Attach.Select("lp_name='" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name + "'");
  104. if (dr1.Length > 0)
  105. {
  106. OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
  107. }
  108. }
  109. LogManager.DoLog("打印参数【" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Name + "】赋值," + "取值SQL:" + ExeSQL + ",取到值" + OutBoxDoc.Variables.FreeVariables.Item(j + 1).Value);
  110. }
  111. catch (Exception)
  112. {
  113. return;
  114. }
  115. }
  116. }
  117. }
  118. OutBoxDoc.PrintDocument();
  119. }
  120. }
  121. public class BarTender
  122. {
  123. public static void SinglePrint()
  124. {
  125. }
  126. public static void MidPrint()
  127. {
  128. }
  129. public static void OutPrint()
  130. {
  131. }
  132. }
  133. }
  134. }