SystemSetting_PrinterTest.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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.Drawing.Printing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. using UAS_MES_NEW.DataOperate;
  12. using UAS_MES_NEW.Entity;
  13. using UAS_MES_NEW.PublicMethod;
  14. using static System.Runtime.CompilerServices.RuntimeHelpers;
  15. namespace UAS_MES_NEW.SystemSetting
  16. {
  17. public partial class SystemSetting_PrinterTest : Form
  18. {
  19. Engine engine = new Engine();
  20. LabelFormatDocument format;
  21. DataHelper dh = SystemInf.dh;
  22. DataTable Dbfind;
  23. public SystemSetting_PrinterTest()
  24. {
  25. InitializeComponent();
  26. try { UAS_MES_NEW.I18n.LanguageManager.Localize(this); } catch { }
  27. }
  28. private void PrintTest_Click(object sender, EventArgs e)
  29. {
  30. PrintDocument print = new PrintDocument();
  31. print.PrinterSettings.PrinterName = PrinterList.Text;
  32. print.PrintPage += Print_PrintPage;
  33. print.Print();
  34. }
  35. private void Print_PrintPage(object sender, PrintPageEventArgs e)
  36. {
  37. Graphics g = e.Graphics;
  38. float leftMargin = 10f; //左边距
  39. SolidBrush myBrush = new SolidBrush(System.Drawing.Color.Black);//刷子
  40. float yPosition = 5f;//行定位
  41. Font printFont = new Font("微软雅黑", 20f, FontStyle.Bold);//设置字体
  42. yPosition += printFont.GetHeight(g);//另起一行
  43. g.DrawString("成功连接此打印机", printFont, myBrush, leftMargin, yPosition, new StringFormat());
  44. }
  45. private void Setting_Click(object sender, EventArgs e)
  46. {
  47. PrintDialog printd = new PrintDialog();
  48. printd.PrinterSettings.PrinterName = PrinterList.Text;
  49. printd.ShowDialog();
  50. }
  51. private void Export_Click(object sender, EventArgs e)
  52. {
  53. if (!dh.CheckExist("make", "ma_code='" + ma_code.Text + "'"))
  54. {
  55. MessageBox.Show(UAS_MES_NEW.I18n.LanguageManager.T("工单号不存在"));
  56. return;
  57. }
  58. /*DataTable dt = (DataTable)dh.ExecuteSql("select pr_machinetype from make left join product on ma_prodcode=pr_code where ma_code='" + ma_code.Text + "'", "select");
  59. if (dt.Rows.Count > 0)
  60. {
  61. string pr_machinetype = dt.Rows[0]["pr_machinetype"].ToString();
  62. if (pr_machinetype != Prefix.Text)
  63. {
  64. MessageBox.Show(UAS_MES_NEW.I18n.LanguageManager.T("前缀和产品机型") + pr_machinetype + UAS_MES_NEW.I18n.LanguageManager.T("不匹配"));
  65. return;
  66. }
  67. }*/
  68. if (OneColumn.Checked)
  69. {
  70. format = engine.Documents.Open(Application.StartupPath + "/单排.btw");
  71. for (int i = int.Parse(Rn.Text); i < (int.Parse(Num.Text) + int.Parse(Rn.Text)); i = i + 1)
  72. {
  73. int temp = i;
  74. for (int j = 0; j < format.SubStrings.Count; j++)
  75. {
  76. switch (format.SubStrings[j].Name)
  77. {
  78. case "SN":
  79. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp).ToString()));
  80. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  81. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  82. break;
  83. case "COLOR":
  84. format.SubStrings[j].Value = Color.Text;
  85. break;
  86. case "MACHINE":
  87. format.SubStrings[j].Value = MachineType.Text;
  88. break;
  89. case "RAM":
  90. format.SubStrings[j].Value = Ram.Text;
  91. break;
  92. default:
  93. break;
  94. }
  95. }
  96. format.PrintSetup.PrinterName = PrinterList.Text;
  97. format.PrintSetup.IdenticalCopiesOfLabel = 1;
  98. format.Print();
  99. DataTable dt = (DataTable)dh.ExecuteSql("select ma_qty,ma_prodcode,pr_detail,ma_printnum from make left join product on ma_prodcode=pr_code left join (select count(1)ma_printnum,msl_makecode from makesnlist where msl_printstatus=-1 group by msl_makecode) on msl_makecode=ma_code where ma_code='" + ma_code.Text + "'", "select");
  100. if (dt.Rows.Count > 0)
  101. {
  102. pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString();
  103. ma_qty.Text = dt.Rows[0]["ma_qty"].ToString();
  104. ma_printcount.Text = dt.Rows[0]["ma_printnum"].ToString();
  105. pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
  106. }
  107. }
  108. }
  109. if (TwoColumn.Checked)
  110. {
  111. format = engine.Documents.Open(Application.StartupPath + "/双排.btw");
  112. for (int i = int.Parse(Rn.Text); i < (int.Parse(Num.Text) + int.Parse(Rn.Text)); i = i + 2)
  113. {
  114. int temp = i;
  115. for (int j = 0; j < format.SubStrings.Count; j++)
  116. {
  117. switch (format.SubStrings[j].Name)
  118. {
  119. case "SN":
  120. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp).ToString()));
  121. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  122. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  123. break;
  124. case "SN2":
  125. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 1).ToString()));
  126. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  127. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  128. break;
  129. default:
  130. break;
  131. }
  132. }
  133. format.PrintSetup.PrinterName = PrinterList.Text;
  134. format.PrintSetup.IdenticalCopiesOfLabel = 1;
  135. format.Print();
  136. DataTable dt = (DataTable)dh.ExecuteSql("select ma_qty,ma_prodcode,pr_detail,ma_printnum from make left join product on ma_prodcode=pr_code left join (select count(1)ma_printnum,msl_makecode from makesnlist where msl_printstatus=-1 group by msl_makecode) on msl_makecode=ma_code where ma_code='" + ma_code.Text + "'", "select");
  137. if (dt.Rows.Count > 0)
  138. {
  139. pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString();
  140. ma_qty.Text = dt.Rows[0]["ma_qty"].ToString();
  141. ma_printcount.Text = dt.Rows[0]["ma_printnum"].ToString();
  142. pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
  143. }
  144. }
  145. }
  146. if (ThreeColumn.Checked)
  147. {
  148. format = engine.Documents.Open(Application.StartupPath + "/Label.btw");
  149. for (int i = int.Parse(Rn.Text); i < (int.Parse(Num.Text) + int.Parse(Rn.Text)); i = i + 3)
  150. {
  151. int temp = i;
  152. for (int j = 0; j < format.SubStrings.Count; j++)
  153. {
  154. switch (format.SubStrings[j].Name)
  155. {
  156. case "SN":
  157. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp).ToString()));
  158. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  159. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  160. break;
  161. case "SN2":
  162. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 1).ToString()));
  163. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  164. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  165. break;
  166. case "SN3":
  167. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 2).ToString()));
  168. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  169. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  170. break;
  171. default:
  172. break;
  173. }
  174. }
  175. format.PrintSetup.PrinterName = PrinterList.Text;
  176. format.PrintSetup.IdenticalCopiesOfLabel = 1;
  177. format.Print();
  178. DataTable dt = (DataTable)dh.ExecuteSql("select ma_qty,ma_prodcode,pr_detail,ma_printnum from make left join product on ma_prodcode=pr_code left join (select count(1)ma_printnum,msl_makecode from makesnlist where msl_printstatus=-1 group by msl_makecode) on msl_makecode=ma_code where ma_code='" + ma_code.Text + "'", "select");
  179. if (dt.Rows.Count > 0)
  180. {
  181. pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString();
  182. ma_qty.Text = dt.Rows[0]["ma_qty"].ToString();
  183. ma_printcount.Text = dt.Rows[0]["ma_printnum"].ToString();
  184. pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
  185. }
  186. }
  187. }
  188. if (FourColumn.Checked)
  189. {
  190. format = engine.Documents.Open(Application.StartupPath + "/四排.btw");
  191. for (int i = int.Parse(Rn.Text); i < (int.Parse(Num.Text) + int.Parse(Rn.Text)); i = i + 4)
  192. {
  193. int temp = i;
  194. for (int j = 0; j < format.SubStrings.Count; j++)
  195. {
  196. switch (format.SubStrings[j].Name)
  197. {
  198. case "SN":
  199. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp).ToString()));
  200. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  201. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  202. break;
  203. case "SN2":
  204. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 1).ToString()));
  205. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  206. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  207. break;
  208. case "SN3":
  209. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 2).ToString()));
  210. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  211. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  212. break;
  213. case "SN4":
  214. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 3).ToString()));
  215. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  216. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  217. break;
  218. default:
  219. break;
  220. }
  221. }
  222. format.PrintSetup.PrinterName = PrinterList.Text;
  223. format.PrintSetup.IdenticalCopiesOfLabel = 1;
  224. format.Print();
  225. DataTable dt = (DataTable)dh.ExecuteSql("select ma_qty,ma_prodcode,pr_detail,ma_printnum from make left join product on ma_prodcode=pr_code left join (select count(1)ma_printnum,msl_makecode from makesnlist where msl_printstatus=-1 group by msl_makecode) on msl_makecode=ma_code where ma_code='" + ma_code.Text + "'", "select");
  226. if (dt.Rows.Count > 0)
  227. {
  228. pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString();
  229. ma_qty.Text = dt.Rows[0]["ma_qty"].ToString();
  230. ma_printcount.Text = dt.Rows[0]["ma_printnum"].ToString();
  231. pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
  232. }
  233. }
  234. }
  235. if (FiveColumn.Checked)
  236. {
  237. format = engine.Documents.Open(Application.StartupPath + "/五排.btw");
  238. for (int i = int.Parse(Rn.Text); i < (int.Parse(Num.Text) + int.Parse(Rn.Text)); i = i + 5)
  239. {
  240. int temp = i;
  241. for (int j = 0; j < format.SubStrings.Count; j++)
  242. {
  243. switch (format.SubStrings[j].Name)
  244. {
  245. case "SN":
  246. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp).ToString()));
  247. if (dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_printstatus='-1'"))
  248. {
  249. return;
  250. }
  251. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  252. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  253. break;
  254. case "SN2":
  255. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 1).ToString()));
  256. if (dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_printstatus='-1'"))
  257. {
  258. return;
  259. }
  260. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  261. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  262. break;
  263. case "SN3":
  264. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 2).ToString()));
  265. if (dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_printstatus='-1'"))
  266. {
  267. return;
  268. }
  269. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  270. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  271. break;
  272. case "SN4":
  273. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 3).ToString()));
  274. if (dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_printstatus='-1'"))
  275. {
  276. return;
  277. }
  278. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  279. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  280. break;
  281. case "SN5":
  282. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 4).ToString()));
  283. if (dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_printstatus='-1'"))
  284. {
  285. return;
  286. }
  287. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  288. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  289. break;
  290. default:
  291. break;
  292. }
  293. }
  294. format.PrintSetup.PrinterName = PrinterList.Text;
  295. format.PrintSetup.IdenticalCopiesOfLabel = 1;
  296. format.Print();
  297. DataTable dt = (DataTable)dh.ExecuteSql("select ma_qty,ma_prodcode,pr_detail,ma_printnum from make left join product on ma_prodcode=pr_code left join (select count(1)ma_printnum,msl_makecode from makesnlist where msl_printstatus=-1 group by msl_makecode) on msl_makecode=ma_code where ma_code='" + ma_code.Text + "'", "select");
  298. if (dt.Rows.Count > 0)
  299. {
  300. pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString();
  301. ma_qty.Text = dt.Rows[0]["ma_qty"].ToString();
  302. ma_printcount.Text = dt.Rows[0]["ma_printnum"].ToString();
  303. pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
  304. }
  305. }
  306. }
  307. if (EightColumn.Checked)
  308. {
  309. format = engine.Documents.Open(Application.StartupPath + "/八排.btw");
  310. for (int i = int.Parse(Rn.Text); i < (int.Parse(Num.Text) + int.Parse(Rn.Text)); i = i + 8)
  311. {
  312. int temp = i;
  313. for (int j = 0; j < format.SubStrings.Count; j++)
  314. {
  315. switch (format.SubStrings[j].Name)
  316. {
  317. case "SN":
  318. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp).ToString()));
  319. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  320. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  321. break;
  322. case "SN2":
  323. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 1).ToString()));
  324. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  325. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  326. break;
  327. case "SN3":
  328. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 2).ToString()));
  329. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  330. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  331. break;
  332. case "SN4":
  333. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 3).ToString()));
  334. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  335. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  336. break;
  337. case "SN5":
  338. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 4).ToString()));
  339. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  340. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  341. break;
  342. case "SN6":
  343. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 5).ToString()));
  344. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  345. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  346. break;
  347. case "SN7":
  348. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 6).ToString()));
  349. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  350. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  351. break;
  352. case "SN8":
  353. format.SubStrings[j].Value = (ma_code.Text + Date.Value.ToString("yyMMdd") + lpad(int.Parse(numericUpDown1.Value.ToString()), (temp + 7).ToString()));
  354. if (!dh.CheckExist("makesnlist", "msl_sncode='" + format.SubStrings[j].Value + "' and msl_makecode='" + ma_code.Text + "'"))
  355. dh.ExecuteSql("insert into makesnlist(msl_id,msl_indate,msl_makecode,msl_sncode,msl_type,msl_printstatus)values(makesnlist_seq.nextval,sysdate,'" + ma_code.Text + "','" + format.SubStrings[j].Value + "','before',-1)", "insert");
  356. break;
  357. default:
  358. break;
  359. }
  360. }
  361. format.PrintSetup.PrinterName = PrinterList.Text;
  362. format.PrintSetup.IdenticalCopiesOfLabel = 1;
  363. format.Print();
  364. DataTable dt = (DataTable)dh.ExecuteSql("select ma_qty,ma_prodcode,pr_detail,ma_printnum from make left join product on ma_prodcode=pr_code left join (select count(1)ma_printnum,msl_makecode from makesnlist where msl_printstatus=-1 group by msl_makecode) on msl_makecode=ma_code where ma_code='" + ma_code.Text + "'", "select");
  365. if (dt.Rows.Count > 0)
  366. {
  367. pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString();
  368. ma_qty.Text = dt.Rows[0]["ma_qty"].ToString();
  369. ma_printcount.Text = dt.Rows[0]["ma_printnum"].ToString();
  370. pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
  371. }
  372. }
  373. }
  374. }
  375. private static string lpad(int length, string number)
  376. {
  377. while (number.Length < length)
  378. {
  379. number = "0" + number;
  380. }
  381. number = number.Substring(number.Length - length, length);
  382. return number;
  383. }
  384. private void SystemSetting_PrinterTest_Load(object sender, EventArgs e)
  385. {
  386. engine.Start();
  387. ma_code.TableName = " make left join product on ma_prodcode=pr_code";
  388. ma_code.SelectField = "ma_code # 工单编号,pr_code # 产品编号,pr_spec # 型号";
  389. ma_code.FormName = Name;
  390. ma_code.SetValueField = new string[] { "ma_code" };
  391. ma_code.Condition = "ma_statuscode='STARTED'";
  392. ma_code.DbChange += pr_code_DbChange;
  393. }
  394. private void pr_code_DbChange(object sender, EventArgs e)
  395. {
  396. Dbfind = ma_code.ReturnData;
  397. BaseUtil.SetFormValue(this.Controls, Dbfind);
  398. DataTable dt = (DataTable)dh.ExecuteSql("select ma_submodel,ma_color,ma_qty,ma_prodcode,pr_detail,ma_printnum from make left join product on ma_prodcode=pr_code left join (select count(1)ma_printnum,mil_makecode from makeimeilist where mil_printstatus=-1 group by mil_makecode) on mil_makecode=ma_code where ma_code='" + ma_code.Text + "'", "select");
  399. if (dt.Rows.Count > 0)
  400. {
  401. Color.Text = dt.Rows[0]["ma_color"].ToString();
  402. MachineType.Text = dt.Rows[0]["ma_submodel"].ToString();
  403. pr_code.Text = dt.Rows[0]["ma_prodcode"].ToString();
  404. ma_qty.Text = dt.Rows[0]["ma_qty"].ToString();
  405. ma_printcount.Text = dt.Rows[0]["ma_printnum"].ToString();
  406. pr_detail.Text = dt.Rows[0]["pr_detail"].ToString();
  407. }
  408. }
  409. private void OneColumn_CheckedChanged(object sender, EventArgs e)
  410. {
  411. }
  412. }
  413. }