Packing_CartonBoxWeigh_ReadLine.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. using LabelManager2;
  2. using Microsoft.Win32;
  3. using Seagull.BarTender.Print;
  4. using System;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.IO.Ports;
  9. using System.Text;
  10. using System.Text.RegularExpressions;
  11. using System.Threading;
  12. using System.Windows.Forms;
  13. using UAS_MES_NEW.DataOperate;
  14. using UAS_MES_NEW.Entity;
  15. using UAS_MES_NEW.PublicForm;
  16. using UAS_MES_NEW.PublicMethod;
  17. using static System.Windows.Forms.VisualStyles.VisualStyleElement;
  18. namespace UAS_MES_NEW.Packing
  19. {
  20. public partial class Packing_CartonBoxWeigh_ReadLine : Form
  21. {
  22. AutoSizeFormClass asc = new AutoSizeFormClass();
  23. DataHelper dh;
  24. DataTable dt;
  25. LogStringBuilder sql = new LogStringBuilder();
  26. ApplicationClass lbl;
  27. Document doc;
  28. Regex re = new Regex("\\d+.\\d+");
  29. Thread thread;
  30. string PR_CHECKCARTONW = "0";
  31. //创建串口实例
  32. SerialPort serialPort1 = new SerialPort();
  33. //true的时候表示从串口读取数据
  34. bool GetData = true;
  35. //箱内总数
  36. int pa_totalqty;
  37. //称量的标准重量
  38. Double Weight;
  39. //最大重量
  40. Double MaxWeight;
  41. //最小重量
  42. Double MinWeight;
  43. DataTable ListC = new DataTable();
  44. Thread InitPrint;
  45. public Packing_CartonBoxWeigh_ReadLine()
  46. {
  47. InitializeComponent();
  48. try { UAS_MES_NEW.I18n.LanguageManager.Localize(this); } catch { }
  49. }
  50. protected override void OnVisibleChanged(EventArgs e)
  51. {
  52. base.OnVisibleChanged(e);
  53. if (!IsHandleCreated)
  54. {
  55. this.Close();
  56. }
  57. }
  58. private void 卡通箱称重_Load(object sender, EventArgs e)
  59. {
  60. CheckForIllegalCrossThreadCalls = false;
  61. asc.controllInitializeSize(this);
  62. ComList.Text = BaseUtil.GetCacheData("PortName").ToString();
  63. BaudRate.Text = BaseUtil.GetCacheData("BaudRate").ToString();
  64. InitPrint = new Thread(InPrint);
  65. SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
  66. BaseUtil.SetFormCenter(stw);
  67. stw.ShowDialog();
  68. StartWeight.PerformClick();
  69. dh = SystemInf.dh;
  70. StepCount.StepCode = User.CurrentStepCode;
  71. StepCount.Source = User.UserSourceCode;
  72. StepCount.LineCode = User.UserLineCode;
  73. StepCount.Dh = dh;
  74. StepCount.Start();
  75. }
  76. Engine engine;
  77. private void InPrint()
  78. {
  79. try
  80. {
  81. engine = new Engine(true);
  82. BaseUtil.WriteLbl();
  83. }
  84. catch (Exception)
  85. {
  86. OperateResult.AppendText("未正确安装BarTender软件\n", Color.Red);
  87. }
  88. }
  89. private void 卡通箱称重_SizeChanged(object sender, EventArgs e)
  90. {
  91. weight.Location = new Point(weight_label.Location.X + weight_label.Size.Width - 10, weight_label.Location.Y - 20);
  92. asc.controlAutoSize(this);
  93. }
  94. private void sncode_KeyDown(object sender, KeyEventArgs e)
  95. {
  96. if (e.KeyCode == Keys.Enter)
  97. {
  98. //根据箱号查询表单数据
  99. sql.Clear();
  100. sql.Append("select pa_totalqty,ma_code,ma_qty,ma_salecode,PA_STANDARDQTY,PA_CURRENTQTY,pr_detail,pr_cartonunit,pr_code,pr_cartongw,");
  101. sql.Append("pr_cartonmaxw,pr_cartonminw,nvl(PR_CHECKCARTONW,'0') PR_CHECKCARTONW,nvl(pr_sendchecktype,'LineCode')pr_sendchecktype from package left join packagedetail ");
  102. sql.Append("on pa_id=pd_paid left join makeserial on ms_sncode=pd_barcode and ms_makecode=pa_makecode left join product on pr_code=pd_prodcode left join make on ma_code=pd_makecode ");
  103. sql.Append(" where pa_outboxcode='" + outboxcode.Text + "' and pa_nextstep='" + User.CurrentStepCode + "'");
  104. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  105. //填充打印文件选项的DataGridView
  106. if (dt.Rows.Count > 0)
  107. {
  108. BaseUtil.SetFormValue(this.Controls, dt);
  109. string ErrorMessage;
  110. //重量的临时变量
  111. PR_CHECKCARTONW = dt.Rows[0]["PR_CHECKCARTONW"].ToString();
  112. string _weight = dt.Rows[0]["pr_cartongw"].ToString();
  113. string _maxweight = dt.Rows[0]["pr_cartonmaxw"].ToString();
  114. string _minweight = dt.Rows[0]["pr_cartonminw"].ToString();
  115. string pa_pr_cartonunit = dt.Rows[0]["pr_cartonunit"].ToString();
  116. string PA_STANDARDQTY = dt.Rows[0]["PA_STANDARDQTY"].ToString();
  117. string PA_CURRENTQTY = dt.Rows[0]["PA_CURRENTQTY"].ToString();
  118. Weight = double.Parse(_weight == "" ? "0" : _weight);
  119. MaxWeight = double.Parse(_maxweight == "" ? "0" : _maxweight);
  120. MinWeight = double.Parse(_minweight == "" ? "0" : _minweight);
  121. pa_totalqty = int.Parse(dt.Rows[0]["pa_totalqty"].ToString());
  122. if (Weight - MinWeight == MaxWeight - Weight)
  123. pr_cartongw.Text = Weight + "±" + (MaxWeight - Weight) + dt.Rows[0]["pr_cartonunit"].ToString();
  124. else
  125. pr_cartongw.Text = MinWeight + "-" + MaxWeight + dt.Rows[0]["pr_cartonunit"].ToString();
  126. double ActualWeight = double.Parse(weight.Text == "" ? "0" : weight.Text.Replace("kg", "").Trim());
  127. //需要检查称重重量
  128. if (PR_CHECKCARTONW != "0" && PA_STANDARDQTY == PA_CURRENTQTY)
  129. {
  130. //称量合格或不合格都记录重量
  131. if (ActualWeight >= MinWeight && ActualWeight <= MaxWeight && ActualWeight != 0)
  132. {
  133. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "卡通箱" + outboxcode.Text + "称重", "称量合格:" + weight.Text.Trim(), outboxcode.Text, "");
  134. LogicHandler.RecordProdWeight(outboxcode.Text, "CARTON", float.Parse(ActualWeight.ToString()), "kg", User.UserLineCode, pr_code.Text, User.UserSourceCode, User.UserName);
  135. OperateResult.AppendText(">>箱号" + outboxcode.Text + "检测合格\n", Color.Green);
  136. }
  137. else
  138. {
  139. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "卡通箱" + outboxcode.Text + "称重", "称量不合格:" + weight.Text.Trim(), outboxcode.Text, "");
  140. LogicHandler.RecordProdWeight(outboxcode.Text, "CARTON", float.Parse(ActualWeight.ToString()), "kg", User.UserLineCode, pr_code.Text, User.UserSourceCode, User.UserName);
  141. OperateResult.AppendText(">>箱号" + outboxcode.Text + "检测未通过\n", Color.Red);
  142. return;
  143. }
  144. }
  145. else
  146. {
  147. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "卡通箱" + outboxcode.Text + "称重", "称量完成:" + weight.Text.Trim(), outboxcode.Text, "");
  148. LogicHandler.RecordProdWeight(outboxcode.Text, "CARTON", float.Parse(ActualWeight.ToString()), "kg", User.UserLineCode, pr_code.Text, User.UserSourceCode, User.UserName);
  149. }
  150. ListViewItem lsi = new ListViewItem();
  151. lsi.SubItems.Add(outboxcode.Text);
  152. lsi.SubItems.Add(ActualWeight.ToString() + pr_cartonunit.Text);
  153. lsi.SubItems.Add(System.DateTime.Now.ToString());
  154. WeighRecord.Items.Add(lsi);
  155. OperateResult.AppendText(">>箱号" + outboxcode.Text + "称重完成\n", Color.Green);
  156. //if (LogicHandler.CartonBoxStepPass(ma_code.Text, User.UserSourceCode, outboxcode.Text, User.UserCode, "卡通箱:" + outboxcode.Text + "整箱过站", out ErrorMessage))
  157. //{
  158. // dh.UpdateByCondition("package", "pa_printcount= nvl(pa_printcount,0)+1,pa_weight='" + ActualWeight + "',pa_status=1,pa_packageqty=pa_currentqty,pa_totalqty=pa_currentqty", "pa_outboxcode='" + outboxcode.Text + "'");
  159. // dh.UpdateByCondition("package", "pa_nextstep='" + dh.getFieldDataByCondition("packagedetail left join makeserial on ms_sncode=pd_barcode and ms_makecode=pd_makecode", "max(ms_nextstepcode)", "pd_outboxcode='" + outboxcode.Text + "'").ToString() + "' ,PA_CURRENTSTEP = '' ", "pa_outboxcode='" + outboxcode.Text + "'");
  160. //}
  161. //else
  162. //{
  163. // OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  164. //}
  165. if (!LogicHandler.OutBoxStepPass(outboxcode.Text, ma_code.Text, User.UserSourceCode, User.UserCode, "卡通箱:" + outboxcode.Text + "整箱过站", "卡通箱整箱过站", out ErrorMessage))
  166. {
  167. OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
  168. return;
  169. }
  170. dh.UpdateByCondition("package", "pa_printcount= nvl(pa_printcount,0)+1,pa_weight='" + ActualWeight + "',pa_status=1,pa_packageqty=pa_currentqty,pa_totalqty=pa_currentqty", "pa_outboxcode='" + outboxcode.Text + "'");
  171. dh.UpdateByCondition("package", "pa_nextstep='" + dh.getFieldDataByCondition("packagedetail left join makeserial on ms_sncode=pd_barcode and ms_makecode=pd_makecode", "max(ms_nextstepcode)", "pd_outboxcode='" + outboxcode.Text + "'").ToString() + "' ,PA_CURRENTSTEP = '' ", "pa_outboxcode='" + outboxcode.Text + "'");
  172. if (AutoPrint.Checked)
  173. {
  174. if (PrintLabel.Items.Count > 0)
  175. {
  176. Confirm.PerformClick();
  177. }
  178. else
  179. {
  180. OperateResult.AppendText(">>产品" + pr_code.Text + "未维护卡通标签\n", Color.Red);
  181. }
  182. }
  183. LoadCheckQTY();
  184. outboxcode.SelectAll();
  185. }
  186. else OperateResult.AppendText(">>箱号" + outboxcode.Text + "当前执行工序不是" + User.CurrentStepCode + "\n", Color.Red);
  187. }
  188. }
  189. private void getSerialData()
  190. {
  191. if (serialPort1.IsOpen)
  192. {
  193. OperateResult.AppendText(SystemInf.OpenPort.Contains(serialPort1.PortName).ToString());
  194. if (!SystemInf.OpenPort.Contains(serialPort1.PortName))
  195. {
  196. SystemInf.OpenPort.Add(serialPort1.PortName);
  197. try
  198. {
  199. while (GetData)
  200. {
  201. try
  202. {
  203. int len = serialPort1.BytesToRead;
  204. Byte[] readBuffer = new Byte[len];
  205. serialPort1.Read(readBuffer, 0, len); //将数据读入缓存
  206. string weigh = Encoding.Default.GetString(readBuffer);
  207. string str = re.Match(weigh.Trim()).Groups[0].Value;
  208. OperateResult.AppendText(str);
  209. if (str != "")
  210. {
  211. weight.Text = str;
  212. }
  213. }
  214. catch (Exception)
  215. {
  216. GetData = false;
  217. }
  218. }
  219. }
  220. catch (IOException ex) { OperateResult.AppendText(">>" + ex.Message + "\n", Color.Red); }
  221. }
  222. else OperateResult.AppendText(">>端口已被占用,请关闭其他窗口\n", Color.Red);
  223. }
  224. }
  225. //确认打印
  226. private void Confirm_Click(object sender, EventArgs e)
  227. {
  228. //doc = lbl.Documents.Open(PrintLabel.Text);
  229. if (dh.CheckExist("package", "pa_outboxcode='" + outboxcode.Text + "' and pa_weight is null"))
  230. {
  231. OperateResult.AppendText(">>箱号" + outboxcode.Text + "未称重,不允许打印\n", Color.Red);
  232. return;
  233. }
  234. string ErrorMessage = "";
  235. if (!Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, outboxcode.Text, int.Parse(PrintNum.Text), ma_code.Text, pr_code.Text, "卡通箱标", "0", out ErrorMessage))
  236. {
  237. OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
  238. }
  239. if (PrintSecond.Checked)
  240. {
  241. if (Print.BarTender(Tag.ToString(), ref engine, PrintLabel1.Text, PrintLabel1.SelectedValue.ToString(), PrintList1.Text, outboxcode.Text, int.Parse(PrintNum1.Text), ma_code.Text, pr_code.Text, "卡通箱标", "0", out ErrorMessage))
  242. {
  243. OperateResult.AppendText(">>开始打印箱号" + outboxcode.Text + "\n", Color.Black);
  244. }
  245. else
  246. {
  247. OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
  248. }
  249. }
  250. }
  251. //停止进程,关闭串口
  252. private void StopWeight_Click(object sender, EventArgs e)
  253. {
  254. if (serialPort1.IsOpen)
  255. {
  256. GetData = false;
  257. serialPort1.Close();
  258. SystemInf.OpenPort.Remove(serialPort1.PortName);
  259. thread.Abort();
  260. }
  261. }
  262. //关闭窗口的时候停止进程,不再读取串口数据
  263. private void 卡通箱称重_FormClosing(object sender, FormClosingEventArgs e)
  264. {
  265. BaseUtil.ClosePrint(lbl);
  266. StopWeight.PerformClick();
  267. InitPrint.Abort();
  268. if (serialPort1.IsOpen)
  269. {
  270. GetData = false;
  271. serialPort1.Close();
  272. SystemInf.OpenPort.Remove(serialPort1.PortName);
  273. thread.Interrupt();
  274. }
  275. //thread.Abort();
  276. }
  277. private void StartWeight_Click(object sender, EventArgs e)
  278. {
  279. thread = new Thread(getSerialData);
  280. try
  281. {
  282. GetData = true;
  283. serialPort1.PortName = this.ComList.Text;
  284. serialPort1.BaudRate = int.Parse(BaudRate.Text);
  285. serialPort1.Open();
  286. thread.Start();
  287. }
  288. catch (Exception mes)
  289. {
  290. if (BaudRate.Text == "" || ComList.Text == "")
  291. OperateResult.AppendText(">>请先在电子秤调试界面维护波特率和串口\n", Color.Red);
  292. else
  293. OperateResult.AppendText(">>" + mes.Message + "\n", Color.Red);
  294. }
  295. }
  296. private void pr_code_TextChanged(object sender, EventArgs e)
  297. {
  298. DataTable _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault,replace(LA_SOFTTYPE,';',',')LA_SOFTTYPE from label where la_prodcode='" + pr_code.Text + "' and la_templatetype='卡通箱标' and la_statuscode='AUDITED' order by la_isdefault", "select");
  299. if (_dt.Rows.Count == 0)
  300. {
  301. _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");
  302. }
  303. if (_dt.Rows.Count > 0)
  304. {
  305. string la_id = _dt.Rows[0]["la_id"].ToString();
  306. _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_id='" + la_id + "') where COLUMN_VALUE is not null)", "select");
  307. PrintLabel.DataSource = _dt;
  308. PrintLabel.DisplayMember = "la_url";
  309. PrintLabel.ValueMember = "la_id";
  310. PrintLabel1.DataSource = _dt.Copy();
  311. PrintLabel1.DisplayMember = "la_url";
  312. PrintLabel1.ValueMember = "la_id";
  313. }
  314. }
  315. private void PrintLabel_SelectedValueChanged(object sender, EventArgs e)
  316. {
  317. if (PrintLabel.SelectedValue != null && PrintLabel.SelectedValue.ToString() != "System.Data.DataRowView")
  318. {
  319. string PrintNums = dh.getFieldDataByCondition("label", "la_printnos", "la_id='" + PrintLabel.SelectedValue.ToString() + "'").ToString();
  320. PrintNum.Text = (PrintNums == "" ? "1" : PrintNums);
  321. }
  322. }
  323. private void SendCheck_Click(object sender, EventArgs e)
  324. {
  325. 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");
  326. if (dt.Rows[0][0].ToString() != "")
  327. {
  328. OperateResult.AppendText(">>批次" + ob_checkno.Text + "存在箱号" + dt.Rows[0][0].ToString() + "未封箱,请先进行封箱\n", Color.Red);
  329. return;
  330. }
  331. sql.Clear();
  332. sql.Append("update oqcbatch set ob_status='UNCHECK' where ob_checkno ='" + ob_checkno.Text + "'");
  333. dh.ExecuteSql(sql.GetString(), "select");
  334. ob_nowcheckqty.Text = "";
  335. ob_batchqty.Text = "";
  336. ob_nowcheckqty.ForeColor = Color.Black;
  337. SendCheck.Enabled = false;
  338. OperateResult.AppendText(">>批次" + ob_checkno.Text + "送检成功\n", Color.Green);
  339. LogicHandler.InsertMakeProcess("", ma_code.Text, User.UserSourceCode, "手动送检", "手动送检成功", User.UserCode);
  340. //记录操作日志
  341. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "手动送检", "手动送检成功", "", ob_checkno.Text);
  342. ob_checkno.Text = "";
  343. }
  344. bool AutoCut;
  345. private void LoadCheckQTY()
  346. {
  347. sql.Clear();
  348. string condition = "";
  349. int nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
  350. int batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
  351. if (nowcheckqty + 1 == batchqty && AutoCut)
  352. {
  353. condition = "and ob_status='UNCHECK' and ob_checkno='" + ob_checkno.Text + "'";
  354. }
  355. else
  356. {
  357. condition = "and ob_status='ENTERING' ";
  358. }
  359. if (pr_sendchecktype.Text == "SaleCode")
  360. {
  361. condition += " and ob_salecode='" + ma_salecode.Text + "'";
  362. }
  363. sql.Append("select ob_batchqty,ob_nowcheckqty,ob_checkno from oqcbatch where ");
  364. sql.Append("ob_linecode='" + User.UserLineCode + "' and ob_prodcode='" + pr_code.Text + "' and ");
  365. sql.Append("ob_stepcode='" + User.CurrentStepCode + "' " + condition);
  366. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  367. if (dt.Rows.Count > 0)
  368. {
  369. ob_batchqty.Text = dt.Rows[0]["ob_batchqty"].ToString();
  370. ob_nowcheckqty.Text = dt.Rows[0]["ob_nowcheckqty"].ToString();
  371. ob_checkno.Text = dt.Rows[0]["ob_checkno"].ToString();
  372. nowcheckqty = int.Parse(ob_nowcheckqty.Text == "" ? "0" : ob_nowcheckqty.Text);
  373. batchqty = int.Parse(ob_batchqty.Text == "" ? "0" : ob_batchqty.Text);
  374. if (nowcheckqty >= batchqty)
  375. {
  376. ob_nowcheckqty.ForeColor = Color.Red;
  377. OperateResult.AppendText(">>当前采集数量已达到送检数量\n", Color.Red);
  378. if (AutoCut)
  379. {
  380. OperateResult.AppendText(">>批次" + ob_checkno.Text + "自动断批\n", Color.Green);
  381. }
  382. }
  383. }
  384. else
  385. {
  386. ob_batchqty.Text = "";
  387. ob_nowcheckqty.Text = "";
  388. ob_checkno.Text = "";
  389. SendCheck.Enabled = false;
  390. }
  391. if (ob_batchqty.Text != "")
  392. {
  393. SendCheck.Enabled = true;
  394. }
  395. else
  396. {
  397. SendCheck.Enabled = false;
  398. }
  399. }
  400. private void ob_checkno_TextChanged(object sender, EventArgs e)
  401. {
  402. if (ob_checkno.Text != "")
  403. {
  404. string Cut = dh.getFieldDataByCondition("product left join oqcbatch on ob_prodcode=pr_code", "pr_ifautocutcheckno", "ob_checkno='" + ob_checkno.Text + "'").ToString();
  405. if (Cut == "" || Cut == "0")
  406. AutoCut = false;
  407. else
  408. AutoCut = true;
  409. SendCheck.Enabled = true;
  410. }
  411. }
  412. private void RefreshWeigh_Click(object sender, EventArgs e)
  413. {
  414. sql.Clear();
  415. sql.Append("select pr_cartonmaxw,pr_cartonunit,pr_cartonminw,pr_cartongw from product where pr_code='" + pr_code.Text + "'");
  416. DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  417. //填充打印文件选项的DataGridView
  418. if (dt.Rows.Count > 0)
  419. {
  420. string _weight = dt.Rows[0]["pr_cartongw"].ToString();
  421. string _maxweight = dt.Rows[0]["pr_cartonmaxw"].ToString();
  422. string _minweight = dt.Rows[0]["pr_cartonminw"].ToString();
  423. Weight = double.Parse(_weight == "" ? "0" : _weight);
  424. MaxWeight = double.Parse(_maxweight == "" ? "0" : _maxweight);
  425. MinWeight = double.Parse(_minweight == "" ? "0" : _minweight);
  426. if (Weight - MinWeight == MaxWeight - Weight)
  427. pr_cartongw.Text = Weight + "±" + (MaxWeight - Weight) + dt.Rows[0]["pr_cartonunit"].ToString();
  428. else
  429. pr_cartongw.Text = MinWeight + "-" + MaxWeight + dt.Rows[0]["pr_cartonunit"].ToString();
  430. }
  431. }
  432. }
  433. }