| | |
| | | } |
| | | } |
| | | |
| | | /// <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; |