FirmLibPost.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using Com.FirmLib.UI.Insuer;
  8. using Com.FirmLib.UI.Insuer.Model;
  9. using Com.FirmLib.UI.Maintainer;
  10. using Com.FirmLib.UI.Manufacturer;
  11. using Com.FirmLib.UI.Manufacturer.Model;
  12. using Com.FirmLib.UI.Seller;
  13. using FWindSoft.Wpf;
  14. using FWindSoft.Wpf.Controls;
  15. namespace Com.FirmLib.UI
  16. {
  17. public static class FirmLibPost
  18. {
  19. private static readonly Dictionary<string, Type> m_TypeRelations = new Dictionary<string, Type>();
  20. static FirmLibPost()
  21. {
  22. m_TypeRelations.Add(typeof(WinManufactureBaseInfo).Name, typeof(WinManufactureBaseInfo));
  23. m_TypeRelations.Add(typeof(WinManufactureInfo).Name, typeof(WinManufactureInfo));
  24. m_TypeRelations.Add(typeof(WinProductType).Name, typeof(WinProductType));
  25. m_TypeRelations.Add(typeof(WinSellerBaseInfo).Name, typeof(WinSellerBaseInfo));
  26. m_TypeRelations.Add(typeof(WinSellerInfo).Name, typeof(WinSellerInfo));
  27. m_TypeRelations.Add(typeof(WinSellerProjectContract).Name, typeof(WinSellerProjectContract));
  28. m_TypeRelations.Add(typeof(WinMaintainerBaseInfo).Name, typeof(WinMaintainerBaseInfo));
  29. m_TypeRelations.Add(typeof(WinMaintainerInfo).Name, typeof(WinMaintainerInfo));
  30. m_TypeRelations.Add(typeof(WinMaintainerProjectAsset).Name, typeof(WinMaintainerProjectAsset));
  31. m_TypeRelations.Add(typeof(WinInsuerBaseInfo).Name, typeof(WinInsuerBaseInfo));
  32. m_TypeRelations.Add(typeof(WinInsuerInfo).Name, typeof(WinInsuerInfo));
  33. m_TypeRelations.Add(typeof(WinInsurancePolicyEditor).Name, typeof(WinInsurancePolicyEditor));
  34. }
  35. public static Window StartWindow(string path, Dictionary<string, object> values)
  36. {
  37. Window win=null;
  38. try
  39. {
  40. WinFirmMain useWin = null;
  41. var flags = path.Split('\\').ToList();
  42. for (int i = 0; i < flags.Count; i++)
  43. {
  44. var child = GetNWindow(flags[i], values);
  45. if (child == null)
  46. continue;
  47. if (useWin == null)
  48. {
  49. useWin = new WinFirmMain(child);
  50. }
  51. else
  52. {
  53. useWin.NavigationBar.Add(child);
  54. }
  55. }
  56. win = useWin;
  57. }
  58. catch (Exception e)
  59. {
  60. MessageTipEx.Show( e);
  61. }
  62. if (win != null)
  63. {
  64. win.Title = "厂商库管理";
  65. }
  66. return win;
  67. }
  68. /*
  69. 解析模式 base/man/type
  70. */
  71. private static NChildWindow GetNWindow(string flag, Dictionary<string, object> values)
  72. {
  73. Type useType = null;
  74. if (!m_TypeRelations.TryGetValue(flag, out useType))
  75. throw new ArgumentException(nameof(flag) + "标志的窗体未找到");
  76. var window= Activator.CreateInstance(useType,true) as NChildWindow;
  77. if (window != null)
  78. {
  79. LoadParameter parameter = ParseLoadParameter(window, values);
  80. LoadParameter.StartParameter(window, parameter);
  81. }
  82. return window;
  83. }
  84. private static LoadParameter ParseLoadParameter(NChildWindow window,Dictionary<string, object> values)
  85. {
  86. LoadParameter result = null;
  87. do
  88. {
  89. #region 生产厂家维护
  90. if (typeof(WinManufactureBaseInfo) == window.GetType())
  91. {
  92. break;
  93. }
  94. if (typeof(WinManufactureInfo) == window.GetType())
  95. {
  96. result = new LoadParameter(values["ManufactureId"]);
  97. break;
  98. }
  99. if (typeof(WinProductType) == window.GetType())
  100. {
  101. ProductShowItem showItem = new ProductShowItem();
  102. showItem.VenderId = values["ManufactureId"].ToString();
  103. showItem.BrandId = values["BrandId"].ToString();
  104. showItem.ProductId = values["ProductId"].ToString();
  105. result = new LoadParameter(showItem);
  106. break;
  107. }
  108. #endregion
  109. #region 供应商维护
  110. if (typeof(WinSellerBaseInfo) == window.GetType())
  111. {
  112. break;
  113. }
  114. if (typeof(WinSellerInfo) == window.GetType())
  115. {
  116. result = new LoadParameter(values["SellerId"]);
  117. break;
  118. }
  119. if (typeof(WinSellerProjectContract) == window.GetType())
  120. {
  121. result = new LoadParameter(values["SellerId"]);
  122. break;
  123. }
  124. #endregion
  125. #region 维修商维护
  126. if (typeof(WinMaintainerBaseInfo) == window.GetType())
  127. {
  128. break;
  129. }
  130. if (typeof(WinMaintainerInfo) == window.GetType())
  131. {
  132. result = new LoadParameter(values["MaintainerId"]);
  133. break;
  134. }
  135. if (typeof(WinMaintainerProjectAsset) == window.GetType())
  136. {
  137. result = new LoadParameter(values["MaintainerId"]);
  138. break;
  139. }
  140. #endregion
  141. #region 保险商维护
  142. if (typeof(WinInsuerBaseInfo) == window.GetType())
  143. {
  144. break;
  145. }
  146. if (typeof(WinInsuerInfo) == window.GetType())
  147. {
  148. result = new LoadParameter(values["InsuerId"]);
  149. break;
  150. }
  151. if (typeof(WinInsurancePolicyEditor) == window.GetType())
  152. {
  153. var f = new InsuerParameter();
  154. f.Insuer.Id = values["InsuerId"].ToString();
  155. result = new LoadParameter(f);
  156. break;
  157. }
  158. #endregion
  159. } while (false);
  160. return result;
  161. }
  162. }
  163. }