change-封装非阻塞式消息控件,修改所有消息弹框提示

dev
liuwf 2 months ago
parent 5db57c889c
commit e8ce75823c

@ -85,6 +85,7 @@ namespace SlnMesnac.Business
private void test()
{
// MesProductPlanDetail? mesProductPlanDetail = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<MesProductPlanDetail>().First(x => x.PlanCode == "20240724144533JL001");
//sqlSugarClient.AsTenant().BeginTran();
//string epc = "JYHB01010102";

@ -0,0 +1,136 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Threading;
using System.Windows;
using MaterialDesignThemes.Wpf;
namespace SlnMesnac.WPF.MessageTips
{
public class MessageAdorner : Adorner
{
private ListBox listBox;
private UIElement _child;
private FrameworkElement adornedElement;
public MessageAdorner(UIElement adornedElement) : base(adornedElement)
{
this.adornedElement = adornedElement as FrameworkElement;
}
public void PushMessage(string message, int msgtype, int outTime)
{
if (listBox == null)
{
listBox = new ListBox() { Style = null, BorderThickness = new Thickness(0), Background = Brushes.Transparent };
listBox.IsHitTestVisible = false;
Child = listBox;
}
Border border = new Border();
border.CornerRadius = new CornerRadius(10);
border.BorderThickness = new Thickness(0);
border.Opacity = 0.8;
StackPanel panel = new StackPanel();
panel.Orientation = Orientation.Horizontal;
panel.MaxWidth = 700;
PackIcon icon = new PackIcon();
icon.Padding = new Thickness(2);
icon.Margin = new Thickness(2);
icon.MaxWidth = 100;
icon.VerticalAlignment = VerticalAlignment.Center;
icon.HorizontalAlignment = HorizontalAlignment.Center;
panel.Children.Add(icon);
border.Height = 100; // 设置高度
TextBlock textBlock = new TextBlock();
textBlock.Text = message;
textBlock.TextWrapping = TextWrapping.Wrap;
textBlock.Padding = new Thickness(5);
textBlock.Margin = new Thickness(5);
textBlock.MaxWidth = 600;
textBlock.FontSize = 25; // 增加字体大小
textBlock.VerticalAlignment = VerticalAlignment.Center;
textBlock.HorizontalAlignment = HorizontalAlignment.Center;
panel.Children.Add(textBlock);
border.Child = panel;
if (msgtype == 0)
{
border.Background = Brushes.LightGreen;
icon.Kind = PackIconKind.Check;
//textBlock.Foreground=Brushes.Green;
}
if (msgtype == 1)
{
border.Background = Brushes.Yellow;
icon.Kind = PackIconKind.Alert;
//textBlock.Foreground = Brushes.Yellow;
}
if (msgtype == 2)
{
border.Background = Brushes.Red;
icon.Kind = PackIconKind.Close;
//textBlock.Foreground = Brushes.Red;
}
var item = new MessageItem { Content = border };
var timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(outTime);
timer.Tick += (sender, e) =>
{
listBox.Items.Remove(item);
timer.Stop();
};
listBox.Items.Insert(0, item);
timer.Start();
}
public UIElement Child
{
get => _child;
set
{
if (value == null)
{
RemoveVisualChild(_child);
_child = value;
return;
}
AddVisualChild(value);
_child = value;
}
}
protected override int VisualChildrenCount
{
get
{
return _child != null ? 1 : 0;
}
}
protected override Size ArrangeOverride(Size finalSize)
{
var x = (adornedElement.ActualWidth - _child.DesiredSize.Width) / 2;
_child.Arrange(new Rect(new Point(x, 20), _child.DesiredSize));
return finalSize;
}
protected override Visual GetVisualChild(int index)
{
if (index == 0 && _child != null) return _child;
return base.GetVisualChild(index);
}
}
}

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace SlnMesnac.WPF.MessageTips
{
public class MessageItem : ListBoxItem
{
public MessageBoxImage MessageType
{
get { return (MessageBoxImage)GetValue(MessageTypeProperty); }
set { SetValue(MessageTypeProperty, value); }
}
public static readonly DependencyProperty MessageTypeProperty =
DependencyProperty.Register("MessageType", typeof(MessageBoxImage), typeof(MessageItem), new PropertyMetadata(MessageBoxImage.Information));
}
}

@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows;
namespace SlnMesnac.WPF.MessageTips
{
public static class Msg
{
private static MessageAdorner messageAdorner;
/// <summary>
/// 消息弹出
/// </summary>
/// <param name="message">消息内容</param>
/// <param name="msgtype">消息类型;0正常1警告2错误</param>
/// <param name="outTime">自动关闭时间。默认5秒</param>
/// <exception cref="Exception"></exception>
public static void MsgShow(string message, int msgtype, int outTime = 3)
{
try
{
if (messageAdorner != null)
{
messageAdorner.PushMessage(message, msgtype, outTime);
return;
}
Window win = null;
if (Application.Current.Windows.Count > 0)
{
win = Application.Current.Windows.OfType<Window>().FirstOrDefault(o => o.IsActive);
if (win == null)
win = Application.Current.Windows.OfType<Window>().First(o => o.IsActive);
}
var layer = GetAdornerLayer(win);
if (layer == null)
throw new Exception("not AdornerLayer is null");
messageAdorner = new MessageAdorner(layer);
layer.Add(messageAdorner);
messageAdorner.PushMessage(message, msgtype, outTime);
}catch(Exception ex)
{
Console.WriteLine("MsgShow异常:"+ex.Message);
}
}
static AdornerLayer GetAdornerLayer(Visual visual)
{
var decorator = visual as AdornerDecorator;
if (decorator != null)
return decorator.AdornerLayer;
var presenter = visual as ScrollContentPresenter;
if (presenter != null)
return presenter.AdornerLayer;
var visualContent = (visual as Window)?.Content as Visual;
return AdornerLayer.GetAdornerLayer(visualContent ?? visual);
}
}
}

@ -8,6 +8,7 @@ using SlnMesnac.Model.enums;
using SlnMesnac.Plc;
using SlnMesnac.Repository.service;
using SlnMesnac.WPF.Dto;
using SlnMesnac.WPF.MessageTips;
using SlnMesnac.WPF.Model;
using SlnMesnac.WPF.ViewModel;
using SqlSugar;
@ -44,7 +45,7 @@ namespace SlnMesnac.WPF.Page
// 设备参数实时状态
private List<DmsRealtimeStatus>? realtimeStatusList = null;
private ISqlSugarClient? sqlClient = null;
private BaseBusiness? baseBusiness = null;
private readonly ConfigInfoBusiness? _configInfoBusiness;
@ -67,7 +68,7 @@ namespace SlnMesnac.WPF.Page
dmsRecordShutDownService = App.ServiceProvider.GetService<IDmsRecordShutDownService>();
dmsRecordAlarmTimeService = App.ServiceProvider.GetService<IDmsRecordAlarmTimeService>();
dmsRealtimeStatusService = App.ServiceProvider.GetService<IDmsRealtimeStatusService>();
RecipeModeSetWindow.ManualChangeRecipeEvent += ManualChangeRecipe;
_logger = App.ServiceProvider.GetService<ILogger<DevMonitorPage>>();
_configInfoBusiness = App.ServiceProvider.GetService<ConfigInfoBusiness>();
@ -105,6 +106,8 @@ namespace SlnMesnac.WPF.Page
// HotSpiralSpeedTxt.Text = configInfos.Where(x => x.ConfigKey == "烘干机螺旋频率设定值").FirstOrDefault().ConfigValue;
//HotTempTxt.Text = configInfos.Where(x => x.ConfigKey == "烘干机温度设定值").FirstOrDefault().ConfigValue;
}
/// <summary>
@ -395,20 +398,25 @@ namespace SlnMesnac.WPF.Page
{
int status = getStopLevelByWarnStatus(warnStatusEnum);
Application.Current.Dispatcher.Invoke(() =>
{
var alarmWindow = new SystemAlarmWindow();
var viewModel = new SystemAlarmViewModel();
viewModel.AlarmMsg = warnStatusEnum.ToString();
viewModel.AlarmConfirmed += (sender, isConfirmed) =>
{
alarmWindow.Close();
};
{
Msg.MsgShow($"{warnStatusEnum.ToString()}", 2, 8);
});
alarmWindow.DataContext = viewModel;
//Application.Current.Dispatcher.Invoke(() =>
// {
// var alarmWindow = new SystemAlarmWindow();
// var viewModel = new SystemAlarmViewModel();
// viewModel.AlarmMsg = warnStatusEnum.ToString();
// viewModel.AlarmConfirmed += (sender, isConfirmed) =>
// {
// alarmWindow.Close();
// };
alarmWindow.ShowDialog();
});
if (status >= 0)
// alarmWindow.DataContext = viewModel;
// alarmWindow.ShowDialog();
// });
//if (status >= 0)
{
Task.Run(() =>
{
@ -730,22 +738,39 @@ namespace SlnMesnac.WPF.Page
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES允许远程")) == false)
{
MessageBox.Show("拆包机MES屏蔽");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("拆包机MES屏蔽!", 1, 5);
});
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES允许远程")) == false)
{
MessageBox.Show("磁选机MES屏蔽");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("磁选机MES屏蔽!", 1, 5);
});
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1MES允许远程")) == false)
{
MessageBox.Show("螺旋1MES屏蔽");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("螺旋1MES屏蔽!", 1, 5);
});
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2MES允许远程")) == false)
{
MessageBox.Show("螺旋2MES屏蔽");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("螺旋2MES屏蔽!", 1, 5);
});
return;
}
App.Current.Dispatcher.BeginInvoke((Action)(() =>
@ -798,6 +823,7 @@ namespace SlnMesnac.WPF.Page
{
StartButton.IsEnabled = true;
}));
MessageBoxAndLog("一键启动所有机器成功!");
}
@ -805,7 +831,11 @@ namespace SlnMesnac.WPF.Page
}
catch (Exception ex)
{
_logger.LogError($"一键启动异常:{ex.Message}");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"一键启动异常:{ex.Message}", 2, 5);
});
StartButton.IsEnabled = true;
}
}
@ -852,7 +882,11 @@ namespace SlnMesnac.WPF.Page
}
catch (Exception ex)
{
_logger.LogError($"一键停止:{ex.Message}");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"一键停止:{ex.Message}", 2, 5);
});
StopButton.IsEnabled = true;
}
}
@ -970,18 +1004,30 @@ namespace SlnMesnac.WPF.Page
{
if(StopUrgentButton.Content.ToString() == "复位")
{
MessageBox.Show("请先点击复位按钮");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("请先点击复位按钮!", 1, 5);
});
return;
}
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机MES允许远程")) == false)
{
MessageBox.Show("拆包机MES屏蔽");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("拆包机MES屏蔽!", 1, 5);
});
return;
}
bool unPackWarn = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("拆包机堵料停螺旋"));
if (unPackWarn)
{
MessageBox.Show("拆包机堵料停螺旋,请先处理再开机!");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("拆包机堵料停螺旋,请先处理再开机!!", 1, 5);
});
return;
}
Task.Run(() =>
@ -1056,14 +1102,23 @@ namespace SlnMesnac.WPF.Page
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES允许远程")) == false)
{
MessageBox.Show("磁选机MES屏蔽");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("磁选机MES屏蔽", 1, 5);
});
return;
}
//判断报警---
bool magNetWarn = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机设备故障反馈"));
if (magNetWarn)
{
MessageBox.Show("磁选机设备故障,请检查后再启动");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("磁选机设备故障,请检查后再启动", 1, 5);
});
return;
}
Task.Run(() =>
@ -1116,7 +1171,13 @@ namespace SlnMesnac.WPF.Page
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("除尘报警")) == true)
{
MessageBox.Show("除尘故障报警,请先点击除尘机变频器复位按钮");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("除尘故障报警,请先点击除尘机变频器复位按钮", 1, 5);
});
return false;
}
//1除尘远程启动
@ -1147,7 +1208,13 @@ namespace SlnMesnac.WPF.Page
}
catch (Exception ex)
{
MessageBox.Show($"除尘启动:{ex.Message}");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"除尘启动:{ex.Message}", 2, 5);
});
return false;
}
@ -1189,7 +1256,11 @@ namespace SlnMesnac.WPF.Page
return true;
}catch(Exception ex)
{
MessageBox.Show($"除尘停止异常:{ex.Message}");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"除尘停止异常:{ex.Message}", 2, 5);
});
_logger.LogError($"除尘停止异常:{ex.Message}");
return false;
}
@ -1210,14 +1281,23 @@ namespace SlnMesnac.WPF.Page
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1MES允许远程")) == false)
{
MessageBox.Show("螺旋1MES允许远程未切换远程");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("螺旋1MES允许远程未切换远程", 1, 5);
});
return;
}
bool spiralWarn = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1变频器状态"));
bool spira2Warn = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2变频器状态"));
if (spiralWarn || spira2Warn)
{
MessageBox.Show("螺旋1或螺旋2设备故障请检查后再启动");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("螺旋1或螺旋2设备故障请检查后再启动", 1, 5);
});
return;
}
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), true);
@ -1225,7 +1305,11 @@ namespace SlnMesnac.WPF.Page
}
catch (Exception ex)
{
MessageBoxAndLog($"螺旋1启动异常:{ex.Message}", true);
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"螺旋1启动异常:{ex.Message}", 2, 5);
});
}
return;
@ -1245,7 +1329,12 @@ namespace SlnMesnac.WPF.Page
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2MES允许远程")) == false)
{
MessageBox.Show("螺旋2MES允许远程未切换远程");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("螺旋2MES允许远程未切换远程", 1, 5);
});
return;
}
else
@ -1254,7 +1343,12 @@ namespace SlnMesnac.WPF.Page
bool spira2Warn = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2变频器状态"));
if (spiralWarn || spira2Warn)
{
MessageBox.Show("螺旋1或螺旋2设备故障请检查后再启动");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("螺旋1或螺旋2设备故障请检查后再启动", 1, 5);
});
return;
}
@ -1478,7 +1572,12 @@ namespace SlnMesnac.WPF.Page
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2MES允许远程")) == false)
{
MessageBox.Show("螺旋2MES允许远程未切换远程");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("螺旋2MES允许远程未切换远程", 1, 5);
});
result = false;
}
else
@ -1509,7 +1608,12 @@ namespace SlnMesnac.WPF.Page
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机MES允许远程")) == false)
{
MessageBox.Show("磁选机MES允许远程未切换远程");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("磁选机MES允许远程未切换远程", 1, 5);
});
return false;
}
#region 启动磁选机 / 前提:check螺旋2启动及速度是否达标
@ -1518,13 +1622,23 @@ namespace SlnMesnac.WPF.Page
int speed2 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度反馈"));
if (!startFlag)
{
MessageBox.Show($"前提条件螺旋2未成功启动,请检查后重新启动");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"前提条件螺旋2未成功启动,请检查后重新启动", 2, 5);
});
return false;
}
if (speed2 < value2 * 100 * 0.8)
{
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), false);
MessageBox.Show($"前提条件螺旋2速度{speed2}未达到设定值{value2}的下限阈值80%,请检查后重新启动");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"前提条件螺旋2速度{speed2}未达到设定值{value2}的下限阈值80%,请检查后重新启动", 2, 5);
});
return false;
}
SendPulseSignal("磁选机一键启动");
@ -1560,14 +1674,24 @@ namespace SlnMesnac.WPF.Page
{
if (plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1MES允许远程")) == false)
{
MessageBox.Show("螺旋1MES允许远程未切换远程");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"螺旋1MES允许远程未切换远程", 1, 5);
});
return false;
}
bool flag1 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机磁选启动"));
bool flag2 = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("磁选机震动启动"));
if (!flag1 || !flag2)
{
MessageBoxAndLog("前提条件磁选机未启动,请先检查设备状态再启动", true);
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"前提条件磁选机未启动,请先检查设备状态再启动", 1, 5);
});
return false;
}
@ -1580,7 +1704,12 @@ namespace SlnMesnac.WPF.Page
}
catch (Exception ex)
{
MessageBoxAndLog($"螺旋1启动异常:{ex.Message}", true);
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"螺旋1启动异常:{ex.Message}", 1, 5);
});
result = false;
}
return result;
@ -1601,13 +1730,24 @@ namespace SlnMesnac.WPF.Page
int speed1 = plc.readInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度反馈"));
if (!startFlag)
{
MessageBox.Show($"烘干机螺旋启动失败:前提条件螺旋1未成功启动,请检查后重新启动");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"烘干机螺旋启动失败:前提条件螺旋1未成功启动,请检查后重新启动", 2, 5);
});
return false;
}
if (speed1 < value1 * 100 * 0.8)
{
// plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), false);
MessageBox.Show($"烘干机螺旋启动失败:前提条件螺旋1速度{speed1}未达到设定值{value1}的下限阈值80%,请检查后重新启动");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"烘干机螺旋启动失败:前提条件螺旋1速度{speed1}未达到设定值{value1}的下限阈值80%,请检查后重新启动", 2, 5);
});
return false;
}
@ -1636,7 +1776,13 @@ namespace SlnMesnac.WPF.Page
bool startFlag = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机反馈传动启动"));
if (!startFlag)
{
MessageBox.Show($"烘干机风机启动失败:前提条件烘干机螺旋未成功启动,请检查后重新启动");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"烘干机风机启动失败:前提条件烘干机螺旋未成功启动,请检查后重新启动", 2, 5);
});
return false;
}
SendPulseSignal("烘干机风机启动");
@ -1662,7 +1808,12 @@ namespace SlnMesnac.WPF.Page
bool startFlag = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机反馈风机启动"));
if (!startFlag)
{
MessageBox.Show($"烘干机燃烧启动失败:前提条件烘干机风机未成功启动,请检查后重新启动");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow($"烘干机燃烧启动失败:前提条件烘干机风机未成功启动,请检查后重新启动", 2, 5);
});
return false;
}
int value = int.Parse(baseBusiness.GetPlcAddressByConfigKey("烘干机温度设定值"));
@ -2088,7 +2239,11 @@ namespace SlnMesnac.WPF.Page
{
_logger.LogInformation(message);
}
MessageBox.Show(message);
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow(message, isError==false?0:2, 5);
});
}
@ -2300,6 +2455,27 @@ namespace SlnMesnac.WPF.Page
window.ShowDialog();
}
private void testTips()
{
MessageBoxAndLog("一键启动所有机器成功");
Task.Run(() =>
{
while (true)
{
Thread.Sleep(7000);
Application.Current.Dispatcher.Invoke(() =>
{
Random random = new Random();
int randomValue = random.Next(0, 3); // 生成 0 到 2 之间的随机整数
Msg.MsgShow("消息提示测试", randomValue, 5);
// MessageBoxAndLog("一键启动所有机器成功");
});
}
});
}
}
}

@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Business;
using SlnMesnac.Model.domain;
using SlnMesnac.WPF.MessageTips;
using SlnMesnac.WPF.ViewModel;
using System;
using System.Collections.Generic;
@ -64,7 +65,13 @@ namespace SlnMesnac.WPF.Page
total += amount;
if(total < 0)
{
MessageBox.Show("数量不能小于0");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("数量不能小于0", 1, 5);
});
return;
}
BagsAmountTxt.Text = total.ToString();

@ -2,6 +2,7 @@
using Quartz.Util;
using SlnMesnac.Business;
using SlnMesnac.Model.domain;
using SlnMesnac.WPF.MessageTips;
using SlnMesnac.WPF.Model;
using SlnMesnac.WPF.ViewModel;
using System;
@ -48,7 +49,11 @@ namespace SlnMesnac.WPF.Page
}
else
{
MessageBox.Show("请输入合理的重量");
Msg.MsgShow("请输入合理的重量", 0, 5);
}
}
}

@ -39,6 +39,7 @@
<PackageReference Include="Lierda.WPFHelper" Version="1.0.3" />
<PackageReference Include="LiveCharts" Version="0.9.7" />
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7" />
<PackageReference Include="MaterialDesignThemes" Version="5.1.0" />
<PackageReference Include="MvvmLightLibs" Version="5.4.1.1" />
<PackageReference Include="WindowsAPICodePack-Shell" Version="1.1.1" />
</ItemGroup>

@ -7,6 +7,7 @@ using SlnMesnac.Model.dto;
using SlnMesnac.Model.enums;
using SlnMesnac.Plc;
using SlnMesnac.Repository.service;
using SlnMesnac.WPF.MessageTips;
using SqlSugar;
using System;
using System.Collections.Generic;
@ -127,12 +128,23 @@ namespace SlnMesnac.WPF.ViewModel
{
if (string.IsNullOrEmpty(targetLocation.ContainerCode) || wmsRawStock==null)
{
MessageBox.Show("该库位没有库存,请重新输入");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("该库位没有库存,请重新输入", 2, 5);
});
return;
}
if (targetLocation.LocationStatus != "1")
{
MessageBox.Show("该库位状态异常,禁止出");
Application.Current.Dispatcher.Invoke(() =>
{
Msg.MsgShow("该库位状态异常,禁止出", 2, 5);
});
return;
}
if (targetLocation.LocDeep == 1)
@ -141,7 +153,10 @@ namespace SlnMesnac.WPF.ViewModel
WmsBaseLocation? shallowLocation = sqlSugarClient.AsTenant().GetConnection("mes").Queryable<WmsBaseLocation>().Where(it => it.WarehouseId == 311 && it.LocRow==row && it.LocColumn==targetLocation.LocColumn).First();
if (shallowLocation != null && shallowLocation.LocationStatus != "1")
{
MessageBox.Show("当前库位对应的浅库位状态异常,禁止出库");
Msg.MsgShow("当前库位对应的浅库位状态异常,禁止出库", 2, 5);
return;
}
@ -159,17 +174,30 @@ namespace SlnMesnac.WPF.ViewModel
wmsRawPreferredOut.UseFlag = "1";
wmsRawPreferredOutService.Insert(wmsRawPreferredOut);
Init();
MessageBox.Show("保存成功");
Msg.MsgShow("保存成功", 0, 5);
}
else
{
MessageBox.Show("输入的库位有误,请重新输入");
Msg.MsgShow("输入的库位有误,请重新输入", 2, 5);
return;
}
}
catch (Exception ex)
{
Console.WriteLine($"保存异常:{ex.Message}");
Msg.MsgShow($"保存异常:{ex.Message}", 2, 5);
}
}

Loading…
Cancel
Save