非空校验

This commit is contained in:
MoYue 2024-08-29 13:44:34 +08:00
parent 0938cb02b2
commit eb6cf78500
2 changed files with 11 additions and 2 deletions

View File

@ -29,7 +29,7 @@ namespace InSituLaboratory.ViewModels.Pages.Dialogs
public SysSequentialDetails SysSequentialdata { get; set; } public SysSequentialDetails SysSequentialdata { get; set; }
public List<Int32> Intlist { get; set; } = new List<Int32>() { 1, 2, 3, 4, 5, 6 }; public static List<Int32> Intlist { get; set; } = new List<Int32>() { 1, 2, 3, 4, 5, 6 };
public string? workTime { get; set; } public string? workTime { get; set; }
public string? minworkTime { get; set; } public string? minworkTime { get; set; }
@ -163,6 +163,7 @@ namespace InSituLaboratory.ViewModels.Pages.Dialogs
} }
DeviceNodes = _deviceSvice.GetDevices().ToList(); DeviceNodes = _deviceSvice.GetDevices().ToList();
Intlist = new List<Int32>() { 1, 2, 3, 4, 5, 6 };
} }
public override void DoSave() public override void DoSave()

View File

@ -2,6 +2,7 @@
using InSituLaboratory.IService; using InSituLaboratory.IService;
using InSituLaboratory.Models; using InSituLaboratory.Models;
using InSituLaboratory.Service; using InSituLaboratory.Service;
using Microsoft.IdentityModel.Tokens;
using Prism.Commands; using Prism.Commands;
using Prism.Services.Dialogs; using Prism.Services.Dialogs;
using System; using System;
@ -10,6 +11,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Forms;
namespace InSituLaboratory.ViewModels.Pages.Dialogs namespace InSituLaboratory.ViewModels.Pages.Dialogs
{ {
@ -59,6 +61,12 @@ namespace InSituLaboratory.ViewModels.Pages.Dialogs
{ {
try try
{ {
//非空校验
if (string.IsNullOrEmpty(SysDevice.DeviceType) || string.IsNullOrEmpty(SysDevice.DeviceName) || string.IsNullOrEmpty(SysDevice.WorkTime) || string.IsNullOrEmpty(SysDevice.MinWorkTime))
{
throw new Exception("参数配置信息不能为空!");
}
//新增 //新增
if (SysDevice.ID == 0) if (SysDevice.ID == 0)
{ {
@ -84,7 +92,7 @@ namespace InSituLaboratory.ViewModels.Pages.Dialogs
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message); System.Windows.Forms.MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
} }
} }