Make_PackageCollectionWeigh.cs 27 KB

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