| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737 |
- using ivf_tl_Entity.DTO;
- using ivf_tl_Entity.GlobalEntitys;
- using ivf_tl_Entity.GlobalEnums;
- using ivf_tl_Operate.Converts;
- using ivf_tl_Operate.Windows;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- namespace ivf_tl_Operate.View
- {
- /// <summary>
- /// AddDishWindowView.xaml 的交互逻辑
- /// </summary>
- public partial class AddDishWindowView : Window
- {
- private double centerX, centerY;
- private int Count = 16;
- private double angle;
- private double angleOffset = 90;
- private double imageBigRadius = 450;
- private double imageRadius = 80;
- private double textBigRadius = 300;
- int ellipseCount = 16;
- List<Border> BorderList = new List<Border>();
- private string tlsn;
- private int housesn;
- private bool isBalacne = false;
- private long balanceId = 0;
- private ExDish ExDish = null;
- /// <summary>
- /// 新建患者
- /// </summary>
- /// <param name="housesn"></param>
- /// <param name="isBalacne"></param>
- /// <param name="balanceId"></param>
- /// <param name="exDish"></param>
- public AddDishWindowView(int housesn, bool isBalacne, long balanceId)
- {
- InitializeComponent();
- this.Owner = AppData.Instance.MainWindow;
- this.isBalacne = isBalacne;
- this.balanceId = balanceId;
- this.TextBlock_HouseSn.Text = housesn.ToString();
- if (isBalacne)
- {
- //this._balance_Button.Content = "结束平衡";
- this._balance_Button.Content = KeyToStringConvert.GetLanguageStringByKey("C0029");
- }
- this.tlsn = AppData.Instance.TlSn;
- this.housesn = housesn;
- //this.numbertext.Text = $"新建患者信息";
- this.numbertext.Text = KeyToStringConvert.GetLanguageStringByKey("C0262");
- centerX = 1422 / 2.0;
- centerY = 1229 / 2.0;
- angle = 360.00 / 16;
- int curreYeat = DateTime.Now.Year;
- for (int i = 1963; i <= curreYeat; i++) YearsList.Add(i);
- for (int i = 1; i <= 12; i++) MonthList.Add(i);
- for (int i = 1; i <= 31; i++) DayList.Add(i);
- this._wifeYear.ItemsSource = YearsList;
- this._wifeMonth.ItemsSource = MonthList;
- this._wifeDay.ItemsSource = DayList;
- this._husbandYear.ItemsSource = YearsList;
- this._husbandMonth.ItemsSource = MonthList;
- this._husbandDay.ItemsSource = DayList;
- this._freType_ComboBox.ItemsSource = AppData.Instance.FertilizationTypeEntitieList;
- InitAddCustom();
- Closed += (a, b) => AppData.Instance.MainWindow.Activate();
- }
- /// <summary>
- /// 修改患者
- /// </summary>
- /// <param name="housesn"></param>
- /// <param name="exDish"></param>
- public AddDishWindowView(ExDish exDish, List<DishPicAndVideo> datas)
- {
- InitializeComponent();
- this.Owner = AppData.Instance.MainWindow;
- ExDish = exDish;
- this.TextBlock_HouseSn.Text = ExDish.houseSn.ToString();
- //this.numbertext.Text = $"编辑患者信息";
- this.numbertext.Text = KeyToStringConvert.GetLanguageStringByKey("C0263");
- centerX = 1422 / 2.0;
- centerY = 1229 / 2.0;
- angle = 360.00 / 16;
- int curreYeat = DateTime.Now.Year;
- for (int i = 1963; i <= curreYeat; i++) YearsList.Add(i);
- for (int i = 1; i <= 12; i++) MonthList.Add(i);
- for (int i = 1; i <= 31; i++) DayList.Add(i);
- this._wifeYear.ItemsSource = YearsList;
- this._wifeMonth.ItemsSource = MonthList;
- this._wifeDay.ItemsSource = DayList;
- this._husbandYear.ItemsSource = YearsList;
- this._husbandMonth.ItemsSource = MonthList;
- this._husbandDay.ItemsSource = DayList;
- this._freType_ComboBox.ItemsSource = AppData.Instance.FertilizationTypeEntitieList;
- InitEditCustom(datas);
- Closed += (a, b) => AppData.Instance.MainWindow.Activate();
- }
- List<int> YearsList = new List<int>();
- List<int> MonthList = new List<int>();
- List<int> DayList = new List<int>();
- private void InitAddCustom()
- {
- this._addDishButton.Visibility = Visibility.Visible;
- for (int i = 0; i < ellipseCount; i++)
- {
- TextBlock borderT = new TextBlock();
- Panel.SetZIndex(borderT, 7);
- this._canvas.Children.Add(borderT);
- borderT.Height = 28;
- borderT.Width = 35;
- borderT.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Width / 2);
- borderT.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Height / 2);
- borderT.Text = $"{i + 1}";
- borderT.TextAlignment = TextAlignment.Center;
- borderT.FontSize = 27;
- borderT.Foreground = new SolidColorBrush(Colors.Gray);
- Border border = new Border();
- this._canvas.Children.Add(border);
- BorderList.Add(border);
- border.Name = $"B{i + 1}";
- border.CornerRadius = new CornerRadius(imageRadius);
- border.Background = new SolidColorBrush(Colors.Red);
- Panel.SetZIndex(border, 9);
- border.Tag = false;
- border.Width = imageRadius * 2;
- border.Height = imageRadius * 2;
- border.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - border.Width / 2);
- border.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - border.Height / 2);
- border.SetValue(Panel.ZIndexProperty, 9);
- border.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Resources/Image/ellipse_backgroud.png", UriKind.RelativeOrAbsolute)));
- border.MouseUp += (s, e) =>
- {
- if (!(s is Border so)) return;
- var newTag = !(bool)so.Tag;
- if (newTag)
- {
- so.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Resources/Image/photo_embryo.png", UriKind.RelativeOrAbsolute)));
- }
- else
- {
- so.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Resources/Image/ellipse_backgroud.png", UriKind.RelativeOrAbsolute)));
- }
- so.Tag = newTag;
- };
- }
- if (this._freType_ComboBox.HasItems)
- {
- this._freType_ComboBox.SelectedIndex = 0;
- }
- }
- private void InitEditCustom(List<DishPicAndVideo> datas)
- {
- this._editDishButton.Visibility = Visibility.Visible;
- this._caseId_TextBox.IsEnabled = false;
- this._freType_ComboBox.IsEnabled = false;
- this._Border_TextBox.IsEnabled = false;
- this._cycle_TextBox.IsEnabled = false;
- this._Border_TextBox.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E4E4E4"));
- this._Border_TextBox.BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#D1D1D1"));
- this._startTime_TextBox.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#A4A4A4"));
- this._caseId_TextBox.Text = ExDish.caseId;
- this._wife_TextBox.Text = ExDish.wife;
- this._cycle_TextBox.Text = ExDish.cycle;
- this._isVip.IsChecked = ExDish.vip == 1 ? true : false;
- if (DateTime.TryParse(ExDish.wifeBirth, out DateTime wifeTime))
- {
- this._wifeYear.SelectedItem = wifeTime.Year;
- this._wifeMonth.SelectedItem = wifeTime.Month;
- this._wifeDay.SelectedItem = wifeTime.Day;
- }
- this._husband_TextBox.Text = ExDish.husband;
- if (DateTime.TryParse(ExDish.husbandBirth, out DateTime husTime))
- {
- this._husbandYear.SelectedItem = husTime.Year;
- this._husbandMonth.SelectedItem = husTime.Month;
- this._husbandDay.SelectedItem = husTime.Day;
- }
- this._startTime_TextBox.Text = ExDish.startTime;
- int k = -1;
- for (int i = 0; i < AppData.Instance.FertilizationTypeEntitieList.Count; i++)
- {
- if (AppData.Instance.FertilizationTypeEntitieList[i].dictKey == ExDish.fertilizationType)
- {
- k = i;
- break;
- }
- }
- if (k != -1) this._freType_ComboBox.SelectedIndex = k;
- ExEmbryo exEmbryo = null;
- for (int i = 0; i < ellipseCount; i++)
- {
- exEmbryo = ExDish.embryoList.FirstOrDefault(x => x.wellSn == (i + 1));
- TextBlock borderT = new TextBlock();
- Panel.SetZIndex(borderT, 7);
- this._canvas.Children.Add(borderT);
- borderT.Height = 28;
- borderT.Width = 35;
- borderT.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Width / 2);
- borderT.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Height / 2);
- borderT.Text = $"{i + 1}";
- borderT.TextAlignment = TextAlignment.Center;
- borderT.FontSize = 27;
- borderT.Foreground = new SolidColorBrush(Colors.Gray);
- Border border = new Border();
- this._canvas.Children.Add(border);
- BorderList.Add(border);
- border.Name = $"B{i + 1}";
- border.CornerRadius = new CornerRadius(imageRadius);
- border.Background = new SolidColorBrush(Colors.Red);
- Panel.SetZIndex(border, 9);
- border.Tag = false;
- border.Width = imageRadius * 2;
- border.Height = imageRadius * 2;
- border.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - border.Width / 2);
- border.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - border.Height / 2);
- border.SetValue(Panel.ZIndexProperty, 9);
- border.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Resources/Image/ellipse_backgroud.png", UriKind.RelativeOrAbsolute)));
- if (exEmbryo == null)
- {
- border.MouseUp += (s, e) =>
- {
- if (!(s is Border so)) return;
- var newTag = !(bool)so.Tag;
- if (newTag)
- {
- so.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Resources/Image/photo_embryo.png", UriKind.RelativeOrAbsolute)));
- }
- else
- {
- so.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Resources/Image/ellipse_backgroud.png", UriKind.RelativeOrAbsolute)));
- }
- so.Tag = newTag;
- };
- }
- else
- {
- border.Tag = true;
- var currentData = datas.FirstOrDefault(x => x.wellSn == exEmbryo.wellSn);
- if (currentData != null && !string.IsNullOrEmpty(currentData.lastPicture))
- {
- string imageurl = $"{AppData.Instance.BaseUrl}{currentData.lastPicture.Replace(AppData.Instance.PicSuf, $"_160x160{AppData.Instance.PicSuf}")}?token={AppData.Instance.HttpHelper.GetToken()}";
- border.Background = new ImageBrush(AppData.Instance.ConvertHelper.StringToBitmapImage(imageurl));
- }
- else
- {
- border.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Resources/Image/photo_embryo.png", UriKind.RelativeOrAbsolute)));
- }
- }
- }
- }
- /// <summary>
- /// 修改培养
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void EditDishSave_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- List<int> wellList = new List<int>();
- foreach (var item in BorderList)
- {
- if ((bool)item.Tag == true)
- {
- string borderName = item.Name;
- string number = borderName.Substring(1);
- if (int.TryParse(number, out int result))
- {
- wellList.Add(result);
- }
- }
- }
- string caseIdString = this._caseId_TextBox.Text.Trim();
- if (string.IsNullOrEmpty(caseIdString))
- {
- //MessageInfo("请输入病例编号");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0148"));
- return;
- }
- string cycleIdString = this._cycle_TextBox.Text.Trim();
- if (string.IsNullOrEmpty(cycleIdString))
- {
- //MessageInfo("请输入周期编号");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0316"));
- return;
- }
- string wifeString = this._wife_TextBox.Text.Trim();
- if (string.IsNullOrEmpty(wifeString))
- {
- //MessageInfo("请输入女方姓名");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0149"));
- return;
- }
- //if (wifeString.Length > 100)
- //{
- // MessageInfo("女方姓名字符长度为1-100");
- // return;
- //}
- string wifeBirthString = this._wifeAge.Text.Trim();
- if (string.IsNullOrEmpty(wifeBirthString))
- {
- wifeBirthString = null;
- //MessageInfo("请输入女方年龄");
- //return;
- }
- else
- {
- if (DateTime.TryParse($"{this._wifeYear.SelectedItem}-{this._wifeMonth.SelectedItem}-{this._wifeDay.SelectedItem}", out DateTime wifeTime)) wifeBirthString = wifeTime.ToString("yyyy-MM-dd HH:mm:ss");
- else
- {
- MessageInfo("女方年龄错误");
- return;
- }
- }
- string husbandString = this._husband_TextBox.Text.Trim();
- if (string.IsNullOrEmpty(husbandString))
- {
- //MessageInfo("请输入男方姓名");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0150"));
- return;
- }
- //if (husbandString.Length > 100)
- //{
- // MessageInfo("男方姓名字符长度为1-100");
- // return;
- //}
- string husbandBirthString = this._husbandAge.Text.Trim();
- if (string.IsNullOrEmpty(husbandBirthString))
- {
- husbandBirthString = null;
- //MessageInfo("请输入男方年龄");
- //return;
- }
- else
- {
- if (DateTime.TryParse($"{this._husbandYear.SelectedItem}-{this._husbandMonth.SelectedItem}-{(int)this._husbandDay.SelectedItem}", out DateTime husTime)) husbandBirthString = husTime.ToString("yyyy-MM-dd HH:mm:ss");
- else
- {
- MessageInfo("男方年龄错误");
- return;
- }
- }
- //ExDish.caseId = caseIdString;
- ExDish.wife = wifeString;
- ExDish.wifeBirth = wifeBirthString;
- ExDish.husbandBirth = husbandBirthString;
- ExDish.husband = husbandString;
- ExDish.vip = this._isVip.IsChecked == true ? 1 : 0;
- ExDish.embryoCount = wellList.Count;
- ExDish.cycle = cycleIdString;
- string body = JsonConvert.SerializeObject(new
- {
- embryoCount = ExDish.embryoCount,
- husband = ExDish.husband,
- husbandBirth = ExDish.husbandBirth,
- id = ExDish.id,
- vip = ExDish.vip,
- wellSn = wellList,
- wife = ExDish.wife,
- wifeBirth = ExDish.wifeBirth,
- cycle = ExDish.cycle,
- });
- if (!AppData.Instance.HttpHelper.UpdateDishInfoApi(body))
- {
- //MessageInfo("修改信息失败");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0243"));
- }
- else
- {
- this.DialogResult = true;
- }
- }
- catch (Exception ex)
- {
- AppData.Instance.LogHelper.ExceptionLog(ex, "AddDishWindowView.EditDishSave_Click", LogEnum.RunException);
- }
- }
- /// <summary>
- /// 开始培养
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void StartDish_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- List<int> wellList = new List<int>();
- foreach (var item in BorderList)
- {
- if ((bool)item.Tag == true)
- {
- string borderName = item.Name;
- string number = borderName.Substring(1);
- if (int.TryParse(number, out int result)) wellList.Add(result);
- }
- }
- if (!wellList.Any())
- {
- //MessageInfo("请选择胚胎孔位");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0317"));
- return;
- }
- string caseIdString = this._caseId_TextBox.Text.Trim();
- if (string.IsNullOrEmpty(caseIdString))
- {
- //MessageInfo("请输入病例编号");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0148"));
- return;
- }
- string cycleIdString = this._cycle_TextBox.Text.Trim();
- if (string.IsNullOrEmpty(cycleIdString))
- {
- //MessageInfo("请输入周期编号");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0316"));
- return;
- }
- string wifeString = this._wife_TextBox.Text.Trim();
- if (string.IsNullOrEmpty(wifeString))
- {
- //MessageInfo("请输入女方姓名");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0149"));
- return;
- }
- //if (wifeString.Length > 100)
- //{
- // MessageInfo("女方姓名字符长度为1-100");
- // return;
- //}
- string wifeBirthString = this._wifeAge.Text.Trim();
- if (string.IsNullOrEmpty(wifeBirthString))
- {
- wifeBirthString = null;
- //MessageInfo("请输入女方年龄");
- //return;
- }
- else
- {
- if (DateTime.TryParse($"{this._wifeYear.SelectedItem}-{this._wifeMonth.SelectedItem}-{this._wifeDay.SelectedItem}", out DateTime wifeTime)) wifeBirthString = wifeTime.ToString("yyyy-MM-dd HH:mm:ss");
- else
- {
- MessageInfo("女方年龄错误");
- return;
- }
- }
- string husbandString = this._husband_TextBox.Text.Trim();
- if (string.IsNullOrEmpty(husbandString))
- {
- //MessageInfo("请输入男方姓名");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0150"));
- return;
- }
- //if (husbandString.Length > 100)
- //{
- // MessageInfo("男方姓名字符长度为1-100");
- // return;
- //}
- string husbandBirthString = this._husbandAge.Text.Trim();
- if (string.IsNullOrEmpty(husbandBirthString))
- {
- husbandBirthString = null;
- //MessageInfo("请输入男方年龄");
- //return;
- }
- else
- {
- if (DateTime.TryParse($"{this._husbandYear.SelectedItem}-{this._husbandMonth.SelectedItem}-{(int)this._husbandDay.SelectedItem}", out DateTime husTime)) husbandBirthString = husTime.ToString("yyyy-MM-dd HH:mm:ss");
- else
- {
- MessageInfo("男方年龄错误");
- return;
- }
- }
- string startTimeString = this._startTime_TextBox.Text.Trim();
- if (string.IsNullOrEmpty(startTimeString))
- {
- //MessageInfo("请输入受精时间");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0154"));
- return;
- }
- if (DateTime.TryParse(startTimeString, out DateTime result1))
- {
- if (result1 > DateTime.Now)
- {
- //MessageInfo("受精时间不能超过当前时间");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0264"));
- return;
- }
- }
- else
- {
- //MessageInfo("受精时间输入错误");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0154"));
- return;
- }
- //string cycleString = this._cycle_TextBox.Text.Trim();
- //string phoneString = this._phone_TextBox.Text.Trim();
- //if (string.IsNullOrEmpty(phoneString))
- //{
- // MessageInfo("请输入联系方式");
- // return;
- //}
- //if (!Regex.IsMatch(phoneString, @"^1[3456789]\d{9}$"))
- //{
- // MessageInfo("联系方式输入错误");
- // return;
- //}
- ExDish exDish = new ExDish();
- exDish.tlSn = tlsn;
- exDish.houseSn = housesn;
- exDish.caseId = caseIdString;
- exDish.wife = wifeString;
- exDish.cycle = cycleIdString;
- exDish.wifeBirth = wifeBirthString;
- exDish.husbandBirth = husbandBirthString;
- exDish.husband = husbandString;
- exDish.vip = this._isVip.IsChecked == true ? 1 : 0;
- exDish.embryoCount = wellList.Count;
- exDish.startTime = startTimeString;
- if (this._freType_ComboBox.SelectedItem is FertilizationTypeEntity typeEntity)
- {
- exDish.fertilizationType = typeEntity.dictKey;
- exDish.fertilizationTypeId = int.Parse(typeEntity.dictValue);
- }
- //exDish.phone = phoneString;
- exDish.embryoCount = wellList.Count;
- exDish.wellSn = wellList;
- string error = AppData.Instance.HttpHelper.AddCultureRecordApi(exDish);
- if (!string.IsNullOrEmpty(error))
- {
- //MessageInfo($"开始培养失败:{error}");
- MessageInfo($"{KeyToStringConvert.GetLanguageStringByKey("C0265")}:{error}");
- }
- else
- {
- this.DialogResult = true;
- }
- }
- catch (Exception ex)
- {
- AppData.Instance.LogHelper.ExceptionLog(ex, "AddDishWindowView.StartDish_Click", LogEnum.RunException);
- }
- e.Handled = true;
- }
- /// <summary>
- /// 平衡操作
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void StartBalance_Click(object sender, RoutedEventArgs e)
- {
- //Debug.WriteLine("平衡按钮");
- if (isBalacne)//结束平衡
- {
- if (balanceId == 0)
- {
- //MessageInfo("获取平衡记录失败");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0266"));
- return;
- }
- if (AppData.Instance.HttpHelper.StopBalanceApi(balanceId))
- {
- this.DialogResult = true;
- }
- else
- {
- //MessageInfo("结束平衡失败");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0267"));
- }
- }
- else//开始平衡
- {
- if (AppData.Instance.HttpHelper.StartBalanceApi(housesn, tlsn))
- {
- this.DialogResult = true;
- }
- else
- {
- //MessageInfo("开始平衡失败");
- MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0268"));
- }
- }
- }
- private void Cancel_Click(object sender, RoutedEventArgs e)
- {
- this.DialogResult = false;
- }
- private void Cancel_MouseUp(object sender, MouseButtonEventArgs e)
- {
- //MessageBox.Show("点击×");
- //int is1 = 1 + 1;
- //Debug.WriteLine("==============================================================");
- this.DialogResult = false;
- }
- private string GetDataTime()
- {
- try
- {
- this._mask.Visibility = Visibility.Visible;
- GetDateWindow getDate = new GetDateWindow(this);
- getDate._dateControl.SetNYR(false);
- getDate.isClos = false;
- var result = getDate.ShowDialog();
- if (result.Value == true)
- {
- return $"{getDate.Date}:00";
- }
- return null;
- }
- catch (Exception ex)
- {
- return null;
- }
- finally
- {
- this._mask.Visibility = Visibility.Hidden;
- }
- }
- private void StartTime_MouseUp(object sender, MouseButtonEventArgs e)
- {
- string newTime = GetDataTime();
- if (string.IsNullOrEmpty(newTime))
- {
- return;
- }
- this._startTime_TextBox.Text = newTime;
- this._startTime_TextBox.Foreground = new SolidColorBrush(Colors.Black);
- }
- private void WifeBirth_MouseUp(object sender, MouseButtonEventArgs e)
- {
- string newTime = GetDataTime();
- if (string.IsNullOrEmpty(newTime))
- {
- return;
- }
- //this._wifeBirth_TextBox.Text = newTime;
- }
- private void HusbandBirth_MouseUp(object sender, MouseButtonEventArgs e)
- {
- string newTime = GetDataTime();
- if (string.IsNullOrEmpty(newTime))
- {
- return;
- }
- //this._husbandBirth_TextBox.Text = newTime;
- }
- private void Wifi_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (this._wifeYear.SelectedItem != null && this._wifeMonth.SelectedItem != null && this._wifeDay.SelectedItem != null)
- {
- int CurrentYear = (int)this._wifeYear.SelectedItem;
- int CurrentMonth = (int)this._wifeMonth.SelectedItem;
- int CurrentDay = (int)this._wifeDay.SelectedItem;
- int age = DateTime.Now.Year - CurrentYear;
- if (DateTime.Now.Month < CurrentMonth || (DateTime.Now.Month == CurrentMonth && DateTime.Now.Day < CurrentDay)) age--;
- this._wifeAge.Text = age.ToString();
- }
- }
- private void HusBand_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (this._husbandYear.SelectedItem != null && this._husbandMonth.SelectedItem != null && this._husbandDay.SelectedItem != null)
- {
- int CurrentYear = (int)this._husbandYear.SelectedItem;
- int CurrentMonth = (int)this._husbandMonth.SelectedItem;
- int CurrentDay = (int)this._husbandDay.SelectedItem;
- int age = DateTime.Now.Year - CurrentYear;
- if (DateTime.Now.Month < CurrentMonth || (DateTime.Now.Month == CurrentMonth && DateTime.Now.Day < CurrentDay)) age--;
- this._husbandAge.Text = age.ToString();
- }
- }
- private void Border_MouseUp(object sender, MouseButtonEventArgs e)
- {
- //MessageBox.Show("点击生效");
- int kk = 1 + 1;
- }
- private void Grid_PreviewTouchDown(object sender, TouchEventArgs e)
- {
- //Debug.WriteLine("===================ImageTouchDown===========================================");
- }
- private void MessageInfo(string mess)
- {
- this._errorInfo_TextBlock.Text = mess;
- }
- }
- }
|