123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
-
- ///////////////////////////////////////////////////////////////////////////////
- //文件名称: VmManufacturerEditor.cs
- //文件描述: 生产厂商编辑
- //创 建 者: xls
- //创建日期: 2018/5/27 10:52:53
- //版 本 号:1.0.0.0
- ////////////////////////////////////////////////////////////////////////////////
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using Com.FirmLib.Bll;
- using Com.FirmLib.Entity;
- using FWindSoft.DataFramework;
- using FWindSoft.MVVM;
- using FWindSoft.Wpf;
- namespace Com.FirmLib.UI.Manufacturer
- {
- public class VmManufacturerEditor : BaseViewModel
- {
- public VmManufacturerEditor()
- {
- Init();
- }
- private void Init()
- {
- }
- public void Init(LoadParameter parameter)
- {
- //todo 根据参数加载项目信息
- }
- #region 属性相关
- private string m_Name;
- /// <summary>
- /// 厂商名称
- /// </summary>
- public string Name
- {
- get { return this.m_Name; }
- set
- {
- this.m_Name = value;
- RaisePropertyChanged(() => this.Name);
- }
- }
- #endregion
- /// <summary>
- /// 关联Id新厂商Id
- /// </summary>
- public string Id { get;private set; }
- /// <summary>
- /// 管理厂商库
- /// </summary>
- public bool ManagerManufacturer { get; private set; }
- #region 命令相关
- /// <summary>
- /// 添加工厂
- /// </summary>
- /// <param name="parameter"></param>
- [Command]
- public void AddCommand(object parameter)
- {
- try
- {
- if (!CreateManufacturer())
- return;
- ManagerManufacturer = false;
- Window window = parameter as Window;
- if (window != null)
- window.DialogResult = true;
- }
- catch (Exception ex)
- {
- MessageTipEx.Show(ex);
- }
- }
- public bool CanAddCommand(object parameter)
- {
- return IsValidated;
- }
- /// <summary>
- /// 添加并管理工厂
- /// </summary>
- /// <param name="parameter"></param>
- [Command]
- public void AddAndManage(object parameter)
- {
- try
- {
- if (!CreateManufacturer())
- return;
- ManagerManufacturer = true;
- Window window = parameter as Window;
- if (window != null)
- window.DialogResult = true;
- }
- catch (Exception ex)
- {
- MessageTipEx.Show(ex);
- }
- }
- public bool CanAddAndManage(object parameter)
- {
- return IsValidated;
- }
- #endregion
- /// <summary>
- /// 创建厂商库,返回是否成功创建
- /// </summary>
- /// <returns></returns>
- private bool CreateManufacturer()
- {
- ManufacturerItem item = new ManufacturerItem();
- item.Name = this.Name;
- var result = BllFactory<ManufacturerBll>.Instance.Add(item);
- if (result)
- {
- Id = item.Id;
- }
- else
- {
- MessageTip.Show(this.GetWindow(), BllFactory<ManufacturerBll>.Instance.ErrorMessage ?? string.Empty);
- }
- return result;
- }
- }
- }
|