123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
-
- ///////////////////////////////////////////////////////////////////////////////
- //文件名称: VmMaintainerEditor.cs
- //文件描述: 维修商编辑
- //创 建 者: xls
- //创建日期: 2018/5/24 22:03:44
- //版 本 号: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.Maintainer
- {
- public class VmMaintainerEditor : BaseViewModel
- {
- public VmMaintainerEditor()
- {
- Init();
- }
- private void Init()
- {
- }
- #region 属性相关
- /// <summary>
- /// 是否管理
- /// </summary>
- public bool IsManage { get; set; }
- /// <summary>
- /// 新维修商Id
- /// </summary>
- public string Id { get; set; }
- private string m_Name;
- /// <summary>
- /// 维修商名称
- /// </summary>
- public string Name
- {
- get { return this.m_Name; }
- set
- {
- this.m_Name = value;
- RaisePropertyChanged(() => this.Name);
- }
- }
- private string m_Url;
- /// <summary>
- /// 维修商Url
- /// </summary>
- public string Url
- {
- get { return this.m_Url; }
- set
- {
- this.m_Url = value;
- RaisePropertyChanged(() => this.Url);
- }
- }
- #endregion
- #region 命令相关
- /// <summary>
- /// 添加工厂完场
- /// </summary>
- /// <param name="parameter"></param>
- [Command]
- public void AddCommand(object parameter)
- {
- try
- {
- if (!CreateMaintainer())
- return;
- 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 AddAndManageCommand(object parameter)
- {
- try
- {
- if (!CreateMaintainer())
- return;
- IsManage = true;
- Window window = parameter as Window;
- if (window != null)
- window.DialogResult = true;
- }
- catch (Exception ex)
- {
- MessageTipEx.Show(ex);
- }
- }
- public bool CanAddAndManageCommand(object parameter)
- {
- return IsValidated;
- }
- #endregion
- /// <summary>
- /// 创建供应商
- /// </summary>
- /// <returns></returns>
- private bool CreateMaintainer()
- {
- MaintainerItem item = new MaintainerItem();
- item.Name = this.Name??string.Empty;
- item.Website = Url ?? string.Empty;
- var result = BllFactory<MaintainerBll>.Instance.Add(item);
- if (result)
- {
- Id = item.Id;
- }
- else
- {
- MessageTip.Show(this.GetWindow(), BllFactory<MaintainerBll>.Instance.ErrorMessage ?? string.Empty);
- }
- return result;
- }
- }
- }
|