| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496 |
- using ivf_tl_CustomControls;
- using ivf_tl_Entity.Entity.balance;
- using ivf_tl_Entity.Entity.DownLoad;
- using ivf_tl_Entity.Response;
- using ivf_tl_Manage.Converts;
- using ivf_tl_Manage.ViewModels;
- using ivf_tl_Manage.Win;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Security.Policy;
- 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.Navigation;
- using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;
- namespace ivf_tl_Manage.Views
- {
- /// <summary>
- /// DishRecordView.xaml 的交互逻辑
- /// </summary>
- public partial class DishRecordView : UserControl
- {
- private DishRecordViewModel vm;
- public DishRecordView()
- {
- InitializeComponent();
- var a = this.ItemsControl_ShowData.Items;
- Loaded += (s, e) =>
- {
- vm = (DishRecordViewModel)this.DataContext;
- if (vm == null) return;
- this._tlName_ComBox.SelectedItem = vm.CurrentTlInfo;
- this._caseId_TextBox.Text = vm.CasedId;
- this._cycle_TextBox.Text = vm.Cycle;
- this._name_TextBox.Text = vm.SearchName;
- this._time_TextBox.Text = vm.SearchTime;
- this._HouseSn_ComBox.SelectedItem = vm.CurrentHouse;
- Task.Run(() =>
- {
- Dispatcher.Invoke(() =>
- {
- vm.UpdataCount();
- });
- });
- };
- }
- private void Oper_Click(object sender, RoutedEventArgs e)
- {
- }
- private void UserControl_KeyDown(object sender, KeyEventArgs e)
- {
- if (this._name_TextBox.IsFocused || this._time_TextBox.IsFocused)
- {
- if (e.Key == Key.Enter)
- {
- string newTime = this._time_TextBox.Text.Trim();
- string newName = this._name_TextBox.Text.Trim();
- if (!string.IsNullOrEmpty(newTime))
- {
- if (!DateTime.TryParse(newTime, out DateTime time))
- {
- //new ToastMessageWindow(AppData.Instance.MainWindow, 1920, 65, "受精时间输入错误").Show();
- new ToastMessageWindow(AppData.Instance.MainWindow, 1920, 65, KeyToStringConvert.GetLanguageStringByKey("0317")).Show();
- return;
- }
- }
- vm.SetSearchNameAndTime(newName, newTime);
- e.Handled = true;
- }
- }
- }
- private void RadioButtonMarkSetting_Checked(object sender, RoutedEventArgs e)
- {
- if (vm == null) return;
- if (!(sender is RadioButtonMarkSetting source)) return;
- if (!source.IsLoaded) return;
- vm.SetSelectedType(source.Tag.ToString());
- }
- private void PaginationUserControl_PageChangedEvent(UserControls.PaginationUserControl arg1, int arg2)
- {
- if (vm == null) return;
- if (!arg1.IsLoaded) return;
- NoUp = true;
- this._all_CheckBox1.IsChecked = false;
- NoUp = false;
- //this._exportDish.IsEnabled = false;
- vm.SetPageCurrent(arg2);
- }
- private void House_DropDownClosed(object sender, EventArgs e)
- {
- if (vm == null) return;
- if (!(sender is ComBoxCustom2 source)) return;
- if (!source.IsLoaded) return;
- string newTime = this._time_TextBox.Text.Trim();
- string newName = this._name_TextBox.Text.Trim();
- if (!string.IsNullOrEmpty(newTime))
- {
- if (!DateTime.TryParse(newTime, out DateTime time))
- {
- //new ToastMessageWindow(AppData.Instance.MainWindow, 1920, 65, "受精时间输入错误").Show();
- new ToastMessageWindow(AppData.Instance.MainWindow, 1920, 65, KeyToStringConvert.GetLanguageStringByKey("0317")).Show();
- return;
- }
- }
- if (source.SelectedItem == null)
- {
- vm.SetCurrentHouse(-1, newName, newTime);
- return;
- }
- vm.SetCurrentHouse((int)source.SelectedItem, newName, newTime);
- }
- private void TLSN_DropDownClosed(object sender, EventArgs e)
- {
- if (vm == null) return;
- if (!(sender is ComBoxCustom2 source)) return;
- if (!source.IsLoaded) return;
- string newTime = this._time_TextBox.Text.Trim();
- string newName = this._name_TextBox.Text.Trim();
- if (!string.IsNullOrEmpty(newTime))
- {
- if (!DateTime.TryParse(newTime, out DateTime time))
- {
- //new ToastMessageWindow(AppData.Instance.MainWindow, 1920, 65, "受精时间输入错误").Show();
- new ToastMessageWindow(AppData.Instance.MainWindow, 1920, 65, KeyToStringConvert.GetLanguageStringByKey("0317")).Show();
- return;
- }
- }
- if (source.SelectedItem == null)
- {
- vm.SetCurrentTlInfo(null, newName, newTime);
- return;
- }
- vm.SetCurrentTlInfo((TLInfo)source.SelectedItem, newName, newTime);
- }
- private void TextBoxButtonCustom_TestEvent(TextBoxButtonCustom source, string newName)
- {
- if (vm == null || source == null) return;
- if (!source.IsLoaded) return;
- vm.SetSearchName(newName);
- }
- private void TextBoxButtonCustom_TestEvent1(TextBoxButtonCustom source, string newTime)
- {
- if (vm == null || source == null) return;
- if (!source.IsLoaded) return;
- if (!string.IsNullOrEmpty(newTime))
- {
- if (!DateTime.TryParse(newTime, out DateTime time))
- {
- //new ToastMessageWindow(AppData.Instance.MainWindow, 1920, 65, "受精时间输入错误").Show();
- new ToastMessageWindow(AppData.Instance.MainWindow, 1920, 65, KeyToStringConvert.GetLanguageStringByKey("0317")).Show();
- return;
- }
- }
- vm.SetSearchTime(newTime);
- }
- private void DishRecordOper_CanvasMouseDown(object sender, MouseButtonEventArgs e)
- {
- try
- {
- if (vm == null) return;
- if (!(sender is Border source)) return;
- if (!source.IsLoaded) return;
- if (!(source.Tag is DishRecordEntity dishRecordEntity)) return;
- vm.OpenDishDetail(dishRecordEntity);
- //vm.OpenPdfView(dishRecordEntity);
- }
- finally
- {
- e.Handled = true;
- }
- }
- private void DishRecordOper_CanvasMouseDown1(object sender, MouseButtonEventArgs e)
- {
- try
- {
- if (vm == null) return;
- if (!(sender is StackPanel source)) return;
- if (!source.IsLoaded) return;
- if (!(source.Tag is DishRecordEntity dishRecordEntity)) return;
- vm.OpenDishDetail(dishRecordEntity);
- }
- finally
- {
- e.Handled = true;
- }
- }
- private void DishRecordOper_MouseDown(object sender, MouseButtonEventArgs e)
- {
- try
- {
- if (!this.IsLoaded) return;
- if (vm == null) return;
- if (!(sender is ImageCustom source)) return;
- if (!source.IsLoaded) return;
- if (!(source.Tag is DishRecordEntity dishRecordEntity)) return;
- vm.OpenDishDetail(dishRecordEntity);
- }
- finally
- {
- e.Handled = true;
- }
- }
- private void DishRecordDel_MouseDown(object sender, MouseButtonEventArgs e)
- {
- try
- {
- if (!this.IsLoaded) return;
- if (vm == null) return;
- if (!(sender is ImageCustom source)) return;
- if (!source.IsLoaded) return;
- if (!(source.Tag is DishRecordEntity dishRecordEntity)) return;
- vm.DeletDishRecord(dishRecordEntity);
- }
- finally
- {
- e.Handled = true;
- }
- }
- private void ScrollViewer_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
- {
- e.Handled = true;
- }
- private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
- {
- if (sender is ScrollViewer scrollViewer)
- {
- if (e.Delta > 0)
- {
- scrollViewer.LineLeft();
- scrollViewer.LineLeft();
- }
- else
- {
- scrollViewer.LineRight();
- scrollViewer.LineRight();
- }
- e.Handled = true;
- }
- //290 0
- //Debug.WriteLine($"{this.ScrollViewer_CenterData.HorizontalOffset} {this.ScrollViewer_CenterData.ViewportWidth} {this.ScrollViewer_CenterData.HorizontalOffset + this.ScrollViewer_CenterData.ViewportWidth} -> {this.ScrollViewer_CenterData.ExtentWidth}");
- }
- private void TextBoxButtonCustom_CasedIdEvent(TextBoxButtonCustom arg1, string arg2)
- {
- if (vm == null || arg1 == null) return;
- if (!arg1.IsLoaded) return;
- vm.SetCaseId(arg2);
- }
- private void TextBoxButtonCustom_CycleEvent(TextBoxButtonCustom arg1, string arg2)
- {
- if (vm == null || arg1 == null) return;
- if (!arg1.IsLoaded) return;
- vm.SetCycle(arg2);
- }
- private void HouesChart_Click(object sender, RoutedEventArgs e)
- {
- if (this.Canvas_OpenSearch.Visibility == Visibility.Visible)
- {
- this.Canvas_OpenSearch.Visibility = Visibility.Hidden;
- this.ButtonLeftImage_Search.Content = KeyToStringConvert.GetLanguageStringByKey("0269");
- this.ButtonLeftImage_Search.IconSource = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishOpenStateIcon.png", UriKind.Absolute));
- this.ButtonLeftImage_Search.MouseOverIconSource = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishOpenStateMouseOverIcon.png", UriKind.Absolute));
- }
- else
- {
- this.Canvas_OpenSearch.Visibility = Visibility.Visible;
- //this.ButtonLeftImage_Search.Content = "收起";
- this.ButtonLeftImage_Search.Content = KeyToStringConvert.GetLanguageStringByKey("0270");
- this.ButtonLeftImage_Search.IconSource = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishCloseStateIcon.png", UriKind.Absolute));
- this.ButtonLeftImage_Search.MouseOverIconSource = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DishCloseStateMouseOverIcon.png", UriKind.Absolute));
- }
- }
- private void _itemsBorder_MouseEnter(object sender, MouseEventArgs e)
- {
- if (vm == null) return;
- if (!(sender is Border source)) return;
- if (!source.IsLoaded) return;
- if (!(source.Tag is DishRecordEntity dishRecordEntity)) return;
- dishRecordEntity.IsMouseOver = true;
- }
- private void _itemsBorder_MouseLeave(object sender, MouseEventArgs e)
- {
- if (vm == null) return;
- if (!(sender is Border source)) return;
- if (!source.IsLoaded) return;
- if (!(source.Tag is DishRecordEntity dishRecordEntity)) return;
- dishRecordEntity.IsMouseOver = false;
- }
- private void AI_MouseDown(object sender, MouseButtonEventArgs e)
- {
- try
- {
- if (!this.IsLoaded) return;
- if (vm == null) return;
- if (!(sender is ImageCustom source)) return;
- if (!source.IsLoaded) return;
- if (!(source.Tag is DishRecordEntity dishRecordEntity)) return;
- vm.OpenPdfView(dishRecordEntity);
- return;
- }
- finally
- {
- e.Handled = true;
- }
- }
- private void ItemsControl_MouseEnter(object sender, MouseEventArgs e)
- {
- }
- protected void ToastMessageShow(string mess)
- {
- new ToastMessageWindow(AppData.Instance.MainWindow, 1920, 65, mess).Show();
- }
- private void ExportDish_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- if (vm == null) return;
- if (vm.DishRecordList != null && vm.DishRecordList.Any())
- {
- var dishList = vm.DishRecordList.Where(x => x.IsCheck).ToList();
- if (dishList.Any())
- {
- ExportDishResponse exportDishResponse = new ExportDishResponse();
- AppData.Instance.MainWindowViewModel.MaskVisibility = true;
- ExportDishWindow exportDishWindow = new ExportDishWindow(exportDishResponse);
- if (exportDishWindow.ShowDialog() == true)
- {
- if (new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0304"), KeyToStringConvert.GetLanguageStringByKey("0619"), AppData.Instance.MainWindow).ShowDialog() == true)
- {
- DownLoadFile(exportDishResponse, dishList);
- }
- }
- AppData.Instance.MainWindowViewModel.MaskVisibility = false;
- return;
- }
- }
- ExportDishResponse exportDishResponse1 = new ExportDishResponse();
- AppData.Instance.MainWindowViewModel.MaskVisibility = true;
- ExportDishWindow exportDishWindow1 = new ExportDishWindow(exportDishResponse1);
- if (exportDishWindow1.ShowDialog() == true)
- {
- if (new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0304"), KeyToStringConvert.GetLanguageStringByKey("0628"), AppData.Instance.MainWindow).ShowDialog() == true)
- {
- var allDish = vm.GetAllDishRecord();
- if (allDish == null || !allDish.Any())
- {
- ToastMessageShow(KeyToStringConvert.GetLanguageStringByKey("0629"));
- return;
- }
- DownLoadFile(exportDishResponse1, allDish);
- }
- }
- AppData.Instance.MainWindowViewModel.MaskVisibility = false;
- }
- finally
- {
- AppData.Instance.MainWindowViewModel.MaskVisibility = false;
- }
- }
- private void DownLoadFile(ExportDishResponse exportDishResponse, List<DishRecordEntity> dishList)
- {
- AppData.Instance.MainWindowViewModel.MaskVisibility = false;
- string timeString = DateTime.Now.ToString("yyyy-MM-dd-HH-mm");
- string fileName;
- foreach (var item in dishList)
- {
- if (string.IsNullOrEmpty(item.husband))
- {
- fileName = $"{timeString}{item.wife}_{item.id}.zip";
- }
- else
- {
- fileName = $"{timeString}{item.wife}_{item.husband}_{item.id}.zip";
- }
- Dictionary<string, string> KeyBody = new Dictionary<string, string>();
- KeyBody.Add("houseSn", item.houseSn.ToString());
- KeyBody.Add("tlSn", item.tlSn);
- KeyBody.Add("freezing", exportDishResponse.freezing.ToString());
- KeyBody.Add("invalid", exportDishResponse.invalid.ToString());
- KeyBody.Add("transplant", exportDishResponse.transplant.ToString());
- KeyBody.Add("deleted", exportDishResponse.deleted.ToString());
- KeyBody.Add("unmark", exportDishResponse.unmark.ToString());
- KeyBody.Add("ids", item.id.ToString());
- DownLoadEntity downLoad = new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
- {
- DownLoadUrl = $"/api/businessManage/pc/resource/exportPictures?{string.Join("&", KeyBody.Select(kv => $"{Uri.EscapeDataString(kv.Key)}={Uri.EscapeDataString(kv.Value)}"))}",
- NewFileFullName = Path.Combine(exportDishResponse.tlSn, fileName),
- FileName = fileName,
- };
- AppData.Instance.MainWindowViewModel.DownLoadStart(downLoad);
- }
- ToastMessageShow(KeyToStringConvert.GetLanguageStringByKey("0299"));
- return;
- }
- private void Item_Unchecked(object sender, RoutedEventArgs e)
- {
- if (vm == null || !this.IsLoaded) return;
- //if (vm.DishRecordList.FirstOrDefault(x => x.IsCheck) == null)
- //{
- // this._exportDish.IsEnabled = false;
- //}
- //else
- //{
- // this._exportDish.IsEnabled = true;
- //}
- NoUp = true;
- this._all_CheckBox1.IsChecked = false;
- NoUp = false;
- }
- private void Item_Checked(object sender, RoutedEventArgs e)
- {
- if (vm == null || !this.IsLoaded) return;
- //if (vm.DishRecordList.FirstOrDefault(x => x.IsCheck) == null)
- //{
- // this._exportDish.IsEnabled = false;
- //}
- //else
- //{
- // this._exportDish.IsEnabled = true;
- //}
- if (vm.DishRecordList.FirstOrDefault(x => !x.IsCheck) == null)
- {
- NoUp = true;
- this._all_CheckBox1.IsChecked = true;
- NoUp = false;
- }
- }
- bool NoUp = false;
- private void All_Checked(object sender, RoutedEventArgs e)
- {
- if (vm == null || NoUp || !this.IsLoaded) return;
- foreach (var item in vm.DishRecordList)
- {
- item.IsCheck = true;
- }
- }
- private void All_UnChecked(object sender, RoutedEventArgs e)
- {
- if (vm == null || NoUp || !this.IsLoaded) return;
- foreach (var item in vm.DishRecordList)
- {
- item.IsCheck = false;
- }
- }
- }
- }
|