You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AUCMA_SCADA/Aucma.Core.Palletiz/ViewModels/HandPalletizViewModel.cs

105 lines
2.9 KiB
C#

using Aucma.Core.Palletiz.Business;
using Aucma.Core.Palletiz.Models;
12 months ago
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using log4net;
using System;
using System.Windows.Forms;
namespace Aucma.Core.Palletiz.ViewModels
{
public partial class HandPalletizViewModel : ObservableObject
{
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(HandPalletizViewModel));
#region 货道信息
private int LevelNo = 1;
private int BinNo = 1;
private int PortNo = 1;
private int RangeNo = 1;
#endregion
public static StackInfoModel tempStackInfo = new StackInfoModel();
12 months ago
public HandPalletizViewModel() {
PromptInfo("请选择信息下传......", "White");
12 months ago
}
#region 分垛信息下传
/// <summary>
/// 分垛信息下传
/// </summary>
[RelayCommand]
public void Save()
{
try
12 months ago
{
PromptInfo("分垛信息下传中......", "White");
DialogResult cr = MessageBox.Show("是否确认下传分垛信息?", "系统提醒", MessageBoxButtons.OKCancel);
if (cr != DialogResult.OK)
{
return;
}
tempStackInfo.LevelNo = LevelNo;
tempStackInfo.BinNo = (BinNo - 1) * 2 + PortNo + ((LevelNo - 1) * 10);
tempStackInfo.PortNo = PortNo;
tempStackInfo.RangeNo = RangeNo;
12 months ago
bool backResult = InstoreBusiness.WritePlc(tempStackInfo);
if (backResult)
{
PromptInfo("分垛信息下传成功!", "White");
}
else
{
PromptInfo("分垛信息下传失败!", "Red");
}
12 months ago
}
catch (Exception ex)
12 months ago
{
PromptInfo($"分垛信息下传失败:{ex.Message}", "Red");
12 months ago
}
}
#endregion
#region 提示信息
private string? msgTxt;
12 months ago
public string? MsgTxt
12 months ago
{
get => msgTxt;
set => SetProperty(ref msgTxt, value);
}
#endregion
#region 字体颜色
private string? msgColor;
public string? MsgColor
{
get => msgColor;
set => SetProperty(ref msgColor, value);
}
#endregion
#region 提示信息
/// <summary>
/// 提示信息
/// </summary>
/// <param name="mesg">提示信息</param>
/// <param name="color">提示信息颜色</param>
public void PromptInfo(string mesg, string color)
{
System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
{
MsgTxt = mesg;
MsgColor = color;
}));
}
#endregion
}
}