Query_BarcodeIn.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. using DevExpress.Printing.Core.PdfExport.Metafile;
  2. using LabelManager2;
  3. using Seagull.BarTender.Print;
  4. using System;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Threading;
  8. using System.Windows.Forms;
  9. using UAS_MES_NEW.DataOperate;
  10. using UAS_MES_NEW.Entity;
  11. using UAS_MES_NEW.PublicForm;
  12. using UAS_MES_NEW.PublicMethod;
  13. using static System.Runtime.CompilerServices.RuntimeHelpers;
  14. namespace UAS_MES_NEW.Query
  15. {
  16. public partial class Query_BarcodeIn : Form
  17. {
  18. DataHelper dh = SystemInf.dh;
  19. DataTable Dbfind;
  20. AutoSizeFormClass asc = new AutoSizeFormClass();
  21. Thread InitPrint;
  22. BarTender.Application engine;
  23. public Query_BarcodeIn()
  24. {
  25. InitializeComponent();
  26. }
  27. private void InPrint()
  28. {
  29. try
  30. {
  31. engine = new BarTender.Application();
  32. }
  33. catch (Exception)
  34. {
  35. MessageBox.Show("未正确安装BarTender软件");
  36. }
  37. }
  38. private void Query_LoadMake_Load(object sender, EventArgs e)
  39. {
  40. asc.controllInitializeSize(this);
  41. InitPrint = new Thread(InPrint);
  42. SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
  43. BaseUtil.SetFormCenter(stw);
  44. stw.ShowDialog();
  45. LoadGridData();
  46. }
  47. private void UpLoadMake_Click(object sender, EventArgs e)
  48. {
  49. LoadGridData();
  50. }
  51. private void LoadGridData()
  52. {
  53. DataTable dt = (DataTable)dh.ExecuteSql(" select * from gwlocation full outer join ( select * from Stencil where st_kind = '钢网' ) on gl_LOCATION = st_location left join stenilcanusepro on SP_STID = st_id left join product on pr_code = SP_PRODCODE" +
  54. " where (st_kind = '钢网' or st_kind is null) and (st_usestatus<>'报废' or st_usestatus is null) order by gl_id asc ", "select");
  55. BaseUtil.FillDgvWithDataTable(DGV, dt);
  56. }
  57. private bool ifcheckrow()
  58. {
  59. for (int i = 0; i < DGV.Rows.Count; i++)
  60. {
  61. if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  62. {
  63. if(DGV.Rows[i].Cells["st_id"].Value.ToString() != "")
  64. return true;
  65. else
  66. return false;
  67. }
  68. }
  69. return false;
  70. }
  71. private void Print_Click(object sender, EventArgs e)
  72. {
  73. string ErrMsg = "";
  74. MessageBox.Show("生成明细成功");
  75. }
  76. private void pi_inoutno_UserControlTextChanged(object sender, EventArgs e)
  77. {
  78. LoadGridData();
  79. }
  80. private void MakeCode_KeyDown(object sender, KeyEventArgs e)
  81. {
  82. if (e.KeyCode == Keys.Enter)
  83. {
  84. //if (pi_inoutno.Text == "")
  85. //{
  86. // MessageBox.Show("出入库单号不能为空");
  87. // return;
  88. //}
  89. //DataTable dt = (DataTable)dh.ExecuteSql("select bi_inqty,bi_barcode from barcodeio left join product on pr_code=bi_prodcode" +
  90. // " where bi_inoutno='" + pi_inoutno.Text + "' and bi_barcode='" + barcode.Text + "'", "select");
  91. //if (dt.Rows.Count > 0)
  92. //{
  93. // MessageBox.Show("出入库单已采集条码" + barcode.Text);
  94. // return;
  95. //}
  96. //dt = (DataTable)dh.ExecuteSql("select bar_vendbarcode,to_char(nvl(bar_madedate,sysdate),'yyyy-mm-dd')bar_madedate,bar_code,bar_remain,bar_prodcode from barcode left " +
  97. // "join product on pr_code=bar_prodcode where bar_code='" + barcode.Text + "'", "select");
  98. //if (dt.Rows.Count == 0)
  99. //{
  100. // MessageBox.Show("条码" + barcode.Text + "不存在");
  101. // return;
  102. //}
  103. //BarCodePrint bar = new BarCodePrint(barcode.Text);
  104. //bar.StartPosition = FormStartPosition.CenterScreen;
  105. //bar.ShowDialog();
  106. //string newbarcode = bar.Controls["newbarcode"].Text;
  107. //string bar_remain = bar.Controls["bar_remain"].Text;
  108. //bar.Controls["PrintBarCode"].Click += Query_BarcodeIn_Click;
  109. //string pi_id = dh.getFieldDataByCondition("prodinout", "pi_id", "pi_inoutno='" + pi_inoutno.Text + "'").ToString();
  110. //string bar_code = dt.Rows[0]["bar_code"].ToString();
  111. //string bar_prodcode = dt.Rows[0]["bar_prodcode"].ToString();
  112. //string bar_madedate = dt.Rows[0]["bar_madedate"].ToString();
  113. //string bar_vendbarcode = dt.Rows[0]["bar_vendbarcode"].ToString();
  114. //dh.ExecuteSql("insert into barcodeio(bi_id,bi_piid,bi_barcode,bi_inoutno,bi_prodcode,bi_indate,bi_inqty,bi_vendbarcode,bi_madedate,bi_sourcecode,bi_printstatus)" +
  115. // "values(barcodeio_seq.nextval,'" + pi_id + "','" + newbarcode + "','" + pi_inoutno.Text + "','" + bar_prodcode + "',sysdate,'" + bar_remain + "','" + bar_vendbarcode + "',to_date('" + bar_madedate + "','yyyy-mm-dd'),'" + bar_code + "',1)", "insert");
  116. //LoadGridData();
  117. //string ErrorMessage = "";
  118. //if (Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, newbarcode, int.Parse("1"), pi_inoutno.Text, bar_prodcode, "自定义", "0", out ErrorMessage))
  119. //{
  120. //}
  121. }
  122. }
  123. private void Query_BarcodeIn_Click(object sender, EventArgs e)
  124. {
  125. }
  126. private void DeleteBarcode_Click(object sender, EventArgs e)
  127. {
  128. //LoadGridData();
  129. }
  130. private void ChooseAll_Click(object sender, EventArgs e)
  131. {
  132. for (int i = 0; i < DGV.Rows.Count; i++)
  133. {
  134. DGV.Rows[i].Cells["choose"].Value = true;
  135. }
  136. }
  137. private void Print_Click_1(object sender, EventArgs e)
  138. {
  139. if (!ifcheckrow())
  140. {
  141. MessageBox.Show("请勾选需要操作的行");
  142. return;
  143. }
  144. for (int i = 0; i < DGV.Rows.Count; i++)
  145. {
  146. if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  147. {
  148. if (DGV.Rows[i].Cells["st_id"].Value.ToString() != "")
  149. {
  150. BarTender.Format doc2 = engine.Formats.Open(System.Windows.Forms.Application.StartupPath + @"\钢网条码.btw");
  151. DataTable ddt = (DataTable)dh.ExecuteSql(" select * from Stencil where st_id = '" + DGV.Rows[i].Cells["st_id"].Value.ToString() + "' ", "select");
  152. doc2.SetNamedSubStringValue("储位", ddt.Rows[0]["st_location"].ToString());
  153. doc2.SetNamedSubStringValue("机型", ddt.Rows[0]["st_name"].ToString());
  154. doc2.SetNamedSubStringValue("编号", ddt.Rows[0]["st_code"].ToString());
  155. doc2.SetNamedSubStringValue("客户", ddt.Rows[0]["st_vendcode"].ToString());
  156. doc2.SetNamedSubStringValue("面别", ddt.Rows[0]["st_table"].ToString());
  157. doc2.SetNamedSubStringValue("厚度", ddt.Rows[0]["st_thickness"].ToString());
  158. // 同样标签的份数
  159. doc2.PrintSetup.IdenticalCopiesOfLabel = 1;
  160. // 序列标签数
  161. doc2.PrintSetup.NumberSerializedLabels = 1;
  162. doc2.PrintSetup.Printer = PrinterList.Text;
  163. doc2.PrintOut(false, false);
  164. doc2.Close(BarTender.BtSaveOptions.btDoNotSaveChanges);
  165. }
  166. }
  167. }
  168. }
  169. private void Query_BarcodeIn_FormClosing(object sender, FormClosingEventArgs e)
  170. {
  171. if (engine != null)
  172. engine.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
  173. dh.Dispose();
  174. }
  175. private void Query_BarcodeIn_SizeChanged(object sender, EventArgs e)
  176. {
  177. asc.controlAutoSize(this);
  178. }
  179. }
  180. }