private void SetRange(decimal count) { decimal error = decimal.Round(count * 100 / planCount, 2); errorBox.Text = error.ToString(); if (sijis == null || sijis.Count == 0) { msgBox.Text = "siji信息错误"; WriteLog("SetRange时,siji信息错误"); return; } if (sijis[0].SECTION == null || sijis[0].LINE == null) { msgBox.Text = "siji信息错误"; WriteLog("SetRange时,siji信息错误"); rangeLimitFromBox.Text = "100"; rangeLimitToBox.Text = "100"; return; } FNRANGEEntity range = DbAccess.GetRange(GlobalAccess.TermNo); if (range == null) { rangeLimitFromBox.Text = "100"; rangeLimitToBox.Text = "100"; } else { rangeLimitFromBox.Text = range.UNIT_WEIGHT_LOWER.ToString(); rangeLimitToBox.Text = range.UNIT_WEIGHT_UPPER.ToString(); } if (error > Convert.ToDecimal(rangeLimitToBox.Text) || error < Convert.ToDecimal(rangeLimitFromBox.Text)) { OutOfRangeWarning frm = new OutOfRangeWarning("产品重量", errorBox.Text, rangeLimitFromBox.Text, rangeLimitToBox.Text); frm.ShowDialog(this); msgBox.Text = "超出范围"; } else { msgBox.Text = string.Empty; } }
private void itemCountBox_KeyPress(object sender, KeyPressEventArgs e) { try { switch (e.KeyChar) { case '\r': if (zaiKo == null) { DbAccess.callSwitchOnLight(GlobalAccess.StationNo, LightType.Data_Error); msgBox.Text = "没有库存数据"; return; } if (zaiKo.PLAN_QTY > 0) { decimal error = decimal.Round((itemCountBox.Value * 100 / zaiKo.PLAN_QTY), 1, MidpointRounding.AwayFromZero); itemWeightErrorBox.Text = error.ToString(); if (error > Convert.ToDecimal(itemWeightRangeLimitToBox.Text) || error < Convert.ToDecimal(itemWeightRangeLimitFromBox.Text)) { DbAccess.callSwitchOnLight(GlobalAccess.StationNo, LightType.Range_Error); OutOfRangeWarning frm = new OutOfRangeWarning("产品重量", itemWeightErrorBox.Text, itemWeightRangeLimitFromBox.Text, itemWeightRangeLimitToBox.Text); frm.ShowDialog(this); msgBox.Text = "超出范围"; } else { msgBox.Text = string.Empty; } } else { itemWeightErrorBox.Text = "100"; } break; } } catch (Exception ex) { msgBox.Text = ex.Message; } }
private void weightLoadBtn_Click(object sender, EventArgs e) { try { if (statusBox.Text == "系统Offline") { return; } if (isOperating == false) { return; } if (statusBox.Text == "正常") { if (zaiKo == null) { msgBox.Text = "请输入TicketNo"; return; } if (zKey == null) { msgBox.Text = "没有此Item主数据"; return; } if (bucket == null) { msgBox.Text = "Bucket未登录"; return; } if (string.IsNullOrEmpty(unitWeightBox.Text)) { msgBox.Text = "请先获得单位重量"; return; } if (decimal.Parse(unitWeightBox.Text) == 0) { msgBox.Text = "单位重量必须大于0"; return; } } weightLoadBtn.Enabled = false; decimal weight = GetWeight(); //称重,错误返回-1 weightLoadBtn.Enabled = true; if (weight == -2) { msgBox.Text = "无法取得安定的计量器数值"; itemWeightBox.Text = string.Empty; itemCountBox.Value = itemCountBox.Minimum; return; } if (weight != -1) { if (bucket != null) { decimal temp = weight - bucket.PACKING_WEIGHT - GlobalAccess.FixedWeight; if (plasticBagStatusBox.Text == "有") { temp -= GlobalAccess.BagWeight; } itemWeightBox.Text = temp < 0 ? "0" : temp.ToString(); } else { itemWeightBox.Text = weight < 0 ? "0" : weight.ToString(); } if (statusBox.Text == "正常") { int count = Convert.ToInt32(decimal.Truncate(decimal.Parse(itemWeightBox.Text) / decimal.Parse(unitWeightBox.Text))); itemCountBox.Value = count; //计算误差 if (zaiKo.PLAN_QTY > 0) { decimal error = decimal.Round((count * 100 / zaiKo.PLAN_QTY), 1, MidpointRounding.AwayFromZero); itemWeightErrorBox.Text = error.ToString(); if (error > Convert.ToDecimal(itemWeightRangeLimitToBox.Text) || error < Convert.ToDecimal(itemWeightRangeLimitFromBox.Text)) { DbAccess.callSwitchOnLight(GlobalAccess.StationNo, LightType.Range_Error); OutOfRangeWarning frm = new OutOfRangeWarning("产品重量", itemWeightErrorBox.Text, itemWeightRangeLimitFromBox.Text, itemWeightRangeLimitToBox.Text); frm.ShowDialog(this); msgBox.Text = "超出范围"; isRangeError = true; //manCheck.Checked = true; } else { msgBox.Text = string.Empty; } } else { itemWeightErrorBox.Text = "100"; } } } else { msgBox.Text = "通信错误"; return; } } catch (Exception ex) { weightLoadBtn.Enabled = true; msgBox.Text = ex.Message; } }
private void unitWeightLoadBtn_Click(object sender, EventArgs e) { try { if (statusBox.Text == "系统Offline") { return; } if (statusBox.Text == "通过") { return; } if (_isOperating == false) { return; } if (_zaiKo == null) { msgBox.Text = "请输入TicketNo"; return; } if (_zKey == null) { msgBox.Text = "没有此Item主数据"; return; } int count = 0;; try { count = Convert.ToInt32(checkCountBox.Value); } catch (Exception) { msgBox.Text = "请输入检查数量"; return; } unitWeightLoadBtn.Enabled = false; decimal weight = GetUnitWeight(); //称重,取单位重量,错误返回-1 unitWeightLoadBtn.Enabled = true; if (weight == -2) { msgBox.Text = "无法取得安定的计量器数值"; unitWeightBox.Text = string.Empty; return; } if (weight != -1) { msgBox.Text = ""; decimal unitWeight = decimal.Round(weight / count, 7, MidpointRounding.AwayFromZero); unitWeightBox.Text = unitWeight.ToString(); //计算误差 if (_zKey.MASTER_UNIT_WEIGHT > 0) { decimal error = decimal.Round((unitWeight * 100 / (_zKey.MASTER_UNIT_WEIGHT * 1000)), 1, MidpointRounding.AwayFromZero); unitWeightErrorBox.Text = error.ToString(); if (error > Convert.ToDecimal(unitWeightRangeLimitToBox.Text) || error < Convert.ToDecimal(unitWeightRangeLimitFromBox.Text)) { DbAccess.callSwitchOnLight(GlobalAccess.StationNo, LightType.Range_Error); OutOfRangeWarning frm = new OutOfRangeWarning("原单位重量", unitWeightErrorBox.Text, unitWeightRangeLimitFromBox.Text, unitWeightRangeLimitToBox.Text); frm.ShowDialog(this); msgBox.Text = "超出范围"; this.setBtn.Enabled = false; } else { msgBox.Text = string.Empty; this.setBtn.Enabled = true; } } else { unitWeightErrorBox.Text = "100"; } } else { msgBox.Text = "通信错误"; return; } } catch (Exception ex) { unitWeightLoadBtn.Enabled = true; msgBox.Text = ex.Message; } }