| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- using ivf_tl_CustomControls;
- using ivf_tl_Entity.Entity.AppSetting;
- using ivf_tl_Entity.Enums;
- using ivf_tl_Manage.Converts;
- using ivf_tl_Service.HttpProvider;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Data.SqlTypes;
- 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>
- /// BusSettingWindow.xaml 的交互逻辑
- /// </summary>
- public partial class BusSettingWindow : Window
- {
- private SettingProvider settingProvider;
- private long ParentId { get; set; } = 0;
- public BusSettingWindow(SettingProvider settingProvider, long id,string name)
- {
- InitializeComponent();
- this.Owner = AppData.Instance.MainWindow;
- ParentId = id;
- this.settingProvider = settingProvider;
- //this._title_TextBlock.Text = $"{name}业务功能关联";
- this._title_TextBlock.Text = $"{name}{KeyToStringConvert.GetLanguageStringByKey("0307")}";
- NoSelectedBus = new ObservableCollection<Business>(settingProvider.GetUnassignedFuncApi());
- SelectedBus = new ObservableCollection<Business>(settingProvider.GetBusByIdApi(id));
- Closed += (s, e) => 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, $"BusSettingWindow.{name}", LogEnum.RunException);
- }
- private void ErrorLog(string message, LogEnum logType)
- {
- AppData.Instance.LogService.TLLog($"BusSettingWindow.{message}", logType);
- }
- public ObservableCollection<Business> NoSelectedBus
- {
- get { return (ObservableCollection<Business>)GetValue(NoSelectedBusProperty); }
- set { SetValue(NoSelectedBusProperty, value); }
- }
- // Using a DependencyProperty as the backing store for NoSelectedBus. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty NoSelectedBusProperty =
- DependencyProperty.Register("NoSelectedBus", typeof(ObservableCollection<Business>), typeof(BusSettingWindow), new PropertyMetadata(new ObservableCollection<Business>()));
- public ObservableCollection<Business> SelectedBus
- {
- get { return (ObservableCollection<Business>)GetValue(SelectedBusProperty); }
- set { SetValue(SelectedBusProperty, value); }
- }
- // Using a DependencyProperty as the backing store for SelectedBus. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty SelectedBusProperty =
- DependencyProperty.Register("SelectedBus", typeof(ObservableCollection<Business>), typeof(BusSettingWindow), new PropertyMetadata(new ObservableCollection<Business>()));
- private void CheckBoxContent_Checked(object sender, RoutedEventArgs e)
- {
- if (!(sender is CheckBoxContent sourcre)) return;
- if (!sourcre.IsLoaded) return;
- if (!(sourcre.Tag is Business bus)) return;
- NoSelectedBus.Remove(bus);
- if (SelectedBus == null) SelectedBus = new ObservableCollection<Business>();
- SelectedBus.Add(bus);
- }
- private void CheckBoxContent_Unchecked(object sender, RoutedEventArgs e)
- {
- if (!(sender is CheckBoxContent sourcre)) return;
- if (!sourcre.IsLoaded) return;
- if (!(sourcre.Tag is Business bus)) return;
- SelectedBus.Remove(bus);
- if (bus.state == 0) return;
- if (NoSelectedBus == null) NoSelectedBus = new ObservableCollection<Business>();
- NoSelectedBus.Add(bus);
- }
- 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
- {
- var checkedIds = SelectedBus.Select(x => x.id).ToList();
- var uncheckedIds = NoSelectedBus.Select(x => x.id).ToList();
- string error = settingProvider.BusSettingApi(ParentId, checkedIds, uncheckedIds);
- if (!string.IsNullOrEmpty(error))
- {
- //MessageBoxShow($"操作失败,{error}");
- MessageBoxShow($"{KeyToStringConvert.GetLanguageStringByKey("0286")},{error}");
- return;
- }
- this.DialogResult = true;
- return;
- }
- catch (Exception ex)
- {
- ExLog(ex, "Ok_Click");
- //MessageBoxShow($"操作失败:{ex.Message}");
- MessageBoxShow($"{KeyToStringConvert.GetLanguageStringByKey("0291")},{ex.Message}");
- }
- }
- }
- }
|