| | |
| | | using System.Collections.ObjectModel; |
| | | using System.ComponentModel; |
| | | using System.Linq; |
| | | using System.Windows; |
| | | |
| | | namespace HMI.AlarmInfoManage |
| | | { |
| | |
| | | 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 = this.lang("App.MustBeUnique", this.lang("Alm.DbAddress")); |
| | | return false; |
| | |
| | | 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(); |
| | | } |
| | | |