
///////////////////////////////////////////////////////////////////////////////  
//文件名称: WinManufacturerEditor.xaml
//文件描述: 生产厂商编辑界面
//创 建 者: xls
//创建日期: 2018/5/27 10:52:53
//版 本 号：1.0.0.0
////////////////////////////////////////////////////////////////////////////////

using System;
using System.Windows;
using Com.FirmLib.UI.Common;
using FWindSoft.Wpf;
using FWindSoft.Wpf.SystemTypeExtensions;

namespace Com.FirmLib.UI.Manufacturer
{
    /// <summary>
    /// WinManufacturerEditor.xaml 的交互逻辑
    /// </summary>
    public partial class WinManufacturerEditor : BaseWindow
    {
        private VmManufacturerEditor m_Vm;
        public WinManufacturerEditor():this(new VmManufacturerEditor())
        {
        }
        public WinManufacturerEditor(VmManufacturerEditor vm)
        {
            InitializeComponent();
            
            this.m_Vm = vm;
            this.m_Vm.SetRefView(this);
            this.m_Vm.WatchValidateResult(()=>!this.HasError());
            this.DataContext = this.m_Vm;
        }

        protected override void LoadData(LoadParameter parameter)
        {
            if (parameter == null)
            {
                this.Title = "添加生产厂商";
            }
            else
            {
                this.Title = "编辑生产厂商";
            }
             TryCatchWrapper.Handled(() => this.m_Vm.Init(parameter));
        }
        #region 界面关联事件
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
     
                bg.UpdateSourceForEach();
                if (this.HasError())
                {
                    //MessageShow.Infomation("请修改错误输入项");
                    return;
                }
            }
            catch (Exception ex)
            {
               // MessageShow.Show(ex);
            }
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }
        #endregion
        /// <summary>
        /// 跳转管理界面
        /// </summary>
        public bool IsManage { get { return this.m_Vm.ManagerManufacturer; } }
        /// <summary>
        /// 新建生产厂家Id
        /// </summary>
        public string ManufacturerId { get { return this.m_Vm.Id; } }
    }
}
