| | |
| | | using HMI.AlarmInfoManage.Entity; |
| | | using HMI.Core.Util; |
| | | using HMI.UI; |
| | | using HMI.UI.DpUtil; |
| | | using HMI.UI.Util; |
| | | using log4net; |
| | | using Panuon.WPF.UI; |
| | |
| | | using System.Collections.ObjectModel; |
| | | using System.ComponentModel; |
| | | using System.Linq; |
| | | using System.Windows; |
| | | |
| | | namespace HMI.AlarmInfoManage |
| | | { |
| | |
| | | catch (Exception ex) |
| | | { |
| | | log.Error("AlarmSetting Form Submit Failed.", ex); |
| | | ToastHelper.Error(this, $"未知异常!{ex.Message}"); |
| | | ToastHelper.Error(this, $"Error: {ex.Message}"); |
| | | e.Cancel = true; |
| | | return; |
| | | } |
| | |
| | | public bool ValidateDBAddress(object value, out string err) |
| | | { |
| | | err = null; |
| | | int dbAddress = Convert.ToInt32(value); |
| | | if (Datasource.FirstOrDefault(e => e.DBAddress == dbAddress) != null) |
| | | if (Datasource?.FirstOrDefault(e => e.DBAddress == value) != null) |
| | | { |
| | | err = "DB地址已存在"; |
| | | err = this.lang("App.MustBeUnique", this.lang("Alm.DbAddress")); |
| | | return false; |
| | | } |
| | | return true; |
| | |
| | | bool flag = FormGroupHelper.ValidateForm(formPanel); |
| | | if (flag) |
| | | { |
| | | Data.DBAddress = Convert.ToInt32(dbAddress.Value); |
| | | Data.StartAddress = Convert.ToInt32(startAddress.Value); |
| | | Data.DBAddress = dbAddress.Text; |
| | | Data.StartAddress = startAddress.Text; |
| | | Data.Length = Convert.ToInt32(length.Value); |
| | | Data.Description = TbDesc.Text; |
| | | } |
| | | return flag; |
| | | } |
| | | |
| | | public bool? Open(int index, AlarmSetting data, |
| | | ObservableCollection<AlarmSetting> dataSource, |
| | | string filePath) |
| | | string filePath, bool showDescription) |
| | | { |
| | | FgDesc.Visibility = showDescription ? Visibility.Visible : Visibility.Collapsed; |
| | | FilePath = filePath; |
| | | DataIndex = index; |
| | | Data = data; |
| | | Datasource = dataSource; |
| | | dbAddress.Value = Data.DBAddress; |
| | | startAddress.Value = Data.StartAddress; |
| | | dbAddress.Text = Data.DBAddress; |
| | | startAddress.Text = Data.StartAddress; |
| | | length.Value = Data.Length; |
| | | TbDesc.Text = Data.Description; |
| | | return this.ShowDialog(); |
| | | } |
| | | |