From 88cbe5d052d4659b69c31b121a3d4b91be288f83 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Mon, 13 May 2024 09:18:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90=E6=9D=A1=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WCS.BLL/Manager/TCPClientManager.cs | 18 ++- WCS.BLL/Services/Service/GenerateService.cs | 6 +- WCS.BLL/Services/Service/InstoreService.cs | 11 +- WCS.BLL/Services/Service/OutstoreService.cs | 64 +++++---- .../Services/Service/StockTakingService.cs | 2 +- WCS.BLL/Tool/TCPClient.cs | 2 +- .../MatBaseInfo/GenerateMatInfoRequest.cs | 5 + .../StockTakingOrderMatDetailModel.cs | 8 -- .../ViewModels/MatBaseInfoViewModel.cs | 13 +- .../ViewModels/MatInventoryDetailViewModel.cs | 14 +- .../ViewModels/OutInventoryAddDucumentViewModel.cs | 14 +- .../ViewModels/OutInventoryDocumentViewModel.cs | 10 ++ 货架标准上位机/Views/MatBaseInfoView.xaml | 10 +- .../Views/MatBaseInoGenarateMatInfoView.xaml | 19 ++- .../Views/MatBaseInoGenarateMatInfoView.xaml.cs | 56 +++++++- 货架标准上位机/Views/MatInfoView.xaml | 124 +++--------------- 货架标准上位机/Views/MatInfoView.xaml.cs | 18 ++- .../Views/MatInventoryDetailView.xaml | 2 +- .../Views/OutInventoryAddDucumentView.xaml.cs | 12 +- .../Views/OutInventoryDocumentView.xaml | 7 + 货架标准上位机/Views/OutInventoryView.xaml | 38 ++++-- 货架标准上位机/Views/StockTakingView.xaml | 29 ++-- 22 files changed, 262 insertions(+), 220 deletions(-) diff --git a/WCS.BLL/Manager/TCPClientManager.cs b/WCS.BLL/Manager/TCPClientManager.cs index 3ed4036..2a11b69 100644 --- a/WCS.BLL/Manager/TCPClientManager.cs +++ b/WCS.BLL/Manager/TCPClientManager.cs @@ -21,14 +21,17 @@ namespace WCS.BLL.Manager public static List TCPClients = new List(); public static void InitTcpClient() { - var ips = DbHelp.db.Queryable().Where(t => t.ShelfCode.Contains("C")).Select(t => t.ClientIp).ToList(); + var ips = DbHelp.db.Queryable() + //.Where(t => t.ShelfCode.Contains("C")) + .Select(t => t.ClientIp) + .Distinct() + .ToList(); foreach (var ip in ips) { var tcpCleint = new TCPClient(ip, "192.168.9.183:20003"); //配置断线重连 tcpCleint.tcpClient.Received += (client, e) => { - var clientIpHost = client.IP + ":" + client.Port; var TcpCleint = TCPClientManager.GetTCPClientByIPHost(clientIpHost); if (TcpCleint == null) @@ -99,33 +102,34 @@ namespace WCS.BLL.Manager Logs.Write("协议处理完毕!"); return EasyTask.CompletedTask; }; - TCPClients.Add(tcpCleint); tcpCleint.Connect(); } } + //后台启动时给所有板子、警示灯发送复位操作 保持状态一致 public static void InitStatus() { Task.Run(() => { try { - - Thread.Sleep(1000); //给所有板子发复位 TCPClients.ForEach(tcpClient => { //板子复位 - new SmartShelfModule() { BoardId = 2047 }.Reset(tcpClient); + new SmartShelfModule() + { + BoardId = 2047 + }.Reset(tcpClient); //报警灯复位 new WarningLight().CloseLight(tcpClient); }); } catch (Exception ex) { - Logs.Write($"启动时复位异常,{ex.Message}"); + Logs.Write($"启动时复位异常,{ex.Message}"); } }); } diff --git a/WCS.BLL/Services/Service/GenerateService.cs b/WCS.BLL/Services/Service/GenerateService.cs index e0e6551..1074923 100644 --- a/WCS.BLL/Services/Service/GenerateService.cs +++ b/WCS.BLL/Services/Service/GenerateService.cs @@ -69,7 +69,7 @@ namespace WCS.BLL.Services.Service MatSn = GetMatSn(matBaseInfo, startNumber + i), MatCode = matBaseInfo.MatCode, MatName = matBaseInfo.MatName, - MatBatch = matBaseInfo.MatBatch, + MatBatch = request.MatBatch, MatSpec = matBaseInfo.MatSpec, MatUnit = matBaseInfo.MatUnit, MatSupplier = matBaseInfo.MatSupplier, @@ -107,11 +107,9 @@ namespace WCS.BLL.Services.Service private string GetMatSn(MatBaseInfo matBaseInfo, int serialNumber) { var gongshi = "=A1&\"-\"&A2&A3"; - - //var matSn = matBaseInfo.MatCode + matBaseInfo.MatBatch + serialNumber.ToString().PadLeft(6, '0'); Dictionary keyValuePairs = new Dictionary(); keyValuePairs.Add("A1", matBaseInfo.MatCode); - keyValuePairs.Add("A2", matBaseInfo.MatName); + keyValuePairs.Add("A2", string.IsNullOrEmpty(matBaseInfo.MatBatch) ? "" : matBaseInfo.MatBatch); keyValuePairs.Add("A3", serialNumber.ToString().PadLeft(6, '0')); var matSn = PnHelp.Jx(gongshi, keyValuePairs); return matSn; diff --git a/WCS.BLL/Services/Service/InstoreService.cs b/WCS.BLL/Services/Service/InstoreService.cs index 0f9a316..b568d89 100644 --- a/WCS.BLL/Services/Service/InstoreService.cs +++ b/WCS.BLL/Services/Service/InstoreService.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Runtime; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; +using System.Text.RegularExpressions; using WCS.BLL.Config; using WCS.BLL.DbModels; using WCS.BLL.HardWare; @@ -15,8 +8,6 @@ using WCS.BLL.Tool; using WCS.BLL.Tool.Api.ApiModel; using WCS.DAL.Db; using WCS.Model; -using WCS.Model.ApiModel.MatBaseInfo; -using static Dm.net.buffer.ByteArrayBuffer; namespace WCS.BLL.Services.Service { diff --git a/WCS.BLL/Services/Service/OutstoreService.cs b/WCS.BLL/Services/Service/OutstoreService.cs index fdf3e67..37c1674 100644 --- a/WCS.BLL/Services/Service/OutstoreService.cs +++ b/WCS.BLL/Services/Service/OutstoreService.cs @@ -30,7 +30,7 @@ namespace WCS.BLL.Services.Service return new ResponseBase() { Code = 201, - Message = "单据同步失败:缺少需要出库的物料类型!" + Message = "出库单据同步失败:缺少需要出库的物料类型!" }; } //保存数据 @@ -65,7 +65,7 @@ namespace WCS.BLL.Services.Service return new ResponseCommon() { Code = 200, - Message = "单据同步成功!" + Message = $"出库单据同步成功!\r\n出库单据号为{request.OrderNumber}", }; ; } catch (Exception ex) @@ -75,7 +75,7 @@ namespace WCS.BLL.Services.Service return new ResponseBase() { Code = 200, - Message = $"单据同步失败:{ex.Message}" + Message = $"出库单据同步失败:{ex.Message}" }; } } @@ -89,7 +89,7 @@ namespace WCS.BLL.Services.Service return new ResponseBase() { Code = 201, - Message = "单据同步失败:缺少物料明细!" + Message = "出库单据同步失败:缺少物料明细!" }; } //库存有无校验 & 库存已锁校验 @@ -109,7 +109,7 @@ namespace WCS.BLL.Services.Service return new ResponseCommon() { Code = 201, - Message = "单据同步失败:存在物料不在库存中!", + Message = "出库单据同步失败:存在物料不在库存中!", Data = request.SnList }; @@ -121,7 +121,7 @@ namespace WCS.BLL.Services.Service return new ResponseCommon() { Code = 201, - Message = "单据同步失败:存在物料被锁定!", + Message = "出库单据同步失败:存在物料被锁定!", Data = inventoryDetails.Where(t => t.IsLocked).Select(t => t.MatSN).ToList() }; } @@ -176,7 +176,7 @@ namespace WCS.BLL.Services.Service return new ResponseCommon() { Code = 200, - Message = $"单据同步成功!", + Message = $"出库单据同步成功!\r\n出库单据号为{request.OrderNumber}", Data = order.Id }; #endregion @@ -187,7 +187,7 @@ namespace WCS.BLL.Services.Service return new ResponseBase() { Code = 201, - Message = $"单据同步失败:{ex.Message}" + Message = $"出库单据同步失败:{ex.Message}" }; } @@ -288,7 +288,7 @@ namespace WCS.BLL.Services.Service return new ResponseCommon() { Code = 201, - Message = $"查询失败:不存在单据号为{request.OrderNumber}的出库单!", + Message = $"查询失败:不存在出库单据号为{request.OrderNumber}的出库单!", }; } } @@ -348,7 +348,7 @@ namespace WCS.BLL.Services.Service return new ResponseCommon() { Code = 201, - Message = $"查询失败:不存在单据号为{request.OrderNumber}的出库单!", + Message = $"查询失败:不存在出库单据号为{request.OrderNumber}的出库单!", }; } } @@ -406,7 +406,7 @@ namespace WCS.BLL.Services.Service //如果是按物料编码出库 需要计算物料明细、并进行物料锁定 if (order.SyncType == SyncTypeEnum.ByMatCode) { - var result = CaculateOutOrderMatDetails(order); + var result = CaculateOutOrderMatDetails(order, request.UserName); if (result.Code != 200) { return result; @@ -465,13 +465,13 @@ namespace WCS.BLL.Services.Service var matCode = outOrderDetailCount.First().bb.Key; outOrderMatDetails = outOrderMatDetails.Where(t => t.MatCode == matCode) .ToList(); - Logs.Write($"发料单{order.OrderNumber},本次亮灯物料{matCode}!"); + Logs.Write($"出库单{order.OrderNumber},本次亮灯物料{matCode}!"); } //相同物料不存在盘数超过n的情况,剩余物料全部亮灯 else { //剩余物料全出 - Logs.Write($"发料单{order.OrderNumber},剩余物料灯全亮!"); + Logs.Write($"出库单{order.OrderNumber},剩余物料灯全亮!"); } } @@ -500,7 +500,7 @@ namespace WCS.BLL.Services.Service } } //计算、加锁 - private ResponseBase CaculateOutOrderMatDetails(OutOrder order) + private ResponseBase CaculateOutOrderMatDetails(OutOrder order, string createUser = "") { try { @@ -514,7 +514,7 @@ namespace WCS.BLL.Services.Service return new ResponseCommon() { Code = 201, - Message = $"计算物料失败,{order.OrderNumber}没有单据明细!" + Message = $"计算物料失败,{order.OrderNumber}没有出库单据明细!" }; } //第二步 开始计算物料 @@ -527,7 +527,7 @@ namespace WCS.BLL.Services.Service .WhereIF(!string.IsNullOrEmpty(outOrderDetail.MatBatch), t => t.MatBatch == outOrderDetail.MatBatch) .Where(t => t.IsLocked == false)//未锁定的物料 .OrderBy(t => t.MatBatch)//先进先出 - .OrderBy(t => t.MatQty)//零散料先出 + //(t => t.MatQty)//零散料先出 .ToList(); //2.2按照搜索出来的库存和当前未出的数量 计算需要出的SN @@ -552,7 +552,7 @@ namespace WCS.BLL.Services.Service MatSupplier = matInventoryDetails[i].MatSupplier, MatCustomer = matInventoryDetails[i].MatCustomer, IsSended = false, - CreateUser = "待定", + CreateUser = createUser, }); outOrderDetail.ReqQty = 0; @@ -580,7 +580,7 @@ namespace WCS.BLL.Services.Service MatSupplier = matInventoryDetails[i].MatSupplier, MatCustomer = matInventoryDetails[i].MatCustomer, IsSended = false, - CreateUser = "待定", + CreateUser = createUser, }); matInventoryDetails[i].IsLocked = true; @@ -590,11 +590,21 @@ namespace WCS.BLL.Services.Service } DbHelp.db.Insertable(outOrderMatDetails).ExecuteCommand(); DbHelp.db.CommitTran(); - return new ResponseCommon() + if (outOrderMatDetails.Count == 0) { - Code = 200, - Message = $"Success" - }; + return new ResponseCommon() + { + Code = 201, + Message = $"计算物料失败,没有满足条件的物料进行出库!(请检查对应物料是否已被锁定)" + }; + } + else + + return new ResponseCommon() + { + Code = 200, + Message = $"Success" + }; } catch (Exception ex) { @@ -607,7 +617,7 @@ namespace WCS.BLL.Services.Service } } - //解锁 + //删除 解锁 private ResponseBase CancelOutOrderMatDetails(OutOrder order) { try @@ -618,7 +628,7 @@ namespace WCS.BLL.Services.Service .Where(t => t.IsSended == false) .ToList(); - var inventoryIds = outOrderMatDetails.Select(t => t.Id).ToList(); + var inventoryIds = outOrderMatDetails.Select(t => t.InventoryDetailId).ToList(); var inventoryDetails = DbHelp.db.Queryable() .Where(t => inventoryIds.Contains(t.Id)) .ToList(); @@ -639,7 +649,7 @@ namespace WCS.BLL.Services.Service return new ResponseCommon() { Code = 300, - Message = $"发生异常:{ex.Message}" + Message = $"解锁物料时发生异常:{ex.Message}" }; } } @@ -679,7 +689,7 @@ namespace WCS.BLL.Services.Service return new ResponseCommon() { Code = 201, - Message = $"单据【{request.OrderNumber}】不在出库中!", + Message = $"出库单据【{request.OrderNumber}】不在出库中!", Data = null }; } @@ -694,8 +704,6 @@ namespace WCS.BLL.Services.Service if (order.SyncType == SyncTypeEnum.ByMatCode) CancelOutOrderMatDetails(order); - - return new ResponseCommon() { Code = 200, diff --git a/WCS.BLL/Services/Service/StockTakingService.cs b/WCS.BLL/Services/Service/StockTakingService.cs index a5c1b95..73a10ed 100644 --- a/WCS.BLL/Services/Service/StockTakingService.cs +++ b/WCS.BLL/Services/Service/StockTakingService.cs @@ -296,7 +296,7 @@ namespace WCS.BLL.Services.Service { Data = new SysStockTakingOrderData() { StocktakingOrderNumber = request.StocktakingOrderNumber }, Code = 200, - Message = $"Success" + Message = $"生成盘点单据成功!\r\n单据号为:{request.StocktakingOrderNumber}" }; } catch (Exception ex) diff --git a/WCS.BLL/Tool/TCPClient.cs b/WCS.BLL/Tool/TCPClient.cs index def1083..2dee961 100644 --- a/WCS.BLL/Tool/TCPClient.cs +++ b/WCS.BLL/Tool/TCPClient.cs @@ -114,7 +114,7 @@ namespace WCS.BLL this.IsOnline = true; return EasyTask.CompletedTask; }; - + tcpClient.Disconnected += (client, e) => { this.IsOnline = false; diff --git a/WCS.Model/ApiModel/MatBaseInfo/GenerateMatInfoRequest.cs b/WCS.Model/ApiModel/MatBaseInfo/GenerateMatInfoRequest.cs index 889f238..d335235 100644 --- a/WCS.Model/ApiModel/MatBaseInfo/GenerateMatInfoRequest.cs +++ b/WCS.Model/ApiModel/MatBaseInfo/GenerateMatInfoRequest.cs @@ -9,6 +9,11 @@ namespace WCS.Model.ApiModel.MatBaseInfo { public MatBaseInfoModel MatBaseInfo { get; set; } + /// + /// 本次生成的批次号 + /// + public string MatBatch { get; set; } + /// /// 每盘数量 /// diff --git a/WCS.Model/ApiModel/Stocktaking/StockTakingOrderMatDetailModel.cs b/WCS.Model/ApiModel/Stocktaking/StockTakingOrderMatDetailModel.cs index 92f7995..815d18a 100644 --- a/WCS.Model/ApiModel/Stocktaking/StockTakingOrderMatDetailModel.cs +++ b/WCS.Model/ApiModel/Stocktaking/StockTakingOrderMatDetailModel.cs @@ -25,14 +25,6 @@ namespace WCS.Model.ApiModel.Stocktaking #endregion public bool IsStocktaking { get; set; } - public string IsStocktakingStr - { - get - { - return - IsStocktaking ? "是" : "否"; - } - } public int StocktakingQty { get; set; } public DateTime UpdateTime { get; set; } public string UpdateUser { get; set; } diff --git a/货架标准上位机/ViewModels/MatBaseInfoViewModel.cs b/货架标准上位机/ViewModels/MatBaseInfoViewModel.cs index 5c5d6ae..a61d065 100644 --- a/货架标准上位机/ViewModels/MatBaseInfoViewModel.cs +++ b/货架标准上位机/ViewModels/MatBaseInfoViewModel.cs @@ -311,6 +311,7 @@ namespace 货架标准上位机.ViewModel if (matBaseInfo == null) { Growl.Warning("请选择需要修改的数据!"); + return; } else { @@ -395,20 +396,10 @@ namespace 货架标准上位机.ViewModel if (matBaseInfo == null) { Growl.Warning("请勾选数据!"); + return; } var generateWindow = new MatBaseInoGenarateMatInfoView(matBaseInfo); var result = generateWindow.ShowDialog(); - - //PrintTender.PrintTag(new PrintClass() - //{ - // MatQty = "123", - // MatCode = "123", - // MatBatch = "123", - // MatName = "123", - // MatSn = "123", - // MatSpec = "123", - - //}); } #endregion diff --git a/货架标准上位机/ViewModels/MatInventoryDetailViewModel.cs b/货架标准上位机/ViewModels/MatInventoryDetailViewModel.cs index 8d133b6..03f5ebc 100644 --- a/货架标准上位机/ViewModels/MatInventoryDetailViewModel.cs +++ b/货架标准上位机/ViewModels/MatInventoryDetailViewModel.cs @@ -326,7 +326,12 @@ namespace 货架标准上位机.ViewModel var Result1 = ApiHelp.GetDataFromHttp(LocalFile.Config.ApiIpHost + "outstore/sysOutOrderByMatSn", body1, "POST"); if (Result1 != null && Result1.Code == 200) { - Growl.Success(Result1.Message); + App.Current.Dispatcher.Invoke(() => + { + dia.Close(); + dia.Collapse(); + HandyControl.Controls.MessageBox.Show(Result1.Message); + }); } else if (Result1 != null) { @@ -419,7 +424,12 @@ namespace 货架标准上位机.ViewModel var Result1 = ApiHelp.GetDataFromHttp(LocalFile.Config.ApiIpHost + "stockTaking/sysStockTakingOrder", body1, "POST"); if (Result1 != null && Result1.Code == 200) { - Growl.Success(Result1.Message); + App.Current.Dispatcher.Invoke(() => + { + dia.Close(); + dia.Collapse(); + HandyControl.Controls.MessageBox.Show(Result1.Message); + }); } else if (Result1 != null) { diff --git a/货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs b/货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs index 90bcbcd..53051e8 100644 --- a/货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs +++ b/货架标准上位机/ViewModels/OutInventoryAddDucumentViewModel.cs @@ -75,12 +75,15 @@ namespace 货架标准上位机.ViewModels } // 定义一个事件,当需要关闭窗口时触发 - public event Action RequestClose; - + public event Action TrueClose; + public event Action FalseClose; // 一个方法,当满足某些条件时调用,以触发关闭窗口 - protected virtual void OnRequestClose() + protected virtual void OnRequestClose(bool IsTrue) { - RequestClose?.Invoke(); + if (IsTrue) + TrueClose?.Invoke(); + else + FalseClose?.Invoke(); } public ICommand GenerateOutOrderCommand { get => new DelegateCommand(GenerateOutOrder); } public void GenerateOutOrder() @@ -128,11 +131,12 @@ namespace 货架标准上位机.ViewModels if (Result != null && Result.Code == 200) { Growl.Success(Result.Message); - OnRequestClose(); + OnRequestClose(true); } else if (Result != null) { Growl.Warning(Result.Message); + return; } } catch (Exception ex) diff --git a/货架标准上位机/ViewModels/OutInventoryDocumentViewModel.cs b/货架标准上位机/ViewModels/OutInventoryDocumentViewModel.cs index 82c6f6e..a62d059 100644 --- a/货架标准上位机/ViewModels/OutInventoryDocumentViewModel.cs +++ b/货架标准上位机/ViewModels/OutInventoryDocumentViewModel.cs @@ -134,6 +134,16 @@ namespace 货架标准上位机.ViewModels //} + public ICommand BtnOutOrderCommand { get => new DelegateCommand(BtnOutOrder); } + public void BtnOutOrder() + { + var window = new OutInventoryAddDucumentView(); + window.Owner = Application.Current.MainWindow; + var result = window.ShowDialog(); + if (result == true) + BtnSearch(true); + } + public ICommand BtnOrderDetailCommand { get => new DelegateCommand(BtnOrderDetail); } public void BtnOrderDetail() { diff --git a/货架标准上位机/Views/MatBaseInfoView.xaml b/货架标准上位机/Views/MatBaseInfoView.xaml index d318135..27c5b35 100644 --- a/货架标准上位机/Views/MatBaseInfoView.xaml +++ b/货架标准上位机/Views/MatBaseInfoView.xaml @@ -160,12 +160,12 @@ - - - - + + + + - + diff --git a/货架标准上位机/Views/MatBaseInoGenarateMatInfoView.xaml b/货架标准上位机/Views/MatBaseInoGenarateMatInfoView.xaml index 74f5992..1bd9a3a 100644 --- a/货架标准上位机/Views/MatBaseInoGenarateMatInfoView.xaml +++ b/货架标准上位机/Views/MatBaseInoGenarateMatInfoView.xaml @@ -42,18 +42,29 @@ - - + + + + + + + + - diff --git a/货架标准上位机/Views/MatBaseInoGenarateMatInfoView.xaml.cs b/货架标准上位机/Views/MatBaseInoGenarateMatInfoView.xaml.cs index acc45eb..e5223c8 100644 --- a/货架标准上位机/Views/MatBaseInoGenarateMatInfoView.xaml.cs +++ b/货架标准上位机/Views/MatBaseInoGenarateMatInfoView.xaml.cs @@ -2,7 +2,9 @@ using SqlSugar; using System; using System.Collections.Generic; +using System.Text.RegularExpressions; using System.Windows; +using System.Windows.Input; using WCS.BLL.DbModels; using WCS.Model; using WCS.Model.ApiModel.MatBaseInfo; @@ -34,14 +36,52 @@ namespace 货架标准上位机 private void btnOk_Click(object sender, RoutedEventArgs e) { + #region 数据校验 + if (string.IsNullOrEmpty(txtMatBatch.Text.Trim())) + { + Growl.Warning("请输入物料批次后进行操作!"); + txtMatBatch.Focus(); + return; + } + var matBatch = txtMatBatch.Text.Trim(); + if (!IsInputNumberAllowed(matBatch)) + { + Growl.Warning("【物料批次】请输入数字!"); + txtMatBatch.Focus(); + return; + //正则表达式 + //匹配年周 + //^\d{ 4}\d{ 1,2}$ + //匹配年月日 + //^\d{ 4} (0[1 - 9] | 1[0 - 2])(0[1 - 9] | [12]\d | 3[01])$ + } + + var matQty = txtMatQty.Text.Trim(); + if (!IsInputNumberAllowed(matQty)) + { + Growl.Warning("【单盘数量】请输入数字!"); + txtMatQty.Focus(); + return; + } + + var totalCount = txtTotalCount.Text.Trim(); + if (!IsInputNumberAllowed(totalCount)) + { + Growl.Warning("【物料盘数】请输入数字!"); + txtTotalCount.Focus(); + return; + } + #endregion + #region 调用接口生成条码 try { var body = new GenerateMatInfoRequest() { MatBaseInfo = matBaseInfo, - TotalCount = Convert.ToInt32(txtTotalCount.Text), - MatQty = Convert.ToInt32(txtMatQty.Text), + MatBatch = matBatch, + TotalCount = Convert.ToInt32(txtTotalCount.Text.Trim()), + MatQty = Convert.ToInt32(txtMatQty.Text.Trim()), UserName = LocalStatic.CurrentUser, DeviceType = LocalFile.Config.DeviceType, }; @@ -54,6 +94,7 @@ namespace 货架标准上位机 catch (Exception ex) { Growl.Error("加载数据失败:" + ex.Message); + return; } #endregion @@ -66,5 +107,16 @@ namespace 货架标准上位机 this.DialogResult = false; this.Close(); } + + private void txtMatBatch_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e) + { + e.Handled = !IsInputNumberAllowed(e.Text); + } + + private bool IsInputNumberAllowed(string text) + { + Regex regex = new Regex("^[0-9]+$"); // 只允许数字 + return regex.IsMatch(text); + } } } diff --git a/货架标准上位机/Views/MatInfoView.xaml b/货架标准上位机/Views/MatInfoView.xaml index 728a4b7..87e801d 100644 --- a/货架标准上位机/Views/MatInfoView.xaml +++ b/货架标准上位机/Views/MatInfoView.xaml @@ -101,19 +101,21 @@ - + - + @@ -123,13 +125,14 @@ - - - - - - - + + + + + + + + @@ -190,95 +193,6 @@ - - diff --git a/货架标准上位机/Views/MatInfoView.xaml.cs b/货架标准上位机/Views/MatInfoView.xaml.cs index c68beb7..19a7e21 100644 --- a/货架标准上位机/Views/MatInfoView.xaml.cs +++ b/货架标准上位机/Views/MatInfoView.xaml.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Web.UI.WebControls; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -37,7 +38,7 @@ namespace 货架标准上位机 if (viewModel.SelectedataGridItem != null) { viewModel.SelectedataGridItem.IsSelected = !viewModel.SelectedataGridItem.IsSelected; - dataGrid.UnselectAllCells();//取消选中 避免手动点击check选项时反选失败 和重新点击该项时反选失败 + //dataGrid.UnselectAllCells(); } } @@ -73,5 +74,20 @@ namespace 货架标准上位机 } } } + + private void DataGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + // 获取点击的 DataGridRow + var hitTestInfo = VisualTreeHelper.HitTest(dataGrid, e.GetPosition(dataGrid)); + if (hitTestInfo.VisualHit is DataGridRow row) + { + // 现在你可以根据 row 做一些事情,比如选中它(如果它还没有被选中) + if (!row.IsSelected) + { + row.IsSelected = true; + } + + } + } } } diff --git a/货架标准上位机/Views/MatInventoryDetailView.xaml b/货架标准上位机/Views/MatInventoryDetailView.xaml index db90403..d34c9be 100644 --- a/货架标准上位机/Views/MatInventoryDetailView.xaml +++ b/货架标准上位机/Views/MatInventoryDetailView.xaml @@ -79,7 +79,7 @@ Text=" 库 位 :" FontSize="18" > + FontSize="18" MinWidth="120" > + @@ -95,6 +96,12 @@ + - + --> @@ -93,7 +93,7 @@ - + - - + --> - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/货架标准上位机/Views/StockTakingView.xaml b/货架标准上位机/Views/StockTakingView.xaml index a193ab2..09ed70a 100644 --- a/货架标准上位机/Views/StockTakingView.xaml +++ b/货架标准上位机/Views/StockTakingView.xaml @@ -112,25 +112,36 @@ ItemsSource="{Binding DataGridItemSource}" RowHeight="40" AutoGenerateColumns="False" FontSize="15"> - + + + + + + + + + + + + - - - - - - - + + + + + + +