123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using Com.FirmLib.UI.Insuer;
- using Com.FirmLib.UI.Insuer.Model;
- using Com.FirmLib.UI.Maintainer;
- using Com.FirmLib.UI.Manufacturer;
- using Com.FirmLib.UI.Manufacturer.Model;
- using Com.FirmLib.UI.Seller;
- using FWindSoft.Wpf;
- using FWindSoft.Wpf.Controls;
- namespace Com.FirmLib.UI
- {
- public static class FirmLibPost
- {
- private static readonly Dictionary<string, Type> m_TypeRelations = new Dictionary<string, Type>();
- static FirmLibPost()
- {
- m_TypeRelations.Add(typeof(WinManufactureBaseInfo).Name, typeof(WinManufactureBaseInfo));
- m_TypeRelations.Add(typeof(WinManufactureInfo).Name, typeof(WinManufactureInfo));
- m_TypeRelations.Add(typeof(WinProductType).Name, typeof(WinProductType));
- m_TypeRelations.Add(typeof(WinSellerBaseInfo).Name, typeof(WinSellerBaseInfo));
- m_TypeRelations.Add(typeof(WinSellerInfo).Name, typeof(WinSellerInfo));
- m_TypeRelations.Add(typeof(WinSellerProjectContract).Name, typeof(WinSellerProjectContract));
- m_TypeRelations.Add(typeof(WinMaintainerBaseInfo).Name, typeof(WinMaintainerBaseInfo));
- m_TypeRelations.Add(typeof(WinMaintainerInfo).Name, typeof(WinMaintainerInfo));
- m_TypeRelations.Add(typeof(WinMaintainerProjectAsset).Name, typeof(WinMaintainerProjectAsset));
- m_TypeRelations.Add(typeof(WinInsuerBaseInfo).Name, typeof(WinInsuerBaseInfo));
- m_TypeRelations.Add(typeof(WinInsuerInfo).Name, typeof(WinInsuerInfo));
- m_TypeRelations.Add(typeof(WinInsurancePolicyEditor).Name, typeof(WinInsurancePolicyEditor));
- }
- public static Window StartWindow(string path, Dictionary<string, object> values)
- {
- Window win=null;
- try
- {
- WinFirmMain useWin = null;
- var flags = path.Split('\\').ToList();
- for (int i = 0; i < flags.Count; i++)
- {
- var child = GetNWindow(flags[i], values);
- if (child == null)
- continue;
- if (useWin == null)
- {
- useWin = new WinFirmMain(child);
- }
- else
- {
- useWin.NavigationBar.Add(child);
- }
- }
- win = useWin;
- }
- catch (Exception e)
- {
- MessageTipEx.Show( e);
- }
- if (win != null)
- {
- win.Title = "厂商库管理";
- }
- return win;
- }
- /*
- 解析模式 base/man/type
- */
- private static NChildWindow GetNWindow(string flag, Dictionary<string, object> values)
- {
- Type useType = null;
- if (!m_TypeRelations.TryGetValue(flag, out useType))
- throw new ArgumentException(nameof(flag) + "标志的窗体未找到");
- var window= Activator.CreateInstance(useType,true) as NChildWindow;
- if (window != null)
- {
- LoadParameter parameter = ParseLoadParameter(window, values);
- LoadParameter.StartParameter(window, parameter);
- }
- return window;
- }
- private static LoadParameter ParseLoadParameter(NChildWindow window,Dictionary<string, object> values)
- {
- LoadParameter result = null;
- do
- {
- #region 生产厂家维护
- if (typeof(WinManufactureBaseInfo) == window.GetType())
- {
- break;
- }
- if (typeof(WinManufactureInfo) == window.GetType())
- {
- result = new LoadParameter(values["ManufactureId"]);
- break;
- }
- if (typeof(WinProductType) == window.GetType())
- {
- ProductShowItem showItem = new ProductShowItem();
- showItem.VenderId = values["ManufactureId"].ToString();
- showItem.BrandId = values["BrandId"].ToString();
- showItem.ProductId = values["ProductId"].ToString();
- result = new LoadParameter(showItem);
- break;
- }
- #endregion
- #region 供应商维护
- if (typeof(WinSellerBaseInfo) == window.GetType())
- {
- break;
- }
- if (typeof(WinSellerInfo) == window.GetType())
- {
- result = new LoadParameter(values["SellerId"]);
- break;
- }
- if (typeof(WinSellerProjectContract) == window.GetType())
- {
- result = new LoadParameter(values["SellerId"]);
- break;
- }
- #endregion
- #region 维修商维护
- if (typeof(WinMaintainerBaseInfo) == window.GetType())
- {
- break;
- }
- if (typeof(WinMaintainerInfo) == window.GetType())
- {
- result = new LoadParameter(values["MaintainerId"]);
- break;
- }
- if (typeof(WinMaintainerProjectAsset) == window.GetType())
- {
- result = new LoadParameter(values["MaintainerId"]);
- break;
- }
- #endregion
- #region 保险商维护
- if (typeof(WinInsuerBaseInfo) == window.GetType())
- {
- break;
- }
- if (typeof(WinInsuerInfo) == window.GetType())
- {
- result = new LoadParameter(values["InsuerId"]);
- break;
- }
- if (typeof(WinInsurancePolicyEditor) == window.GetType())
- {
- var f = new InsuerParameter();
- f.Insuer.Id = values["InsuerId"].ToString();
- result = new LoadParameter(f);
- break;
- }
- #endregion
- } while (false);
- return result;
- }
- }
- }
|