Make_MidBoxWeigh.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. using System;
  2. using System.Data;
  3. using System.IO;
  4. using System.IO.Ports;
  5. using System.Text.RegularExpressions;
  6. using System.Threading;
  7. using System.Windows.Forms;
  8. using UAS_MES_NEW.DataOperate;
  9. using UAS_MES_NEW.Entity;
  10. using UAS_MES_NEW.PublicMethod;
  11. using System.Drawing;
  12. using LabelManager2;
  13. using UAS_MES_NEW.PublicForm;
  14. using System.Net.Sockets;
  15. using System.Collections.Generic;
  16. using System.Net;
  17. using System.Text;
  18. using Seagull.BarTender.Print;
  19. namespace UAS_MES_NEW.Make
  20. {
  21. public partial class Make_MidBoxWeigh : Form
  22. {
  23. AutoSizeFormClass asc = new AutoSizeFormClass();
  24. ApplicationClass lbl;
  25. DataHelper dh;
  26. DataTable dt;
  27. LogStringBuilder sql = new LogStringBuilder();
  28. //启用线程进行称重数据读取
  29. Thread thread;
  30. SerialPort serialPort1 = new SerialPort();
  31. //称量的标准重量
  32. Double Weight;
  33. //最大重量
  34. Double MaxWeight;
  35. //最小重量
  36. Double MinWeight;
  37. //是否通过串口获取数据
  38. bool GetData = true;
  39. string LastSncode;
  40. DataTable Dbfind;
  41. Regex re = new Regex("\\d+.\\W+");
  42. string ErrorMessage;
  43. Thread InitPrint;
  44. private bool AutoCut;
  45. public Make_MidBoxWeigh()
  46. {
  47. InitializeComponent();
  48. CheckForIllegalCrossThreadCalls = false;
  49. }
  50. Engine engine;
  51. private void InPrint()
  52. {
  53. try
  54. {
  55. engine = new Engine(true);
  56. }
  57. catch (Exception ex)
  58. {
  59. OperateResult.AppendText(ex.Message + ex.StackTrace, Color.Red);
  60. }
  61. }
  62. private void Make_ColorBoxWeigh_Load(object sender, EventArgs e)
  63. {
  64. asc.controllInitializeSize(this);
  65. ComList.Text = BaseUtil.GetCacheData("PortName").ToString();
  66. BaudRate.Text = BaseUtil.GetCacheData("BaudRate").ToString();
  67. InitPrint = new Thread(InPrint);
  68. SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
  69. BaseUtil.SetFormCenter(stw);
  70. stw.ShowDialog();
  71. //设置锁定工单
  72. LockMakeCode.GetMakeCodeCtl(ma_code);
  73. ma_code.SetLockCheckBox(LockMakeCode);
  74. //工单号放大镜配置
  75. ma_code.TableName = "make left join product on ma_prodcode=pr_code";
  76. ma_code.SelectField = "ma_code # 工单号,pr_code # 产品编号,pr_spec # 产品规格";
  77. ma_code.FormName = Name;
  78. ma_code.SetValueField = new string[] { "ma_code", "pr_code", "pr_spec" };
  79. ma_code.Condition = "ma_statuscode='STARTED'";
  80. ma_code.DbChange += Ma_code_DbChange;
  81. StartWeight.PerformClick();
  82. dh = SystemInf.dh;
  83. StepCount.StepCode = User.CurrentStepCode;
  84. StepCount.Source = User.UserSourceCode;
  85. StepCount.LineCode = User.UserLineCode;
  86. StepCount.Dh = dh;
  87. StepCount.Start();
  88. AutoPrint.Checked = false;
  89. try
  90. {
  91. if (File.Exists("MidBoxWeigh" + ".txt"))
  92. {
  93. File.Delete("MidBoxWeigh" + ".txt");
  94. }
  95. StreamWriter sw = File.AppendText("MidBoxWeigh" + ".txt");
  96. sw.WriteLine(sncode.Handle);
  97. sw.WriteLine(weight.Handle);
  98. sw.Close();
  99. }
  100. catch (Exception) { }
  101. }
  102. private void Ma_code_DbChange(object sender, EventArgs e)
  103. {
  104. Dbfind = ma_code.ReturnData;
  105. BaseUtil.SetFormValue(this.Controls, Dbfind);
  106. //获取工单的其他信息
  107. sql.Clear();
  108. sql.Append("select ma_code,ma_prodcode as pr_code , pr_detail as pr_spec,");
  109. sql.Append("pr_spec,ma_qty - nvl(mcd_inqty, 0) mcd_remainqty from make left join makecraftdetail_view on ");
  110. sql.Append("mcd_maid=ma_id left join product on pr_code=ma_prodcode where ma_code='" + ma_code.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
  111. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  112. if (dt.Rows.Count > 0)
  113. {
  114. BaseUtil.SetFormValue(this.Controls, dt);
  115. }
  116. }
  117. private void sncode_KeyDown(object sender, KeyEventArgs e)
  118. {
  119. if (e.KeyCode == Keys.Enter)
  120. {
  121. if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
  122. {
  123. string oMakeCode = "";
  124. string oMsID = "";
  125. dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei1='" + sncode.Text + "' order by ms_id desc", "select");
  126. if (dt.Rows.Count > 0)
  127. {
  128. sncode.Text = dt.Rows[0]["ms_sncode"].ToString();
  129. }
  130. else
  131. {
  132. dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei2='" + sncode.Text + "' order by ms_id desc", "select");
  133. if (dt.Rows.Count > 0)
  134. {
  135. sncode.Text = dt.Rows[0]["ms_sncode"].ToString();
  136. }
  137. }
  138. if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage))
  139. {
  140. //string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_id='" + oMsID + "'").ToString();
  141. //if (nextstepcode != User.CurrentStepCode)
  142. //{
  143. // OperateResult.AppendText("<<序列号:" + sncode.Text + "下一工序是" + nextstepcode + ",不是当前岗位的工序\n", Color.Red, sncode);
  144. // return;
  145. //}
  146. sql.Clear();
  147. sql.Append("select ms_makecode ma_code,ma_qty,ma_salecode,pr_detail pr_spec,pr_colorboxunit,pr_code,pr_colorboxgw,");
  148. sql.Append("pr_colorboxunit,pr_midboxmaxweight pr_colorboxmaxw,pr_midboxminweight pr_colorboxminw,nvl(PR_CHECKCOLORBOXW,'0') PR_CHECKCOLORBOXW,nvl(pr_sendchecktype,'LineCode')");
  149. sql.Append("pr_sendchecktype from makeserial left join make on ms_makecode=ma_code left join product on ");
  150. sql.Append("ms_prodcode=pr_code where ms_sncode='" + sncode.Text + "' order by ms_id desc");
  151. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  152. if (dt.Rows.Count > 0)
  153. {
  154. //重量的临时变量
  155. pr_code.Text = dt.Rows[0]["pr_code"].ToString();
  156. string _weight = dt.Rows[0]["pr_colorboxgw"].ToString();
  157. string _maxweight = dt.Rows[0]["pr_colorboxmaxw"].ToString();
  158. string _minweight = dt.Rows[0]["pr_colorboxminw"].ToString();
  159. string pr_colorunit = dt.Rows[0]["pr_colorboxunit"].ToString();
  160. string ma_salecode_text = dt.Rows[0]["ma_salecode"].ToString();
  161. string PR_CHECKCOLORBOXW = dt.Rows[0]["PR_CHECKCOLORBOXW"].ToString();
  162. //赋值重量单位
  163. Weight = double.Parse(_weight == "" ? "0" : _weight);
  164. MaxWeight = double.Parse(_maxweight == "" ? "0" : _maxweight);
  165. MinWeight = double.Parse(_minweight == "" ? "0" : _minweight);
  166. if (locksalecode.Checked && ma_salecode.Text != "" && ma_salecode.Text != ma_salecode_text)
  167. {
  168. OperateResult.AppendText(">>序列号" + sncode.Text + "所属订单号" + ma_salecode_text + "与界面订单号" + ma_salecode.Text + "不同,无法采集\n", Color.Red, sncode);
  169. return;
  170. }
  171. ma_salecode.Text = dt.Rows[0]["ma_salecode"].ToString();
  172. BaseUtil.SetFormValue(this.Controls, dt);
  173. if (Weight - MinWeight == MaxWeight - Weight)
  174. pr_colorboxgw.Text = Weight + "±" + (MaxWeight - Weight) + dt.Rows[0]["pr_colorboxunit"].ToString();
  175. else
  176. pr_colorboxgw.Text = MinWeight + "-" + MaxWeight + dt.Rows[0]["pr_colorboxunit"].ToString();
  177. //重量信息若需要检测则必须符合检测要求才更新
  178. double ActualWeight = double.Parse(weight.Text == "" ? "0" : weight.Text.Replace("kg", "").Replace("g", "").Trim());
  179. if (PR_CHECKCOLORBOXW != "0")
  180. {
  181. if (MinWeight == 0 || MaxWeight == 0)
  182. {
  183. OperateResult.AppendText(">>产品" + pr_code.Text + "未维护中箱重量范围\n", Color.Red);
  184. return;
  185. }
  186. if ((ActualWeight >= MinWeight) && (ActualWeight <= MaxWeight))
  187. {
  188. OperateResult.AppendText(">>中箱" + sncode.Text + "重量检测检测合格\n", Color.Green);
  189. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "中箱称重:" + weight.Text, "称量合格", sncode.Text, "");
  190. LogicHandler.RecordProdWeight(sncode.Text, "SN", float.Parse(ActualWeight.ToString()), "kg", User.UserLineCode, pr_code.Text, User.UserSourceCode, User.UserName);
  191. dh.ExecuteSql("update makeserial set ms_midboxweight='" + ActualWeight + "' where ms_id='" + oMsID + "'", "update");
  192. }
  193. else
  194. {
  195. OperateResult.AppendText(">>中箱" + sncode.Text + "重量检测未通过\n", Color.Red);
  196. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "中箱称重:" + weight.Text, "称量不合格", sncode.Text, "");
  197. LogicHandler.RecordProdWeight(sncode.Text, "SN", float.Parse(ActualWeight.ToString()), "kg", User.UserLineCode, pr_code.Text, User.UserSourceCode, User.UserName);
  198. return;
  199. }
  200. }
  201. else
  202. {
  203. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "中箱称重:" + weight.Text, "称量完成", sncode.Text, "");
  204. LogicHandler.RecordProdWeight(sncode.Text, "SN", float.Parse(ActualWeight.ToString()), "kg", User.UserLineCode, pr_code.Text, User.UserSourceCode, User.UserName);
  205. dh.ExecuteSql("update makeserial set ms_midboxweight='" + ActualWeight + "' where ms_id='" + oMsID + "'", "update");
  206. }
  207. ListViewItem lsi = new ListViewItem();
  208. lsi.SubItems.Add(sncode.Text);
  209. lsi.SubItems.Add(ActualWeight.ToString());
  210. lsi.SubItems.Add(System.DateTime.Now.ToString());
  211. WeighRecord.Items.Add(lsi);
  212. WeighRecord.Items[this.WeighRecord.Items.Count - 1].EnsureVisible();
  213. OperateResult.AppendText(">>中箱" + sncode.Text + "称重完成\n", Color.Green);
  214. //显示最近的三个称量记录
  215. if (LogicHandler.SetStepResult(ma_code.Text, User.UserSourceCode, sncode.Text, "中箱称量", "称量合格", User.UserCode, out ErrorMessage))
  216. {
  217. //提示正确返回时传递的信息
  218. if (ErrorMessage.Contains("AFTERSUCCESS"))
  219. OperateResult.AppendText(">>" + ErrorMessage + "\n");
  220. LoadCheckQTY();
  221. //记录送检前的最后一个序列号
  222. LastSncode = sncode.Text;
  223. if (AutoPrint.Checked)
  224. {
  225. OperateResult.AppendText(">>打印条码号" + sncode.Text + "\n", Color.Green);
  226. Confirm.PerformClick();
  227. }
  228. Remark.Clear();
  229. }
  230. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  231. //if (CollectRemark.Checked && Remark.Text != "")
  232. //{
  233. // LogicHandler.CollectRemarkInf(sncode.Text, "", "", oMakeCode, pr_code.Text, Remark.Text);
  234. //}
  235. LoadCollectedNum();
  236. sncode.Clear();
  237. }
  238. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, sncode);
  239. }
  240. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, sncode);
  241. }
  242. else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, sncode);
  243. }
  244. }
  245. private void getSerialData()
  246. {
  247. if (serialPort1.IsOpen)
  248. {
  249. if (!SystemInf.OpenPort.Contains(serialPort1.PortName))
  250. {
  251. SystemInf.OpenPort.Add(serialPort1.PortName);
  252. try
  253. {
  254. while (GetData)
  255. {
  256. try
  257. {
  258. int len = serialPort1.BytesToRead;
  259. Byte[] readBuffer = new Byte[len];
  260. serialPort1.Read(readBuffer, 0, len); //将数据读入缓存
  261. string weigh = Encoding.Default.GetString(readBuffer);
  262. Remark.AppendText(weigh + "\n");
  263. if (weigh != "")
  264. {
  265. weight.Text = re.Match(weigh).Value;
  266. }
  267. }
  268. catch (Exception)
  269. {
  270. GetData = false;
  271. }
  272. }
  273. }
  274. catch (IOException ex) { MessageBox.Show(ex.Message); }
  275. }
  276. else OperateResult.AppendText(">>端口已被占用,请关闭其他窗口\n", Color.Red);
  277. }
  278. }
  279. private void 中箱称重_SizeChanged(object sender, EventArgs e)
  280. {
  281. weight.Location = new Point(weight_label.Location.X + weight_label.Size.Width - 10, weight_label.Location.Y - 20);
  282. asc.controlAutoSize(this);
  283. }
  284. protected override void OnVisibleChanged(EventArgs e)
  285. {
  286. base.OnVisibleChanged(e);
  287. if (!IsHandleCreated)
  288. {
  289. this.Close();
  290. }
  291. }
  292. private void Clean_Click(object sender, EventArgs e)
  293. {
  294. OperateResult.Clear();
  295. }
  296. //关闭窗口的时候停止进程读取串口数据
  297. private void 中箱称重_FormClosing(object sender, FormClosingEventArgs e)
  298. {
  299. BaseUtil.ClosePrint(lbl);
  300. StopWeight.PerformClick();
  301. InitPrint.Abort();
  302. if (serialPort1.IsOpen)
  303. {
  304. GetData = false;
  305. serialPort1.Close();
  306. SystemInf.OpenPort.Remove(serialPort1.PortName);
  307. thread.Interrupt();
  308. }
  309. //thread.Abort();
  310. }
  311. private void Confirm_Click(object sender, EventArgs e)
  312. {
  313. if (PrintLabel.Items.Count != 0)
  314. {
  315. string oErrorMessage;
  316. if (!Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, sncode.Text, int.Parse(PrintNum.Text), ma_code.Text, pr_code.Text, "中箱标", "0", out oErrorMessage))
  317. {
  318. OperateResult.AppendText(oErrorMessage + "\n", Color.Red);
  319. }
  320. }
  321. else
  322. {
  323. OperateResult.AppendText(">>产品" + pr_code.Text + "未维护打印标签\n", Color.Red);
  324. }
  325. }
  326. Thread threadWatch = null; //负责监听客户端的线程
  327. Socket socketWatch = null; //负责监听客户端的套接字
  328. Socket socConnection;
  329. private void StartWeight_Click(object sender, EventArgs e)
  330. {
  331. thread = new Thread(getSerialData);
  332. try
  333. {
  334. serialPort1.PortName = ComList.Text;
  335. serialPort1.BaudRate = int.Parse(BaudRate.Text);
  336. serialPort1.Open();
  337. GetData = true;
  338. thread.Start();
  339. }
  340. catch (Exception mes)
  341. {
  342. if (BaudRate.Text == "" || ComList.Text == "")
  343. OperateResult.AppendText(">>请先在电子秤调试界面维护波特率和串口\n", Color.Red);
  344. else
  345. OperateResult.AppendText(">>" + mes.Message + "\n", Color.Red);
  346. }
  347. }
  348. private void StopWeight_Click(object sender, EventArgs e)
  349. {
  350. if (serialPort1.IsOpen)
  351. {
  352. GetData = false;
  353. serialPort1.Close();
  354. SystemInf.OpenPort.Remove(serialPort1.PortName);
  355. thread.Abort();
  356. }
  357. }
  358. private void pr_code_TextChanged(object sender, EventArgs e)
  359. {
  360. LoadCheckQTY();
  361. DataTable _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault from label where la_prodcode='" + pr_code.Text + "' and la_templatetype='中箱标' and la_statuscode='AUDITED' order by la_isdefault", "select");
  362. PrintLabel.DataSource = _dt;
  363. PrintLabel.DisplayMember = "la_url";
  364. PrintLabel.ValueMember = "la_id";
  365. }
  366. private void SendCheck_Click(object sender, EventArgs e)
  367. {
  368. sql.Clear();
  369. sql.Append("update oqcbatch set ob_status='UNCHECK',ob_breakingdate=sysdate where ob_checkno ='" + ob_checkno.Text + "'");
  370. dh.ExecuteSql(sql.GetString(), "select");
  371. ob_nowcheckqty.Text = "";
  372. ob_batchqty.Text = "";
  373. ob_nowcheckqty.ForeColor = Color.Black;
  374. SendCheck.Enabled = false;
  375. OperateResult.AppendText(">>批次" + ob_checkno.Text + "送检成功\n", Color.Green);
  376. LogicHandler.InsertMakeProcess(LastSncode, ma_code.Text, User.UserSourceCode, "手动送检", "手动送检成功", User.UserCode);
  377. //记录操作日志
  378. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "手动送检", "手动送检成功", "", ob_checkno.Text);
  379. ob_checkno.Text = "";
  380. }
  381. private void LoadCheckQTY()
  382. {
  383. sql.Clear();
  384. string condition = "";
  385. int nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
  386. int batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
  387. if (nowcheckqty + 1 == batchqty && AutoCut)
  388. {
  389. condition = "and ob_status='UNCHECK' and ob_checkno='" + ob_checkno.Text + "'";
  390. }
  391. else
  392. {
  393. condition = "and ob_status='ENTERING' ";
  394. }
  395. if (pr_sendchecktype.Text == "SaleCode")
  396. {
  397. condition += " and ob_salecode='" + ma_salecode.Text + "'";
  398. }
  399. sql.Append("select ob_batchqty,ob_nowcheckqty,ob_checkno from oqcbatch where ");
  400. sql.Append("ob_linecode='" + User.UserLineCode + "' and ob_prodcode='" + pr_code.Text + "' and ");
  401. sql.Append("ob_stepcode='" + User.CurrentStepCode + "' " + condition);
  402. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  403. if (dt.Rows.Count > 0)
  404. {
  405. ob_batchqty.Text = dt.Rows[0]["ob_batchqty"].ToString();
  406. ob_nowcheckqty.Text = dt.Rows[0]["ob_nowcheckqty"].ToString();
  407. ob_checkno.Text = dt.Rows[0]["ob_checkno"].ToString();
  408. nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
  409. batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
  410. if (nowcheckqty == batchqty)
  411. {
  412. ob_nowcheckqty.ForeColor = Color.Red;
  413. OperateResult.AppendText(">>当前采集数量已达到送检数量\n", Color.Red);
  414. if (AutoCut)
  415. {
  416. OperateResult.AppendText(">>批次" + ob_checkno.Text + "自动断批\n", Color.Green);
  417. }
  418. }
  419. }
  420. else
  421. {
  422. ob_batchqty.Text = "";
  423. ob_nowcheckqty.Text = "";
  424. ob_checkno.Text = "";
  425. SendCheck.Enabled = false;
  426. }
  427. if (ob_batchqty.Text != "")
  428. {
  429. SendCheck.Enabled = true;
  430. }
  431. else
  432. {
  433. SendCheck.Enabled = false;
  434. }
  435. }
  436. private void ob_checkno_TextChanged(object sender, EventArgs e)
  437. {
  438. if (ob_checkno.Text != "")
  439. {
  440. string Cut = dh.getFieldDataByCondition("product left join oqcbatch on ob_prodcode=pr_code", "pr_ifautocutcheckno", "ob_checkno='" + ob_checkno.Text + "'").ToString();
  441. if (Cut == "" || Cut == "0")
  442. AutoCut = false;
  443. else
  444. AutoCut = true;
  445. SendCheck.Enabled = true;
  446. }
  447. }
  448. private void PrintLabel_SelectedValueChanged(object sender, EventArgs e)
  449. {
  450. if (PrintLabel.SelectedValue != null && PrintLabel.SelectedValue.ToString() != "System.Data.DataRowView")
  451. {
  452. string PrintNums = dh.getFieldDataByCondition("label", "la_printnos", "la_id='" + PrintLabel.SelectedValue.ToString() + "'").ToString();
  453. PrintNum.Text = (PrintNums == "" ? "1" : PrintNums);
  454. }
  455. }
  456. private void RefreshWeigh_Click(object sender, EventArgs e)
  457. {
  458. sql.Clear();
  459. sql.Append("select pr_colorboxgw,pr_midboxmaxweight pr_colorboxmaxw,pr_midboxminweight pr_colorboxminw,pr_colorboxunit from product where pr_code='" + pr_code.Text + "'");
  460. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  461. if (dt.Rows.Count > 0)
  462. {
  463. //重量的临时变量
  464. string _weight = dt.Rows[0]["pr_colorboxgw"].ToString();
  465. string _maxweight = dt.Rows[0]["pr_colorboxmaxw"].ToString();
  466. string _minweight = dt.Rows[0]["pr_colorboxminw"].ToString();
  467. //赋值重量单位
  468. Weight = double.Parse(_weight == "" ? "0" : _weight);
  469. MaxWeight = double.Parse(_maxweight == "" ? "0" : _maxweight);
  470. MinWeight = double.Parse(_minweight == "" ? "0" : _minweight);
  471. if (Weight - MinWeight == MaxWeight - Weight)
  472. pr_colorboxgw.Text = Weight + "±" + (MaxWeight - Weight) + dt.Rows[0]["pr_colorboxunit"].ToString();
  473. else
  474. pr_colorboxgw.Text = MinWeight + "-" + MaxWeight + dt.Rows[0]["pr_colorboxunit"].ToString();
  475. }
  476. }
  477. private void LoadCollectedNum()
  478. {
  479. dt = (DataTable)dh.ExecuteSql("select mcd_inqty,ma_qty-mcd_inqty mcd_remainqty from make left join makecraftdetail_view on mcd_macode=ma_code where ma_code='" + ma_code.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'", "select");
  480. BaseUtil.SetFormValue(Controls, dt);
  481. }
  482. private void StepCount_Load(object sender, EventArgs e)
  483. {
  484. }
  485. }
  486. }