!提交代码
This commit is contained in:
94
货架标准上位机/Views/MatBaseInfoAddOrUpdateView.xaml.cs
Normal file
94
货架标准上位机/Views/MatBaseInfoAddOrUpdateView.xaml.cs
Normal file
@ -0,0 +1,94 @@
|
||||
using HandyControl.Controls;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using WCS.BLL.DbModels;
|
||||
using 货架标准上位机.ViewModel;
|
||||
|
||||
namespace 货架标准上位机
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user