| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- using ivf_tl_Entity.Entity.Mark;
- using ivf_tl_Entity.Enums;
- using ivf_tl_Manage.Converts;
- using ivf_tl_Service.HttpProvider;
- 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>
- /// MarkWeightOneWindow.xaml 的交互逻辑
- /// </summary>
- public partial class MarkWeightOneWindow : Window
- {
- private bool isAdd = true;
- private MarkWeight MarkWeight { get; set; } = null;
- public MarkWeightOneWindow(MarkWeight _MarkWeight)
- {
- InitializeComponent();
- this.Owner = AppData.Instance.MainWindow;
- MarkWeight = _MarkWeight;
- this.Closed += (a, b) => AppData.Instance.MainWindow.Activate();
- }
- public MarkWeightOneWindow(MarkWeight _MarkWeight, bool b)
- {
- InitializeComponent();
- this._title_TextBlock.Text = KeyToStringConvert.GetLanguageStringByKey("0083");
- this.Owner = AppData.Instance.MainWindow;
- isAdd = false;
- MarkWeight = _MarkWeight;
- this._name_TextBox.Text = MarkWeight.name;
- this._orderNum_TextBox.Text = MarkWeight.orderNum.ToString();
- this.Closed += (a, b) => AppData.Instance.MainWindow.Activate();
- }
- private void Ok_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- string markNameString = this._name_TextBox.Text.Trim();
- string orderNumString = this._orderNum_TextBox.Text.Trim();
- if (string.IsNullOrEmpty(markNameString))
- {
- MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0228"));
- return;
- }
- if (string.IsNullOrEmpty(orderNumString))
- {
- MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0563"));
- return;
- }
- if (!int.TryParse(orderNumString, out int orderNumInt))
- {
- MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0563"));
- return;
- }
- MarkWeightNoParent newWeight = new MarkWeightNoParent();
- newWeight.id = MarkWeight.id;
- newWeight.name = markNameString;
- newWeight.orderNum = orderNumInt;
- newWeight.weight = MarkWeight.weight;
- newWeight.markKey = MarkWeight.markKey;
- MarkSettingProvider markSettingProvider = AppData.Instance.GetMarkSettingProvider();
- string error = null;
- if (isAdd)
- {
- newWeight.markKey = newWeight.name;
- error = markSettingProvider.AddMarkWeightApi(newWeight);
- }
- else error = markSettingProvider.UpdateMarkWeightApi(JsonConvert.SerializeObject(newWeight));
- if (!string.IsNullOrEmpty(error))
- {
- MessageBoxShow($"{KeyToStringConvert.GetLanguageStringByKey("0286")},{error}");
- return;
- }
- MarkWeight.id = newWeight.id;
- MarkWeight.markKey = newWeight.markKey;
- MarkWeight.name = newWeight.name;
- MarkWeight.orderNum = newWeight.orderNum;
- MarkWeight.weight = newWeight.weight;
- this.DialogResult = true;
- return;
- }
- catch (Exception ex)
- {
- ExLog(ex, "Ok_Click");
- }
- }
- private void MessageBoxShow(string mess)
- {
- this.message.Text = mess;
- }
- private void ExLog(Exception ex, string name)
- {
- AppData.Instance.LogService.ExceptionLog(ex, $"MarkWeightOneWindow.{name}", LogEnum.RunException);
- }
- private void ErrorLog(string message, LogEnum logType)
- {
- AppData.Instance.LogService.TLLog($"MarkWeightOneWindow.{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;
- }
- }
- }
|