| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using ivf_tl_Entity.Entity.Alarm;
- using ivf_tl_Entity.Enums;
- using ivf_tl_Manage.Converts;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace ivf_tl_Manage.Win
- {
- /// <summary>
- /// AlarmPersonneSettingWindow.xaml 的交互逻辑
- /// </summary>
- public partial class AlarmPersonneSettingWindow : Window
- {
- public AlarmPersonneSettingWindow(ObservableCollection<AlarmPersonne> alarmPersonnes)
- {
- this.Owner = AppData.Instance.MainWindow;
- InitializeComponent();
- this._ComBoxCustom1.ItemsSource = alarmPersonnes;
- this._ComBoxCustom2.ItemsSource = alarmPersonnes;
- this._ComBoxCustom3.ItemsSource = alarmPersonnes;
- this._ComBoxCustom1.SelectedItem = alarmPersonnes.FirstOrDefault(x => x.level == 1);
- this._ComBoxCustom2.SelectedItem = alarmPersonnes.FirstOrDefault(x => x.level == 2);
- this._ComBoxCustom3.SelectedItem = alarmPersonnes.FirstOrDefault(x => x.level == 3);
- }
- private void Ok_Click(object sender, RoutedEventArgs e)
- {
- if (!(this._ComBoxCustom1.SelectedItem is AlarmPersonne alarmPersonne1))
- {
- MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0556"));
- return;
- }
- AlarmPersonne alarmPersonne2 = this._ComBoxCustom2.SelectedItem as AlarmPersonne;
- AlarmPersonne alarmPersonne3 = this._ComBoxCustom3.SelectedItem as AlarmPersonne;
- Dictionary<long, int> keyValuePairs = new Dictionary<long, int>();
- keyValuePairs.Add(alarmPersonne1.id, 1);
- if (alarmPersonne2 != null)
- {
- if (keyValuePairs.ContainsKey(alarmPersonne2.id))
- {
- MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0559"));
- return;
- }
- keyValuePairs.Add(alarmPersonne2.id, 2);
- }
- if (alarmPersonne3 != null)
- {
- if (keyValuePairs.ContainsKey(alarmPersonne3.id))
- {
- MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0559"));
- return;
- }
- keyValuePairs.Add(alarmPersonne3.id, 3);
- }
- string error = AppData.Instance.GetAlarmProvider().SetAlarmPersonnelLevelApi(keyValuePairs);
- if (!string.IsNullOrEmpty(error))
- {
- MessageBoxShow($"{KeyToStringConvert.GetLanguageStringByKey("0286")},{error}");
- return;
- }
- alarmPersonne1.level = 1;
- if (alarmPersonne2 != null) alarmPersonne2.level = 2;
- if (alarmPersonne3 != null) alarmPersonne3.level = 3;
- this.DialogResult = true;
- return;
- }
- private void MessageBoxShow(string mess)
- {
- this.message.Text = mess;
- }
- private void ExLog(Exception ex, string name)
- {
- AppData.Instance.LogService.ExceptionLog(ex, $"AlarmPersonneSettingWindow.{name}", LogEnum.RunException);
- }
- private void ErrorLog(string message, LogEnum logType)
- {
- AppData.Instance.LogService.TLLog($"AlarmPersonneSettingWindow.{message}", logType);
- }
- private void Cancel_Click(object sender, RoutedEventArgs e)
- {
- this.DialogResult = false;
- return;
- }
- private void Cancel_MouseUp(object sender, MouseButtonEventArgs e)
- {
- this.DialogResult = false;
- return;
- }
- }
- }
|