Print.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. using LabelManager2;
  2. using Seagull.BarTender.Print;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using UAS_LabelMachine.Entity;
  10. namespace UAS_LabelMachine.PublicMethod
  11. {
  12. class Print
  13. {
  14. public class CodeSoft
  15. {
  16. public static void SinglePrint(Document SingleDoc, DataTable SingleLabelParam, string pib_id)
  17. {
  18. StringBuilder sql = new StringBuilder();
  19. sql.Clear();
  20. for (int j = 0; j < SingleDoc.Variables.FormVariables.Count; j++)
  21. {
  22. DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name + "'");
  23. if (dr1.Length > 0)
  24. {
  25. if (dr1[0]["lp_valuetype"].ToString() == "字符串" && dr1[0]["lp_sql"].ToString() != "")
  26. sql.Append(dr1[0]["lp_sql"].ToString() + ",");
  27. }
  28. }
  29. sql.Append("1,");
  30. DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_id=" + pib_id, "select");
  31. for (int j = 0; j < SingleDoc.Variables.FormVariables.Count; j++)
  32. {
  33. DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name + "'");
  34. if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串" && dr1[0]["lp_sql"].ToString() != "")
  35. {
  36. SingleDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
  37. }
  38. if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
  39. {
  40. DataTable dt1 = (DataTable)SystemInf.sdh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", pib_id), "select");
  41. if (dt1.Rows.Count > 0)
  42. {
  43. SingleDoc.Variables.FormVariables.Item(j + 1).Value = dt1.Rows[0][0].ToString();
  44. }
  45. }
  46. else if (dr1.Length > 0)
  47. {
  48. SingleDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
  49. }
  50. if (SingleDoc.Variables.FormVariables.Item(j + 1).Value == "")
  51. {
  52. dr1 = UAS_出货标签打印.Attach.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name + "'");
  53. if (dr1.Length > 0)
  54. SingleDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
  55. }
  56. }
  57. SingleDoc.PrintDocument();
  58. }
  59. public static void MidPrint(Document MidDoc, DataTable MidLabelParam, string pi_inoutno, string pib_id, string pib_outboxcode1)
  60. {
  61. StringBuilder sql = new StringBuilder();
  62. //查询参数名称相同的获取到取值字段
  63. for (int j = 0; j < MidDoc.Variables.FormVariables.Count; j++)
  64. {
  65. DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name + "'");
  66. if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串" && dr1[0]["lp_sql"].ToString() != "")
  67. {
  68. sql.Append(dr1[0]["lp_sql"].ToString() + ",");
  69. }
  70. }
  71. sql.Append("1,");
  72. DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno + "' and pib_outboxcode1=" + (pib_outboxcode1 == "" ? "0" : pib_outboxcode1), "select");
  73. for (int j = 0; j < MidDoc.Variables.FormVariables.Count; j++)
  74. {
  75. DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name + "'");
  76. if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串" && dr1[0]["lp_sql"].ToString() != "")
  77. {
  78. MidDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
  79. }
  80. //SQL判断多个值的时候
  81. if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
  82. {
  83. DataTable dt1 = (DataTable)SystemInf.sdh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", "'" + pi_inoutno + "'").Replace("{2}", pib_outboxcode1), "select");
  84. for (int i = 0; i < dt1.Rows.Count; i++)
  85. {
  86. for (int k = 0; k < MidDoc.Variables.FormVariables.Count; k++)
  87. {
  88. if (i == 0 & MidDoc.Variables.FormVariables.Item(k + 1).Name == dr1[0]["lp_name"].ToString())
  89. {
  90. MidDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[0][0].ToString();
  91. }
  92. //使用SN开头的参数赋值SN1,SN2,SN3等参数
  93. if (MidDoc.Variables.FormVariables.Item(k + 1).Name == (dr1[0]["lp_name"].ToString() + "_" + (i + 1)))
  94. {
  95. MidDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[i][0].ToString();
  96. }
  97. }
  98. }
  99. }
  100. if (MidDoc.Variables.FormVariables.Item(j + 1).Value == "")
  101. {
  102. dr1 = UAS_出货标签打印.Attach.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name + "'");
  103. if (dr1.Length > 0)
  104. MidDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
  105. }
  106. }
  107. MidDoc.PrintDocument();
  108. }
  109. public static void OutPrint(Document OutBoxDoc, DataTable OutLabelParam, string pi_inoutno, string pib_id, string pib_outboxcode2, bool iCustProdCode, bool iCustPo, bool iDC, bool iLotNo, bool iOrderCode)
  110. {
  111. StringBuilder sql = new StringBuilder();
  112. sql.Clear();
  113. for (int j = 0; j < OutBoxDoc.Variables.FormVariables.Count; j++)
  114. {
  115. DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name + "'");
  116. if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串" && dr1[0]["lp_sql"].ToString() != "")
  117. {
  118. sql.Append(dr1[0]["lp_sql"].ToString() + ",");
  119. }
  120. }
  121. //界面设定的分组条件
  122. string GroupByCondition = "";
  123. if (iCustProdCode)
  124. {
  125. GroupByCondition += "pd_custprodcode,";
  126. }
  127. if (iCustPo)
  128. {
  129. GroupByCondition += "pd_pocode,";
  130. }
  131. if (iDC)
  132. {
  133. GroupByCondition += "pib_datecode,";
  134. }
  135. if (iLotNo)
  136. {
  137. GroupByCondition += "pib_lotno,";
  138. }
  139. if (iOrderCode)
  140. {
  141. GroupByCondition += "pd_ordercode,";
  142. }
  143. if (iCustProdCode || iCustPo || iDC || iLotNo || iOrderCode)
  144. {
  145. GroupByCondition = " group by " + (GroupByCondition.Substring(0, GroupByCondition.Length - 1));
  146. }
  147. sql.Append("1,");
  148. DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno + "' and pib_outboxcode2=" + (pib_outboxcode2 == "" ? "0" : pib_outboxcode2) + GroupByCondition, "select");
  149. if (dt.Rows.Count > 0)
  150. {
  151. for (int j = 0; j < OutBoxDoc.Variables.FormVariables.Count; j++)
  152. {
  153. DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name + "'");
  154. if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "字符串" && dr1[0]["lp_sql"].ToString() != "")
  155. {
  156. OutBoxDoc.Variables.FormVariables.Item(j + 1).Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
  157. }
  158. //SQL判断多个值的时候
  159. if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
  160. {
  161. DataTable dt1 = (DataTable)SystemInf.sdh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", "'" + pi_inoutno + "'").Replace("{2}", pib_outboxcode2), "select");
  162. for (int i = 0; i < dt1.Rows.Count; i++)
  163. {
  164. for (int k = 0; k < OutBoxDoc.Variables.FormVariables.Count; k++)
  165. {
  166. if (i == 0 & OutBoxDoc.Variables.FormVariables.Item(k + 1).Name == dr1[0]["lp_name"].ToString())
  167. {
  168. OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[0][0].ToString();
  169. }
  170. //使用SN开头的参数赋值SN1,SN2,SN3等参数
  171. if (OutBoxDoc.Variables.FormVariables.Item(k + 1).Name == (dr1[0]["lp_name"].ToString() + "_" + (i + 1)))
  172. {
  173. OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[i][0].ToString();
  174. }
  175. if (dr1[0]["lp_sql"].ToString().Contains("pib_year"))
  176. {
  177. string date = dt1.Rows[0][0].ToString();
  178. }
  179. }
  180. }
  181. }
  182. if (OutBoxDoc.Variables.FormVariables.Item(j + 1).Value == "")
  183. {
  184. dr1 = UAS_出货标签打印.Attach.Select("lp_name='" + OutBoxDoc.Variables.FormVariables.Item(j + 1).Name + "'");
  185. if (dr1.Length > 0)
  186. OutBoxDoc.Variables.FormVariables.Item(j + 1).Value = dr1[0]["lp_sql"].ToString();
  187. }
  188. }
  189. OutBoxDoc.PrintDocument();
  190. }
  191. }
  192. }
  193. public class BarTender
  194. {
  195. public static void SinglePrint(LabelFormatDocument SingleFormat, DataTable SingleLabelParam, string pib_id)
  196. {
  197. if (pib_id == "-1")
  198. {
  199. SingleFormat.Print();
  200. return;
  201. }
  202. StringBuilder sql = new StringBuilder();
  203. sql.Clear();
  204. for (int j = 0; j < SingleFormat.SubStrings.Count; j++)
  205. {
  206. DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleFormat.SubStrings[j].Name + "'");
  207. if (dr1.Length > 0 && (dr1[0]["lp_valuetype"].ToString() == "字符串" || dr1[0]["lp_valuetype"].ToString() == "text") && dr1[0]["lp_sql"].ToString() != "")
  208. {
  209. sql.Append(dr1[0]["lp_sql"].ToString() + ",");
  210. }
  211. }
  212. sql.Append("1,");
  213. DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_id=" + pib_id, "select");
  214. for (int j = 0; j < SingleFormat.SubStrings.Count; j++)
  215. {
  216. DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleFormat.SubStrings[j].Name + "'");
  217. if (dr1.Length > 0 && (dr1[0]["lp_valuetype"].ToString() == "字符串" || dr1[0]["lp_valuetype"].ToString() == "text") && dr1[0]["lp_sql"].ToString() != "")
  218. {
  219. SingleFormat.SubStrings[j].Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
  220. }
  221. if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
  222. {
  223. DataTable dt1 = (DataTable)SystemInf.sdh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", pib_id), "select");
  224. if (dt1.Rows.Count > 0)
  225. {
  226. SingleFormat.SubStrings[j].Value = dt1.Rows[0][0].ToString();
  227. }
  228. }
  229. else if (dr1.Length > 0)
  230. {
  231. SingleFormat.SubStrings[j].Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
  232. }
  233. if (SingleFormat.SubStrings[j].Value == "")
  234. {
  235. DataRow[] dr2 = UAS_出货标签打印.Attach.Select("lp_name='" + SingleFormat.SubStrings[j].Name + "'");
  236. if (dr2.Length > 0)
  237. SingleFormat.SubStrings[j].Value = dr2[0]["lp_sql"].ToString();
  238. }
  239. //启用了校验Dc和LotNo不为空的设置
  240. if (SystemInf.CheckDcAndLotNo && dr1.Length > 0 && SingleFormat.SubStrings[j].Value == "")
  241. {
  242. //如果SQL用到了DC和LotNo字段
  243. if ((dr1[0]["lp_sql"].ToString().Contains("pib_lotno") || dr1[0]["lp_sql"].ToString().Contains("pib_datecode")))
  244. {
  245. MessageBox.Show("标签含有DC或者LotNo参数未赋值,请采集数据");
  246. return;
  247. }
  248. }
  249. }
  250. try
  251. {
  252. SingleFormat.PrintSetup.IdenticalCopiesOfLabel = 1;
  253. }
  254. catch (Exception)
  255. {
  256. }
  257. SingleFormat.Print();
  258. }
  259. public static void MidPrint(LabelFormatDocument MidFormat, DataTable MidLabelParam, string pi_inoutno, string pib_id, string pib_outboxcode1)
  260. {
  261. StringBuilder sql = new StringBuilder();
  262. //查询参数名称相同的获取到取值字段
  263. for (int j = 0; j < MidFormat.SubStrings.Count; j++)
  264. {
  265. DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidFormat.SubStrings[j].Name + "'");
  266. if (dr1.Length > 0 && (dr1[0]["lp_valuetype"].ToString() == "字符串" || dr1[0]["lp_valuetype"].ToString() == "text") && dr1[0]["lp_sql"].ToString() != "")
  267. {
  268. sql.Append(dr1[0]["lp_sql"].ToString() + ",");
  269. }
  270. }
  271. sql.Append("1,");
  272. DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno + "' and pib_outboxcode1=" + (pib_outboxcode1 == "" ? "0" : pib_outboxcode1) + " limit 0,1", "select");
  273. for (int j = 0; j < MidFormat.SubStrings.Count; j++)
  274. {
  275. DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidFormat.SubStrings[j].Name + "'");
  276. if (dr1.Length > 0 && (dr1[0]["lp_valuetype"].ToString() == "字符串" || dr1[0]["lp_valuetype"].ToString() == "text") && dr1[0]["lp_sql"].ToString() != "")
  277. {
  278. MidFormat.SubStrings[j].Value = dt.Rows[0][dr1[0]["lp_sql"].ToString()].ToString();
  279. }
  280. //SQL判断多个值的时候
  281. if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
  282. {
  283. DataTable dt1 = (DataTable)SystemInf.sdh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", "'" + pi_inoutno + "'").Replace("{2}", pib_outboxcode1), "select");
  284. for (int i = 0; i < dt1.Rows.Count; i++)
  285. {
  286. for (int k = 0; k < MidFormat.SubStrings.Count; k++)
  287. {
  288. if (i == 0 & MidFormat.SubStrings[k].Name == dr1[0]["lp_name"].ToString())
  289. {
  290. MidFormat.SubStrings[k].Value = dt1.Rows[0][0].ToString();
  291. }
  292. //使用SN开头的参数赋值SN1,SN2,SN3等参数
  293. if (MidFormat.SubStrings[k].Name == (dr1[0]["lp_name"].ToString() + "_" + (i + 1)))
  294. {
  295. MidFormat.SubStrings[k].Value = dt1.Rows[i][0].ToString();
  296. }
  297. }
  298. }
  299. }
  300. if (MidFormat.SubStrings[j].Value == "")
  301. {
  302. DataRow[] dr2 = UAS_出货标签打印.Attach.Select("lp_name='" + MidFormat.SubStrings[j].Name + "'");
  303. if (dr2.Length > 0)
  304. MidFormat.SubStrings[j].Value = dr2[0]["lp_sql"].ToString();
  305. }
  306. //启用了校验Dc和LotNo不为空的设置
  307. if (SystemInf.CheckDcAndLotNo && dr1.Length > 0 && MidFormat.SubStrings[j].Value == "")
  308. {
  309. //如果SQL用到了DC和LotNo字段
  310. if ((dr1[0]["lp_sql"].ToString().Contains("pib_lotno") || dr1[0]["lp_sql"].ToString().Contains("pib_datecode")))
  311. {
  312. MessageBox.Show("标签含有DC或者LotNo参数未赋值,请采集数据");
  313. return;
  314. }
  315. }
  316. }
  317. try
  318. {
  319. MidFormat.PrintSetup.IdenticalCopiesOfLabel = 1;
  320. }
  321. catch (Exception)
  322. {
  323. }
  324. MidFormat.Print();
  325. }
  326. public static void OutPrint(LabelFormatDocument OutFormat, DataTable OutLabelParam, string pi_inoutno, string pib_id, string pib_outboxcode2, bool iCustProdCode, bool iCustPo, bool iDC, bool iLotNo, bool iOrderCode)
  327. {
  328. if (pib_outboxcode2 == "-1")
  329. {
  330. OutFormat.PrintSetup.IdenticalCopiesOfLabel = 1;
  331. OutFormat.Print();
  332. return;
  333. }
  334. StringBuilder sql = new StringBuilder();
  335. sql.Clear();
  336. for (int j = 0; j < OutFormat.SubStrings.Count; j++)
  337. {
  338. DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutFormat.SubStrings[j].Name + "'");
  339. if (dr1.Length > 0 && (dr1[0]["lp_valuetype"].ToString() == "字符串" || dr1[0]["lp_valuetype"].ToString() == "text") && dr1[0]["lp_sql"].ToString() != "")
  340. {
  341. sql.Append(dr1[0]["lp_sql"].ToString() + ",");
  342. }
  343. }
  344. //界面设定的分组条件
  345. string GroupByCondition = "";
  346. if (iCustProdCode)
  347. {
  348. GroupByCondition += "pd_custprodcode,";
  349. }
  350. if (iCustPo)
  351. {
  352. GroupByCondition += "pd_pocode,";
  353. }
  354. if (iDC)
  355. {
  356. GroupByCondition += "pib_datecode,";
  357. }
  358. if (iLotNo)
  359. {
  360. GroupByCondition += "pib_lotno,";
  361. }
  362. if (iOrderCode)
  363. {
  364. GroupByCondition += "pd_ordercode,";
  365. }
  366. if (iCustProdCode || iCustPo || iDC || iLotNo || iOrderCode)
  367. {
  368. GroupByCondition = " group by " + (GroupByCondition.Substring(0, GroupByCondition.Length - 1));
  369. }
  370. sql.Append("max(pib_id),");
  371. DataTable dt = (DataTable)SystemInf.sdh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno + "' and pib_outboxcode2=" + (pib_outboxcode2 == "" ? "0" : pib_outboxcode2) + GroupByCondition, "select");
  372. for (int m = 0; m < dt.Rows.Count; m++)
  373. {
  374. for (int j = 0; j < OutFormat.SubStrings.Count; j++)
  375. {
  376. DataRow[] dr1 = OutLabelParam.Select("lp_name='" + OutFormat.SubStrings[j].Name + "'");
  377. if (dr1.Length > 0 && (dr1[0]["lp_valuetype"].ToString() == "字符串" || dr1[0]["lp_valuetype"].ToString() == "text") && dr1[0]["lp_sql"].ToString() != "")
  378. {
  379. OutFormat.SubStrings[j].Value = dt.Rows[m][dr1[0]["lp_sql"].ToString()].ToString();
  380. }
  381. //SQL判断多个值的时候
  382. if (dr1.Length > 0 && dr1[0]["lp_valuetype"].ToString() == "SQL值")
  383. {
  384. DataTable dt1 = (DataTable)SystemInf.sdh.ExecuteSql(dr1[0]["lp_sql"].ToString().Replace("{1}", "'" + pi_inoutno + "'").Replace("{2}", pib_outboxcode2), "select");
  385. for (int i = 0; i < dt1.Rows.Count; i++)
  386. {
  387. for (int k = 0; k < OutFormat.SubStrings.Count; k++)
  388. {
  389. if (i == 0 & OutFormat.SubStrings[k].Name == dr1[0]["lp_name"].ToString())
  390. {
  391. OutFormat.SubStrings[k].Value = dt1.Rows[0][0].ToString();
  392. }
  393. //使用SN开头的参数赋值SN1,SN2,SN3等参数
  394. if (OutFormat.SubStrings[k].Name == (dr1[0]["lp_name"].ToString() + "_" + (i + 1)))
  395. {
  396. OutFormat.SubStrings[k].Value = dt1.Rows[i][0].ToString();
  397. }
  398. if (dr1[0]["lp_sql"].ToString().Contains("pib_year"))
  399. {
  400. string date = dt1.Rows[0][0].ToString();
  401. }
  402. }
  403. }
  404. }
  405. if (OutFormat.SubStrings[j].Value == "")
  406. {
  407. DataRow[] dr2 = UAS_出货标签打印.Attach.Select("lp_name='" + OutFormat.SubStrings[j].Name + "'");
  408. if (dr2.Length > 0)
  409. OutFormat.SubStrings[j].Value = dr2[0]["lp_sql"].ToString();
  410. }
  411. //启用了校验Dc和LotNo不为空的设置
  412. if (SystemInf.CheckDcAndLotNo && dr1.Length > 0 && OutFormat.SubStrings[j].Value == "")
  413. {
  414. //如果SQL用到了DC和LotNo字段
  415. if ((dr1[0]["lp_sql"].ToString().Contains("pib_lotno") || dr1[0]["lp_sql"].ToString().Contains("pib_datecode")))
  416. {
  417. MessageBox.Show("标签含有DC或者LotNo参数未赋值,请采集数据");
  418. return;
  419. }
  420. }
  421. }
  422. try
  423. {
  424. OutFormat.PrintSetup.IdenticalCopiesOfLabel = 1;
  425. OutFormat.Print();
  426. }
  427. catch (Exception e)
  428. {
  429. Console.WriteLine(e.Message + e.StackTrace);
  430. }
  431. }
  432. }
  433. }
  434. }
  435. }