添加项目文件。
This commit is contained in:
141
WPFWCSDemo/ViewModels/LineManagementViewModel.cs
Normal file
141
WPFWCSDemo/ViewModels/LineManagementViewModel.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using WPFWCSDemo.Data;
|
||||
|
||||
namespace WPFWCSDemo.ViewModels
|
||||
{
|
||||
public partial class LineManagementViewModel:ObservableObject
|
||||
{
|
||||
public LineManagementViewModel(Window window)
|
||||
{
|
||||
LineManagementDialog = window;
|
||||
|
||||
Caption = "输送线管理";
|
||||
|
||||
Enables = new ObservableCollection<int>();
|
||||
|
||||
InitializeStyle();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当前页面
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
string _caption;
|
||||
|
||||
/// <summary>
|
||||
/// 当前页面
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
Window _lineManagementDialog;
|
||||
|
||||
/// <summary>
|
||||
/// 当前页面
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
Color _btnColor;
|
||||
|
||||
|
||||
[RelayCommand]
|
||||
void Accept(Window window)
|
||||
{
|
||||
window.Close();
|
||||
}
|
||||
|
||||
|
||||
[ObservableProperty]
|
||||
ObservableCollection<int> _enables;
|
||||
|
||||
[ObservableProperty]
|
||||
int _e1009;
|
||||
[ObservableProperty]
|
||||
int _e1010;
|
||||
[ObservableProperty]
|
||||
int _e1011;
|
||||
[ObservableProperty]
|
||||
int _e1012;
|
||||
|
||||
|
||||
[ObservableProperty]
|
||||
int _e1002;
|
||||
[ObservableProperty]
|
||||
int _e1004;
|
||||
[ObservableProperty]
|
||||
int _e1006;
|
||||
|
||||
|
||||
[RelayCommand]
|
||||
void StateChange(string targetLocation)
|
||||
{
|
||||
var context = new AppDbContext();
|
||||
|
||||
var res = context.LineState
|
||||
.Where(a => a.Target == int.Parse(targetLocation))
|
||||
.ToList();
|
||||
|
||||
if (res == null) return;
|
||||
|
||||
for (int i = 0; i < res.Count; i++)
|
||||
{
|
||||
if (res[i].IsEnable == 0)
|
||||
{
|
||||
if (MessageBox.Show($"确认要恢复{targetLocation}输送口允许进垛吗?", "警告", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
||||
{
|
||||
res[i].IsEnable = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MessageBox.Show($"确认要禁止{targetLocation}输送口进垛吗?", "警告", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
|
||||
{
|
||||
res[i].IsEnable = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.SaveChanges();
|
||||
|
||||
InitializeStyle();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按钮样式初始化
|
||||
/// </summary>
|
||||
void InitializeStyle()
|
||||
{
|
||||
var context = new AppDbContext();
|
||||
|
||||
var results = context.LineState
|
||||
.Select(a=>a.IsEnable)
|
||||
.ToList();
|
||||
|
||||
Enables.Clear();
|
||||
|
||||
foreach (var result in results)
|
||||
{
|
||||
Enables.Add(result);
|
||||
}
|
||||
|
||||
E1009 = Enables[1];
|
||||
E1010 = Enables[2];
|
||||
E1011 = Enables[3];
|
||||
E1012 = Enables[0];
|
||||
E1002 = Enables[5];
|
||||
E1004 = Enables[6];
|
||||
E1006 = Enables[7];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user