WinSellerInfo.xaml.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. 
  2. ///////////////////////////////////////////////////////////////////////////////
  3. //文件名称: WinSeller.xaml
  4. //文件描述: 供应商信息
  5. //创 建 者: xls
  6. //创建日期: 2018/5/24 21:14:59
  7. //版 本 号:1.0.0.0
  8. ////////////////////////////////////////////////////////////////////////////////
  9. using System;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Input;
  13. using Com.FirmLib.UI.BllCommon;
  14. using Com.FirmLib.UI.Common;
  15. using FWindSoft.Data;
  16. using FWindSoft.Wpf;
  17. using FWindSoft.Wpf.Controls;
  18. namespace Com.FirmLib.UI.Seller
  19. {
  20. /// <summary>
  21. /// WinSeller.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class WinSellerInfo : NChildWindow
  24. {
  25. private VmSellerInfo m_Vm;
  26. public WinSellerInfo():this(new VmSellerInfo())
  27. {
  28. }
  29. public WinSellerInfo(VmSellerInfo vm)
  30. {
  31. InitializeComponent();
  32. EveryTimeLoad = true;
  33. this.m_Vm = vm;
  34. this.m_Vm.SetRefView(this);
  35. this.DataContext = this.m_Vm;
  36. this.CommandBindings.Add(new CommandBinding(EditCommands.SingleUpdate, SingleUpdate));
  37. }
  38. protected override void LoadData(LoadParameter parameter)
  39. {
  40. //初始化列表数据
  41. TryCatchWrapper.Handled(() => this.m_Vm.Init(parameter));
  42. this.Title = this.m_Vm.Name;
  43. }
  44. #region 界面关联事件
  45. private void btnOK_Click(object sender, RoutedEventArgs e)
  46. {
  47. try
  48. {
  49. if (this.HasError())
  50. {
  51. //MessageShow.Infomation("请修改错误输入项");
  52. return;
  53. }
  54. //if (Execute())
  55. //{
  56. // MessageShow.Infomation("");
  57. // DialogResult = true;
  58. //}
  59. }
  60. catch (Exception ex)
  61. {
  62. //MessageShow.Show(ex);
  63. }
  64. }
  65. private void btnCancel_Click(object sender, RoutedEventArgs e)
  66. {
  67. Close();
  68. }
  69. #endregion
  70. #region 命令绑定相关
  71. void SingleUpdate(object sender, ExecutedRoutedEventArgs e)
  72. {
  73. TextBoxEditor editor = e.Parameter as TextBoxEditor;
  74. if (editor == null)
  75. return;
  76. string field = string.Empty;
  77. if (editor.Tag != null)
  78. {
  79. field = editor.Tag.ToString();
  80. }
  81. bool result = this.m_Vm.SingleUpdateVenderItem(field);
  82. if (!result)
  83. {
  84. //editor.Focus();
  85. editor.IsEditing = true;
  86. }
  87. }
  88. #endregion
  89. #region 动态更新列
  90. private void ListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
  91. {
  92. var list = sender as ListBox;
  93. if (list == null)
  94. {
  95. return;
  96. }
  97. var current = (list.SelectedItem as TreeNavigationItem<BasePropertyChanged>)?.RefItem as ShowDataItem;
  98. if (current == null)
  99. {
  100. return;
  101. }
  102. CreateColumns(current.FamilyCode);
  103. }
  104. public void CreateColumns(string code)
  105. {
  106. if (string.IsNullOrEmpty(code))
  107. {
  108. return;
  109. }
  110. for (int i = ProductTypeGrid.Columns.Count - 1; i >1; i--)
  111. {
  112. ProductTypeGrid.Columns.RemoveAt(i);
  113. }
  114. var definitions = ProductTypeManager.GetInfoPointDefinitions(code);
  115. definitions.ForEach(c => c.IsReadOnly = false);
  116. var columns = ProductTypeGrid.CreateColumns(definitions, "RefItem.Parameters", InfoPointTemplateParse.CreateTemplateManager());
  117. columns.ForEach(c =>
  118. {
  119. //DataGridDragCopyOptions.SetCanColumnDragCopy(c, true);
  120. c.Width = c.Header.ToString().Length * 16+40;
  121. c.IsReadOnly = true;
  122. c.MinWidth = 80;
  123. });
  124. }
  125. #endregion
  126. }
  127. }