| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- 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>
- /// MarkKeyWindow.xaml 的交互逻辑
- /// </summary>
- public partial class MarkKeyWindow : Window
- {
- private bool isAdd = true;
- private MarkKeyEntity MarkKey { get; set; } = null;
- public MarkKeyWindow(MarkKeyEntity markKeyEntity)
- {
- InitializeComponent();
- this.Owner = AppData.Instance.MainWindow;
- MarkKey = markKeyEntity;
-
- this.Closed += (a, b) =>
- {
- AppData.Instance.MainWindow.Activate();
- };
- }
- public MarkKeyWindow(MarkKeyEntity markKeyEntity, bool b)
- {
- InitializeComponent();
- this.Owner = AppData.Instance.MainWindow;
- MarkKey = markKeyEntity;
- isAdd = false;
- //this._title_TextBlock.Text = "编辑";
- this._title_TextBlock.Text = KeyToStringConvert.GetLanguageStringByKey("0083");
- this._name_TextBox.Text = markKeyEntity.name;
- this._info_TextBox.Text = markKeyEntity.info;
- this._key_TextBox.Text = markKeyEntity.markKey;
- this._key_TextBox.IsEnabled = false;
- this.Closed += (a, b) =>
- {
- AppData.Instance.MainWindow.Activate();
- };
- }
- private void Ok_Click(object sender, RoutedEventArgs e)
- {
- string nameString = this._name_TextBox.Text.Trim();
- string keyString = this._key_TextBox.Text.Trim();
- string infoString = this._info_TextBox.Text.Trim();
- if (string.IsNullOrEmpty(nameString))
- {
- //MessageBoxShow($"名称不能为空");
- MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0228"));
- return;
- }
- if (string.IsNullOrEmpty(keyString))
- {
- //MessageBoxShow($"KEY值不能为空");
- MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0120"));
- return;
- }
- MarkKeyEntity newKey = new MarkKeyEntity();
- newKey.info = infoString;
- newKey.name = nameString;
- newKey.markKey = keyString;
- newKey.orderNum = MarkKey.orderNum;
- newKey.id = MarkKey.id;
- var pro = AppData.Instance.GetMarkSettingProvider();
- string error = null;
- if (isAdd) error = pro.AddMarkKeyApi(newKey);
- else error = pro.UpdateMarkKeyApi(JsonConvert.SerializeObject(newKey));
- if (!string.IsNullOrEmpty(error))
- {
- //MessageBoxShow($"操作失败,{error}");
- MessageBoxShow($"{KeyToStringConvert.GetLanguageStringByKey("0286")},{error}");
- return;
- }
- MarkKey.info = newKey.info;
- MarkKey.id = newKey.id;
- MarkKey.name = nameString;
- MarkKey.markKey = keyString;
- this.DialogResult = true;
- return;
- }
- private void Cancel_Click(object sender, RoutedEventArgs e)
- {
- this.DialogResult = false;
- return;
- }
- private void MessageBoxShow(string mess)
- {
- this.message.Text = mess;
- }
- private void ExLog(Exception ex, string name)
- {
- AppData.Instance.LogService.ExceptionLog(ex, $"MarkUseView.{name}", LogEnum.RunException);
- }
- private void ErrorLog(string message, LogEnum logType)
- {
- AppData.Instance.LogService.TLLog($"MarkUseView.{message}", logType);
- }
- private void Cancel_MouseUp(object sender, MouseButtonEventArgs e)
- {
- this.DialogResult = false;
- return;
- }
- }
- }
|