| | |
| | | { |
| | | if (value < 0.0 || value > 1.0) |
| | | { |
| | | MsgHelper.Warning("超采率必须在0到1之间!"); |
| | | MsgHelper.ShowError("超采率必须在0到1之间!"); |
| | | txt_lossPercent.Focus(); |
| | | return false; |
| | | } |
| | | |
| | | |
| | | // 格式化显示,保留适当的小数位数 |
| | | txt_lossPercent.EditValue = Math.Round(value, 4); |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | MsgHelper.Warning("请输入有效的数字!"); |
| | | MsgHelper.ShowError("请输入有效的数字!"); |
| | | txt_lossPercent.EditValue = 0.0; |
| | | txt_lossPercent.Focus(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 验证提前到货天数必须为大于0的整数 |
| | | /// </summary> |
| | | private bool ValidateDay() |
| | | { |
| | | var text = txt_day.Text?.Trim(); |
| | | if (string.IsNullOrWhiteSpace(text)) |
| | | { |
| | | // 允许为空,表示不设置提前天数 |
| | | txt_day.EditValue = null; |
| | | return true; |
| | | } |
| | | |
| | | if (int.TryParse(text, out int days)) |
| | | { |
| | | if (days <= 0) |
| | | { |
| | | MsgHelper.ShowError("提前到货天数必须为大于0的整数。"); |
| | | txt_day.Focus(); |
| | | return false; |
| | | } |
| | | |
| | | // 规范化显示为整数 |
| | | txt_day.EditValue = days; |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | MsgHelper.ShowError("请输入有效的整数天数。"); |
| | | txt_day.Focus(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | private void BtnSave_Click(object sender, EventArgs e) |
| | | { |
| | | if (!ValidateDay()) |
| | | return; |
| | | |
| | | string _bz10 = txt_day.Text; |
| | | string _percent = txt_lossPercent.Text; |
| | | string _bz09 = txt_bz09.Text; |
| | | // 保存前验证超采率 |
| | | if (!ValidateLossPercent()) |
| | | if (!string.IsNullOrEmpty(_percent) && !ValidateLossPercent()) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var _obj = new |
| | | { |
| | | guidList = this.guidList, |
| | | bz10 = txt_day.Value, |
| | | percent = txt_lossPercent.EditValue |
| | | bz10 = _bz10,//提前到货天数 |
| | | percent = _percent, |
| | | bz09 = _bz09,//后来改为iqc称重属性1要称重0不称重 |
| | | }; |
| | | try |
| | | { |