Files
2026-04-30 11:34:41 +08:00

121 lines
2.8 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Models.Const;
using Models.Models;
using SamplePre.Models;
using SamplePre.ProcessBll.BLL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace SamplePreSystem.UI.ViewModel.Child
{
public class NewActionViewModel: INotifyPropertyChanged
{
ActionMangerBll actionMangerBll = new ActionMangerBll();
public NewActionViewModel()
{
BindingUnit();
}
public void BindingUnit()
{
ActionUnits = SystemConst.dictDatas.Where(p => p.class_id == 2).ToList();
}
private List<sys_dict> actionUnits;
public event PropertyChangedEventHandler PropertyChanged;
public List<sys_dict> ActionUnits
{
get { return actionUnits; }
set { actionUnits = value;
OnPropertyChanged();
}
}
/// <summary>
/// 选择的动作单元
/// </summary>
private sys_dict _selectSysDict;
public sys_dict SelectSysDict
{
get { return _selectSysDict; }
set { _selectSysDict = value;
OnPropertyChanged();
}
}
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private sys_action sysAction = new sys_action();
public sys_action SysAction
{
get { return sysAction; }
set { sysAction = value;
OnPropertyChanged();
}
}
public int SaveNewData()
{
if (string.IsNullOrEmpty(SysAction.action_name))
{
MessageBox.Show("内容不能为空");
return -1;
}
//判断plc编码是否重复
if (actionMangerBll.IsExtisPlCcode(SysAction.plc_type))
{
MessageBox.Show("存在相同plc编码不能保存");
return -1;
}
sys_action process = new sys_action();
process.id = Guid.NewGuid().ToString();
process.action_name = SysAction.action_name;
process.plc_type = SysAction.plc_type;
process.remark = SysAction.remark;
//var selectItem = cmbActionUnit.SelectedItem as ComboBoxListItem;
process.action_unit = SelectSysDict.id;
//process.action_adress = actionAdress.Text;
int val = actionMangerBll.SaveSysAction(process);
return val;
}
}
}