Make_PackageCollectionWeigh.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. using LabelManager2;
  2. using System;
  3. using System.Data;
  4. using System.Text;
  5. using System.Windows.Forms;
  6. using UAS_MES.DataOperate;
  7. using UAS_MES.Entity;
  8. using UAS_MES.PublicMethod;
  9. using System.Drawing;
  10. using System.Threading;
  11. using UAS_MES.PublicForm;
  12. using System.IO.Ports;
  13. using System.IO;
  14. using System.Text.RegularExpressions;
  15. namespace UAS_MES.Make
  16. {
  17. public partial class Make_PackageCollectionWeigh : Form
  18. {
  19. DataHelper dh;
  20. DataTable dt;
  21. LogStringBuilder sql = new LogStringBuilder();
  22. AutoSizeFormClass asc = new AutoSizeFormClass();
  23. Document doc;
  24. ApplicationClass lbl;
  25. Thread thread;
  26. DataTable Dbfind;
  27. string ErrorMessage = "";
  28. string oMakeCode = "";
  29. string oMsID = "";
  30. //称量的标准重量
  31. double Weight;
  32. //最大重量
  33. double MaxWeight;
  34. //最小重量
  35. double MinWeight;
  36. decimal StandardQTY = 0;
  37. string oOutBoxCode = "";
  38. string LastSncode;
  39. //创建串口实例
  40. SerialPort serialPort1 = new SerialPort();
  41. //true的时候表示从串口读取数据
  42. bool GetData = true;
  43. System.DateTime[] indate;
  44. public Make_PackageCollectionWeigh()
  45. {
  46. InitializeComponent();
  47. }
  48. //创建打印进程
  49. private void NewPrint()
  50. {
  51. try
  52. {
  53. lbl = new ApplicationClass();
  54. BaseUtil.WriteLbl(lbl);
  55. }
  56. catch (Exception ex)
  57. {
  58. OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
  59. }
  60. }
  61. private void 包装采集_Load(object sender, EventArgs e)
  62. {
  63. pa_outboxcode.ShowClickIcon = false;
  64. ComList.Text = BaseUtil.GetCacheData("PortName").ToString();
  65. Baurate.Text = BaseUtil.GetCacheData("BaudRate").ToString();
  66. //设置DbFind的必须的数据
  67. PrintNum.Value = 1;
  68. asc.controllInitializeSize(this);
  69. thread = new Thread(NewPrint);
  70. SetLoadingWindow stw = new SetLoadingWindow(thread, "初始化打印程序");
  71. BaseUtil.SetFormCenter(stw);
  72. stw.ShowDialog();
  73. dh = new DataHelper();
  74. thread = new Thread(getSerialData);
  75. try
  76. {
  77. GetData = true;
  78. serialPort1.PortName = ComList.Text;
  79. serialPort1.BaudRate = int.Parse(Baurate.Text);
  80. serialPort1.Open();
  81. thread.Start();
  82. }
  83. catch (Exception mes)
  84. {
  85. if (Baurate.Text == "" || ComList.Text == "")
  86. OperateResult.AppendText(">>请先在电子秤调试界面维护波特率和串口\n", Color.Red);
  87. else
  88. OperateResult.AppendText(">>" + mes.Message + "\n", Color.Red);
  89. }
  90. }
  91. private void getSerialData()
  92. {
  93. if (serialPort1.IsOpen)
  94. {
  95. if (!SystemInf.OpenPort.Contains(serialPort1.PortName))
  96. {
  97. SystemInf.OpenPort.Add(serialPort1.PortName);
  98. try
  99. {
  100. while (GetData)
  101. {
  102. try
  103. {
  104. weight.Text = Regex.Replace(serialPort1.ReadLine(), "\\D+", "");
  105. if (pr_cartonunit.Text == "kg")
  106. weight.Text = (double.Parse(weight.Text) / 1000).ToString();
  107. }
  108. catch (Exception)
  109. {
  110. GetData = false;
  111. }
  112. }
  113. }
  114. catch (IOException ex) { MessageBox.Show(ex.Message); }
  115. }
  116. else
  117. MessageBox.Show("端口已被占用,请关闭其他窗口");
  118. }
  119. }
  120. private void 包装采集_SizeChanged(object sender, EventArgs e)
  121. {
  122. asc.controlAutoSize(this);
  123. }
  124. private void 包装采集_Activated(object sender, EventArgs e)
  125. {
  126. pa_outboxcode.Focus();
  127. }
  128. //刷新表单的数据的数据
  129. private void LoadData()
  130. {
  131. //加载表单数据
  132. string Err = "";
  133. sql.Clear();
  134. sql.Append("select pa_prodcode,pr_cartonmaxw,pa_makecode,pr_cartonunit,pr_cartonminw,pr_cartongw,pa_outboxcode,pa_sccode,nvl(pa_downstatus,0) pa_downstatus,pa_checkno,");
  135. sql.Append("pa_status,pr_packrule,pr_detail,pa_packageqty,nvl(pa_standardqty,0)pa_standardqty,pr_outboxinnerqty,pa_currentqty from package left join ");
  136. sql.Append("product on pa_prodcode=pr_code where pa_outboxcode='" + pa_outboxcode.Text + "'");
  137. Err = "箱号";
  138. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  139. if (dt.Rows.Count > 0)
  140. {
  141. //重量的临时变量
  142. string _weight = dt.Rows[0]["pr_cartongw"].ToString();
  143. string _maxweight = dt.Rows[0]["pr_cartonmaxw"].ToString();
  144. string _minweight = dt.Rows[0]["pr_cartonminw"].ToString();
  145. //赋值重量单位
  146. Weight = double.Parse(_weight == "" ? "0" : _weight);
  147. MaxWeight = double.Parse(_maxweight == "" ? "0" : _maxweight);
  148. MinWeight = double.Parse(_minweight == "" ? "0" : _minweight);
  149. //记录该数据保证在修改不被允许的前提下能偶回复之前的值
  150. StandardQTY = decimal.Parse(dt.Rows[0]["pr_outboxinnerqty"].ToString());
  151. BaseUtil.SetFormValue(this.Controls, dt);
  152. if (pa_standardqty.Text != "0")
  153. pr_outboxinnerqty.Text = pa_standardqty.Text;
  154. if (Weight - MinWeight == MaxWeight - Weight)
  155. pr_cartonboxgw.Text = Weight + "±" + (MaxWeight - Weight);
  156. else
  157. pr_cartonboxgw.Text = MinWeight + "-" + MaxWeight;
  158. }
  159. else OperateResult.AppendText(">>" + Err + "不存在\n", Color.Red);
  160. }
  161. private void LoadGridData()
  162. {
  163. //加载Grid数据
  164. dt = (DataTable)dh.ExecuteSql("select pa_outboxcode,pa_prodcode,pd_barcode,pd_innerqty,pa_indate from packageDetail left join package on pa_id=pd_paid where pa_outboxcode='" + pa_outboxcode.Text + "'", "select");
  165. BaseUtil.FillDgvWithDataTable(PackageDetail, dt);
  166. //更新界面的采集数量
  167. pa_currentqty.Text = dh.getFieldDataByCondition("package", "pa_currentqty", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString();
  168. }
  169. private void Print_Click(object sender, EventArgs e)
  170. {
  171. if (PrintLabel.Items.Count != 0)
  172. {
  173. if (dh.getFieldDataByCondition("package", "pa_status", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString() == "1")
  174. {
  175. dh.ExecuteSql("update package set pa_printcount=pa_printcount+1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
  176. OperateResult.AppendText(">>开始打印箱号" + pa_outboxcode.Text + "\n", Color.Black);
  177. doc = lbl.Documents.Open(ftpOperater.DownLoadTo+ PrintLabel.Text.Split(':')[1]);
  178. Print.CodeSoft(Tag.ToString(), doc, PrintLabel.Text.Split(':')[1], PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), indate[PrintLabel.SelectedIndex]);
  179. }
  180. else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "尚未封箱,请封箱后执行打印\n", Color.Red);
  181. }
  182. else OperateResult.AppendText(">>产品" + pr_code.Text + "未维护打印标签\n", Color.Red);
  183. }
  184. //加载工单信息和装箱明细信息
  185. private void pa_code_KeyDown(object sender, KeyEventArgs e)
  186. {
  187. if (e.KeyCode == Keys.Enter)
  188. {
  189. LoadData();
  190. LoadGridData();
  191. }
  192. }
  193. //输入序列号的回车事件
  194. private void barcode_KeyDown(object sender, KeyEventArgs e)
  195. {
  196. //当用户输入回车键的时候
  197. if (e.KeyCode == Keys.Enter)
  198. {
  199. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
  200. {
  201. if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, sn_code.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage))
  202. {
  203. sql.Clear();
  204. sql.Append("select ms_makecode,pr_code,nvl(pa_downstatus,0) pa_downstatus,pa_sccode,pa_checkno,pr_packrule,pr_code,pr_detail,");
  205. sql.Append("pr_outboxinnerqty from makeserial left join product on ms_prodcode=pr_code left join packagedetail ");
  206. sql.Append("on pd_barcode=ms_sncode left join package on pa_id =pd_paid where ms_id='" + oMsID + "'");
  207. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  208. if (dt.Rows.Count > 0)
  209. {
  210. StandardQTY = decimal.Parse(dt.Rows[0]["pr_outboxinnerqty"].ToString());
  211. BaseUtil.SetFormValue(this.Controls, dt);
  212. }
  213. if (pa_standardqty.Text != "0" && pa_standardqty.Text != "")
  214. {
  215. pr_outboxinnerqty.Value = int.Parse(pa_standardqty.Text);
  216. }
  217. if (pa_outboxcode.Text == "")
  218. {
  219. string boxcode = dh.getFieldDataByCondition("makeserial", "ms_outboxcode", "ms_id='" + oMsID + "'").ToString();
  220. if (boxcode != "")
  221. {
  222. pa_outboxcode.Text = boxcode;
  223. LoadGridData();
  224. }
  225. else
  226. {
  227. if (AutoGenBoxCode.Checked && (pa_status.Text == "1" || pa_status.Text == ""))
  228. pa_outboxcode.GeneratePaCode_Click(new object(), new EventArgs());
  229. }
  230. }
  231. if (pa_outboxcode.Text == "")
  232. {
  233. OperateResult.AppendText(">>箱号不能为空\n", Color.Red, sn_code);
  234. return;
  235. }
  236. if (pa_status.Text != "1")
  237. {
  238. //按工单核对装箱
  239. switch (pr_packrule.Text.ToUpper())
  240. {
  241. case "MAKE":
  242. if (dh.getFieldDataByCondition("makeserial", "ms_makecode", "ms_id='" + oMsID + "'").ToString() != pa_makecode.Text)
  243. {
  244. OperateResult.AppendText(">>序列号" + sn_code.Text + "所属工单和当前箱号工单不相等\n", Color.Red, sn_code);
  245. return;
  246. }
  247. break;
  248. case "SALE":
  249. if (dh.CheckExist("package", "pa_outboxcode='" + pa_outboxcode.Text + "'"))
  250. {
  251. sql.Clear();
  252. sql.Append("select 1 from package left join make on pa_salecode=ma_salecode and pa_prodcode=ma_prodcode left join makeserial ");
  253. sql.Append("on ma_code=ms_makecode where pa_outboxcode='" + pa_outboxcode.Text + "' and ms_id='" + oMsID + "'");
  254. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  255. if (dt.Rows.Count == 0)
  256. {
  257. OperateResult.AppendText(">>序列号" + sn_code.Text + "所属订单号和当前箱号订单不相等\n", Color.Red, sn_code);
  258. return;
  259. }
  260. }
  261. break;
  262. case "PROD":
  263. if (dh.getFieldDataByCondition("makeserial", "ms_prodcode", "ms_id='" + oMsID + "'").ToString() != pr_code.Text)
  264. {
  265. OperateResult.AppendText(">>序列号" + sn_code.Text + "对应物料和该箱所装物料不同\n", Color.Red, sn_code);
  266. return;
  267. }
  268. break;
  269. case "MIX":
  270. break;
  271. default:
  272. break;
  273. }
  274. }
  275. //判断箱内总数必须大于0
  276. if (pr_outboxinnerqty.Text == "" || pr_outboxinnerqty.Text == "0")
  277. {
  278. OperateResult.AppendText(">>箱内容量必须大于0\n", Color.Red);
  279. return;
  280. }
  281. //如果未勾选了取消录入
  282. if (!Cancel.Checked)
  283. {
  284. //判断序列号是否已经装箱
  285. if (dh.getFieldDataByCondition("makeserial", "ms_outboxcode", "ms_id='" + oMsID + "'").ToString() != "")
  286. {
  287. OperateResult.AppendText(">>序列号" + sn_code.Text + "已经装箱!\n", Color.Red, sn_code);
  288. }
  289. else
  290. {
  291. //满箱之后采集下一个之前自动清除内容,生成新的箱号
  292. if ((AutoGenBoxCode.Checked && pa_currentqty.Text != "" && pr_outboxinnerqty.Text == pa_currentqty.Text) || (AutoGenBoxCode.Checked && pa_status.Text == "1"))
  293. {
  294. pa_currentqty.Text = "";
  295. pa_outboxcode.Text = "";
  296. pa_status.Text = "0";
  297. BaseUtil.CleanDGVData(PackageDetail);
  298. pa_outboxcode.GeneratePaCode_Click(new object(), new EventArgs());
  299. }
  300. ////箱号不存在的情况
  301. if (LogicHandler.Packing(sn_code.Text, pa_outboxcode.Text, AutoGenBoxCode.Checked, "标准", User.UserSourceCode, User.UserCode, pr_outboxinnerqty.Text, Cancel.Checked, out oOutBoxCode, out ErrorMessage))
  302. {
  303. if (LogicHandler.SetStepResult(ms_makecode.Text, User.UserSourceCode, sn_code.Text, "包装采集", "装箱成功", User.UserCode, out ErrorMessage))
  304. {
  305. LoadCheckQTY();
  306. OperateResult.AppendText(">>序列号" + sn_code.Text + "采集成功!\n", Color.Green);
  307. //满箱更新状态为1
  308. LoadData();
  309. if (int.Parse(pa_currentqty.Text == "" ? "0" : pa_currentqty.Text) == int.Parse(pr_outboxinnerqty.Text))
  310. {
  311. //检查重量合格
  312. if (float.Parse(weight.Text) > MinWeight && float.Parse(weight.Text) < MaxWeight)
  313. {
  314. dh.UpdateByCondition("package", "pa_status=1,pa_packageqty=pa_currentqty,pa_weight='" + weight.Text + "'", "pa_outboxcode='" + pa_outboxcode.Text + "'");
  315. pa_standardqty.Text = "";
  316. pa_status.Text = "1";
  317. OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "称量合格\n", Color.Green);
  318. LastSncode = sn_code.Text;
  319. if (AutoPrint.Checked)
  320. Print_Click(new object(), new EventArgs());
  321. }
  322. else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "重量不符合标准重量\n", Color.Red);
  323. }
  324. LoadGridData();
  325. sn_code.Clear();
  326. }
  327. }
  328. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  329. }
  330. }
  331. //勾选了取消箱号先验证箱号存不存在,存在的话移除掉,重新加载一次数据
  332. else
  333. {
  334. if (LogicHandler.Packing(sn_code.Text, pa_outboxcode.Text, AutoGenBoxCode.Checked, "标准", User.UserSourceCode, User.UserCode, pr_outboxinnerqty.Text, Cancel.Checked, out oOutBoxCode, out ErrorMessage))
  335. {
  336. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "装箱采集", "取消采集成功", sn_code.Text, "");
  337. LoadGridData();
  338. pa_status.Text = "0";
  339. OperateResult.AppendText(">>已从该箱中移除序列号" + sn_code.Text + "\n", Color.Green, sn_code);
  340. }
  341. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, sn_code);
  342. }
  343. }
  344. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, sn_code);
  345. }
  346. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, sn_code);
  347. }
  348. }
  349. private void Clean_Click(object sender, EventArgs e)
  350. {
  351. OperateResult.Clear();
  352. }
  353. private void pr_code_TextChanged(object sender, EventArgs e)
  354. {
  355. LoadCheckQTY();
  356. pa_outboxcode.MakeCode = pa_makecode.Text;
  357. pa_outboxcode.ProdCode = pr_code.Text;
  358. pa_outboxcode.Caller = "PACKAGE";
  359. dt = (DataTable)dh.ExecuteSql("select pl_labelcode||':'||pl_labelname pl_laname,pl_labelname,pl_labelcode,pl_labelurl,pl_indate from productlabel where pl_prodcode='" + pr_code.Text + "' and pl_labeltype='卡通箱标' order by pl_isdefault desc ", "select");
  360. PrintLabel.DataSource = dt;
  361. PrintLabel.DisplayMember = "pl_laname";
  362. PrintLabel.ValueMember = "pl_labelcode";
  363. ftpOperater ftp = new ftpOperater();
  364. indate = new System.DateTime[dt.Rows.Count];
  365. for (int i = 0; i < dt.Rows.Count; i++)
  366. {
  367. BaseUtil.GetPrintLabel(dt.Rows[i]["pl_labelname"].ToString(), dt.Rows[i]["pl_labelurl"].ToString(), dt.Rows[i]["pl_indate"].ToString());
  368. indate[i] = Convert.ToDateTime(dt.Rows[i]["pl_indate"].ToString());
  369. }
  370. }
  371. private void 包装采集_FormClosing(object sender, FormClosingEventArgs e)
  372. {
  373. BaseUtil.ClosePrint(lbl);
  374. if (serialPort1.IsOpen)
  375. {
  376. GetData = false;
  377. serialPort1.Close();
  378. SystemInf.OpenPort.Remove(serialPort1.PortName);
  379. thread.Interrupt();
  380. }
  381. dh.Dispose();
  382. }
  383. private void Packing_Click(object sender, EventArgs e)
  384. {
  385. if (dh.CheckExist("package", "pa_outboxcode='" + pa_outboxcode.Text + "' and pa_status<>1"))
  386. {
  387. dh.UpdateByCondition("package", "pa_status=1,pa_totalqty=pa_currentqty,pa_packageqty=pa_currentqty", "pa_outboxcode='" + pa_outboxcode.Text + "'");
  388. pa_status.Text = "1";
  389. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "装箱采集", "封箱成功", pa_outboxcode.Text, "");
  390. OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "封箱成功\n", Color.Green);
  391. }
  392. else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "错误或者已封箱\n", Color.Red);
  393. }
  394. private void SendCheck_Click(object sender, EventArgs e)
  395. {
  396. if (dh.getFieldDataByCondition("package", "pa_status", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString() != "0")
  397. {
  398. DataTable dt = (DataTable)dh.ExecuteSql("select wm_concat(pa_outboxcode) pa_outboxcode from package where pa_checkno='" + ob_checkno.Text + "' and pa_status=0 ", "select");
  399. if (dt.Rows[0][0].ToString() != "")
  400. {
  401. OperateResult.AppendText(">>批次" + ob_checkno.Text + "存在箱号" + dt.Rows[0][0].ToString() + "未封箱,请先进行封箱\n", Color.Red);
  402. return;
  403. }
  404. sql.Clear();
  405. sql.Append("update oqcbatch set ob_status='UNCHECK' where ob_checkno ='" + ob_checkno.Text + "'");
  406. dh.ExecuteSql(sql.GetString(), "select");
  407. ob_nowcheckqty.Text = "";
  408. ob_batchqty.Text = "";
  409. ob_nowcheckqty.ForeColor = Color.Black;
  410. SendCheck.Enabled = false;
  411. OperateResult.AppendText(">>批次" + ob_checkno.Text + "送检成功\n", Color.Green);
  412. LogicHandler.InsertMakeProcess(LastSncode, oMakeCode, User.UserSourceCode, "手动送检", "手动送检成功", User.UserCode);
  413. //记录操作日志
  414. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "手动送检", "手动送检成功", "", ob_checkno.Text);
  415. ob_checkno.Text = "";
  416. }
  417. else OperateResult.AppendText(">>必须封箱才能送检\n", Color.Red);
  418. }
  419. bool AutoCut;
  420. private void LoadCheckQTY()
  421. {
  422. sql.Clear();
  423. string condition = "";
  424. int nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
  425. int batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
  426. if (nowcheckqty + 1 == batchqty && AutoCut)
  427. {
  428. condition = "and ob_status='UNCHECK' and ob_checkno='" + ob_checkno.Text + "'";
  429. }
  430. else
  431. {
  432. condition = "and ob_status='ENTERING' ";
  433. }
  434. sql.Append("select ob_batchqty,ob_nowcheckqty,ob_checkno from oqcbatch where ");
  435. sql.Append("ob_linecode='" + User.UserLineCode + "' and ob_prodcode='" + pr_code.Text + "' and ");
  436. sql.Append("ob_stepcode='" + User.CurrentStepCode + "' " + condition);
  437. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  438. if (dt.Rows.Count > 0)
  439. {
  440. ob_batchqty.Text = dt.Rows[0]["ob_batchqty"].ToString();
  441. ob_nowcheckqty.Text = dt.Rows[0]["ob_nowcheckqty"].ToString();
  442. ob_checkno.Text = dt.Rows[0]["ob_checkno"].ToString();
  443. nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
  444. batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
  445. if (nowcheckqty == batchqty)
  446. {
  447. ob_nowcheckqty.ForeColor = Color.Red;
  448. OperateResult.AppendText(">>当前采集数量已达到送检数量\n", Color.Red);
  449. }
  450. }
  451. else
  452. {
  453. ob_batchqty.Text = "";
  454. ob_nowcheckqty.Text = "";
  455. ob_checkno.Text = "";
  456. SendCheck.Enabled = false;
  457. }
  458. if (ob_batchqty.Text != "")
  459. {
  460. SendCheck.Enabled = true;
  461. }
  462. else
  463. {
  464. SendCheck.Enabled = false;
  465. }
  466. }
  467. private void ob_checkno_TextChanged(object sender, EventArgs e)
  468. {
  469. if (ob_checkno.Text != "")
  470. {
  471. string Cut = dh.getFieldDataByCondition("product left join oqcbatch on ob_prodcode=pr_code", "pr_ifautocutcheckno", "ob_checkno='" + ob_checkno.Text + "'").ToString();
  472. if (Cut == "" || Cut == "0")
  473. AutoCut = false;
  474. else
  475. AutoCut = true;
  476. SendCheck.Enabled = true;
  477. }
  478. }
  479. private void pr_outboxinnerqty_KeyDown(object sender, KeyEventArgs e)
  480. {
  481. if (e.KeyCode == Keys.Enter)
  482. ResetPackQTY();
  483. }
  484. private void pr_outboxinnerqty_Leave(object sender, EventArgs e)
  485. {
  486. ResetPackQTY();
  487. }
  488. private void ResetPackQTY()
  489. {
  490. //数据不符合限制的时候保持原有值
  491. int curretnqty = int.Parse(pa_currentqty.Text == "" ? "0" : pa_currentqty.Text);
  492. if (!(pr_outboxinnerqty.Value >= curretnqty))
  493. {
  494. pr_outboxinnerqty.Value = StandardQTY;
  495. }
  496. else
  497. {
  498. if (dh.CheckExist("package", "pa_outboxcode='" + pa_outboxcode.Text + "'"))
  499. {
  500. string checknostatus = dh.getFieldDataByCondition("oqcbatch", "ob_status", "ob_checkno='" + pa_checkno.Text + "'").ToString();
  501. if (checknostatus == "" || checknostatus == "ENTERING")
  502. {
  503. if (pa_downstatus.Text == "0")
  504. {
  505. if (dh.CheckExist("source", "sc_code='" + pa_sccode.Text + "' and sc_stepcode='" + User.CurrentStepCode + "'"))
  506. {
  507. dh.UpdateByCondition("package", "pa_standardqty='" + pr_outboxinnerqty.Value + "'", "pa_outboxcode='" + pa_outboxcode.Text + "'");
  508. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "修改箱内容量", "原容量" + StandardQTY + ",修改为" + pr_outboxinnerqty.Value + "'", pa_outboxcode.Text, pa_checkno.Text);
  509. return;
  510. }
  511. else
  512. OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "当前所在工序不是登录岗位资源所在工序,不允许修改数量\n", Color.Red);
  513. }
  514. else
  515. OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "处于下地状态,不允许修改标准容量\n", Color.Red);
  516. }
  517. else
  518. OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "处于送检中,不允许修改标准容量\n", Color.Red);
  519. }
  520. else
  521. OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "不存在,修改容量无效\n", Color.Red);
  522. pr_outboxinnerqty.Value = StandardQTY;
  523. }
  524. }
  525. }
  526. }