Query_BarcodeIn1.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. using DevExpress.Printing.Core.PdfExport.Metafile;
  2. using HslCommunication;
  3. using LabelManager2;
  4. using Seagull.BarTender.Print;
  5. using System;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Threading;
  9. using System.Windows.Forms;
  10. using UAS_MES_NEW.DataOperate;
  11. using UAS_MES_NEW.Entity;
  12. using UAS_MES_NEW.PublicForm;
  13. using UAS_MES_NEW.PublicMethod;
  14. using static System.Runtime.CompilerServices.RuntimeHelpers;
  15. namespace UAS_MES_NEW.Query
  16. {
  17. public partial class Query_BarcodeIn1 : Form
  18. {
  19. DataHelper dh = SystemInf.dh;
  20. DataTable Dbfind;
  21. Thread InitPrint;
  22. Engine engine;
  23. public Query_BarcodeIn1()
  24. {
  25. InitializeComponent();
  26. }
  27. private void InPrint()
  28. {
  29. try
  30. {
  31. engine = new Engine(true);
  32. }
  33. catch (Exception)
  34. {
  35. MessageBox.Show("未正确安装BarTender软件");
  36. }
  37. }
  38. private void Query_LoadMake_Load(object sender, EventArgs e)
  39. {
  40. pi_inoutno.TableName = "prodinout";
  41. pi_inoutno.SelectField = "pi_inoutno#单号";
  42. pi_inoutno.FormName = Name;
  43. pi_inoutno.SetValueField = new string[] { "pi_inoutno" };
  44. pi_inoutno.Condition = "1=1";
  45. pi_inoutno.DbChange += Ma_code_DbChange;
  46. InitPrint = new Thread(InPrint);
  47. SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
  48. BaseUtil.SetFormCenter(stw);
  49. stw.ShowDialog();
  50. LoadGridData();
  51. DataTable _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault,replace(LA_SOFTTYPE,';',',')LA_SOFTTYPE from label where la_prodcode='生产退料标签' and la_templatetype='自定义' and la_statuscode='AUDITED' order by la_isdefault", "select");
  52. if (_dt.Rows.Count == 0)
  53. {
  54. _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault,replace(LA_SOFTTYPE,';',',')LA_SOFTTYPE from label where la_prodcode is null and la_templatetype='自定义' and la_statuscode='AUDITED' order by la_isdefault", "select");
  55. }
  56. if (_dt.Rows.Count > 0)
  57. {
  58. string la_id = _dt.Rows[0]["la_id"].ToString();
  59. _dt = (DataTable)dh.ExecuteSql("select fp_name la_url,'" + la_id + "' la_id from FILEPATH where fp_id in (select * from table(select parsestring(LA_SOFTTYPE,';') from label where la_templatetype='自定义' and la_id='" + la_id + "') where COLUMN_VALUE is not null)", "select");
  60. PrintLabel.DataSource = _dt;
  61. PrintLabel.DisplayMember = "la_url";
  62. PrintLabel.ValueMember = "la_id";
  63. }
  64. }
  65. private void Ma_code_DbChange(object sender, EventArgs e)
  66. {
  67. Dbfind = pi_inoutno.ReturnData;
  68. BaseUtil.SetFormValue(this.Controls, Dbfind);
  69. }
  70. private void UpLoadMake_Click(object sender, EventArgs e)
  71. {
  72. LoadGridData();
  73. }
  74. private void LoadGridData()
  75. {
  76. DataTable dt = (DataTable)dh.ExecuteSql("select * from barcodeio left join product on pr_code=bi_prodcode where bi_inoutno='" + pi_inoutno.Text + "'", "select");
  77. BaseUtil.FillDgvWithDataTable(DGV, dt);
  78. }
  79. private bool ifcheckrow()
  80. {
  81. for (int i = 0; i < DGV.Rows.Count; i++)
  82. {
  83. if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  84. {
  85. return true;
  86. }
  87. }
  88. return false;
  89. }
  90. private void Print_Click(object sender, EventArgs e)
  91. {
  92. string ErrMsg = "";
  93. LogicHandler.GenProdiodetail(pi_inoutno.Text, out ErrMsg);
  94. MessageBox.Show("生成明细成功");
  95. }
  96. private void pi_inoutno_UserControlTextChanged(object sender, EventArgs e)
  97. {
  98. LoadGridData();
  99. }
  100. private void MakeCode_KeyDown(object sender, KeyEventArgs e)
  101. {
  102. if (e.KeyCode == Keys.Enter)
  103. {
  104. if (pi_inoutno.Text == "")
  105. {
  106. MessageBox.Show("出入库单号不能为空");
  107. return;
  108. }
  109. DataTable dt = (DataTable)dh.ExecuteSql("select bi_inqty,bi_barcode from barcodeio left join product on pr_code=bi_prodcode" +
  110. " where bi_inoutno='" + pi_inoutno.Text + "' and bi_barcode='" + barcode.Text + "'", "select");
  111. if (dt.Rows.Count > 0)
  112. {
  113. MessageBox.Show("出入库单已采集条码" + barcode.Text);
  114. return;
  115. }
  116. dt = (DataTable)dh.ExecuteSql("select bar_vendbarcode,bar_remain,to_char(nvl(bar_madedate,sysdate),'yyyy-mm-dd')bar_madedate,bar_code,bar_remain,bar_prodcode from barcode left " +
  117. "join product on pr_code=bar_prodcode where bar_code='" + barcode.Text + "'", "select");
  118. if (dt.Rows.Count == 0)
  119. {
  120. MessageBox.Show("条码" + barcode.Text + "不存在");
  121. return;
  122. }
  123. string pi_id = dh.getFieldDataByCondition("prodinout", "pi_id", "pi_inoutno='" + pi_inoutno.Text + "'").ToString();
  124. string bar_code = dt.Rows[0]["bar_code"].ToString();
  125. string bar_prodcode = dt.Rows[0]["bar_prodcode"].ToString();
  126. string bar_madedate = dt.Rows[0]["bar_madedate"].ToString();
  127. string bar_remain = dt.Rows[0]["bar_remain"].ToString();
  128. string bar_vendbarcode = dt.Rows[0]["bar_vendbarcode"].ToString();
  129. 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)" +
  130. "values(barcodeio_seq.nextval,'" + pi_id + "','" + barcode.Text + "','" + pi_inoutno.Text + "','" + bar_prodcode + "',sysdate,'" + bar_remain + "','" + bar_vendbarcode + "',to_date('" + bar_madedate + "','yyyy-mm-dd'),'" + bar_code + "',1)", "insert");
  131. LoadGridData();
  132. string ErrorMessage = "";
  133. //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))
  134. //{
  135. //}
  136. }
  137. }
  138. private void Query_BarcodeIn_Click(object sender, EventArgs e)
  139. {
  140. }
  141. private void DeleteBarcode_Click(object sender, EventArgs e)
  142. {
  143. if (!ifcheckrow())
  144. {
  145. MessageBox.Show("请勾选需要操作的行");
  146. return;
  147. }
  148. for (int i = 0; i < DGV.Rows.Count; i++)
  149. {
  150. if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  151. {
  152. string barcode = DGV.Rows[i].Cells["bi_barcode"].Value.ToString();
  153. string prodcode = DGV.Rows[i].Cells["bi_prodcode"].Value.ToString();
  154. dh.ExecuteSql("delete from barcodeio where bi_id=" + DGV.Rows[i].Cells["bi_id"].Value.ToString(), "delete");
  155. }
  156. }
  157. LoadGridData();
  158. }
  159. private void ChooseAll_Click(object sender, EventArgs e)
  160. {
  161. for (int i = 0; i < DGV.Rows.Count; i++)
  162. {
  163. DGV.Rows[i].Cells["choose"].Value = true;
  164. }
  165. }
  166. private void Print_Click_1(object sender, EventArgs e)
  167. {
  168. if (!ifcheckrow())
  169. {
  170. MessageBox.Show("请勾选需要操作的行");
  171. return;
  172. }
  173. for (int i = 0; i < DGV.Rows.Count; i++)
  174. {
  175. if (DGV.Rows[i].Cells["Choose"].Value != null && DGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  176. {
  177. string barcode = DGV.Rows[i].Cells["bi_barcode"].Value.ToString();
  178. string prodcode = DGV.Rows[i].Cells["bi_prodcode"].Value.ToString();
  179. string ErrorMessage = "";
  180. if (Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, barcode, int.Parse("1"), pi_inoutno.Text, prodcode, "自定义", "0", out ErrorMessage))
  181. {
  182. }
  183. }
  184. }
  185. }
  186. }
  187. }