WinInsurancePolicyEditor.xaml.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. 
  2. ///////////////////////////////////////////////////////////////////////////////
  3. //文件名称: WinInsurancePolicyEditor.xaml
  4. //文件描述: 保险单编辑
  5. //创 建 者: xls
  6. //创建日期: 2018/5/24 22:01:48
  7. //版 本 号:1.0.0.0
  8. ////////////////////////////////////////////////////////////////////////////////
  9. using System;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using Com.FirmLib.UI.Insuer.Model;
  13. using FWindSoft.Wpf;
  14. using FWindSoft.Wpf.Controls;
  15. namespace Com.FirmLib.UI.Insuer
  16. {
  17. /// <summary>
  18. /// WinInsurancePolicyEditor.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class WinInsurancePolicyEditor : NChildWindow
  21. {
  22. private VmInsurancePolicyEditor m_Vm;
  23. public WinInsurancePolicyEditor():this(new VmInsurancePolicyEditor())
  24. {
  25. }
  26. public WinInsurancePolicyEditor(VmInsurancePolicyEditor vm)
  27. {
  28. InitializeComponent();
  29. this.m_Vm = vm;
  30. this.m_Vm.SetRefView(this);
  31. this.DataContext = this.m_Vm;
  32. this.m_Vm.WatchValidateResult(() => !this.HasError());
  33. }
  34. protected override void LoadData(LoadParameter parameter)
  35. {
  36. InsuerParameter currentParameter = parameter.Parameter as InsuerParameter;
  37. if (string.IsNullOrWhiteSpace(currentParameter.Project.Id))
  38. {
  39. this.Title = "增加保单";
  40. }
  41. else
  42. {
  43. this.Title = "修改保单";
  44. }
  45. TryCatchWrapper.Handled(() => this.m_Vm.Init(parameter));
  46. }
  47. #region 界面关联事件
  48. private void btnOK_Click(object sender, RoutedEventArgs e)
  49. {
  50. try
  51. {
  52. try
  53. {
  54. this.m_Vm.BeginInEdit();
  55. var textBoxes = this.GetSpecifyTypeChildren<TextBox>();
  56. foreach (var textBox in textBoxes)
  57. {
  58. var binding = textBox.GetBindingExpression(TextBox.TextProperty);
  59. if (binding != null)
  60. {
  61. binding.UpdateSource();
  62. }
  63. }
  64. }
  65. finally
  66. {
  67. this.m_Vm.EndInEdit();
  68. }
  69. if (this.HasError())
  70. {
  71. //MessageShow.Infomation("请修改错误输入项");
  72. return;
  73. }
  74. }
  75. catch (Exception ex)
  76. {
  77. //MessageShow.Show(ex);
  78. }
  79. }
  80. private void btnCancel_Click(object sender, RoutedEventArgs e)
  81. {
  82. Close();
  83. }
  84. #endregion
  85. }
  86. }