入库条码规则解析.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. using LabelManager2;
  2. using Seagull.BarTender.Print;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Drawing.Printing;
  8. using System.Linq;
  9. using System.Media;
  10. using System.Threading;
  11. using System.Windows.Forms;
  12. using static System.Runtime.CompilerServices.RuntimeHelpers;
  13. namespace UAS_BARCODEIO
  14. {
  15. public partial class 入库条码规则解析 : Form
  16. {
  17. ApplicationClass lbl;
  18. DataHelper dh = new DataHelper();
  19. Document SingleDoc;
  20. Document OutDoc;
  21. DataTable Dbfind;
  22. //自适应屏幕
  23. AutoSizeFormClass asc = new AutoSizeFormClass();
  24. public 入库条码规则解析()
  25. {
  26. InitializeComponent();
  27. }
  28. delegate void BindDataSource(DataGridView dgv, DataTable dt);//定义委托
  29. void bindingsource(DataGridView dgv, DataTable dt)
  30. {
  31. //dgv.AutoGenerateColumns = false;
  32. //dgv.DataSource = null;
  33. //dgv.DataSource = dt;
  34. if (dgv.InvokeRequired)
  35. {
  36. dgv.Invoke(new BindDataSource(bindingsource), new object[] { dgv, dt });
  37. }
  38. else
  39. {
  40. dgv.AutoGenerateColumns = false;
  41. dgv.DataSource = dt;
  42. }
  43. }
  44. private void Form1_Load(object sender, EventArgs e)
  45. {
  46. es_custcode.TableName = "CS_EXPORTSETTING ";
  47. es_custcode.SelectField = "es_custcode # 品牌";
  48. es_custcode.FormName = Name;
  49. es_custcode.DBTitle = "解析规则查询";
  50. es_custcode.SetValueField = new string[] { "es_custcode" };
  51. es_custcode.Condition = "";
  52. es_custcode.DbChange += nr_rule_DBChange;
  53. SystemInf.dh = dh;
  54. try
  55. {
  56. lbl = new ApplicationClass();
  57. }
  58. catch (Exception ex)
  59. {
  60. Console.WriteLine(ex.Message);
  61. throw;
  62. }
  63. SingleDoc = lbl.Documents.Open(System.Windows.Forms.Application.StartupPath + @"\BARCODE.lab");
  64. OutDoc = lbl.Documents.Open(System.Windows.Forms.Application.StartupPath + @"\BOXCODE.lab");
  65. asc.controllInitializeSize(this);
  66. asc.controlAutoSize(this);
  67. PrintDocument print = new PrintDocument();
  68. string sDefault = print.PrinterSettings.PrinterName;//默认打印机名
  69. foreach (string sPrint in PrinterSettings.InstalledPrinters)//获取所有打印机名称
  70. {
  71. PrinterList.Items.Add(sPrint);
  72. if (sPrint == sDefault)
  73. PrinterList.SelectedIndex = PrinterList.Items.IndexOf(sPrint);
  74. }
  75. }
  76. private void nr_rule_DBChange(object sender, EventArgs e)
  77. {
  78. Dbfind = es_custcode.ReturnData;
  79. BaseUtil.SetFormValue(this.Controls, Dbfind);
  80. }
  81. private void pi_inoutnokeydown(object sender, KeyEventArgs e)
  82. {
  83. if (e.KeyCode == Keys.Enter)
  84. {
  85. LoadGridData();
  86. }
  87. }
  88. private void LoadGridData()
  89. {
  90. string sql = "select pd_inqty,pd_prodcode,pr_detail,pr_orispeccode,pr_spec,bi_inqty,pr_brand from " +
  91. "(select max(pd_prodcode)pd_prodcode,sum(pd_inqty)pd_inqty from prodiodetail left join product on pd_prodcode=pr_code where pd_inoutno='" + pi_inoutno.Text + "' group by pr_orispeccode,pr_brand)" +
  92. " left join (select max(bi_prodcode)bi_prodcode,nvl(sum(bi_inqty),0)bi_inqty from barcodeio left join product on pr_code=bi_prodcode " +
  93. "where bi_inoutno='" + pi_inoutno.Text + "' group by pr_orispeccode,pr_brand) on pd_prodcode=bi_prodcode left join product on pr_code=pd_prodcode order by pr_code";
  94. DataTable dt = (DataTable)dh.ExecuteSql(sql, "select");
  95. BaseUtil.FillDgvWithDataTable(Prodiodetail, dt);
  96. if (Prodiodetail.Rows.Count > SelectIndex)
  97. {
  98. Prodiodetail.Rows[SelectIndex].Selected = true;
  99. }
  100. }
  101. private void Barcode_KeyDown(object sender, KeyEventArgs e)
  102. {
  103. if (e.KeyCode == Keys.Enter)
  104. {
  105. DataTable dt = (DataTable)dh.ExecuteSql("select esd_caption,esd_enable,el_type from cs_exportsettingdetail left join CS_EXPORTSETTING" +
  106. " on es_id=esd_esid where es_custcode='" + es_custcode.Text + "'", "select");
  107. if (dt.Rows.Count == 0)
  108. {
  109. Play("NG");
  110. MessageBox.Show("无条码解析规则");
  111. return;
  112. }
  113. string split = dt.Rows[0]["el_type"].ToString();
  114. string[] str = Barcode.Text.Split(split.ToCharArray()[0]);
  115. //分割后的字符串数组需要大于设置的参数解析
  116. if (str.Length < dt.Rows.Count)
  117. {
  118. Play("NG");
  119. MessageBox.Show("解析参数与解析规则不匹配");
  120. return;
  121. }
  122. for (int i = 0; i < dt.Rows.Count; i++)
  123. {
  124. string name = dt.Rows[i]["esd_caption"].ToString();
  125. string index = dt.Rows[i]["esd_enable"].ToString();
  126. switch (name)
  127. {
  128. case "LOTNO":
  129. LOTNO.Text = str[int.Parse(index) - 1];
  130. break;
  131. case "DC":
  132. DC.Text = str[int.Parse(index) - 1];
  133. break;
  134. case "PROD":
  135. pr_orispeccode3.Text = str[int.Parse(index) - 1];
  136. break;
  137. case "QTY":
  138. INQTY.Text = str[int.Parse(index) - 1];
  139. break;
  140. case "SCCODE":
  141. SCCODE.Text = str[int.Parse(index) - 1];
  142. break;
  143. default:
  144. break;
  145. }
  146. }
  147. string madedate;
  148. string outqty;
  149. string lotno;
  150. string spec;
  151. LogicHandler.GetWeekData(DC.Text, INQTY.Text, es_custcode.Text.ToUpper(), pr_orispeccode3.Text, LOTNO.Text, out madedate, out outqty, out lotno, out spec);
  152. DC.Text = madedate;
  153. INQTY.Text = outqty;
  154. LOTNO.Text = lotno;
  155. pr_orispeccode3.Text = spec;
  156. Barcode.Clear();
  157. GenBarCode.PerformClick();
  158. Play("OK");
  159. }
  160. }
  161. bool AutoSized = false;
  162. private void 入库条码规则解析_AutoSizeChanged(object sender, EventArgs e)
  163. {
  164. if (!AutoSized)
  165. {
  166. asc.controlAutoSize(this);
  167. AutoSized = true;
  168. }
  169. }
  170. private void Prodiodetail_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
  171. {
  172. bool mouseOver = e.CellBounds.Contains(this.PointToClient(Cursor.Position));
  173. if (e.ColumnIndex > 0 && e.RowIndex >= 0)
  174. {
  175. if (Prodiodetail.Columns[e.ColumnIndex].Name == "pd_prodcode")
  176. {
  177. SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
  178. if (Prodiodetail.Rows[e.RowIndex].Cells["pd_prodcode"].Value.ToString() != Prodiodetail.Rows[e.RowIndex].Cells["pd_prodcode"].Value.ToString())
  179. e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.Yellow, e.CellBounds);
  180. else
  181. e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.White, e.CellBounds);
  182. Rectangle border = e.CellBounds;
  183. border.Width -= 1;
  184. e.Graphics.DrawRectangle(Pens.White, border);
  185. e.PaintContent(e.CellBounds);
  186. e.Handled = true;
  187. }
  188. }
  189. }
  190. private void Prodiodetail_SelectionChanged(object sender, EventArgs e)
  191. {
  192. if (Prodiodetail.SelectedRows.Count > 0)
  193. {
  194. DataGridViewSelectedRowCollection dsc = Prodiodetail.SelectedRows;
  195. Prodiodetail.Rows[dsc[0].Index].Selected = true;
  196. if (dsc[0].Index - 2 >= 0)
  197. Prodiodetail.FirstDisplayedScrollingRowIndex = dsc[0].Index - 2;
  198. else
  199. Prodiodetail.FirstDisplayedScrollingRowIndex = dsc[0].Index;
  200. }
  201. }
  202. private void GenBarCode_Click(object sender, EventArgs e)
  203. {
  204. string sql = "select pr_zxbzs,pd_piid,pd_piclass,pd_inqty,pd_prodcode,pr_detail,pr_spec,nvl(bi_inqty,0)bi_inqty from " +
  205. "(select max(pd_piid)pd_piid,max(pd_piclass)pd_piclass,max(pd_prodcode)pd_prodcode,sum(pd_inqty)pd_inqty from prodiodetail left join product on pr_code=pd_prodcode where pd_inoutno='" + pi_inoutno.Text + "' group by pr_orispeccode,pr_brand)" +
  206. " left join (select max(bi_prodcode)bi_prodcode,nvl(sum(bi_inqty),0)bi_inqty from barcodeio left join product on pr_code=bi_prodcode " +
  207. "where bi_inoutno='" + pi_inoutno.Text + "' group by pr_orispeccode,pr_brand) on pd_prodcode=bi_prodcode left join product on pr_code=pd_prodcode " +
  208. "where pr_code='" + PR_CODE.Text + "'";
  209. DataTable dt = (DataTable)dh.ExecuteSql(sql, "select");
  210. if (dt.Rows.Count == 0)
  211. {
  212. Play("NG");
  213. MessageBox.Show("物料不在对应入库单中" + pi_inoutno.Text);
  214. return;
  215. }
  216. if (pr_orispeccode2.Text != pr_orispeccode3.Text)
  217. {
  218. Play("NG");
  219. MessageBox.Show("解析型号和单据型号不对应");
  220. return;
  221. }
  222. ZXBZ.Text = dt.Rows[0]["pr_zxbzs"].ToString();
  223. int pdinqty = int.Parse(dt.Rows[0]["pd_inqty"].ToString());
  224. int barqty = int.Parse(dt.Rows[0]["bi_inqty"].ToString());
  225. int Minpackage = 0;
  226. string pi_id = dt.Rows[0]["pd_piid"].ToString();
  227. string pd_piclass = dt.Rows[0]["pd_piclass"].ToString();
  228. //本次入库数
  229. int NowInqty = int.Parse(INQTY.Text);
  230. if (!int.TryParse(ZXBZ.Text, out Minpackage))
  231. {
  232. Play("NG");
  233. MessageBox.Show("最小包装数错误,料号" + PR_CODE.Text);
  234. return;
  235. }
  236. if (int.Parse(INQTY.Text) > pdinqty - barqty)
  237. {
  238. Play("NG");
  239. MessageBox.Show("物料采集后超出入库单数量" + PR_CODE.Text);
  240. return;
  241. }
  242. string outboxcode = "";
  243. if (GenBoxCode.Checked)
  244. {
  245. string[] param = new string[] { PR_CODE.Text, "", outboxcode };
  246. dh.CallProcedure("SP_GETBOX", ref param);
  247. outboxcode = param[2].Replace("BOX:", "");
  248. }
  249. //生成条码数量
  250. int barcount = NowInqty % Minpackage == 0 ? NowInqty / Minpackage : (NowInqty / Minpackage) + 1;
  251. List<string> bi_inqty = new List<string>();
  252. List<string> bi_barcode = new List<string>();
  253. List<string> bi_vendbarcode = new List<string>();
  254. List<string> bi_madedate = new List<string>();
  255. List<string> bi_sccode = new List<string>();
  256. for (int i = 0; i < barcount; i++)
  257. {
  258. string barcode = "";
  259. int OneUnit = 0;
  260. string[] param = new string[] { PR_CODE.Text, "", barcode };
  261. dh.CallProcedure("SP_GETBARCODE", ref param);
  262. barcode = param[2].Replace("BARCODE:", "");
  263. //如果最后有尾数的话
  264. if (i == barcount - 1)
  265. {
  266. if (NowInqty % Minpackage == 0)
  267. {
  268. OneUnit = Minpackage;
  269. }
  270. else
  271. {
  272. OneUnit = NowInqty % Minpackage;
  273. }
  274. }
  275. else
  276. {
  277. OneUnit = Minpackage;
  278. }
  279. bi_inqty.Add(OneUnit.ToString());
  280. bi_barcode.Add(barcode);
  281. bi_vendbarcode.Add(LOTNO.Text);
  282. bi_madedate.Add(DC.Text);
  283. bi_sccode.Add(SCCODE.Text);
  284. }
  285. sql = "insert into barcodeio(BI_ID, BI_BARCODE, BI_PIID, BI_PICLASS, BI_INOUTNO, BI_PDNO, BI_PDID, BI_PRODCODE, BI_INQTY,bi_vendbarcode, " +
  286. "BI_MADEDATE, BI_PRODID, BI_STATUS, BI_ORDERCODE, BI_INMAN, BI_INDATE,BI_OUTBOXCODE,bi_sccode)select barcodeio_seq.nextval,:bi_barcode,'" + pi_id + "'," +
  287. "'" + pd_piclass + "','" + pi_inoutno.Text + "',0,0,'" + PR_CODE.Text + "',:bi_inqty,:bi_vendbarcode,to_date(:bi_madedate,'yyyy-mm-dd'),pr_id,0,'','管理员',sysdate,'" + outboxcode + "',:bi_sccode " +
  288. " from product where pr_code='" + PR_CODE.Text + "'";
  289. dh.BatchInsert(sql, new string[] { "bi_inqty", "bi_barcode", "bi_vendbarcode", "bi_madedate" , "bi_sccode" }, bi_barcode.ToArray(), bi_inqty.ToArray(), bi_vendbarcode.ToArray(), bi_madedate.ToArray(),bi_sccode.ToArray());
  290. LoadGridData();
  291. LoadBarcodeioData(PR_CODE.Text);
  292. }
  293. private void LoadBarcodeioData(string pr_code)
  294. {
  295. string sql = "select 0 CheckBox,bi_sccode,bi_barcode,bi_inqty,bi_datecode,bi_outboxcode,bi_vendbarcode,to_char(bi_madedate,'yyyy-mm-dd')bi_madedate,pr_detail,pr_spec,bi_prodcode,pr_orispeccode from barcodeio left join product on bi_prodcode=pr_code where bi_inoutno='" + pi_inoutno.Text + "' and bi_prodcode='" + pr_code + "'";
  296. DataTable dt = (DataTable)dh.ExecuteSql(sql, "select");
  297. BaseUtil.FillDgvWithDataTable(BarcodeIO, dt);
  298. }
  299. private void PrintBarCode_Click(object sender, EventArgs e)
  300. {
  301. for (int i = 0; i < BarcodeIO.Rows.Count; i++)
  302. {
  303. if (BarcodeIO.Rows[i].Cells["CheckBox"].FormattedValue != null && BarcodeIO.Rows[i].Cells["CheckBox"].FormattedValue.ToString() == "True")
  304. {
  305. for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
  306. {
  307. if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "BARCODE")
  308. {
  309. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  310. SingleDoc.Variables.FreeVariables.Item(j + 1).Value = BarcodeIO.Rows[i].Cells["bi_barcode"].Value.ToString();
  311. }
  312. if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "DC")
  313. {
  314. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  315. SingleDoc.Variables.FreeVariables.Item(j + 1).Value = BarcodeIO.Rows[i].Cells["bi_madedate"].Value.ToString();
  316. }
  317. if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "LOTNO")
  318. {
  319. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  320. SingleDoc.Variables.FreeVariables.Item(j + 1).Value = BarcodeIO.Rows[i].Cells["bi_vendbarcode"].Value.ToString();
  321. }
  322. if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "QTY")
  323. {
  324. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  325. SingleDoc.Variables.FreeVariables.Item(j + 1).Value = BarcodeIO.Rows[i].Cells["bi_inqty1"].Value.ToString();
  326. }
  327. if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "PRCODE")
  328. {
  329. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  330. SingleDoc.Variables.FreeVariables.Item(j + 1).Value = BarcodeIO.Rows[i].Cells["bi_prodcode"].Value.ToString();
  331. }
  332. if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "PRSPEC")
  333. {
  334. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  335. SingleDoc.Variables.FreeVariables.Item(j + 1).Value = BarcodeIO.Rows[i].Cells["pr_spec1"].Value.ToString();
  336. }
  337. if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "PRDETAIL")
  338. {
  339. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  340. SingleDoc.Variables.FreeVariables.Item(j + 1).Value = BarcodeIO.Rows[i].Cells["pr_detail1"].Value.ToString();
  341. }
  342. if (SingleDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "ORISPEC")
  343. {
  344. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  345. SingleDoc.Variables.FreeVariables.Item(j + 1).Value = BarcodeIO.Rows[i].Cells["pr_orispeccode"].Value.ToString();
  346. }
  347. }
  348. SingleDoc.Printer.SwitchTo(PrinterList.Text);
  349. SingleDoc.PrintDocument();
  350. }
  351. }
  352. }
  353. private void Prodiodetail_CellContentClick(object sender, DataGridViewCellEventArgs e)
  354. {
  355. if (Prodiodetail.Rows[e.RowIndex].Cells["pd_prodcode"].Value.ToString() != "")
  356. {
  357. }
  358. }
  359. int SelectIndex = 0;
  360. private void Prodiodetail_CellClick(object sender, DataGridViewCellEventArgs e)
  361. {
  362. if (Prodiodetail.Rows[e.RowIndex].Cells["pd_prodcode"].Value.ToString() != "")
  363. {
  364. LoadBarcodeioData(Prodiodetail.Rows[e.RowIndex].Cells["pd_prodcode"].Value.ToString());
  365. Console.WriteLine(Prodiodetail.Rows[e.RowIndex].Cells["pr_brand"].Value.ToString());
  366. es_custcode.Text = Prodiodetail.Rows[e.RowIndex].Cells["pr_brand"].Value.ToString();
  367. PR_CODE.Text = Prodiodetail.Rows[e.RowIndex].Cells["pd_prodcode"].Value.ToString();
  368. pr_orispeccode2.Text = Prodiodetail.Rows[e.RowIndex].Cells["pr_orispeccode1"].Value.ToString();
  369. LoadBarcodeioData(Prodiodetail.Rows[e.RowIndex].Cells["pd_prodcode"].Value.ToString());
  370. SelectIndex = e.RowIndex;
  371. }
  372. }
  373. private void ChooseAll_Click(object sender, EventArgs e)
  374. {
  375. for (int i = 0; i < BarcodeIO.Rows.Count; i++)
  376. {
  377. BarcodeIO.Rows[i].Cells["CheckBox"].Value = true;
  378. }
  379. }
  380. private void PrintBox_Click(object sender, EventArgs e)
  381. {
  382. List<string> outboxcode = new List<string>();
  383. for (int i = 0; i < BarcodeIO.Rows.Count; i++)
  384. {
  385. if (BarcodeIO.Rows[i].Cells["CheckBox"].FormattedValue != null && BarcodeIO.Rows[i].Cells["CheckBox"].FormattedValue.ToString() == "True")
  386. {
  387. if (!outboxcode.Contains(BarcodeIO.Rows[i].Cells["bi_outboxcode"].FormattedValue))
  388. {
  389. outboxcode.Add(BarcodeIO.Rows[i].Cells["bi_outboxcode"].Value.ToString());
  390. }
  391. }
  392. }
  393. string[] box = outboxcode.ToArray();
  394. for (int i = 0; i < box.Length; i++)
  395. {
  396. string sql = "select bi_outboxcode,sum(bi_inqty)bi_inqty,max(bi_datecode)bi_datecode,max(bi_vendbarcode)bi_vendbarcode,max(to_char(bi_madedate,'yyyy-mm-dd'))bi_madedate," +
  397. "max(pr_detail)pr_detail,max(pr_spec)pr_spec,max(bi_prodcode)bi_prodcode,max(pr_orispeccode)pr_orispeccode,max(pr_detail)pr_detail from barcodeio left join product on bi_prodcode=pr_code where bi_outboxcode='" + box[i] + "' group by bi_outboxcode";
  398. DataTable dt = (DataTable)dh.ExecuteSql(sql, "select");
  399. for (int j = 0; j < SingleDoc.Variables.FreeVariables.Count; j++)
  400. {
  401. if (OutDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "BARCODE")
  402. {
  403. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  404. OutDoc.Variables.FreeVariables.Item(j + 1).Value = dt.Rows[0]["bi_outboxcode"].ToString();
  405. }
  406. if (OutDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "DC")
  407. {
  408. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  409. OutDoc.Variables.FreeVariables.Item(j + 1).Value = dt.Rows[0]["bi_madedate"].ToString();
  410. }
  411. if (OutDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "LOTNO")
  412. {
  413. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  414. OutDoc.Variables.FreeVariables.Item(j + 1).Value = dt.Rows[0]["bi_vendbarcode"].ToString();
  415. }
  416. if (OutDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "QTY")
  417. {
  418. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  419. OutDoc.Variables.FreeVariables.Item(j + 1).Value = dt.Rows[0]["bi_inqty"].ToString();
  420. }
  421. if (OutDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "PRCODE")
  422. {
  423. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  424. OutDoc.Variables.FreeVariables.Item(j + 1).Value = dt.Rows[0]["bi_prodcode"].ToString();
  425. }
  426. if (OutDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "PRSPEC")
  427. {
  428. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  429. OutDoc.Variables.FreeVariables.Item(j + 1).Value = dt.Rows[0]["pr_spec"].ToString();
  430. }
  431. if (OutDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "PRDETAIL")
  432. {
  433. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  434. OutDoc.Variables.FreeVariables.Item(j + 1).Value = dt.Rows[0]["pr_detail"].ToString();
  435. }
  436. if (OutDoc.Variables.FreeVariables.Item(j + 1).Name.ToUpper() == "ORISPEC")
  437. {
  438. if (BarcodeIO.Rows[i].Cells["bi_madedate"].Value != null)
  439. OutDoc.Variables.FreeVariables.Item(j + 1).Value = dt.Rows[0]["pr_orispeccode"].ToString();
  440. }
  441. }
  442. OutDoc.Printer.SwitchTo(PrinterList.Text);
  443. OutDoc.PrintDocument();
  444. }
  445. }
  446. private void PrintStockBarCode_Click(object sender, EventArgs e)
  447. {
  448. 库存条码打印 form = new 库存条码打印();
  449. form.ShowDialog();
  450. }
  451. private void DeletaBarcode_Click(object sender, EventArgs e)
  452. {
  453. for (int i = 0; i < BarcodeIO.Rows.Count; i++)
  454. {
  455. if (BarcodeIO.Rows[i].Cells["CheckBox"].FormattedValue != null && BarcodeIO.Rows[i].Cells["CheckBox"].FormattedValue.ToString() == "True")
  456. {
  457. dh.ExecuteSql("delete from barcodeio where bi_barcode='" + BarcodeIO.Rows[i].Cells["bi_barcode"].Value.ToString() + "'", "delete");
  458. }
  459. }
  460. LoadBarcodeioData(PR_CODE.Text);
  461. }
  462. Thread thread;
  463. string FileName = "";
  464. public void Play(string Type)
  465. {
  466. if (Type == "OK")
  467. {
  468. FileName = System.Windows.Forms.Application.StartupPath + @"\Resources\Sound\8378.wav";
  469. thread = new Thread(PlaySound);
  470. thread.Start();
  471. }
  472. else
  473. {
  474. FileName = System.Windows.Forms.Application.StartupPath + @"\Resources\Sound\5185.wav";
  475. thread = new Thread(PlaySound);
  476. thread.Start();
  477. }
  478. }
  479. private void PlaySound()
  480. {
  481. //要加载COM组件:Microsoft speech object Library
  482. if (!System.IO.File.Exists(FileName))
  483. {
  484. return;
  485. }
  486. try
  487. {
  488. SoundPlayer player = new SoundPlayer();
  489. player.SoundLocation = FileName;
  490. player.Load();
  491. player.Play();
  492. }
  493. catch (Exception e)
  494. {
  495. MessageBox.Show(e.Message);
  496. }
  497. }
  498. }
  499. }