| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- 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.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>
- /// MarkWeightWindow.xaml 的交互逻辑
- /// </summary>
- public partial class MarkWeightWindow : Window
- {
- private bool isAdd = true;
- private MarkWeight MarkWeight { get; set; } = null;
- public MarkWeightWindow(MarkWeight _MarkWeight, ObservableCollection<MarkEntity> MarkEntityList)
- {
- try
- {
- InitializeComponent();
- this.Owner = AppData.Instance.MainWindow;
- this._markKey_ComBox.ItemsSource = MarkEntityList;
- MarkWeight = _MarkWeight;
- if (_MarkWeight.ParentMarkWeight == null)
- {
- this._ParentId_Grid.Visibility = Visibility.Collapsed;
- }
- else
- {
- this._parentID_TextBox.Text = _MarkWeight.ParentMarkWeight.name;
- }
- this.Closed += (a, b) => AppData.Instance.MainWindow.Activate();
- }
- catch (Exception ex)
- {
- ExLog(ex, "MarkWeightWindow");
- }
- }
- public MarkWeightWindow(MarkWeight _MarkWeight, ObservableCollection<MarkEntity> MarkEntityList, bool b)
- {
- try
- {
- isAdd = false;
- InitializeComponent();
- this._markKey_ComBox.ItemsSource = MarkEntityList;
- this.Owner = AppData.Instance.MainWindow;
- isAdd = false;
- MarkWeight = _MarkWeight;
- if (_MarkWeight.ParentMarkWeight == null)
- {
- this._ParentId_Grid.Visibility = Visibility.Collapsed;
- }
- else
- {
- this._parentID_TextBox.Text = _MarkWeight.ParentMarkWeight.name;
- }
- this._title_TextBlock.Text = KeyToStringConvert.GetLanguageStringByKey("0083");
- //this._name_TextBox.Text = MarkWeight.name;
- this._markKey_ComBox.SelectedItem = MarkEntityList.FirstOrDefault(x => x.markKey == MarkWeight.markKey);
- //this._orderNum_TextBox.Text = MarkWeight.orderNum.ToString();
- this._weight_TextBox.Text = MarkWeight.weight.ToString();
- this.Closed += (a, b) => AppData.Instance.MainWindow.Activate();
- }
- catch (Exception ex)
- {
- ExLog(ex, "MarkWeightWindow");
- }
- }
- private void Cancel_MouseUp(object sender, MouseButtonEventArgs e)
- {
- this.DialogResult = false;
- return;
- }
- private void Cancel_Click(object sender, RoutedEventArgs e)
- {
- this.DialogResult = false;
- return;
- }
- private void Ok_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- //string markKeyString = this._markKey_TextBox.Text.Trim();
- // string markNameString = this._name_TextBox.Text.Trim();
- //string orderNumString = this._orderNum_TextBox.Text.Trim();
- string weightString = this._weight_TextBox.Text.Trim();
- //if (string.IsNullOrEmpty(markNameString))
- //{
- // MessageBoxShow("名称不能为空");
- // return;
- //}
- //if (string.IsNullOrEmpty(markKeyString))
- //{
- // MessageBoxShow("MarkKey不能为空");
- // return;
- //}
- if (!(this._markKey_ComBox.SelectedItem is MarkEntity markEntity))
- {
- MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0116"));
- return;
- }
- //if (string.IsNullOrEmpty(orderNumString))
- //{
- // MessageBoxShow("优先级不能为空");
- // return;
- //}
- //if (!int.TryParse(orderNumString, out int orderNumInt))
- //{
- // MessageBoxShow("优先级只能输入数字");
- // return;
- //}
- if (string.IsNullOrEmpty(weightString))
- {
- MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0118"));
- return;
- }
- if (!decimal.TryParse(weightString, out decimal weightDouble))
- {
- MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0288"));
- return;
- }
- MarkWeight newWeight = new MarkWeight();
- newWeight.id = MarkWeight.id;
- newWeight.markKey = markEntity.markKey;
- newWeight.name = markEntity.name;
- newWeight.orderNum = 1;
- newWeight.parentId = MarkWeight.parentId;
- newWeight.weight = weightDouble;
- MarkSettingProvider markSettingProvider = AppData.Instance.GetMarkSettingProvider();
- string error = null;
- if (isAdd) 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.parentId = newWeight.parentId;
- 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, $"MarkWeightWindow.{name}", LogEnum.RunException);
- }
- private void ErrorLog(string message, LogEnum logType)
- {
- AppData.Instance.LogService.TLLog($"MarkWeightWindow.{message}", logType);
- }
- }
- }
|