| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- using ivf_tl_Entity.Entity.Alarm;
- using ivf_tl_Entity.Entity.Mark;
- using ivf_tl_Entity.Enums;
- using ivf_tl_Manage.Converts;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- 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>
- /// AlarmUserWindow.xaml 的交互逻辑
- /// </summary>
- public partial class AlarmUserWindow : Window
- {
- private bool isAdd = true;
- private AlarmUserEntity alarmUser = null;
- public AlarmUserWindow()
- {
- try
- {
- InitializeComponent();
- this.Owner = AppData.Instance.MainWindow;
- this.Closed += (a, b) => AppData.Instance.MainWindow.Activate();
- }
- catch (Exception ex)
- {
- ExLog(ex, "AlarmUserWindow");
- }
- }
- public AlarmUserWindow(AlarmUserEntity editAlarm)
- {
- try
- {
- InitializeComponent();
- this.Owner = AppData.Instance.MainWindow;
- alarmUser = editAlarm;
- isAdd = false;
- //this._title_TextBlock.Text = "编辑";
- this._title_TextBlock.Text = KeyToStringConvert.GetLanguageStringByKey("0083");
- this._name_TextBox.Text = alarmUser.name;
- this._phone_TextBox.Text = alarmUser.phone;
- if (alarmUser.sms == 1) this._sms_CheckBox.IsChecked = true;
- if (alarmUser.tel == 1) this._call_CheckBox.IsChecked = true;
- this.Closed += (a, b) => AppData.Instance.MainWindow.Activate();
- }
- catch (Exception ex)
- {
- ExLog(ex, "AlarmUserWindow");
- }
- }
- private void Cancel_Click(object sender, RoutedEventArgs e)
- {
- this.DialogResult = false;
- return;
- }
- private void Ok_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- string nameString = this._name_TextBox.Text.Trim();
- if (string.IsNullOrEmpty(nameString))
- {
- //MessageBoxShow("通知对象不能为空");
- MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0182"));
- return;
- }
- string phoneString = this._phone_TextBox.Text.Trim();
- if (string.IsNullOrEmpty(phoneString))
- {
- //MessageBoxShow("联系方式不能为空");
- MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0183"));
- return;
- }
- int smsState = 0;
- if (this._sms_CheckBox.IsChecked == true) smsState = 1;
- int callState = 0;
- if (this._call_CheckBox.IsChecked == true) callState = 1;
- if (smsState == 0 && callState == 0)
- {
- //MessageBoxShow("至少选择一种通知方式");
- MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0312"));
- return;
- }
- var pro = AppData.Instance.GetAlarmProvider();
- string error = null;
- if (isAdd) error = pro.AddAlarmUserApi(nameString, phoneString, smsState, callState);
- else
- {
- error = pro.UpdateAlarmUserApi(alarmUser.id, nameString, phoneString, smsState, callState);
- }
- if (!string.IsNullOrEmpty(error))
- {
- //MessageBoxShow($"操作失败,{error}");
- MessageBoxShow($"{KeyToStringConvert.GetLanguageStringByKey("0286")},{error}");
- return;
- }
- if (!isAdd)
- {
- alarmUser.name = nameString;
- alarmUser.phone = phoneString;
- alarmUser.sms = smsState;
- alarmUser.tel = callState;
- }
- this.DialogResult = true;
- return;
- }
- catch (Exception ex)
- {
- ExLog(ex, "Ok_Click");
- //MessageBoxShow($"操作失败:{ex.Message}");
- MessageBoxShow($"{KeyToStringConvert.GetLanguageStringByKey("0291")}:{ex.Message}");
- }
- }
- private void MessageBoxShow(string mess)
- {
- this.message.Text = mess;
- }
- private void ExLog(Exception ex, string name)
- {
- AppData.Instance.LogService.ExceptionLog(ex, $"AlarmUserWindow.{name}", LogEnum.RunException);
- }
- private void ErrorLog(string message, LogEnum logType)
- {
- AppData.Instance.LogService.TLLog($"AlarmUserWindow.{message}", logType);
- }
- }
- }
|