AddDishWindowView.xaml.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. using ivf_tl_Entity.DTO;
  2. using ivf_tl_Entity.GlobalEntitys;
  3. using ivf_tl_Entity.GlobalEnums;
  4. using ivf_tl_Operate.Converts;
  5. using ivf_tl_Operate.Windows;
  6. using Newtonsoft.Json;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Diagnostics;
  10. using System.Linq;
  11. using System.Windows;
  12. using System.Windows.Controls;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. namespace ivf_tl_Operate.View
  17. {
  18. /// <summary>
  19. /// AddDishWindowView.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class AddDishWindowView : Window
  22. {
  23. private double centerX, centerY;
  24. private int Count = 16;
  25. private double angle;
  26. private double angleOffset = 90;
  27. private double imageBigRadius = 450;
  28. private double imageRadius = 80;
  29. private double textBigRadius = 300;
  30. int ellipseCount = 16;
  31. List<Border> BorderList = new List<Border>();
  32. private string tlsn;
  33. private int housesn;
  34. private bool isBalacne = false;
  35. private long balanceId = 0;
  36. private ExDish ExDish = null;
  37. /// <summary>
  38. /// 新建患者
  39. /// </summary>
  40. /// <param name="housesn"></param>
  41. /// <param name="isBalacne"></param>
  42. /// <param name="balanceId"></param>
  43. /// <param name="exDish"></param>
  44. public AddDishWindowView(int housesn, bool isBalacne, long balanceId)
  45. {
  46. InitializeComponent();
  47. this.Owner = AppData.Instance.MainWindow;
  48. this.isBalacne = isBalacne;
  49. this.balanceId = balanceId;
  50. this.TextBlock_HouseSn.Text = housesn.ToString();
  51. if (isBalacne)
  52. {
  53. //this._balance_Button.Content = "结束平衡";
  54. this._balance_Button.Content = KeyToStringConvert.GetLanguageStringByKey("C0029");
  55. }
  56. this.tlsn = AppData.Instance.TlSn;
  57. this.housesn = housesn;
  58. //this.numbertext.Text = $"新建患者信息";
  59. this.numbertext.Text = KeyToStringConvert.GetLanguageStringByKey("C0262");
  60. centerX = 1422 / 2.0;
  61. centerY = 1229 / 2.0;
  62. angle = 360.00 / 16;
  63. int curreYeat = DateTime.Now.Year;
  64. for (int i = 1963; i <= curreYeat; i++) YearsList.Add(i);
  65. for (int i = 1; i <= 12; i++) MonthList.Add(i);
  66. for (int i = 1; i <= 31; i++) DayList.Add(i);
  67. this._wifeYear.ItemsSource = YearsList;
  68. this._wifeMonth.ItemsSource = MonthList;
  69. this._wifeDay.ItemsSource = DayList;
  70. this._husbandYear.ItemsSource = YearsList;
  71. this._husbandMonth.ItemsSource = MonthList;
  72. this._husbandDay.ItemsSource = DayList;
  73. this._freType_ComboBox.ItemsSource = AppData.Instance.FertilizationTypeEntitieList;
  74. InitAddCustom();
  75. Closed += (a, b) => AppData.Instance.MainWindow.Activate();
  76. }
  77. /// <summary>
  78. /// 修改患者
  79. /// </summary>
  80. /// <param name="housesn"></param>
  81. /// <param name="exDish"></param>
  82. public AddDishWindowView(ExDish exDish, List<DishPicAndVideo> datas)
  83. {
  84. InitializeComponent();
  85. this.Owner = AppData.Instance.MainWindow;
  86. ExDish = exDish;
  87. this.TextBlock_HouseSn.Text = ExDish.houseSn.ToString();
  88. //this.numbertext.Text = $"编辑患者信息";
  89. this.numbertext.Text = KeyToStringConvert.GetLanguageStringByKey("C0263");
  90. centerX = 1422 / 2.0;
  91. centerY = 1229 / 2.0;
  92. angle = 360.00 / 16;
  93. int curreYeat = DateTime.Now.Year;
  94. for (int i = 1963; i <= curreYeat; i++) YearsList.Add(i);
  95. for (int i = 1; i <= 12; i++) MonthList.Add(i);
  96. for (int i = 1; i <= 31; i++) DayList.Add(i);
  97. this._wifeYear.ItemsSource = YearsList;
  98. this._wifeMonth.ItemsSource = MonthList;
  99. this._wifeDay.ItemsSource = DayList;
  100. this._husbandYear.ItemsSource = YearsList;
  101. this._husbandMonth.ItemsSource = MonthList;
  102. this._husbandDay.ItemsSource = DayList;
  103. this._freType_ComboBox.ItemsSource = AppData.Instance.FertilizationTypeEntitieList;
  104. InitEditCustom(datas);
  105. Closed += (a, b) => AppData.Instance.MainWindow.Activate();
  106. }
  107. List<int> YearsList = new List<int>();
  108. List<int> MonthList = new List<int>();
  109. List<int> DayList = new List<int>();
  110. private void InitAddCustom()
  111. {
  112. this._addDishButton.Visibility = Visibility.Visible;
  113. for (int i = 0; i < ellipseCount; i++)
  114. {
  115. TextBlock borderT = new TextBlock();
  116. Panel.SetZIndex(borderT, 7);
  117. this._canvas.Children.Add(borderT);
  118. borderT.Height = 28;
  119. borderT.Width = 35;
  120. borderT.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Width / 2);
  121. borderT.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Height / 2);
  122. borderT.Text = $"{i + 1}";
  123. borderT.TextAlignment = TextAlignment.Center;
  124. borderT.FontSize = 27;
  125. borderT.Foreground = new SolidColorBrush(Colors.Gray);
  126. Border border = new Border();
  127. this._canvas.Children.Add(border);
  128. BorderList.Add(border);
  129. border.Name = $"B{i + 1}";
  130. border.CornerRadius = new CornerRadius(imageRadius);
  131. border.Background = new SolidColorBrush(Colors.Red);
  132. Panel.SetZIndex(border, 9);
  133. border.Tag = false;
  134. border.Width = imageRadius * 2;
  135. border.Height = imageRadius * 2;
  136. border.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - border.Width / 2);
  137. border.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - border.Height / 2);
  138. border.SetValue(Panel.ZIndexProperty, 9);
  139. border.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Resources/Image/ellipse_backgroud.png", UriKind.RelativeOrAbsolute)));
  140. border.MouseUp += (s, e) =>
  141. {
  142. if (!(s is Border so)) return;
  143. var newTag = !(bool)so.Tag;
  144. if (newTag)
  145. {
  146. so.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Resources/Image/photo_embryo.png", UriKind.RelativeOrAbsolute)));
  147. }
  148. else
  149. {
  150. so.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Resources/Image/ellipse_backgroud.png", UriKind.RelativeOrAbsolute)));
  151. }
  152. so.Tag = newTag;
  153. };
  154. }
  155. if (this._freType_ComboBox.HasItems)
  156. {
  157. this._freType_ComboBox.SelectedIndex = 0;
  158. }
  159. }
  160. private void InitEditCustom(List<DishPicAndVideo> datas)
  161. {
  162. this._editDishButton.Visibility = Visibility.Visible;
  163. this._caseId_TextBox.IsEnabled = false;
  164. this._freType_ComboBox.IsEnabled = false;
  165. this._Border_TextBox.IsEnabled = false;
  166. this._cycle_TextBox.IsEnabled = false;
  167. this._Border_TextBox.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E4E4E4"));
  168. this._Border_TextBox.BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#D1D1D1"));
  169. this._startTime_TextBox.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#A4A4A4"));
  170. this._caseId_TextBox.Text = ExDish.caseId;
  171. this._wife_TextBox.Text = ExDish.wife;
  172. this._cycle_TextBox.Text = ExDish.cycle;
  173. this._isVip.IsChecked = ExDish.vip == 1 ? true : false;
  174. if (DateTime.TryParse(ExDish.wifeBirth, out DateTime wifeTime))
  175. {
  176. this._wifeYear.SelectedItem = wifeTime.Year;
  177. this._wifeMonth.SelectedItem = wifeTime.Month;
  178. this._wifeDay.SelectedItem = wifeTime.Day;
  179. }
  180. this._husband_TextBox.Text = ExDish.husband;
  181. if (DateTime.TryParse(ExDish.husbandBirth, out DateTime husTime))
  182. {
  183. this._husbandYear.SelectedItem = husTime.Year;
  184. this._husbandMonth.SelectedItem = husTime.Month;
  185. this._husbandDay.SelectedItem = husTime.Day;
  186. }
  187. this._startTime_TextBox.Text = ExDish.startTime;
  188. int k = -1;
  189. for (int i = 0; i < AppData.Instance.FertilizationTypeEntitieList.Count; i++)
  190. {
  191. if (AppData.Instance.FertilizationTypeEntitieList[i].dictKey == ExDish.fertilizationType)
  192. {
  193. k = i;
  194. break;
  195. }
  196. }
  197. if (k != -1) this._freType_ComboBox.SelectedIndex = k;
  198. ExEmbryo exEmbryo = null;
  199. for (int i = 0; i < ellipseCount; i++)
  200. {
  201. exEmbryo = ExDish.embryoList.FirstOrDefault(x => x.wellSn == (i + 1));
  202. TextBlock borderT = new TextBlock();
  203. Panel.SetZIndex(borderT, 7);
  204. this._canvas.Children.Add(borderT);
  205. borderT.Height = 28;
  206. borderT.Width = 35;
  207. borderT.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Width / 2);
  208. borderT.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Height / 2);
  209. borderT.Text = $"{i + 1}";
  210. borderT.TextAlignment = TextAlignment.Center;
  211. borderT.FontSize = 27;
  212. borderT.Foreground = new SolidColorBrush(Colors.Gray);
  213. Border border = new Border();
  214. this._canvas.Children.Add(border);
  215. BorderList.Add(border);
  216. border.Name = $"B{i + 1}";
  217. border.CornerRadius = new CornerRadius(imageRadius);
  218. border.Background = new SolidColorBrush(Colors.Red);
  219. Panel.SetZIndex(border, 9);
  220. border.Tag = false;
  221. border.Width = imageRadius * 2;
  222. border.Height = imageRadius * 2;
  223. border.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - border.Width / 2);
  224. border.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - border.Height / 2);
  225. border.SetValue(Panel.ZIndexProperty, 9);
  226. border.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Resources/Image/ellipse_backgroud.png", UriKind.RelativeOrAbsolute)));
  227. if (exEmbryo == null)
  228. {
  229. border.MouseUp += (s, e) =>
  230. {
  231. if (!(s is Border so)) return;
  232. var newTag = !(bool)so.Tag;
  233. if (newTag)
  234. {
  235. so.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Resources/Image/photo_embryo.png", UriKind.RelativeOrAbsolute)));
  236. }
  237. else
  238. {
  239. so.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Resources/Image/ellipse_backgroud.png", UriKind.RelativeOrAbsolute)));
  240. }
  241. so.Tag = newTag;
  242. };
  243. }
  244. else
  245. {
  246. border.Tag = true;
  247. var currentData = datas.FirstOrDefault(x => x.wellSn == exEmbryo.wellSn);
  248. if (currentData != null && !string.IsNullOrEmpty(currentData.lastPicture))
  249. {
  250. string imageurl = $"{AppData.Instance.BaseUrl}{currentData.lastPicture.Replace(AppData.Instance.PicSuf, $"_160x160{AppData.Instance.PicSuf}")}?token={AppData.Instance.HttpHelper.GetToken()}";
  251. border.Background = new ImageBrush(AppData.Instance.ConvertHelper.StringToBitmapImage(imageurl));
  252. }
  253. else
  254. {
  255. border.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Resources/Image/photo_embryo.png", UriKind.RelativeOrAbsolute)));
  256. }
  257. }
  258. }
  259. }
  260. /// <summary>
  261. /// 修改培养
  262. /// </summary>
  263. /// <param name="sender"></param>
  264. /// <param name="e"></param>
  265. private void EditDishSave_Click(object sender, RoutedEventArgs e)
  266. {
  267. try
  268. {
  269. List<int> wellList = new List<int>();
  270. foreach (var item in BorderList)
  271. {
  272. if ((bool)item.Tag == true)
  273. {
  274. string borderName = item.Name;
  275. string number = borderName.Substring(1);
  276. if (int.TryParse(number, out int result))
  277. {
  278. wellList.Add(result);
  279. }
  280. }
  281. }
  282. string caseIdString = this._caseId_TextBox.Text.Trim();
  283. if (string.IsNullOrEmpty(caseIdString))
  284. {
  285. //MessageInfo("请输入病例编号");
  286. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0148"));
  287. return;
  288. }
  289. string cycleIdString = this._cycle_TextBox.Text.Trim();
  290. if (string.IsNullOrEmpty(cycleIdString))
  291. {
  292. //MessageInfo("请输入周期编号");
  293. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0316"));
  294. return;
  295. }
  296. string wifeString = this._wife_TextBox.Text.Trim();
  297. if (string.IsNullOrEmpty(wifeString))
  298. {
  299. //MessageInfo("请输入女方姓名");
  300. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0149"));
  301. return;
  302. }
  303. //if (wifeString.Length > 100)
  304. //{
  305. // MessageInfo("女方姓名字符长度为1-100");
  306. // return;
  307. //}
  308. string wifeBirthString = this._wifeAge.Text.Trim();
  309. if (string.IsNullOrEmpty(wifeBirthString))
  310. {
  311. wifeBirthString = null;
  312. //MessageInfo("请输入女方年龄");
  313. //return;
  314. }
  315. else
  316. {
  317. if (DateTime.TryParse($"{this._wifeYear.SelectedItem}-{this._wifeMonth.SelectedItem}-{this._wifeDay.SelectedItem}", out DateTime wifeTime)) wifeBirthString = wifeTime.ToString("yyyy-MM-dd HH:mm:ss");
  318. else
  319. {
  320. MessageInfo("女方年龄错误");
  321. return;
  322. }
  323. }
  324. string husbandString = this._husband_TextBox.Text.Trim();
  325. if (string.IsNullOrEmpty(husbandString))
  326. {
  327. //MessageInfo("请输入男方姓名");
  328. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0150"));
  329. return;
  330. }
  331. //if (husbandString.Length > 100)
  332. //{
  333. // MessageInfo("男方姓名字符长度为1-100");
  334. // return;
  335. //}
  336. string husbandBirthString = this._husbandAge.Text.Trim();
  337. if (string.IsNullOrEmpty(husbandBirthString))
  338. {
  339. husbandBirthString = null;
  340. //MessageInfo("请输入男方年龄");
  341. //return;
  342. }
  343. else
  344. {
  345. 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");
  346. else
  347. {
  348. MessageInfo("男方年龄错误");
  349. return;
  350. }
  351. }
  352. //ExDish.caseId = caseIdString;
  353. ExDish.wife = wifeString;
  354. ExDish.wifeBirth = wifeBirthString;
  355. ExDish.husbandBirth = husbandBirthString;
  356. ExDish.husband = husbandString;
  357. ExDish.vip = this._isVip.IsChecked == true ? 1 : 0;
  358. ExDish.embryoCount = wellList.Count;
  359. ExDish.cycle = cycleIdString;
  360. string body = JsonConvert.SerializeObject(new
  361. {
  362. embryoCount = ExDish.embryoCount,
  363. husband = ExDish.husband,
  364. husbandBirth = ExDish.husbandBirth,
  365. id = ExDish.id,
  366. vip = ExDish.vip,
  367. wellSn = wellList,
  368. wife = ExDish.wife,
  369. wifeBirth = ExDish.wifeBirth,
  370. cycle = ExDish.cycle,
  371. });
  372. if (!AppData.Instance.HttpHelper.UpdateDishInfoApi(body))
  373. {
  374. //MessageInfo("修改信息失败");
  375. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0243"));
  376. }
  377. else
  378. {
  379. this.DialogResult = true;
  380. }
  381. }
  382. catch (Exception ex)
  383. {
  384. AppData.Instance.LogHelper.ExceptionLog(ex, "AddDishWindowView.EditDishSave_Click", LogEnum.RunException);
  385. }
  386. }
  387. /// <summary>
  388. /// 开始培养
  389. /// </summary>
  390. /// <param name="sender"></param>
  391. /// <param name="e"></param>
  392. private void StartDish_Click(object sender, RoutedEventArgs e)
  393. {
  394. try
  395. {
  396. List<int> wellList = new List<int>();
  397. foreach (var item in BorderList)
  398. {
  399. if ((bool)item.Tag == true)
  400. {
  401. string borderName = item.Name;
  402. string number = borderName.Substring(1);
  403. if (int.TryParse(number, out int result)) wellList.Add(result);
  404. }
  405. }
  406. if (!wellList.Any())
  407. {
  408. //MessageInfo("请选择胚胎孔位");
  409. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0317"));
  410. return;
  411. }
  412. string caseIdString = this._caseId_TextBox.Text.Trim();
  413. if (string.IsNullOrEmpty(caseIdString))
  414. {
  415. //MessageInfo("请输入病例编号");
  416. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0148"));
  417. return;
  418. }
  419. string cycleIdString = this._cycle_TextBox.Text.Trim();
  420. if (string.IsNullOrEmpty(cycleIdString))
  421. {
  422. //MessageInfo("请输入周期编号");
  423. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0316"));
  424. return;
  425. }
  426. string wifeString = this._wife_TextBox.Text.Trim();
  427. if (string.IsNullOrEmpty(wifeString))
  428. {
  429. //MessageInfo("请输入女方姓名");
  430. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0149"));
  431. return;
  432. }
  433. //if (wifeString.Length > 100)
  434. //{
  435. // MessageInfo("女方姓名字符长度为1-100");
  436. // return;
  437. //}
  438. string wifeBirthString = this._wifeAge.Text.Trim();
  439. if (string.IsNullOrEmpty(wifeBirthString))
  440. {
  441. wifeBirthString = null;
  442. //MessageInfo("请输入女方年龄");
  443. //return;
  444. }
  445. else
  446. {
  447. if (DateTime.TryParse($"{this._wifeYear.SelectedItem}-{this._wifeMonth.SelectedItem}-{this._wifeDay.SelectedItem}", out DateTime wifeTime)) wifeBirthString = wifeTime.ToString("yyyy-MM-dd HH:mm:ss");
  448. else
  449. {
  450. MessageInfo("女方年龄错误");
  451. return;
  452. }
  453. }
  454. string husbandString = this._husband_TextBox.Text.Trim();
  455. if (string.IsNullOrEmpty(husbandString))
  456. {
  457. //MessageInfo("请输入男方姓名");
  458. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0150"));
  459. return;
  460. }
  461. //if (husbandString.Length > 100)
  462. //{
  463. // MessageInfo("男方姓名字符长度为1-100");
  464. // return;
  465. //}
  466. string husbandBirthString = this._husbandAge.Text.Trim();
  467. if (string.IsNullOrEmpty(husbandBirthString))
  468. {
  469. husbandBirthString = null;
  470. //MessageInfo("请输入男方年龄");
  471. //return;
  472. }
  473. else
  474. {
  475. 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");
  476. else
  477. {
  478. MessageInfo("男方年龄错误");
  479. return;
  480. }
  481. }
  482. string startTimeString = this._startTime_TextBox.Text.Trim();
  483. if (string.IsNullOrEmpty(startTimeString))
  484. {
  485. //MessageInfo("请输入受精时间");
  486. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0154"));
  487. return;
  488. }
  489. if (DateTime.TryParse(startTimeString, out DateTime result1))
  490. {
  491. if (result1 > DateTime.Now)
  492. {
  493. //MessageInfo("受精时间不能超过当前时间");
  494. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0264"));
  495. return;
  496. }
  497. }
  498. else
  499. {
  500. //MessageInfo("受精时间输入错误");
  501. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0154"));
  502. return;
  503. }
  504. //string cycleString = this._cycle_TextBox.Text.Trim();
  505. //string phoneString = this._phone_TextBox.Text.Trim();
  506. //if (string.IsNullOrEmpty(phoneString))
  507. //{
  508. // MessageInfo("请输入联系方式");
  509. // return;
  510. //}
  511. //if (!Regex.IsMatch(phoneString, @"^1[3456789]\d{9}$"))
  512. //{
  513. // MessageInfo("联系方式输入错误");
  514. // return;
  515. //}
  516. ExDish exDish = new ExDish();
  517. exDish.tlSn = tlsn;
  518. exDish.houseSn = housesn;
  519. exDish.caseId = caseIdString;
  520. exDish.wife = wifeString;
  521. exDish.cycle = cycleIdString;
  522. exDish.wifeBirth = wifeBirthString;
  523. exDish.husbandBirth = husbandBirthString;
  524. exDish.husband = husbandString;
  525. exDish.vip = this._isVip.IsChecked == true ? 1 : 0;
  526. exDish.embryoCount = wellList.Count;
  527. exDish.startTime = startTimeString;
  528. if (this._freType_ComboBox.SelectedItem is FertilizationTypeEntity typeEntity)
  529. {
  530. exDish.fertilizationType = typeEntity.dictKey;
  531. exDish.fertilizationTypeId = int.Parse(typeEntity.dictValue);
  532. }
  533. //exDish.phone = phoneString;
  534. exDish.embryoCount = wellList.Count;
  535. exDish.wellSn = wellList;
  536. string error = AppData.Instance.HttpHelper.AddCultureRecordApi(exDish);
  537. if (!string.IsNullOrEmpty(error))
  538. {
  539. //MessageInfo($"开始培养失败:{error}");
  540. MessageInfo($"{KeyToStringConvert.GetLanguageStringByKey("C0265")}:{error}");
  541. }
  542. else
  543. {
  544. this.DialogResult = true;
  545. }
  546. }
  547. catch (Exception ex)
  548. {
  549. AppData.Instance.LogHelper.ExceptionLog(ex, "AddDishWindowView.StartDish_Click", LogEnum.RunException);
  550. }
  551. e.Handled = true;
  552. }
  553. /// <summary>
  554. /// 平衡操作
  555. /// </summary>
  556. /// <param name="sender"></param>
  557. /// <param name="e"></param>
  558. private void StartBalance_Click(object sender, RoutedEventArgs e)
  559. {
  560. //Debug.WriteLine("平衡按钮");
  561. if (isBalacne)//结束平衡
  562. {
  563. if (balanceId == 0)
  564. {
  565. //MessageInfo("获取平衡记录失败");
  566. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0266"));
  567. return;
  568. }
  569. if (AppData.Instance.HttpHelper.StopBalanceApi(balanceId))
  570. {
  571. this.DialogResult = true;
  572. }
  573. else
  574. {
  575. //MessageInfo("结束平衡失败");
  576. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0267"));
  577. }
  578. }
  579. else//开始平衡
  580. {
  581. if (AppData.Instance.HttpHelper.StartBalanceApi(housesn, tlsn))
  582. {
  583. this.DialogResult = true;
  584. }
  585. else
  586. {
  587. //MessageInfo("开始平衡失败");
  588. MessageInfo(KeyToStringConvert.GetLanguageStringByKey("C0268"));
  589. }
  590. }
  591. }
  592. private void Cancel_Click(object sender, RoutedEventArgs e)
  593. {
  594. this.DialogResult = false;
  595. }
  596. private void Cancel_MouseUp(object sender, MouseButtonEventArgs e)
  597. {
  598. //MessageBox.Show("点击×");
  599. //int is1 = 1 + 1;
  600. //Debug.WriteLine("==============================================================");
  601. this.DialogResult = false;
  602. }
  603. private string GetDataTime()
  604. {
  605. try
  606. {
  607. this._mask.Visibility = Visibility.Visible;
  608. GetDateWindow getDate = new GetDateWindow(this);
  609. getDate._dateControl.SetNYR(false);
  610. getDate.isClos = false;
  611. var result = getDate.ShowDialog();
  612. if (result.Value == true)
  613. {
  614. return $"{getDate.Date}:00";
  615. }
  616. return null;
  617. }
  618. catch (Exception ex)
  619. {
  620. return null;
  621. }
  622. finally
  623. {
  624. this._mask.Visibility = Visibility.Hidden;
  625. }
  626. }
  627. private void StartTime_MouseUp(object sender, MouseButtonEventArgs e)
  628. {
  629. string newTime = GetDataTime();
  630. if (string.IsNullOrEmpty(newTime))
  631. {
  632. return;
  633. }
  634. this._startTime_TextBox.Text = newTime;
  635. this._startTime_TextBox.Foreground = new SolidColorBrush(Colors.Black);
  636. }
  637. private void WifeBirth_MouseUp(object sender, MouseButtonEventArgs e)
  638. {
  639. string newTime = GetDataTime();
  640. if (string.IsNullOrEmpty(newTime))
  641. {
  642. return;
  643. }
  644. //this._wifeBirth_TextBox.Text = newTime;
  645. }
  646. private void HusbandBirth_MouseUp(object sender, MouseButtonEventArgs e)
  647. {
  648. string newTime = GetDataTime();
  649. if (string.IsNullOrEmpty(newTime))
  650. {
  651. return;
  652. }
  653. //this._husbandBirth_TextBox.Text = newTime;
  654. }
  655. private void Wifi_SelectionChanged(object sender, SelectionChangedEventArgs e)
  656. {
  657. if (this._wifeYear.SelectedItem != null && this._wifeMonth.SelectedItem != null && this._wifeDay.SelectedItem != null)
  658. {
  659. int CurrentYear = (int)this._wifeYear.SelectedItem;
  660. int CurrentMonth = (int)this._wifeMonth.SelectedItem;
  661. int CurrentDay = (int)this._wifeDay.SelectedItem;
  662. int age = DateTime.Now.Year - CurrentYear;
  663. if (DateTime.Now.Month < CurrentMonth || (DateTime.Now.Month == CurrentMonth && DateTime.Now.Day < CurrentDay)) age--;
  664. this._wifeAge.Text = age.ToString();
  665. }
  666. }
  667. private void HusBand_SelectionChanged(object sender, SelectionChangedEventArgs e)
  668. {
  669. if (this._husbandYear.SelectedItem != null && this._husbandMonth.SelectedItem != null && this._husbandDay.SelectedItem != null)
  670. {
  671. int CurrentYear = (int)this._husbandYear.SelectedItem;
  672. int CurrentMonth = (int)this._husbandMonth.SelectedItem;
  673. int CurrentDay = (int)this._husbandDay.SelectedItem;
  674. int age = DateTime.Now.Year - CurrentYear;
  675. if (DateTime.Now.Month < CurrentMonth || (DateTime.Now.Month == CurrentMonth && DateTime.Now.Day < CurrentDay)) age--;
  676. this._husbandAge.Text = age.ToString();
  677. }
  678. }
  679. private void Border_MouseUp(object sender, MouseButtonEventArgs e)
  680. {
  681. //MessageBox.Show("点击生效");
  682. int kk = 1 + 1;
  683. }
  684. private void Grid_PreviewTouchDown(object sender, TouchEventArgs e)
  685. {
  686. //Debug.WriteLine("===================ImageTouchDown===========================================");
  687. }
  688. private void MessageInfo(string mess)
  689. {
  690. this._errorInfo_TextBlock.Text = mess;
  691. }
  692. }
  693. }