95 lines
2.6 KiB
C#
95 lines
2.6 KiB
C#
using HandyControl.Controls;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Windows;
|
|
using WCS.BLL.DbModels;
|
|
using 智能仓储WCS管理系统.ViewModel;
|
|
|
|
namespace 智能仓储WCS管理系统
|
|
{
|
|
public partial class MatBaseInfoAddOrUpdateView : System.Windows.Window
|
|
{
|
|
|
|
public MatBaseInfoAddOrUpdateViewModel ViewModel = new MatBaseInfoAddOrUpdateViewModel();
|
|
public MatBaseInfoModel matBaseInfo = null;
|
|
|
|
|
|
public MatBaseInfoAddOrUpdateView(string _titleText, MatBaseInfoModel _matBaseInfo = null)
|
|
{
|
|
InitializeComponent();
|
|
this.DataContext = ViewModel;
|
|
|
|
if (_matBaseInfo != null)
|
|
{
|
|
matBaseInfo = _matBaseInfo;
|
|
//绑定数据
|
|
MatCode.Text = matBaseInfo.MatCode;
|
|
MatName.Text = matBaseInfo.MatName;
|
|
MatSpec.Text = matBaseInfo.MatSpec;
|
|
MatUnit.Text = matBaseInfo.MatUnit;
|
|
MatCustomer.Text = matBaseInfo.MatCustomer;
|
|
ViewModel.IsEnable = matBaseInfo.IsEnable;
|
|
|
|
MatCode.IsEnabled = false;
|
|
}
|
|
else
|
|
{
|
|
matBaseInfo = new MatBaseInfoModel();
|
|
ViewModel.IsEnable = true;
|
|
}
|
|
|
|
|
|
//绑定标题
|
|
if (!string.IsNullOrEmpty(_titleText))
|
|
{
|
|
Title.Text = _titleText;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private void btnOk_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(MatCode.Text))
|
|
{
|
|
Growl.Warning($"物料编码必填!");
|
|
MatCode.Focus();
|
|
return;
|
|
}
|
|
else if (string.IsNullOrEmpty(MatName.Text))
|
|
{
|
|
Growl.Warning($"物料名称必填!");
|
|
MatName.Focus();
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
matBaseInfo.MatCode = MatCode.Text;
|
|
matBaseInfo.MatName = MatName.Text;
|
|
matBaseInfo.MatSpec = MatSpec.Text;
|
|
matBaseInfo.MatUnit = MatUnit.Text;
|
|
matBaseInfo.MatCustomer = MatCustomer.Text;
|
|
matBaseInfo.IsEnable = ViewModel.IsEnable;
|
|
}
|
|
//绑定数据
|
|
catch (Exception ex)
|
|
{
|
|
Growl.Error($"发生异常:{ex.Message}");
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
this.DialogResult = true;
|
|
this.Close();
|
|
}
|
|
|
|
private void closeClick(object sender, RoutedEventArgs e)
|
|
{
|
|
this.DialogResult = false;
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|