| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- using ivf_tl_Entity.Entity.AppSetting;
- 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>
- /// RoleWindow.xaml 的交互逻辑
- /// </summary>
- public partial class RoleWindow : Window
- {
- private RoleEntity CurrentRole { get; set; } = null;
- private bool isAdd = true;
- public RoleWindow()
- {
- InitializeComponent();
- this.Owner = AppData.Instance.MainWindow;
- this.Closed += (a, b) =>
- {
- AppData.Instance.MainWindow.Activate();
- };
- }
- public RoleWindow(RoleEntity business)
- {
- InitializeComponent();
- this.Owner = AppData.Instance.MainWindow;
- CurrentRole = business;
- isAdd = false;
- //this._title_TextBlock.Text = "编辑";
- this._title_TextBlock.Text = KeyToStringConvert.GetLanguageStringByKey("0083");
- this._name_TextBox.Text = business.name;
- this._rem_TextBox.Text = business.remark;
- this.Closed += (a, b) =>
- {
- AppData.Instance.MainWindow.Activate();
- };
- }
- private void MessageBoxShow(string mess)
- {
- this.message.Text = mess;
- }
- private void ExLog(Exception ex, string name)
- {
- AppData.Instance.LogService.ExceptionLog(ex, $"RoleWindow.{name}", LogEnum.RunException);
- }
- private void ErrorLog(string message, LogEnum logType)
- {
- AppData.Instance.LogService.TLLog($"RoleWindow.{message}", logType);
- }
- 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 nameString = this._name_TextBox.Text.Trim();
- if (string.IsNullOrEmpty(nameString))
- {
- //MessageBoxShow($"角色名称不能为空");
- MessageBoxShow(KeyToStringConvert.GetLanguageStringByKey("0218"));
- return;
- }
- string remString = this._rem_TextBox.Text.Trim();
-
- var pro = AppData.Instance.GetSettingProvider();
- string error = null;
- if (isAdd)
- {
- string body = JsonConvert.SerializeObject(new
- {
- name = nameString,
- remark = remString
- });
- error = pro.AddRoleApi(body);
- }
- else
- {
- string body = JsonConvert.SerializeObject(new
- {
- id= CurrentRole.id,
- name = nameString,
- remark = remString
- });
- error = pro.EditRoleApi(body);
- }
- if (!string.IsNullOrEmpty(error))
- {
- //MessageBoxShow($"操作失败,{error}");
- MessageBoxShow($"{KeyToStringConvert.GetLanguageStringByKey("0286")},{error}");
- return;
- }
- if (!isAdd)
- {
- CurrentRole.name = nameString;
- CurrentRole.remark = remString;
- }
- this.DialogResult = true;
- return;
- }
- catch (Exception ex)
- {
- ExLog(ex, "Ok_Click");
- //MessageBoxShow($"操作失败:{ex.Message}");
- MessageBoxShow($"{KeyToStringConvert.GetLanguageStringByKey("0291")}:{ex.Message}");
- }
- }
- }
- }
|