更新不刷新页面、新增多批次入库、修改调拨入库、添加账册页面、修改盘点页面、添加盘点记录页等

This commit is contained in:
maqiao 2024-02-04 13:35:45 +08:00
parent d6066ef0ca
commit 3df79378b7
109 changed files with 11038 additions and 821 deletions

View File

@ -3,7 +3,7 @@
<connectionStrings>
<!-- 数据库连接字符串 -->
<!--<add name="database" connectionString="server=127.0.0.1;database=wpf_dm_program;userid=root;password=qq1223" />-->
<add name="database" connectionString="server=127.0.0.1;port=3306;database=hkcdb;userid=root;password=root" />
<add name="database" connectionString="server=127.0.0.1;port=3306;database=hunanxianchang_db;userid=root;password=root" />
</connectionStrings>
<!--<runtime>
--><!--配置之后Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
@ -13,10 +13,14 @@
<!-- 设备id -->
<add key="machineId" value="DM1" />
<!-- 供应单位 -->
<add key="supplierDept" value="药库" />
<!-- 领用部门 -->
<add key="receiveDept" value="麻精药房" />
<!--2023/7/13 药房代码 有则写无则空 -->
<add key="storage" value="" />
<!-- 登录模式 1单人登录2双人登录 -->
<add key="loginMode" value="1" />
<add key="loginMode" value="2" />
<!-- 登录顺序,指定先登录的人的名称有效值只有在登录模式等于2时才会生效 发药人【operator】审核人【reviewer】 -->
<add key="firstLogin" value="operator" />
<!-- 按处方还药或者按取药记录还药 1:处方2药品-->
@ -24,7 +28,7 @@
<!-- 自动退出时间单位秒为0时不自动退出 -->
<add key="autoExit" value="0"/>
<!--报表数据库连接-->
<add key="gridConnectionString" value="MYSQL; Database=hkcdb; Password=root; Port=3306; Server=127.0.0.1; User=root;"/>
<add key="gridConnectionString" value="MYSQL; Database=hunanxianchang_db; Password=root; Port=3306; Server=127.0.0.1; User=root;"/>
<!-- 查询处方是orderNo还是orderGroupNo -->
<add key="OrderNoName" value="orderNo" />
<!-- 后门耗材板地址 没有则填写0-->
@ -36,11 +40,11 @@
<!-- 抽屉串口使用的协议232或者485 -->
<add key="DrawerProtocol" value="485" />
<!-- 抽屉串口的串口号 -->
<add key="DrawerPortPath" value="COM1" />
<add key="DrawerPortPath" value="COM3" />
<!-- can总线串口的串口号 -->
<add key="CanBusPortPath" value="COM5" />
<add key="CanBusPortPath" value="COM9" />
<!-- 条码枪串口的串口号 -->
<add key="ScanCodePortPath" value="COM8" />
<add key="ScanCodePortPath" value="COM11" />
<!-- 抽屉串口的串口号 --><!--
<add key="DrawerPortPath" value="COM11" />
--><!-- can总线串口的串口号 --><!--
@ -49,12 +53,12 @@
<add key="ScanPortPath" value="COM7" />-->
<!-- 指纹机类型 1无屏幕2有屏幕 -->
<!-- 指纹机类型 1无屏幕BW设备2有屏幕(TFT设备 -->
<add key="machineType" value="2"/>
<!-- 指纹机号码 -->
<add key="machineNumber" value="1"/>
<!-- 指纹机ip -->
<add key="fingerIp" value="192.168.1.201"/>
<add key="fingerIp" value="192.168.50.201"/>
<!--一个抽屉对应标签数-->
<add key="labelCount" value="2"/>

View File

@ -6,7 +6,7 @@
d1p1:Ignorable="d"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:local="clr-namespace:DM_Weight"
xmlns:prism="http://prismlibrary.com/">
xmlns:prism="http://prismlibrary.com/" Startup="PrismApplication_Startup">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

View File

@ -26,6 +26,9 @@ using System.Timers;
using DM_Weight.Models;
using SqlSugar;
using Microsoft.Extensions.DependencyInjection;
using DM_Weight.Services;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace DM_Weight
{
@ -114,7 +117,7 @@ namespace DM_Weight
// 串口工具
containerRegistry.RegisterSingleton<PortUtil>();
// 指纹机工具
//containerRegistry.RegisterSingleton<FingerprintUtil>();
containerRegistry.RegisterSingleton<FingerprintUtil>();
// 组态屏工具
containerRegistry.RegisterSingleton<ScreenUtil>();
@ -164,6 +167,8 @@ namespace DM_Weight
containerRegistry.RegisterForNavigation<SelfAddWindow, SelfAddWindowViewModel>();
// 调拨加药页面
containerRegistry.RegisterForNavigation<InvoiceInWindow, InvoiceInWindowViewModel>();
// 调拨加药页面
containerRegistry.RegisterForNavigation<InvoiceInNewWindow, InvoiceInNewWindowViewModel>();
// 调拨取药模态框
containerRegistry.RegisterDialog<InvoiceAddDialog>();
@ -173,6 +178,8 @@ namespace DM_Weight
// 自选加药模态框
containerRegistry.RegisterDialog<SelfAddDialog>();
containerRegistry.RegisterForNavigation<SelfAddDialog, SelfAddDialogViewModel>();
//多批次抽屉加药
containerRegistry.RegisterForNavigation<AddDrugControl, AddDrugControlViewModel>();
#endregion
#region
@ -200,11 +207,24 @@ namespace DM_Weight
// 库位绑定模态框
containerRegistry.RegisterDialog<BindingChannelDialog>();
containerRegistry.RegisterForNavigation<BindingChannelDialog, BindingChannelDialogViewModel>();
// 库位绑定模态框
containerRegistry.RegisterDialog<BindingChannelNewDialog>();
containerRegistry.RegisterForNavigation<BindingChannelNewDialog, BindingChannelNewDialogViewModel>();
// 库存盘点页面
containerRegistry.RegisterForNavigation<CheckStockWindow, CheckStockWindowViewModel>();
containerRegistry.RegisterDialog<CheckRecordDetailDialog>();
containerRegistry.RegisterForNavigation<CheckRecordDetailDialog, CheckRecordDetailDialogViewModel>();
// 库存盘点页面--新(类似库存列表页面)
containerRegistry.RegisterForNavigation<CheckStockNewWindow, CheckStockNewWindowViewModel>();
// 库存盘点页面--新(类似库存列表页面)
containerRegistry.RegisterForNavigation<CheckStockNew2Window, CheckStockNew2WindowViewModel>();
// 库存盘点页面--新(类似库存列表页面)
containerRegistry.RegisterForNavigation<CheckRecordNewWindow, CheckRecordNewWindowViewModel>();
// 药品列表页面
containerRegistry.RegisterForNavigation<DrugListWindow, DrugListWindowViewModel>();
//库存列表导出账册弹窗
containerRegistry.RegisterForNavigation<StockListAccountDialog, StockListAccountDialogViewModel>();
#endregion
#region
@ -239,9 +259,48 @@ namespace DM_Weight
containerRegistry.RegisterSingleton<SqlSugarScope>(() => SqlSugarHelperNew.GetInstance());
containerRegistry.RegisterForNavigation<TestCheckBox, TestCheckBoxViewModel>();
//账册页面
containerRegistry.RegisterForNavigation<AccountWindow,AccountWindowViewModel>();
//账册服务类
containerRegistry.Register<MachineRecordService>();
}
private void PrismApplication_Startup(object sender, StartupEventArgs e)
{
//获取欲启动程序名
string processName = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
//检查程序是否已经启动,已经启动则显示提示退出程序
if (System.Diagnostics.Process.GetProcessesByName(processName).Length > 1)
{
//系统在运行
RaiseOtherProcess();
Application.Current.Shutdown();
return;
}
}
private static void RaiseOtherProcess()
{
Process proc = Process.GetCurrentProcess();
foreach (Process otherProc in Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName))
{
if (proc.Id != otherProc.Id)
{
IntPtr hWnd = otherProc.MainWindowHandle;
if (IsIconic(hWnd))
{
ShowWindowAsync(hWnd, 9);
}
SetForegroundWindow(hWnd);
break;
}
}
}
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll")]
private static extern bool IsIconic(IntPtr hWnd);
//protected IServiceProvider ConfigureServices(IServiceCollection services)
//{
// // 创建 SqlSugar 实例

View File

@ -23,7 +23,15 @@ namespace DM_Weight.Converter
foreach (var item in items)
{
var de = item as ChannelStock;
total += de.Quantity;
try
{
total += de.Quantity;
}
catch (Exception)
{
var de2 = item as CheckRecordStock;
total = de2.quantity;
}
}
}
return "总库存:" + total;

View File

@ -0,0 +1,33 @@
using DM_Weight.Models;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace DM_Weight.Converter
{
public class TotalCountConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var total = 0;
if (value is List<ChannelStock> items)
{
foreach (var item in items)
{
var de = item as ChannelStock;
total += de.Quantity;
}
}
return total;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@ -70,6 +70,7 @@
<PackageReference Include="MaterialDesignThemes" Version="4.8.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Prism.Unity" Version="8.1.97" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.67" />
<PackageReference Include="SuperSimpleTcp" Version="3.0.10" />
@ -87,6 +88,12 @@
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Compile Update="Views\CheckStockNew2Window.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="App.config">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
@ -106,6 +113,12 @@
<None Update="ReportTemp\machine_log_check.grf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="ReportTemp\machine_log_check_new.grf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="ReportTemp\machine_log_check_new2.grf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="ReportTemp\machine_log_return.grf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

View File

@ -20,22 +20,22 @@ namespace DM_Weight.Finger
{
private readonly ILog logger = LogManager.GetLogger(typeof(FingerprintUtil));
public zkemkeeper.CZKEMClass axCZKEM1; //= new zkemkeeper.CZKEMClass();
public zkemkeeper.CZKEMClass axCZKEM1;// = new zkemkeeper.CZKEMClass();
public bool bIsConnected = false;
private string fingerIp = ConfigurationManager.AppSettings["fingerIp"]?.ToString()??"";
private string fingerIp = ConfigurationManager.AppSettings["fingerIp"]?.ToString() ?? "";
private int fingerPort = 4370;
private int machineNumber = Convert.ToInt32(ConfigurationManager.AppSettings["machineNumber"]?.ToString()??"0");
private int machineType = Convert.ToInt32(ConfigurationManager.AppSettings["machineType"]?.ToString()??"0");
private int machineNumber = Convert.ToInt32(ConfigurationManager.AppSettings["machineNumber"]?.ToString() ?? "0");
private int machineType = Convert.ToInt32(ConfigurationManager.AppSettings["machineType"]?.ToString() ?? "0");
private readonly IEventAggregator _eventAggregator;
public FingerprintUtil(IEventAggregator eventAggregator)
{
_eventAggregator = eventAggregator;
logger.Info($"进入构造器,开始连接指纹机");
Task.Run(() =>
{
// Task.Factory.StartNew(() =>
//{
ConnectionMain();
});
//});
}
public void ConnectionMain()
@ -47,7 +47,7 @@ namespace DM_Weight.Finger
logger.Info($"连接指纹机,IP:{fingerIp},端口:{fingerPort},机器号:{machineNumber},连接结果:{bIsConnected}");
if (bIsConnected)
{
if (axCZKEM1.RegEvent(machineNumber, 65535))
if (axCZKEM1.RegEvent(machineNumber, 9))
{
this.axCZKEM1.OnAttTransactionEx += new zkemkeeper._IZKEMEvents_OnAttTransactionExEventHandler(axCZKEM1_OnAttTransactionEx);
//this.axCZKEM1.OnEnrollFinger += new zkemkeeper._IZKEMEvents_OnEnrollFingerEventHandler(axCZKEM1_OnEnrollFinger);
@ -62,7 +62,7 @@ namespace DM_Weight.Finger
Result = bIsConnected,
});
}
catch(Exception ex)
catch (Exception ex)
{
logger.Info($"连接指纹机异常{ex.Message.ToString()}");
}
@ -90,10 +90,10 @@ namespace DM_Weight.Finger
Id = iEnrollNumber,
FingerIndex = iFingerIndex
};
axCZKEM1.StartIdentify();
axCZKEM1.RefreshData(1);
logger.Info($"触发用户登记指纹事件用户id:{iEnrollNumber}指纹索引:{iFingerIndex}登记结果:{(iActionResult == 0)}");
message.Result = (iActionResult == 0);
_eventAggregator.GetEvent<FingerprintEvent>().Publish(message);
@ -161,8 +161,16 @@ namespace DM_Weight.Finger
bool result = false;
// 取消其他操作
bool res2 = axCZKEM1.CancelOperation();
// 删除源指纹
bool res = axCZKEM1.DelUserTmp(machineNumber, Id, FingerIndex);
if (machineType == 1)
{
// 删除源指纹
bool res = axCZKEM1.DelUserTmp(machineNumber, Id, FingerIndex);
}
else
{
// 删除源指纹
bool res = axCZKEM1.SSR_DelUserTmp(machineNumber, Id.ToString(), FingerIndex);
}
// 添加新指纹
result = axCZKEM1.StartEnrollEx(Id.ToString(), FingerIndex, 3);
return result;

View File

@ -0,0 +1,87 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.Models
{
/// <summary>
/// 账册
/// </summary>
public class AccountModel
{
/// <summary>
/// 总结存
/// </summary>
public int StockQuantity { get; set; }
/// <summary>
/// 借入数量
/// </summary>
public int InQuantity { get; set; }
/// <summary>
/// 发出数量
/// </summary>
public int OutQuantity { get; set; }
/// <summary>
/// 日期
/// </summary>
public string OperationTime { get; set; }
/// <summary>
/// 凭证号
/// </summary>
public string InvoiceId { get;set; }
/// <summary>
/// 药品名称
/// </summary>
public string DrugName { get; set; }
/// <summary>
/// 药品ID
/// </summary>
public string DrugId { get; set; }
/// <summary>
/// 单位
/// </summary>
public string PackUnit { get; set; }
/// <summary>
/// 剂型
/// </summary>
public string Dosage { get; set; }
/// <summary>
/// 厂家
/// </summary>
public string Manufactory { get; set; }
/// <summary>
/// 批次
/// </summary>
public string ManuNo { get;set; }
/// <summary>
/// 效期
/// </summary>
public string EffDate { get; set; }
/// <summary>
/// 操作人
/// </summary>
public string OperatorName { get;set; }
/// <summary>
/// 复核人
/// </summary>
public string ReviewerName { get; set; }
/// <summary>
/// 规格
/// </summary>
public string DrugSpec { get; set; }
public DrugInfo DrugInfo { get; set; }
/// <summary>
/// 供应单位
/// </summary>
public string SupplierDept { get; set; }
/// <summary>
/// 领用部门
/// </summary>
public string ReceiveDept { get; set; }
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.Models
{
/// <summary>
/// 账册类型
/// </summary>
public class AccountType
{
/// <summary>
/// 账册类型名称
/// </summary>
public string AccountTypeName { get; set; }
/// <summary>
/// 账册类型值
/// </summary>
public int AccountTypeValue { get; set; }
}
}

View File

@ -0,0 +1,184 @@
using Prism.Commands;
using Prism.Mvvm;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.Models
{
[SugarTable("channel_list")]
public class ChannelList : BindableBase
{
/// <summary>
///
///</summary>
[SugarColumn(ColumnName = "chnguid", IsPrimaryKey = true)]
//[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
public string Id { get; set; }
/// <summary>
///
/// 默认值: NULL
///</summary>
[SugarColumn(ColumnName = "machine_id")]
public string MachineId { get; set; }
/// <summary>
///
/// 默认值: NULL
///</summary>
[SugarColumn(ColumnName = "row_no")]
public int DrawerNo { get; set; }
/// <summary>
///
/// 默认值: NULL
///</summary>
[SugarColumn(ColumnName = "col_no")]
public int ColNo { get; set; }
/// <summary>
///
/// 默认值: NULL
///</summary>
[SugarColumn(ColumnName = "pos_no")]
public int PosNo { get; set; }
/// <summary>
///
/// 默认值: NULL
///</summary>
[SugarColumn(ColumnName = "drug_id")]
public string DrugId { get; set; }
///// <summary>
/////
///// 默认值: NULL
/////</summary>
//[SugarColumn(ColumnName = "manu_no")]
//public string ManuNo { get; set; }
///// <summary>
/////
///// 默认值: NULL
/////</summary>
//[SugarColumn(ColumnName = "eff_date")]
//public string EffDate { get; set; }
///// <summary>
/////
///// 默认值: NULL
/////</summary>
//[SugarColumn(ColumnName = "quantity")]
//public int Quantity { get; set; }
/// <summary>
///
/// 默认值: 1
///</summary>
[SugarColumn(ColumnName = "drawer_type")]
public int DrawerType { get; set; }
/// <summary>
///
/// 默认值: 1
///</summary>
[SugarColumn(ColumnName = "board_type")]
public int BoardType { get; set; }
/// <summary>
///
/// 默认值: 1
///</summary>
[SugarColumn(ColumnName = "state")]
public int? State { get; set; }
[SugarColumn(IsIgnore = true)]
public bool IsSelected { get; set; }
[SugarColumn(IsIgnore = true)]
public InOutInvoice Invoice { get; set; }
[SugarColumn(IsIgnore = true)]
public string Location
{
get => DrawerNo + "-" + ColNo;
}
//private int _addQuantity = 0;
//[SugarColumn(IsIgnore = true)]
//public int AddQuantity
//{
// get => _addQuantity;
// set
// {
// SetProperty(ref _addQuantity, value);
// }
//}
//private int _takeQuantity = 0;
//[SugarColumn(IsIgnore = true)]
//public int TakeQuantity
//{
// get => _takeQuantity;
// set
// {
// if (value > Quantity)
// {
// throw new ArgumentException("取药数量不能大于库存");
// }
// SetProperty(ref _takeQuantity, value);
// }
//}
//private int _returnQuantity = 0;
//[SugarColumn(IsIgnore = true)]
//public int ReturnQuantity
//{
// get => _returnQuantity;
// set
// {
// SetProperty(ref _returnQuantity, value);
// }
//}
//private int _checkQuantity = 0;
//[SugarColumn(IsIgnore = true)]
//public int CheckQuantity
//{
// get => _checkQuantity;
// set
// {
// if (value < 0)
// {
// throw new ArgumentException("盘点数量不能是负数");
// }
// SetProperty(ref _checkQuantity, value);
// }
//}
//[SugarColumn(IsIgnore = true)]
//public int? CanReturnQuantity { get; set; }
private DrugInfo? _DrugInfo;
[Navigate(NavigateType.ManyToOne, nameof(DrugId))]
public DrugInfo Drug { get => _DrugInfo; set => SetProperty(ref _DrugInfo, value); }
//[SugarColumn(IsIgnore = true)]
//public int process { get; set; } = 0;
private DrugManuNo? _drugManuNo;
[SugarColumn(IsIgnore = true)]
public DrugManuNo? drugManuNo { get => _drugManuNo; set => SetProperty(ref _drugManuNo, value); }
private List<ChannelStock>? _channelStocks;
[Navigate(NavigateType.OneToMany, nameof(ChannelStock.Chnguid))]
public List<ChannelStock> channelStocks { get => _channelStocks; set => SetProperty(ref _channelStocks, value); }
public int _totalCount;
[SugarColumn(IsIgnore = true)]
public int totalCount { get => _totalCount;set=> SetProperty(ref _totalCount, value); }
}
}

View File

@ -19,6 +19,8 @@ namespace DM_Weight.Models
//[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
public string Id { get; set; }
[SugarColumn(ColumnName = "chnguid")]
public string Chnguid { get; set; }
/// <summary>
///
/// 默认值: NULL
@ -185,5 +187,10 @@ namespace DM_Weight.Models
//private string _manuNoEffDate;
//[SugarColumn(IsIgnore = true)]
//public string ManuNoEffDate { get => _manuNoEffDate; set => SetProperty(ref _manuNoEffDate, value); }
private ChannelList? _channelList;
[Navigate(NavigateType.ManyToOne, nameof(Chnguid))]
public ChannelList ChannelLst { get => _channelList; set => SetProperty(ref _channelList, value); }
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.Models
{
public class ChannelStockCount
{
public int DrawerNo { get; set; }
public int ColNo { get; set; }
public string DrugId { get; set; }
public string ManuNo { get;set; }
public int Quantity { get;set; }
public string EffDate { get; set; }
public string DrugName { get; set; }
public string DrugSpec { get; set; }
public string Dosage { get;set; }
public string ManuFactory { get;set; }
public string SmallUnit { get;set; }
public string PackUnit { get; set; }
public string MachineId { get; set; }
}
}

View File

@ -0,0 +1,94 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.Models
{
/// <summary>
/// 盘点后药品库存数
/// </summary>
[SugarTable("check_stock")]
public class CheckRecordStock
{
[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
public int ID { get; set; }
/// <summary>
/// 抽屉号
/// </summary>
[SugarColumn(ColumnName = "row_no")]
public int rowNo { get; set; }
/// <summary>
/// 列号
/// </summary>
[SugarColumn(ColumnName = "col_no")]
public int colNo { get; set; }
/// <summary>
/// 数量
/// </summary>
[SugarColumn(ColumnName = "quantity")]
public int quantity { get; set; }
/// <summary>
/// 批次
/// </summary>
[SugarColumn(ColumnName = "manu_no")]
public string manuNo { get; set; }
/// <summary>
/// 效期
/// </summary>
[SugarColumn(ColumnName = "eff_date")]
public string effDate { get; set; }
/// <summary>
/// 药品名称
/// </summary>
[SugarColumn(ColumnName = "drug_name")]
public string drugName { get; set; }
/// <summary>
/// 规格
/// </summary>
[SugarColumn(ColumnName = "drug_spec")]
public string drugSpec { get; set; }
//
[SugarColumn(ColumnName = "pack_unit")]
public string packUnit { get; set; }
/// <summary>
/// 厂商
/// </summary>
[SugarColumn(ColumnName = "manufactory")]
public string manufactory { get; set; }
[SugarColumn(ColumnName = "max_stock")]
public int maxStock { get; set; }
[SugarColumn(ColumnName = "drug_id")]
public string drugId { get; set; }
[SugarColumn(ColumnName = "machine_id")]
public string MachineId { get; set; }
/// <summary>
/// 批次总库存
/// </summary>
[SugarColumn(ColumnName = "manuQuantity")]
public int ManuQuantity { get; set; }
/// <summary>
/// 操作时间
/// </summary>
[SugarColumn(ColumnName = "optdate")]
public string optdate { get; set; }
/// <summary>
/// 操作人
/// </summary>
[SugarColumn(ColumnName = "operator")]
public string operatorUser { get; set; }
/// <summary>
/// 审核人
/// </summary>
[SugarColumn(ColumnName = "reviewer")]
public string reviewerUser { get; set; }
[SugarColumn(IsIgnore =true)]
public List<CheckRecordStock> manuNoDetails { get;set; }
[Navigate(NavigateType.ManyToOne, nameof(drugId))]
public DrugInfo DrugInfo { get; set; }
}
}

View File

@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.Models
{
internal class Class1
{
}
/// <summary> /// 行政区表
/// /// </summary>
public class DistrictModel
{ /// <summary> /// 主键 /// </summary>
private int id; /// <summary> /// 代码 /// </summary>
private int code; /// <summary> /// 名称 /// </summary>
private string name;
public int Id { get { return id; } set { id = value; } }
/// <summary> /// 代码 /// </summary>
public int Code { get { return code; } set { code = value; } }
/// <summary> /// 名称 /// </summary>
public string Name { get { return name; } set { name = value; } }
}
/// <summary> /// 表 /// </summary>
public class MapSpotModel
{
private int id; //名称
private string name; //代码
private int code; //个数
private int allNumber; //面积
private double allArea;
private int hCTureNumber;
private double hCTrueArea;
/// <summary>
/// 通过个数
/// </summary>
private int hCTruePassNumber; //不通过个数
private int hCTrueNoPassNumber; //通过率
private string hCTruePassingRate; //个数
private int jLTureNumber; //面积
private double jLTrueArea; //通过个数
private int jLTruePassNumber; //不通过个数
private int jLTrueNoPassNumber; //通过率
private string jLTruePassingRate;
private DistrictModel districtModels;
public int Id { get { return id; } set { id = value; } }
/// <summary> /// 名称 /// </summary>
public string Name { get { return name; } set { name = value; } } /// <summary> /// 代码 /// </summary>
public int Code { get { return code; } set { code = value; } } /// <summary> /// 个数 /// </summary>
public int AllNumber { get { return allNumber; } set { allNumber = value; } } /// <summary> /// 面积 /// </summary>
public double AllArea { get { return allArea; } set { allArea = value; } } /// <summary> /// 个数 /// </summary>
public int HCTureNumber { get { return hCTureNumber; } set { hCTureNumber = value; } } /// <summary> /// 面积 /// </summary>
public double HCTrueArea { get { return hCTrueArea; } set { hCTrueArea = value; } }
/// <summary> /// 通过个数 /// </summary>
public int HCTruePassNumber { get { return hCTruePassNumber; } set { hCTruePassNumber = value; } }
/// /// <summary> /// 不通过个数 /// </summary>
public int HCTrueNoPassNumber { get { return hCTrueNoPassNumber; } set { hCTrueNoPassNumber = value; } }
/// /// <summary> /// 通过率 /// </summary>
public string HCTruePassingRate { get { return hCTruePassingRate; } set { hCTruePassingRate = value; } } /// <summary> /// 个数 /// </summary>
public int JLTureNumber { get { return jLTureNumber; } set { jLTureNumber = value; } }
/// <summary> /// 面积 /// </summary>
public double JLTrueArea { get { return jLTrueArea; } set { jLTrueArea = value; } }
/// /// <summary> /// 通过个数 /// </summary>
public int JLTruePassNumber { get { return jLTruePassNumber; } set { jLTruePassNumber = value; } }
/// /// <summary> /// 不通过个数 /// </summary>
public int JLTrueNoPassNumber { get { return jLTrueNoPassNumber; } set { jLTrueNoPassNumber = value; } }
/// /// <summary> /// 监理单位已审核图斑-通过率 /// </summary>
public string JLTruePassingRate { get { return jLTruePassingRate; } set { jLTruePassingRate = value; } }
public DistrictModel DistrictModels { get { return districtModels; } set { districtModels = value; } }
}
}

View File

@ -145,5 +145,11 @@ namespace DM_Weight.Models
[SugarColumn(ColumnName = "cancel_flag")]
public int CancelFlag { get; set; }
[SugarColumn(IsIgnore =true)]
public int CountNum { get; set; }
[SugarColumn(IsIgnore =true)]
public int SumQuantity { get; set; }
}
}

View File

@ -143,5 +143,15 @@ namespace DM_Weight.Models
/// </summary>
[SugarColumn(ColumnName = "manunoQuantity")]
public int? ManunoQuantity { get; set; }
/// <summary>
/// 供应单位
/// </summary>
[SugarColumn(ColumnName = "supplierDept")]
public string SupplierDept { get; set; }
/// <summary>
/// 领用部门
/// </summary>
[SugarColumn(ColumnName = "receiveDept")]
public string ReceiveDept { get; set; }
}
}

View File

@ -63,9 +63,9 @@ namespace DM_Weight.Port
// 取药操作的窗口名【处方取药、抽屉取药、自选取药、调拨出库】
private string[] TakeNames = new string[] { "DrawerTakeDrugWindow", "OrderTakeDrugWindow", "SelfTakeDrugWindow", "InvoiceTakeDrugWindow" };
// 加药操作的窗口名【自选加药、抽屉加药、还药】
private string[] AddNames = new string[] { "SelfAddWindow", "ReturnDrugWindow", "ReturnDrug1Window", "DrawerAddDrugWindow" };
private string[] AddNames = new string[] { "SelfAddWindow", "ReturnDrugWindow", "ReturnDrug1Window", "DrawerAddDrugWindow", "AddDrugControl" };
// 盘点操作的窗口名【盘点】
private string[] CheckNames = new string[] { "CheckStockWindow" };
private string[] CheckNames = new string[] { "CheckStockWindow", "CheckStockNewWindow" };
// 归还空瓶操作的窗口名【盘点】
private string[] ReturnEmptyNames = new string[] { "ReturnEmptyWindow" };
@ -85,7 +85,7 @@ namespace DM_Weight.Port
public DateTime dateTime { get; set; } = DateTime.Now;
public async void ResetData()
public async Task ResetData()
{
logger.Info($"重新设置串口数据状态【{statue}】,抽屉【{DrawerNo}】");
if (!"HomeWindow".Equals(WindowName) && statue == 1)
@ -112,7 +112,7 @@ namespace DM_Weight.Port
}
if (BoardType == 5)
{
await WriteQuantityArray();
//await WriteQuantityArray();
}
}
Operate = false;
@ -139,9 +139,10 @@ namespace DM_Weight.Port
if (BoardType == 4)
{
byte[] result = await OpenStorage();
logger.Info($"储物箱使能返回:" + Convert.ToHexString(result));
int[] r = result.Select(it => Convert.ToInt32(it)).ToArray();
logger.Info($"储物箱使能返回:" + string.Join("", r));
logger.Info($"储物箱使能返回:{Convert.ToHexString(result)}");
if (r[4] != 0)
{
logger.Info($"储物箱使能成功");
@ -151,6 +152,7 @@ namespace DM_Weight.Port
else
{
string _WindowName = WindowName;
logger.Info($"储物箱使能失败r:" + string.Join("", r));
// 重新初始化数据
ResetData();
// 指令发送错误,未打开
@ -161,7 +163,6 @@ namespace DM_Weight.Port
WindowName = _WindowName,
Message = "储物箱使能失败"
});
logger.Info($"储物箱使能失败r:" + string.Join("", r));
}
}
else
@ -190,6 +191,7 @@ namespace DM_Weight.Port
else
{
string _WindowName = WindowName;
logger.Info($"回收箱打开失败");
// 重新初始化数据
ResetData();
// 返回消息开启失败
@ -200,7 +202,6 @@ namespace DM_Weight.Port
WindowName = _WindowName,
Message = "回收箱打开失败"
});
logger.Info($"回收箱打开失败");
}
}
}
@ -300,6 +301,7 @@ namespace DM_Weight.Port
{
string _WindowName = WindowName;
statue = 1;
logger.Info(ex.Message);
// 重新初始化数据
ResetData();
// 返回消息 抽屉打开失败
@ -309,7 +311,6 @@ namespace DM_Weight.Port
WindowName = _WindowName,
Message = $"操作异常{ex.Message}"
});
logger.Info(ex.Message);
}
}
@ -439,15 +440,16 @@ namespace DM_Weight.Port
await BoxLockLightOff2();
}
string _WindowName = WindowName;
logger.Info($"抽屉【{DrawerNo}】已关闭");
// 重新初始化数据
ResetData();
await ResetData();
// 返回消息 抽屉已经关闭
_eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
{
EventType = util.EventType.DRAWERCLOSE,
WindowName = _WindowName,
});
logger.Info($"抽屉【{DrawerNo}】已关闭");
}
}
@ -456,6 +458,7 @@ namespace DM_Weight.Port
{
string _WindowName = WindowName;
logger.Info($"GetDrawerStatus异常{ex.Message}");
// 重新初始化数据
ResetData();
_eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
@ -464,7 +467,6 @@ namespace DM_Weight.Port
WindowName = _WindowName,
Message = $"GetDrawerStatus异常{ex.Message}"
});
logger.Info($"GetDrawerStatus异常{ex.Message}");
}
}
@ -552,9 +554,9 @@ namespace DM_Weight.Port
statue = 2;
string _WindowName = WindowName;
logger.Info($"储物箱关闭");
// 重新初始化数据
ResetData();
logger.Info($"储物箱关闭");
_eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
{
EventType = util.EventType.DRAWERCLOSE,
@ -587,6 +589,8 @@ namespace DM_Weight.Port
catch (Exception ex)
{
logger.Info($"GetBackDoorState异常{ex.Message}");
// 重新初始化数据
ResetData();
}
}
@ -665,7 +669,44 @@ namespace DM_Weight.Port
}
if (_length != length)
{
throw new TimeoutException($"串口【{serialPort.PortName}】交互超时");
if(_length!=0)
{
byte[] _buffer = new byte[_length];
serialPort.Read(_buffer, 0, _length);
logger.Info($"交互超时回复:{Convert.ToHexString(buffer)}");
}
throw new TimeoutException($"串口【{serialPort.PortName}】交互超时");
}
serialPort.Read(buffer, 0, length);
//}
//catch (Exception ex)
//{
// logger.Error($"GetBufferByPort{ex.Message}");
//}
return buffer;
}
private byte[] GetBufferByPort(SerialPort serialPort, int length, int timeout,string operation)
{
byte[] buffer = new byte[length];
//try
//{
int _length = 0;
DateTime start = DateTime.Now;
DateTime end = DateTime.Now;
while (_length != length && end.Subtract(start).TotalMilliseconds < timeout)
{
_length = serialPort.BytesToRead;
end = DateTime.Now;
}
if (_length != length)
{
if (_length != 0)
{
byte[] _buffer = new byte[_length];
serialPort.Read(_buffer, 0, _length);
logger.Info($"交互超时回复:{Convert.ToHexString(buffer)},{operation}");
}
throw new TimeoutException($"串口【{serialPort.PortName}】交互超时,操作为{operation}");
}
serialPort.Read(buffer, 0, length);
//}
@ -681,6 +722,11 @@ namespace DM_Weight.Port
return Task.Run(() => GetBufferByPort(serialPort, length, 3000));
}
private Task<byte[]> GetBufferByPort(SerialPort serialPort, int length,string operation)
{
return Task.Run(() => GetBufferByPort(serialPort, length, 3000,operation));
}
public static SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
public void SpeakAsync(string textinfo)
@ -764,9 +810,9 @@ namespace DM_Weight.Port
canBusSerial.DiscardInBuffer();
byte[] buffer = new byte[] { 0xaa, (byte)(_doorAddr), 0x01, (byte)_storageBoxAddr, 0x00, 0x00, 0x00, 0xee };
canBusSerial.Write(buffer, 0, 8);
logger.Info($"OpenStorage:{string.Join("", buffer)}");
logger.Info($"OpenStorage:{Convert.ToHexString(buffer)}");
return await GetBufferByPort(canBusSerial, 8);
return await GetBufferByPort(canBusSerial, 8,"开储物箱");
}
// 关闭电控门储物箱(有灯失能)
public void CloseStorage()
@ -806,9 +852,9 @@ namespace DM_Weight.Port
Array.Reverse(schar);
int[] iArray = Array.ConvertAll(schar, c => (int)Char.GetNumericValue(c));
int[] addArray = new int[8 - iArray.Length];
if(iArray.Length<8)
if (iArray.Length < 8)
{
for (int i = 0; i < 8- iArray.Length; i++)
for (int i = 0; i < 8 - iArray.Length; i++)
{
addArray[i] = 0;
}
@ -837,7 +883,7 @@ namespace DM_Weight.Port
byte[] buffer = new byte[] { 0xaa, (byte)(0xf0 + DrawerNo), 0x01, 0x00, 0x00, 0x00, 0x00, 0xee };
logger.Info($"单支板发送库位数量查询【{string.Join(",", buffer)}】");
logger.Info($"单支板发送库位数量查询【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
return await GetBufferByPort(canBusSerial, 13);
@ -969,6 +1015,7 @@ namespace DM_Weight.Port
{
try
{
logger.Info($"写标签数据:{type}-{content}-{drawerNo}-{colNo}");
canBusSerial.DiscardInBuffer();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
byte[] contentBuf = Encoding.GetEncoding("gb2312").GetBytes(trim(content));
@ -1071,6 +1118,39 @@ namespace DM_Weight.Port
}
// 写入数量
public void WriteQuantity(int drawerNo, int colNo, int quantity)
{
try
{
logger.Info($"写入数量:{drawerNo}-{colNo}-{quantity}");
canBusSerial.DiscardInBuffer();
int channel = ((drawerNo > 8 ? (drawerNo - 8) * 2 : (drawerNo * 2 - 1)) - 1) * this.labelCount + 10 + colNo;
byte[] buffer = new byte[] { 0xaa, (byte)channel, 0x21, 0, 0, 0, 0, 0xee };
buffer[5] = (byte)(quantity >> 8);
buffer[6] = (byte)(quantity & 0xff);
logger.Info($"写入数量buffer:{Convert.ToHexString(buffer)}");
canBusSerial.Write(buffer, 0, 8);
Task<byte[]> task = GetBufferByPort(canBusSerial, 8);
if (task.Status == TaskStatus.Created)
{
task.Start();
}
byte[] bytes = task.Result;
logger.Info($"写入数量返回:" + Convert.ToHexString(bytes));
}
catch (Exception ex)
{
_eventAggregator.GetEvent<PortUtilEvent>().Publish(new util.DeviceMsg()
{
EventType = util.EventType.OPENERROR,
WindowName = WindowName,
Message = $"操作发生异常{ex.InnerException}"
});
logger.Info($"操作发生异常ex:{ex.InnerException}");
}
}
// 写入数量
public async void WriteQuantityAsync(int drawerNo, int colNo, int quantity)
{
try
{
@ -1080,6 +1160,8 @@ namespace DM_Weight.Port
buffer[5] = (byte)(quantity >> 8);
buffer[6] = (byte)(quantity & 0xff);
canBusSerial.Write(buffer, 0, 8);
byte[] bufferReturn=await GetBufferByPort(canBusSerial, 8);
logger.Info($"写入数量返回:" + Convert.ToHexString(bufferReturn));
}
catch (Exception ex)
{
@ -1114,7 +1196,7 @@ namespace DM_Weight.Port
byte[] buffer = new byte[] { 0xAA, 0x9A, 0x04, 0x00, 0x00, 0x00, 0x00, 0xEE };
canBusSerial.Write(buffer, 0, 8);
return await GetBufferByPort(canBusSerial, 8);
return await GetBufferByPort(canBusSerial, 8, "打开回收箱");
}
catch (Exception ex)
{
@ -1188,14 +1270,14 @@ namespace DM_Weight.Port
canBusSerial.DiscardInBuffer();
var channel = Convert.ToInt32((DrawerNo * 10 + 1).ToString(), 16);
byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x28, 0x00, 0x00, 0x00, 0x00, 0xee };
logger.Info($"称重发送库位数量查询1【{string.Join(",", buffer)}】");
logger.Info($"称重发送库位数量查询1【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
byte[] result1 = await GetBufferByPort(canBusSerial, 8);
var channel2 = Convert.ToInt32((DrawerNo * 10 + 2).ToString(), 16);
byte[] buffer2 = new byte[] { 0xaa, (byte)(channel2), 0x28, 0x00, 0x00, 0x00, 0x00, 0xee };
logger.Info($"称重发送库位数量查询2【{string.Join(",", buffer2)}】");
logger.Info($"称重发送库位数量查询2【{Convert.ToHexString(buffer2)}】");
canBusSerial.Write(buffer2, 0, 8);
byte[] result2 = await GetBufferByPort(canBusSerial, 8);
@ -1221,10 +1303,10 @@ namespace DM_Weight.Port
var channel = Convert.ToInt32((DrawerNo * 10 + index).ToString(), 16);
byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x27, (byte)lock1, 0x00, 0x00, 0x00, 0xee };
logger.Info($"称重发送库位数量查询1【{string.Join(",", buffer)}】");
logger.Info($"称重发送库位数量查询1【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
byte[] result = await GetBufferByPort(canBusSerial, 8);
logger.Info($"称重发送库位数量查询1返回结果【{string.Join(",", result)}】");
logger.Info($"称重发送库位数量查询1返回结果【{Convert.ToHexString(result)}】");
byte[] hl = result.Skip(3).Take(2).ToArray();
int quantity = BitConverter.ToInt16(hl.Reverse().ToArray(), 0);
res[ColNos[i] - 1] = quantity;
@ -1243,7 +1325,7 @@ namespace DM_Weight.Port
var lock1 = ColNos[i] % 3 == 0 ? 3 : ColNos[i] % 3;
var channel = Convert.ToInt32((DrawerNo * 10 + index).ToString(), 16);
byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x03, (byte)lock1, 0x00, 0x00, 0x00, 0xee };
logger.Info($"称重发送药盒使能【{string.Join(",", buffer)}】");
logger.Info($"称重发送药盒使能【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
await Task.Delay(TimeSpan.FromMilliseconds(500));
}
@ -1258,7 +1340,7 @@ namespace DM_Weight.Port
var lock1 = ColNos[i] % 3 == 0 ? 3 : ColNos[i] % 3;
var channel = Convert.ToInt32((DrawerNo * 10 + index).ToString(), 16);
byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x04, (byte)lock1, 0x00, 0x00, 0x00, 0xee };
logger.Info($"称重发送药盒失能【{string.Join(",", buffer)}】");
logger.Info($"称重发送药盒失能【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
await Task.Delay(TimeSpan.FromMilliseconds(50));
}
@ -1274,7 +1356,7 @@ namespace DM_Weight.Port
var channel = Convert.ToInt32((DrawerNo * 10 + index).ToString(), 16);
byte[] buffer = new byte[] { 0xaa, (byte)(channel), 0x25, (byte)lock1, 0x00, 0x00, 0x00, 0xee };
logger.Info($"称重发送清空计数【{string.Join(",", buffer)}】");
logger.Info($"称重发送清空计数【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
}
catch (Exception ex)
@ -1305,7 +1387,7 @@ namespace DM_Weight.Port
buffer[5] = (byte)(Quantity & 0xff);
logger.Info($"称重发送数量【{string.Join(",", buffer)}】");
logger.Info($"称重发送数量【{Convert.ToHexString(buffer)}】");
canBusSerial.Write(buffer, 0, 8);
}
catch (Exception ex)

View File

@ -53,7 +53,32 @@ namespace DM_Weight.Report
Report.DetailGrid.Recordset.QuerySQL = SQL;
Report.PrintPreview(true);
}
public static void PrintReportAccountBook(DateTime? startDate, DateTime? endDate,string drug_id)
/// <summary>
/// 导出盘点后库存信息
/// </summary>
/// <param name="startDate"></param>
/// <param name="endDate"></param>
public static void PrintReportStockNew(DateTime? startDate, DateTime? endDate)
{
DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1);
// 定义Grid++Report报表主对象
GridppReport Report = new GridppReport();
//Report.Initialize += new _IGridppReportEvents_InitializeEventHandler(() =>
//{
// Report.ParameterByName("machine_id").Value = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
//});
string machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
string SQL = $@"SELECT cl.`row_no` AS drawerNo,cl.`col_no` AS colNo,cl.`quantity` AS quantity,cl.`manu_no` AS manuNo,cl.`eff_date` AS effDate,
`drug_name` AS drugName,`drug_spec` AS drugSpec,`pack_unit` AS packUnit,`manufactory` AS manuFactory,`max_stock` AS baseQuantity,
cl.`drug_id` AS drugId,cl.manuquantity, cl.`optdate` FROM check_stock cl WHERE cl.`machine_id` = '{machine_id}' AND cl.`optdate` > '{p_startDate}' AND cl.`optdate` < '{p_endDate}' ORDER BY cl.`optdate` desc, cl.`drug_id`";
// 加载模板文件
Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//" + "machine_log_check_new2.grf");
Report.DetailGrid.Recordset.ConnectionString = gridConnectionString;
Report.DetailGrid.Recordset.QuerySQL = SQL;
Report.PrintPreview(true);
}
public static void PrintReportAccountBook(DateTime? startDate, DateTime? endDate,int type,string drug_id)
{
DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1);
@ -71,19 +96,36 @@ namespace DM_Weight.Report
Report.ParameterByName("endDate").Value = endDate ?? DateTime.Now.AddDays(1);
});
//Report.DetailGrid.Recordset.QuerySQL = SQL;
SQL = $@"SELECT mr.`stock_quantity` AS `stockQuantity`, IF(mr.`type` IN (1, 31), mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` > 0, mr.`quantity`, 0))
SQL = $@"SELECT TYPE, stockQuantity,inQuantity,outQuantity,operationTime,invoiceId,drugName,drugId,drugSpec,packUnit,dosage,manufactory,manuNo,effDate,
operatorName,reviewerName,supplierDept,receiveDept,bigUnit FROM
(SELECT mr.type, mr.`stock_quantity` AS `stockQuantity`, IF(mr.`type` IN (1, 31), mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` > 0, mr.`quantity`, 0))
AS `inQuantity`, IF(mr.`type` = 2, mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` < 0, (0 - mr.`quantity`), 0)) AS `outQuantity`,
mr.`operation_time` AS `operationTime`,IF(mr.`type`=1,mr.`invoice_id`,NULL) AS `invoiceId`, di.`drug_name` AS `drugName`, di.`drug_id` AS `drugId`,
di.`drug_spec` AS `drugSpec`, di.`pack_unit` AS `packUnit`, di.`dosage` AS `dosage`, di.`manufactory` AS `manufactory`,
mr.`manu_no` AS `manuNo`, mr.`eff_date` AS `effDate`, u1.`user_name` AS `operatorName`, u2.`user_name` AS `reviewerName` FROM
di.`drug_spec` AS `drugSpec`, di.`pack_unit` AS `packUnit`,di.big_unit as bigUnit, di.`dosage` AS `dosage`, di.`manufactory` AS `manufactory`,
mr.`manu_no` AS `manuNo`, mr.`eff_date` AS `effDate`, u1.`user_name` AS `operatorName`, u2.`user_name` AS `reviewerName`,mr.supplierDept,mr.receiveDept FROM
dm_machine_record mr LEFT JOIN drug_info di ON mr.`drug_id` = di.`drug_id` LEFT JOIN user_list u1 ON mr.`operator` = u1.`id`
LEFT JOIN user_list u2 ON mr.`reviewer` = u2.`id` WHERE mr.`machine_id` = '{p_machine_id}' AND mr.`operation_time` > '{p_startDate}'
AND mr.`operation_time` < '{p_endDate}' ";
AND mr.`operation_time` < '{p_endDate}' and IF(mr.`type` = 4 AND mr.`quantity` = 0, 99999, mr.`quantity`) <>99999 ";
if(!string.IsNullOrEmpty(drug_id))
{
SQL+= " AND mr.drug_id='"+ drug_id+"' ";
}
SQL+="ORDER BY mr.`drug_id`, mr.`operation_time`, mr.`id`";
SQL+= " ORDER BY mr.`drug_id`, mr.`operation_time`, mr.`id`) AS T";
if (type > 0)
{
if (type == 1)
{
SQL += " WHERE inQuantity>0 ";
}
if (type == 2)
{
SQL += " WHERE outQuantity>0 ";
}
if (type == 5)
{
SQL += " WHERE type=5 ";
}
}
Report.DetailGrid.Recordset.QuerySQL = SQL;
Report.PrintPreview(true);
}
@ -203,5 +245,25 @@ namespace DM_Weight.Report
Report.DetailGrid.Recordset.QuerySQL = SQL;
Report.PrintPreview(true);
}
/// <summary>
/// 盘点页面导出记录,按选中行进行导出
/// </summary>
/// <param name="type"></param>
/// <param name="startDate"></param>
/// <param name="endDate"></param>
public static void PrintReportMechineRecordForSelect(List<MachineRecord> data)
{
// 定义Grid++Report报表主对象
GridppReport Report = new GridppReport();
// 加载模板文件
Report.LoadFromFile(new FileInfo(AppDomain.CurrentDomain.BaseDirectory) + "ReportTemp//machine_log_check.grf");
Dictionary<string,List<MachineRecord>> records = new Dictionary<string,List<MachineRecord>>();
records.Add("table", data);
string str= JsonConvert.SerializeObject(records);
Report.LoadDataFromXML(str);
// 加载数据
Report.PrintPreview(true);
}
}
}

View File

@ -15,7 +15,6 @@
},
"DetailGrid":{
"CenterView":true,
"AppendBlankRow":true,
"Recordset":{
"Field":[
{
@ -75,7 +74,7 @@
},
{
"Name":"单位",
"DBFieldName":"packUnit"
"DBFieldName":"bigUnit"
},
{
"Name":"剂型",
@ -105,6 +104,14 @@
{
"Name":"凭证号",
"DBFieldName":"invoiceId"
},
{
"Name":"供应单位",
"DBFieldName":"supplierDept"
},
{
"Name":"领用部门",
"DBFieldName":"receiveDept"
}
]
},
@ -222,11 +229,11 @@
"FreeCell":true,
"Control":[
{
"Type":"StaticBox",
"Name":"StaticBox6",
"Type":"FieldBox",
"Name":"FieldBox14",
"Dock":"Fill",
"TextAlign":"MiddleCenter",
"Text":"药库"
"DataField":"供应单位"
}
]
},
@ -235,11 +242,11 @@
"FreeCell":true,
"Control":[
{
"Type":"StaticBox",
"Name":"StaticBox7",
"Type":"FieldBox",
"Name":"FieldBox15",
"Dock":"Fill",
"TextAlign":"MiddleCenter",
"Text":"门诊药房11"
"DataField":"领用部门"
}
]
}

View File

@ -13,7 +13,6 @@
},
"DetailGrid":{
"CenterView":true,
"AppendBlankRow":true,
"Recordset":{
"QuerySQL":"SELECT \r\n dmr.`drawer_no` AS drawerNo,\r\n dmr.`col_no` AS colNo,\r\n dmr.`type` AS `type`,\r\n dmr.`quantity` AS quantity,\r\n dmr.`manu_no` AS manuNo,\r\n dmr.`eff_date` AS effDate,\r\n dmr.`operation_time` AS operationTime,\r\n di.`drug_name` AS drugName,\r\n di.`drug_spec` AS drugSpec,\r\n di.`pack_unit` AS packUnit,\r\n di.`manufactory` AS manuFactory,\r\n di.`max_stock` AS baseQuantity,\r\n dmr.`drug_id` AS drugId,\r\n ul.`user_name` AS nickname\r\nFROM\r\n dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` = 1 \r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate",
"Field":[

View File

@ -13,7 +13,6 @@
},
"DetailGrid":{
"CenterView":true,
"AppendBlankRow":true,
"Recordset":{
"QuerySQL":"SELECT \r\n dmr.`drawer_no` AS drawerNo,\r\n dmr.`col_no` AS colNo,\r\n dmr.`type` AS `type`,\r\n dmr.`quantity` AS quantity,\r\n dmr.`manu_no` AS manuNo,\r\n dmr.`eff_date` AS effDate,\r\n dmr.`operation_time` AS operationTime,\r\n di.`drug_name` AS drugName,\r\n di.`drug_spec` AS drugSpec,\r\n di.`pack_unit` AS packUnit,\r\n di.`manufactory` AS manuFactory,\r\n di.`max_stock` AS baseQuantity,\r\n dmr.`drug_id` AS drugId,\r\n ul.`user_name` AS nickname\r\nFROM\r\n dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` = 4 \r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate",
"Field":[
@ -60,6 +59,10 @@
"Name":"type2",
"Type":"Integer",
"DBFieldName":"type"
},
{
"Name":"规格",
"DBFieldName":"drugSpec"
}
]
},
@ -80,6 +83,10 @@
"Name":"药品名称",
"Width":4.63021
},
{
"Name":"规格",
"Width":1.69333
},
{
"Name":"数量",
"Width":1.98438
@ -119,6 +126,10 @@
"TextAlign":"MiddleCenter",
"DataField":"药品名称"
},
{
"Column":"规格",
"DataField":"规格"
},
{
"Column":"数量",
"TextAlign":"MiddleCenter",
@ -210,6 +221,18 @@
"TextAlign":"MiddleCenter",
"Text":"药品名称"
},
{
"GroupTitle":false,
"Column":"规格",
"Font":{
"Name":"宋体",
"Size":120000,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"规格"
},
{
"GroupTitle":false,
"Column":"数量",

View File

@ -0,0 +1,313 @@
{
"Version":"6.3.0.1",
"Font":{
"Name":"宋体",
"Size":105000,
"Weight":400,
"Charset":134
},
"Printer":{
"Oriention":"Landscape"
},
"DetailGrid":{
"CenterView":true,
"PrintAdaptMethod":"ResizeToFit",
"Recordset":{
"QuerySQL":"SELECT \r\n cl.`row_no` AS drawerNo,\r\n cl.`col_no` AS colNo,\r\n cl.`quantity` AS quantity,\r\n cl.`manu_no` AS manuNo,\r\n cl.`eff_date` AS effDate,\r\n di.`drug_name` AS drugName,\r\n di.`drug_spec` AS drugSpec,\r\n di.`pack_unit` AS packUnit,\r\n di.`manufactory` AS manuFactory,\r\n di.`max_stock` AS baseQuantity,\r\n cl.`drug_id` AS drugId\r\nFROM\r\n channel_stock cl\r\nINNER JOIN drug_info di ON di.`drug_id` = cl.`drug_id`\r\nWHERE cl.`machine_id` = :machine_id\r\n AND cl.`drawer_type` = 1\r\n ORDER BY cl.`drug_id`",
"Field":[
{
"Name":"drugName"
},
{
"Name":"drugSpec"
},
{
"Name":"manuFactory"
},
{
"Name":"quantityCount",
"Type":"Integer"
},
{
"Name":"manuNo"
},
{
"Name":"effDate"
},
{
"Name":"quantity",
"Type":"Integer",
"Format":"0"
},
{
"Name":"drawerNo"
},
{
"Name":"drugId"
},
{
"Name":"baseQuantity",
"Type":"Integer"
},
{
"Name":"manuquantity",
"Type":"Integer"
},
{
"Name":"optDate",
"DBFieldName":"optdate"
}
]
},
"Column":[
{
"Name":"optDate",
"Width":4.20688
},
{
"Name":"drugName",
"Width":4.57729
},
{
"Name":"drugSpec"
},
{
"Name":"manuFactory",
"Width":4.60375
},
{
"Name":"quantityCount",
"Width":2.19604
},
{
"Name":"manuNo"
},
{
"Name":"effDate",
"Width":2.61938
},
{
"Name":"quantity",
"Width":1.42875
}
],
"ColumnContent":{
"Height":0.79375,
"ColumnContentCell":[
{
"Column":"optDate",
"DataField":"optDate"
},
{
"Column":"drugName",
"TextAlign":"MiddleCenter",
"DataField":"drugName"
},
{
"Column":"drugSpec",
"TextAlign":"MiddleCenter",
"DataField":"drugSpec"
},
{
"Column":"manuFactory",
"TextAlign":"MiddleCenter",
"DataField":"manuFactory"
},
{
"Column":"quantityCount",
"FreeCell":true,
"Control":[
{
"Type":"MemoBox",
"Name":"MemoBox1",
"Dock":"Fill",
"Text":"[#Sum(manuquantity)#]"
}
]
},
{
"Column":"manuNo",
"TextAlign":"MiddleCenter",
"DataField":"manuNo"
},
{
"Column":"effDate",
"TextAlign":"MiddleCenter",
"DataField":"effDate"
},
{
"Column":"quantity",
"TextAlign":"MiddleCenter",
"DataField":"manuquantity"
}
]
},
"ColumnTitle":{
"Height":1.19063,
"RepeatStyle":"OnPage",
"ColumnTitleCell":[
{
"GroupTitle":false,
"Column":"optDate",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"盘点日期"
},
{
"GroupTitle":false,
"Column":"drugName",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"药品名称"
},
{
"GroupTitle":false,
"Column":"drugSpec",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"规格"
},
{
"GroupTitle":false,
"Column":"manuFactory",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"厂家"
},
{
"GroupTitle":false,
"Column":"quantityCount",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"总库存"
},
{
"GroupTitle":false,
"Column":"manuNo",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"批次"
},
{
"GroupTitle":false,
"Column":"effDate",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"效期"
},
{
"GroupTitle":false,
"Column":"quantity",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"数量"
}
]
},
"Group":[
{
"Name":"Group2",
"ByFields":"optDate",
"GroupHeader":{
"Height":0.635,
"OccupyColumn":true,
"OccupiedColumns":"optDate",
"VAlign":"Middle"
},
"GroupFooter":{
"Visible":false,
"Height":0
}
},
{
"Name":"drugId",
"ByFields":"drugId",
"GroupHeader":{
"Visible":false,
"Height":0.79375,
"RepeatOnPage":true,
"OccupyColumn":true,
"IncludeFooter":true,
"OccupiedColumns":"drugName;drugSpec;manuFactory;quantityCount",
"VAlign":"Middle"
},
"GroupFooter":{
"Visible":false,
"Height":0
}
}
]
},
"Parameter":[
{
"Name":"machine_id",
"Value":"DM1"
}
],
"ReportHeader":[
{
"Name":"ReportHeader1",
"Height":2.40771,
"Control":[
{
"Type":"StaticBox",
"Name":"StaticBox1",
"Center":"Horizontal",
"Left":8.22854,
"Top":0.608542,
"Width":9.18104,
"Height":1.21708,
"Font":{
"Name":"宋体",
"Size":217500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"毒麻药品盘点后库存信息"
}
],
"RepeatOnPage":true
}
]
}

View File

@ -0,0 +1,278 @@
{
"Version":"6.3.0.1",
"Font":{
"Name":"宋体",
"Size":105000,
"Weight":400,
"Charset":134
},
"Printer":{
"LeftMargin":1,
"TopMargin":1,
"RightMargin":1,
"BottomMargin":1
},
"DetailGrid":{
"Recordset":{
"Field":[
{
"Name":"盘点日期",
"DBFieldName":"optDate"
},
{
"Name":"药品名称",
"DBFieldName":"drugName"
},
{
"Name":"drugId"
},
{
"Name":"规格",
"DBFieldName":"drugSpec"
},
{
"Name":"厂家",
"DBFieldName":"manuFactory"
},
{
"Name":"总库存",
"DBFieldName":"quantity"
},
{
"Name":"批次",
"DBFieldName":"manuNo"
},
{
"Name":"效期",
"DBFieldName":"effDate"
},
{
"Name":"数量",
"DBFieldName":"manuquantity"
}
]
},
"Column":[
{
"Name":"盘点日期",
"Width":2.56646
},
{
"Name":"药品名称",
"Width":2.80458
},
{
"Name":"规格",
"Width":2.01083
},
{
"Name":"厂家",
"Width":2.98979
},
{
"Name":"总库存",
"Width":1.69333
},
{
"Name":"批次",
"Width":2.06375
},
{
"Name":"效期",
"Width":2.19604
},
{
"Name":"数量",
"Width":1.69333
}
],
"ColumnContent":{
"Height":0.79375,
"ColumnContentCell":[
{
"Column":"盘点日期",
"DataField":"盘点日期"
},
{
"Column":"药品名称",
"DataField":"药品名称"
},
{
"Column":"规格",
"DataField":"规格"
},
{
"Column":"厂家",
"DataField":"厂家"
},
{
"Column":"总库存",
"DataField":"总库存"
},
{
"Column":"批次",
"DataField":"批次"
},
{
"Column":"效期",
"DataField":"效期"
},
{
"Column":"数量",
"DataField":"数量"
}
]
},
"ColumnTitle":{
"Height":1.19063,
"RepeatStyle":"OnPage",
"ColumnTitleCell":[
{
"GroupTitle":false,
"Column":"盘点日期",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"盘点日期"
},
{
"GroupTitle":false,
"Column":"药品名称",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"药品名称"
},
{
"GroupTitle":false,
"Column":"规格",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"规格"
},
{
"GroupTitle":false,
"Column":"厂家",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"厂家"
},
{
"GroupTitle":false,
"Column":"总库存",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"总库存"
},
{
"GroupTitle":false,
"Column":"批次",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"批次"
},
{
"GroupTitle":false,
"Column":"效期",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"效期"
},
{
"GroupTitle":false,
"Column":"数量",
"Font":{
"Name":"宋体",
"Size":142500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"数量"
}
]
},
"Group":[
{
"Name":"Group1",
"ByFields":"盘点日期",
"GroupHeader":{
"Height":0.635,
"OccupyColumn":true,
"OccupiedColumns":"盘点日期",
"VAlign":"Middle"
},
"GroupFooter":{
"Height":0
}
},
{
"Name":"Group2",
"ByFields":"drugId",
"GroupHeader":{
"Height":0.635,
"OccupyColumn":true,
"OccupiedColumns":"药品名称;厂家;规格;总库存",
"VAlign":"Middle"
},
"GroupFooter":{
"Height":0
}
}
]
},
"ReportHeader":[
{
"Name":"ReportHeader1",
"Height":1.32292,
"Control":[
{
"Type":"MemoBox",
"Name":"MemoBox1",
"Dock":"Fill",
"Font":{
"Name":"宋体",
"Size":157500,
"Bold":true,
"Charset":134
},
"TextAlign":"MiddleCenter",
"Text":"毒麻药品盘点后库存信息"
}
]
}
]
}

View File

@ -13,7 +13,6 @@
},
"DetailGrid":{
"CenterView":true,
"AppendBlankRow":true,
"Recordset":{
"QuerySQL":"SELECT \r\n dmr.`drawer_no` AS drawerNo,\r\n dmr.`col_no` AS colNo,\r\n dmr.`type` AS `type`,\r\n CONCAT(dmr.`quantity`,IF(dmr.`type`=32,\"(空瓶)\",\"\")) AS quantity,\r\n dmr.`manu_no` AS manuNo,\r\n dmr.`eff_date` AS effDate,\r\n dmr.`operation_time` AS operationTime,\r\n di.`drug_name` AS drugName,\r\n di.`drug_spec` AS drugSpec,\r\n di.`pack_unit` AS packUnit,\r\n di.`manufactory` AS manuFactory,\r\n di.`max_stock` AS baseQuantity,\r\n dmr.`drug_id` AS drugId,\r\n ul.`user_name` AS nickname\r\nFROM\r\n dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` in (31, 32)\r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate",
"Field":[

View File

@ -13,7 +13,6 @@
},
"DetailGrid":{
"CenterView":true,
"AppendBlankRow":true,
"Recordset":{
"QuerySQL":"SELECT \r\n dmr.`drawer_no` AS drawerNo,\r\n dmr.`col_no` AS colNo,\r\n dmr.`type` AS `type`,\r\n dmr.`quantity` AS quantity,\r\n dmr.`manu_no` AS manuNo,\r\n dmr.`eff_date` AS effDate,\r\n dmr.`operation_time` AS operationTime,\r\n di.`drug_name` AS drugName,\r\n di.`drug_spec` AS drugSpec,\r\n di.`pack_unit` AS packUnit,\r\n di.`manufactory` AS manuFactory,\r\n di.`max_stock` AS baseQuantity,\r\n dmr.`drug_id` AS drugId,\r\n ul.`user_name` AS nickname\r\nFROM\r\n dm_machine_record dmr\r\nLEFT JOIN drug_info di ON di.`drug_id` = dmr.`drug_id`\r\nLEFT JOIN user_list ul ON ul.`id` = dmr.`Operator`\r\nWHERE dmr.`type` = 2 \r\n AND dmr.`machine_id` = :machine_id\r\n AND dmr.`operation_time` > :startDate\r\n AND dmr.`operation_time` < :endDate",
"Field":[

View File

@ -12,7 +12,6 @@
"DetailGrid":{
"CenterView":true,
"PrintAdaptMethod":"ResizeToFit",
"AppendBlankRow":true,
"Recordset":{
"QuerySQL":"SELECT \r\n cl.`row_no` AS drawerNo,\r\n cl.`col_no` AS colNo,\r\n cl.`quantity` AS quantity,\r\n cl.`manu_no` AS manuNo,\r\n cl.`eff_date` AS effDate,\r\n di.`drug_name` AS drugName,\r\n di.`drug_spec` AS drugSpec,\r\n di.`pack_unit` AS packUnit,\r\n di.`manufactory` AS manuFactory,\r\n di.`max_stock` AS baseQuantity,\r\n cl.`drug_id` AS drugId\r\nFROM\r\n channel_stock cl\r\nINNER JOIN drug_info di ON di.`drug_id` = cl.`drug_id`\r\nWHERE cl.`machine_id` = :machine_id\r\n AND cl.`drawer_type` = 1\r\n ORDER BY cl.`drug_id`",
"Field":[

View File

@ -0,0 +1,37 @@
using DM_Weight.Models;
using DM_Weight.util;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.Services
{
public class ChannelStockService
{
////private SqlSugarScope SqlSugarHelper.Db;
//public ChannelStockService(SqlSugarScope sqlSugarScope)
//{
// //this.SqlSugarHelper.Db = sqlSugarScope;
//}
public List<ChannelStockCount> GetAll()
{
string p_machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
string SQL = $@"SELECT CS.drug_id as DrugId,CS.manu_no as ManuNo,sum(quantity) as Quantity,CS.eff_date as EffDate,DI.drug_name as DrugName,
DI.drug_spec as DrugSpec,DI.dosage as Dosage,DI.manufactory as ManuFactory,DI.small_unit as SmallUnit,DI.pack_unit as PackUnit,
CS.machine_id as MachineId FROM channel_stock CS
INNER JOIN drug_info DI ON CS.drug_id=DI.drug_id where CS.machine_id='{p_machine_id}' AND quantity>0 GROUP BY CS.drug_id,CS.manu_no ";
List<ChannelStockCount> accountList = SqlSugarHelper.Db.SqlQueryable<ChannelStockCount>(SQL).ToList();
//List<ChannelStock> accountList = SqlSugarHelper.Db.Queryable<ChannelStock>().Includes<DrugInfo>(cs=>cs.DrugInfo)
// .GroupBy(cs=>new { cs.DrugId, cs.ManuNo })
// .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"]??"DM1"))
// .Where(cs=>cs.Quantity>0)
// .ToList();
return accountList;
}
}
}

View File

@ -0,0 +1,79 @@
using DM_Weight.Models;
using DM_Weight.util;
using DM_Weight.Views.Dialog;
using gregn6Lib;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.Services
{
/// <summary>
/// 账册服务类
/// </summary>
public class MachineRecordService
{
////private SqlSugarScope SqlSugarHelper.Db;
public MachineRecordService()
{
////this.SqlSugarHelper.Db = sqlSugarScope;
}
public List<AccountModel> ReportAccountBook(DateTime? startDate, DateTime? endDate,int type, string drug_id="")
{
DateTime? p_startDate = startDate ?? Convert.ToDateTime("2010-1-1");
DateTime? p_endDate = endDate ?? DateTime.Now.AddDays(1);
string p_machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
string SQL = $@"SELECT TYPE, stockQuantity,inQuantity,outQuantity,operationTime,invoiceId,drugName,drugId,drugSpec,packUnit,dosage,manufactory,manuNo,effDate,
operatorName,reviewerName,supplierDept,receiveDept FROM
(SELECT mr.type,mr.`stock_quantity` AS `stockQuantity`, IF(mr.`type` IN (1, 31), mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` > 0, mr.`quantity`, 0))
AS `inQuantity`, IF(mr.`type` = 2, mr.`quantity`, IF(mr.`type` = 4 AND mr.`quantity` < 0, (0 - mr.`quantity`), 0)) AS `outQuantity`,
DATE_FORMAT(mr.`operation_time`,'%m/%d') AS `operationTime`,IF(mr.`type`=1,mr.`invoice_id`,NULL) AS `invoiceId`, di.`drug_name` AS `drugName`, di.`drug_id` AS `drugId`,
di.`drug_spec` AS `drugSpec`, di.`pack_unit` AS `packUnit`, di.`dosage` AS `dosage`, di.`manufactory` AS `manufactory`,
mr.`manu_no` AS `manuNo`, DATE_FORMAT(mr.`eff_date`,'%y/%m/%d') AS `effDate`, u1.`user_name` AS `operatorName`, u2.`user_name` AS `reviewerName`,mr.supplierDept,mr.receiveDept FROM
dm_machine_record mr LEFT JOIN drug_info di ON mr.`drug_id` = di.`drug_id` LEFT JOIN user_list u1 ON mr.`operator` = u1.`id`
LEFT JOIN user_list u2 ON mr.`reviewer` = u2.`id` WHERE mr.`machine_id` = '{p_machine_id}' AND mr.`operation_time` > '{p_startDate}'
AND mr.`operation_time` < '{p_endDate}' and IF(mr.`type` = 4 AND mr.`quantity` = 0, 99999, mr.`quantity`) <>99999 ";
if (!string.IsNullOrEmpty(drug_id))
{
SQL += " AND mr.drug_id='" + drug_id + "' ";
}
SQL += " ORDER BY mr.`drug_id`, mr.`operation_time`, mr.`id`) AS T";
if(type>0)
{
if(type==1)
{
SQL += " WHERE inQuantity>0 ";
}
if(type==2)
{
SQL += " WHERE outQuantity>0 ";
}
if(type==5)
{
SQL += " WHERE type=5 ";
}
}
//ChannelStocks = q.Select(it => { it.CheckQuantity = it.Quantity; return it; }).ToList();
List<AccountModel> accountList = SqlSugarHelper.Db.SqlQueryable<AccountModel>(SQL)
.AddParameters(new
{
machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1"
})
//.Select(it => new { o = new AccountModel(), i = new DrugInfo() })
//.Select(it=>new AccountModel())
//.Select("*") //让上面一行不生成sql
.ToList();
//List<AccountModel> accountList=new List<AccountModel>();
return accountList;
}
}
}

View File

@ -0,0 +1,54 @@
using DM_Weight.Models;
using MySqlConnector;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.Services
{
public class UserService
{
//public static string connStr = ConfigurationManager.AppSettings["database"].ToString();
public static string connStr = ConfigurationManager.ConnectionStrings["database"].ToString();
public UserList CheckUserByFingerPrinter(int fingerPrinterId)
{
UserList? user = null;
using (MySqlConnection con = new MySqlConnection(connStr))
{
con.Open();
string sql = @"select ul.id as id,ul.User_name as userName,r.id,r.role_name,r.permissions,r.machine_id from user_list ul
INNER JOIN role r on ul.machine_role_id=r.id where ul.Id=@ID and ul.machine_id=@machine_id and r.machine_id=@machine_id;";
MySqlCommand cmd = new MySqlCommand(sql, con);
cmd.Parameters.Clear();
MySqlParameter[] mySqlParameter = new MySqlParameter[] {new MySqlParameter("ID", fingerPrinterId),new MySqlParameter("machine_id", (ConfigurationManager.AppSettings["machineId"] ?? "DM1")) };
cmd.Parameters.AddRange(mySqlParameter);
//执行语句
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
user = new UserList();
user.Id = reader.GetInt32("id");
user.UserName = reader["userName"] is DBNull ? "" : reader.GetString("userName");
//user.UserName = reader["id"] is DBNull ? "" : reader.GetString("id");
user.Nickname= reader["userName"] is DBNull ? "" : reader.GetString("userName");
user.MachineId = reader["machine_id"] is DBNull ? "" : reader.GetString("machine_id");
RoleDm role= new RoleDm();
role.Id= reader.GetInt32("id");
//role.Permissions = reader["permissions"] is DBNull ? "" : reader.GetString("permissions");
role.RoleName = reader["role_name"] is DBNull ? "" : reader.GetString("role_name");
role.Permissions = JsonConvert.DeserializeObject<List<PremissionDm>>(reader["permissions"] is DBNull ? "" : reader.GetString("permissions")); // JsonConvert.SerializeObject(reader.GetString("permissions")).ToList();
user.Role = role;
}
reader.Close();
return user;
}
}
}
}

View File

@ -0,0 +1,414 @@
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Report;
using DM_Weight.Services;
using DM_Weight.util;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace DM_Weight.ViewModels
{
public class AccountWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
{
public static AccountWindowViewModel vm;
//private int _pageNum = 1;
//public int PageNum
//{
// get => _pageNum;
// set
// {
// SetProperty(ref _pageNum, value);
// RequestData();
// }
//}
//private int _pageCount = 1;
//public int PageCount
//{
// get => _pageCount;
// set
// {
// SetProperty(ref _pageCount, value);
// }
//}
//private int _pageSize = 8;
//public int PageSize
//{
// get => _pageSize;
// set
// {
// SetProperty(ref _pageSize, value);
// }
//}
//private int _totalCount = 0;
//public int TotalCount
//{
// get => _totalCount;
// set
// {
// SetProperty(ref _totalCount, value);
// }
//}
private DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
private DateTime? nowDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
public DateTime? StartDate
{
get => _startDate;
set
{
if (value != null)
{
SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0));
}
else
{
SetProperty(ref _startDate, value);
}
RequestData();
}
}
private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
public DateTime? EndDate
{
get => _endDate;
set
{
if (value != null)
{
TimeSpan ershisi = new TimeSpan(23, 59, 59);
SetProperty(ref _endDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0, 23, 59, 59));
}
else
{
SetProperty(ref _endDate, value);
}
RequestData();
}
}
private static readonly DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
/// <summary>
/// 账册
/// </summary>
private List<AccountModel> _accountList = new();
public List<AccountModel> AccountList
{
get => _accountList;
set => SetProperty(ref _accountList, value);
}
/// <summary>
/// 药品
/// </summary>
private List<DrugInfo>? _drugInfos;
public List<DrugInfo>? DrugInfos
{
get => _drugInfos;
set => SetProperty(ref _drugInfos, value);
}
private DrugInfo? _drugInfo;
public DrugInfo? DrugInfo
{
get => _drugInfo;
set
{
SetProperty(ref _drugInfo, value);
//if (_drugInfo != null)
//{
//DrugManuNos = _drugInfo.DrugManuNos.OrderByDescending(dm => dm.ManuNo).ToList();
//}
RequestData();
}
}
/// <summary>
/// 账册类型1入2出3总结存
/// </summary>
private List<AccountType> _accountTypeList = new List<AccountType>() {
new AccountType
{
AccountTypeName="借入",
AccountTypeValue=1
},
new AccountType
{
AccountTypeName="发出",
AccountTypeValue=2
},
new AccountType
{
AccountTypeName="日结存",
AccountTypeValue=5
}
};
public List<AccountType>? AccountTypeList
{
get => _accountTypeList;
set
{
SetProperty(ref _accountTypeList, value);
RequestData();
}
}
private AccountType? _accountType;
public AccountType AccountType
{
get => _accountType;
set
{
SetProperty(ref _accountType, value);
RequestData();
}
}
MachineRecordService _machineRecordService;
ChannelStockService _channelStockService;
IEventAggregator _eventAggregator;
////private SqlSugarScope SqlSugarHelper.Db;
public AccountWindowViewModel(MachineRecordService machineRecord, ChannelStockService channelStockService, IEventAggregator eventAggregator)
{
_machineRecordService = machineRecord;
_channelStockService = channelStockService;
////this.SqlSugarHelper.Db = sqlSugarScope;
_eventAggregator = eventAggregator;
vm = this;
}
void RequestData()
{
int totalCount = 0;
AccountList = _machineRecordService.ReportAccountBook(StartDate, EndDate, AccountType == null ? 0 : AccountType.AccountTypeValue, DrugInfo == null ? "" : DrugInfo.DrugId ?? "");
//for (int i = 0; i < accountList.Count; i++)
//{
// if (accountList[i].DrugInfo is null)
// {
// DrugInfo drug= new DrugInfo();
// drug.DrugId = accountList[i].DrugId;
// drug.DrugName = accountList[i].DrugName;
// drug.DrugSpec = accountList[i].DrugSpec;
// drug.Dosage= accountList[i].Dosage;
// drug.PackUnit= accountList[i].PackUnit;
// drug.Manufactory= accountList[i].Manufactory;
// accountList[i].DrugInfo= drug;
// }
//}
//ICollectionView vw = CollectionViewSource.GetDefaultView(accountList);
//vw.GroupDescriptions.Add(new PropertyGroupDescription("DrugInfo"));
}
private void GetAllDrugInfos()
{
var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
DrugInfos = list;
DrugInfo = list[0];
}
/// <summary>
/// 生成日结存
/// </summary>
public DelegateCommand DayAccountBook
{
get => new DelegateCommand(() =>
{
DayAccountAction();
RequestData();
});
}
//生成一条当日没有记录的账册记录
private void DayAccountAction()
{
try
{
//查询账册中所有记录,与库存中的记录做比校,如果账册中没有,则添加一条
List<AccountModel> accountList = _machineRecordService.ReportAccountBook(nowDate, null, 0);
//库存中的记录
List<ChannelStockCount> channelStockList = _channelStockService.GetAll();
//List<ChannelStock> channelStockInsert = new List<ChannelStock>();
if (accountList != null && accountList.Count() > 0)
{
//账册中有记录则与库存记录对比
for (int i = 0; i < channelStockList.Count; i++)
{
int Count = accountList.Where(cs => cs.DrugId == channelStockList[i].DrugId && cs.ManuNo == channelStockList[i].ManuNo).Count();
if (Count <= 0)
{
//没有直接插入
// 保存数据 出/入库记录
string InvoiceId = "Account_" + CurrentTimeMillis();
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = channelStockList[i].MachineId,
DrawerNo = 0,//channelStockList[i].DrawerNo,
ColNo = 0,// channelStockList[i].ColNo,FV
DrugId = channelStockList[i].DrugId,
ManuNo = channelStockList[i].ManuNo,
EffDate = !String.IsNullOrEmpty(channelStockList[i].EffDate) ? DateTime.ParseExact(channelStockList[i].EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
Quantity = 0,
Type = 5,
InvoiceId = string.Empty,//InvoiceId,
StockQuantity = channelStockList[i].Quantity,
ManunoQuantity = 0,
SupplierDept = ConfigurationManager.AppSettings["supplierDept"].ToString(),
ReceiveDept = ConfigurationManager.AppSettings["receiveDept"].ToString()
}).ExecuteCommand();
}
}
}
else
{
for (int i = 0; i < channelStockList.Count; i++)
{
//账册中没有记录则把库存中的所有数据都要生成一条账册记录
// 保存数据 出/入库记录
string InvoiceId = "Account_" + CurrentTimeMillis();
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = channelStockList[i].MachineId,
DrawerNo = 0,//channelStockList[i].DrawerNo,
ColNo = 0,//channelStockList[i].ColNo,
DrugId = channelStockList[i].DrugId,
ManuNo = channelStockList[i].ManuNo,
EffDate = !String.IsNullOrEmpty(channelStockList[i].EffDate) ? DateTime.ParseExact(channelStockList[i].EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
Quantity = 0,
Type = 5,
InvoiceId = string.Empty,//InvoiceId,
StockQuantity = channelStockList[i].Quantity,
ManunoQuantity = 0,
SupplierDept = ConfigurationManager.AppSettings["supplierDept"].ToString(),
ReceiveDept = ConfigurationManager.AppSettings["receiveDept"].ToString()
}).ExecuteCommand();
}
}
AlertMsg alertMsg = new AlertMsg
{
Message = "日结存已生成完成",
Type = MsgType.SUCCESS,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
catch (Exception ex)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "生成日结存失败",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
RequestData();
}
public long CurrentTimeMillis()
{
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
//public void InsertDayAccount()
//{
// // 保存数据 出/入库记录
// SqlSugarHelper.Db.Insertable(new MachineRecord()
// {
// MachineId = it.MachineId,
// DrawerNo = it.DrawerNo,
// ColNo = it.ColNo,
// DrugId = it.DrugId,
// ManuNo = it.ManuNo,
// EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
// Operator = HomeWindowViewModel.Operator?.Id,
// Reviewer = HomeWindowViewModel.Reviewer?.Id,
// OperationTime = DateTime.Now,
// Quantity = it.AddQuantity,
// Type = 1,
// InvoiceId = InvoiceId,
// StockQuantity = nowChannels.Sum(it => it.Quantity),
// ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
// SupplierDept = Invoice.PharmacyName1 ?? ConfigurationManager.AppSettings["supplierDept"].ToString(),
// ReceiveDept = Invoice.PharmacyName2 ?? ConfigurationManager.AppSettings["receiveDept"].ToString()
// }).ExecuteCommand();
//}
/// <summary>
/// 导出账册
/// </summary>
public DelegateCommand DownloadAccountBook
{
get => new DelegateCommand(() =>
{
GridReportUtil.PrintReportAccountBook(StartDate, EndDate, AccountType == null ? 0 : AccountType.AccountTypeValue, DrugInfo == null ? "" : DrugInfo.DrugId);
});
}
/// <summary>
/// 刷新
/// </summary>
public DelegateCommand Query
{
get => new DelegateCommand(() =>
{
RequestData();
});
}
public bool KeepAlive => true;
public void UpdateComboBoxItems(string text)
{
string str = @"SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,
d.manufactory,d.max_stock FROM `drug_info` d";
if (string.IsNullOrEmpty(text))
{
DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
return;
}
if (DrugInfos != null)
{
DrugInfos.Clear();
}
DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text) || di.DrugId.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
}
public void OnNavigatedTo(NavigationContext navigationContext)
{
//药品信息
GetAllDrugInfos();
//查询表格数据
RequestData();
}
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
public void OnNavigatedFrom(NavigationContext navigationContext)
{
}
}
}

View File

@ -0,0 +1,545 @@
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using log4net;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Drawing.Printing;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Documents;
namespace DM_Weight.ViewModels
{
public class AddDrugControlViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
{
private readonly ILog logger = LogManager.GetLogger(typeof(AddDrugControlViewModel));
private List<int> _drawerNoList = new List<int>();
public static AddDrugControlViewModel vm;
//凭证号
private string _pzh;
public string PZH { get => _pzh; set { SetProperty(ref _pzh, value); } }
private List<ChannelList>? _channelLsts;
public List<ChannelList>? ChannelLsts
{
get => _channelLsts;
set => SetProperty(ref _channelLsts, value);
}
private List<ChannelStock> __channelStocks = new List<ChannelStock>();
public List<ChannelStock> ChannelStocks
{
get => __channelStocks;
set => SetProperty(ref __channelStocks, value);
}
private ChannelStock? _channelStock;
public ChannelStock? CStock
{
get => _channelStock;
set => SetProperty(ref _channelStock, value);
}
//private ChannelList? _channelList;
//public ChannelList? ChannelLst
//{
// get => _channelList;
// set => SetProperty(ref _channelList, value);
//}
private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
IDialogService _dialogService;
////private SqlSugarScope SqlSugarHelper.Db;
public AddDrugControlViewModel(IDialogService DialogService, PortUtil portUtil, IEventAggregator eventAggregator)
{
_dialogService = DialogService;
_portUtil = portUtil;
_eventAggregator = eventAggregator;
////this.SqlSugarHelper.Db = sqlSugarScope;
vm = this;
}
public DelegateCommand SelectionChangedCommand => new DelegateCommand(selectionAction);
private async void selectionAction()
{
if (CStock != null)
{
// 此处延时1毫秒等待页面渲染
await Task.Delay(TimeSpan.FromMilliseconds(1));
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("addManuno", CStock);
DialogServiceExtensions.ShowDialogHost(_dialogService, "AddManunoDialog", dialogParameters, DoDialogResult, "RootDialog");
}
}
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
// dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
//if(dialogResult.Result == ButtonResult.OK)
//{
CStock = null;
RequestData();
//}
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
void DoMyPrismEvent(DeviceMsg msg)
{
if (msg.WindowName == "AddDrugControl")
{
switch (msg.EventType)
{
// 抽屉打开
case EventType.DRAWEROPEN:
if (Status == 1)
{
Status = 2;
}
break;
// 抽屉关闭
case EventType.DRAWERCLOSE:
if (Status == 2)
{
Status = 3;
}
break;
// 数量变化
case EventType.UPDATEQUANTITY:
if (Status == 2)
{
//ChannelStocks.ForEach(it => it.AddQuantity = msg.Quantitys[it.ColNo - 1]);
}
break;
// 打开失败
case EventType.OPENERROR:
AlertMsg alertMsg = new AlertMsg
{
Message = msg.Message,
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Status = 0;
break;
}
}
}
private int _status;
public int Status { get => _status; set => SetProperty(ref _status, value); }
private int _drawerNo = 1;
public int DrawerNo
{
get => _drawerNo;
set => SetProperty(ref _drawerNo, value);
}
private bool _is8Drawer = true;
public bool Is8Drawer { get => _is8Drawer; set => SetProperty(ref _is8Drawer, value); }
private bool _is16Drawer = false;
public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); }
private bool _is17Drawer = false;
public bool Is17Drawer { get => _is17Drawer; set => SetProperty(ref _is17Drawer, value); }
public DelegateCommand<string> UpdateDrawerNo
{
get => new DelegateCommand<string>((DrawerNo) =>
{
this.DrawerNo = Convert.ToInt32(DrawerNo);
RequestData();
}, (DrawerNo) => Status == 0
);
}
public DelegateCommand OpenDrawer
{
get => new DelegateCommand(() =>
{
Status = 1;
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
try
{
//List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
List<ChannelList> singleChannels = ChannelLsts.FindAll(it => it.BoardType != 1);
_portUtil.WindowName = "AddDrugControl";
_portUtil.Operate = true;
_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
_portUtil.ColNos = new int[] { };// singleChannels.Select(it => it.ColNo).ToArray();
//_portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
_portUtil.DrawerNo = DrawerNo;
_portUtil.Start();
}
catch (Exception ex)
{
logger.Info($"OpenDrawer异常{ex.Message}");
}
}, () => Status == 0).ObservesProperty(() => Status);
}
private bool _isFinishClick = false;
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(() =>
{
if (!_isFinishClick)
{
_isFinishClick = true;
foreach (ChannelList lst in ChannelLsts)
{
ChannelStocks.AddRange(lst.channelStocks);
}
List<ChannelStock> record = ChannelStocks.FindAll(it => it.AddQuantity != 0).ToList();
if (record.Count > 0)
{
//string InvoiceId = "DRAWER_" + CurrentTimeMillis();
string InvoiceId = PZH;
//List<string> repeatList = new List<string>();
List<ChannelStock> stockRepeats = new List<ChannelStock>();
var f = SqlSugarHelper.Db.UseTran(() =>
{
for (int i = 0; i < record.Count; i++)
{
ChannelStock it = record[i];
it.ManuNo = it.drugManuNo.ManuNo;
it.EffDate = it.drugManuNo.EffDate;
if (it.Id != null)
{
// 更新数据 库存信息
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity + it.AddQuantity,
ManuNo = it.ManuNo,
EffDate = it.EffDate,
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
}
else
{
//如果批号重复则不让添加
List<ChannelStock> csCount = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == it.DrawerNo && cs.ManuNo == it.ManuNo && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).ToList();
if (csCount.Count > 0)
{
//repeatList.Add(it.ManuNo);
stockRepeats.Add(it);
continue;
}
// 更新数据 库存信息
SqlSugarHelper.Db.Insertable(new ChannelStock()
{
Quantity = it.AddQuantity,
Chnguid = it.Chnguid,
ManuNo = it.ManuNo,
EffDate = it.EffDate,
DrawerNo = it.DrawerNo,
ColNo = it.ColNo,
DrugId = it.DrugId,
DrawerType = it.DrawerType,
BoardType = it.BoardType,
Id = Guid.NewGuid().ToString(),
MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1"
}).ExecuteCommand();
}
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
// 保存数据 入库记录
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = it.MachineId,
DrawerNo = it.DrawerNo,
ColNo = it.ColNo,
DrugId = it.DrugId,
ManuNo = it.ManuNo,
EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer= HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
Quantity = it.AddQuantity,
Type = 1,
InvoiceId = InvoiceId,
StockQuantity = nowChannels.Sum(it => it.Quantity),
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
}).ExecuteCommand();
}
return true;
});
//ChannelStocks.Clear();
if (stockRepeats.Count == record.Count)
{
AlertMsg alertMsg = new AlertMsg
{
Message = $"该抽屉已存在此药品批次{string.Join(',', stockRepeats.Select(r=>r.ManuNo).ToArray())},请选择其他批次",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
else
{
if (f.Data)
{
string msg = string.Empty;
MsgType type = MsgType.SUCCESS;
if (stockRepeats.Count > 0)
{
msg = $"该抽屉下批次{string.Join(',', stockRepeats.Select(r => r.ManuNo).ToArray())}已存在,不可重复添加,其他批次加药完成,库存已更新";
foreach(var stockRpt in stockRepeats)
{
//移除重复的信息,以免更新屏显库存时更新了重复数据
record.Remove(stockRpt);
}
type = MsgType.WARING;
}
else
{
msg = "抽屉加药完成,库存已更新";
}
// 更新屏显库存
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = ChannelStocks.Where(it => it.BoardType != 1)
.GroupBy(it => it.ColNo)
.Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(itx => itx.Quantity);
ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
ret.EffDate = it.Min(it => it.EffDate);
ret.ManuNo = it.OrderBy(it=>it.ManuNo).Select(it=>it.ManuNo).First().ToString();
return ret;
})
.OrderBy(it=>it.EffDate)
.ToList();
singleChannels = singleChannels.Where(it => it.AddQuantity > 0).ToList();
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
//将库位多批次的总库存数更新标签
//_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) + singleChannels.Sum(it => it.AddQuantity));
singleChannels.ForEach(it =>
{
_portUtil.WriteChannelInfo(6, it.EffDate == null ? "" : it.EffDate, it.DrawerNo, it.ColNo);
Thread.Sleep(200);
_portUtil.WriteChannelInfo(5, it.ManuNo, it.DrawerNo, it.ColNo);
Thread.Sleep(200);
_portUtil.ShowContent(it.DrawerNo, it.ColNo);
Thread.Sleep(500);
//写库存数量
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
});
}
RequestData();
AlertMsg alertMsg = new AlertMsg
{
Message = msg,
Type = type,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
else
{
AlertMsg alertMsg = new AlertMsg
{
Message = "更新库存失败",
Type = MsgType.SUCCESS,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
}
Status = 0;
_isFinishClick = false;
PZH = string.Empty;
ChannelStocks.Clear();
}
else
{
_isFinishClick = false;
AlertMsg alertMsg = new AlertMsg
{
Message = "没有填写加药数量",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
}
});
}
// 取消按钮
public DelegateCommand CancleTake
{
get => new DelegateCommand(() =>
{
_portUtil.ResetData();
Status = 0;
});
}
public bool KeepAlive => true;
//添加批次
public void AddAction(ChannelList channelLS)
{
if (channelLS != null)
{
ChannelStock cls = new ChannelStock();
DrugManuNo drugManu = new DrugManuNo();
cls.DrugInfo = channelLS.Drug;
if (channelLS.channelStocks.Count > 0)
{
cls.drugManuNo = channelLS.channelStocks[0].drugManuNo;
}
else
{
//drugManu= cls.DrugInfo.DrugManuNos[0];
if (cls.DrugInfo.DrugManuNos.Count > 0)
{
cls.drugManuNo = cls.DrugInfo.DrugManuNos[0];
}
else
{
AlertMsg alertMsg = new AlertMsg
{
Message = "该药品下没有批次,请先添加批次",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
}
//cls.Id = "";
cls.Chnguid = channelLS.Id;
cls.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
cls.DrawerNo = channelLS.DrawerNo;
cls.BoardType = channelLS.BoardType;
cls.DrawerType = channelLS.DrawerType;
cls.ColNo = channelLS.ColNo;
cls.DrugId = channelLS.DrugId;
cls.AddQuantity = 0;
List<ChannelStock> stockList = new List<ChannelStock>();
stockList.AddRange(channelLS.channelStocks);
stockList.Add(cls);
channelLS.channelStocks = stockList;
}
}
public long CurrentTimeMillis()
{
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
public void FindDrawerCount()
{
int count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType != 3)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
Is8Drawer = count < 9;
Is16Drawer = count >= 16;
Is17Drawer = count > 16;
}
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
{
continuationCallback(true);
}
public void RequestData()
{
List<ChannelList> queryData = SqlSugarHelper.Db.Queryable<ChannelList>()
.Includes(cl => cl.Drug, di => di.DrugManuNos)
.Includes(cl => cl.channelStocks, dr => dr.DrugInfo, d => d.DrugManuNos)
.Where(cl => cl.DrawerNo == DrawerNo)
.Where(cl => cl.DrawerType == 1)
.Where(cl => cl.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
.Where(cl => cl.DrugId != null)
.OrderBy(cl => cl.ColNo)
.ToList();
ChannelLsts = queryData.Select(cl =>
{
cl.channelStocks = cl.channelStocks.Select(cs =>
{
cs.drugManuNo = cl.Drug.DrugManuNos.Find(it => it.ManuNo.Equals(cs.ManuNo));
return cs;
}).ToList();
return cl;
}).ToList();
//ChannelLsts = new ObservableCollection<ChannelList>(queryData);
ChannelLsts.ForEach(cl => cl.channelStocks.ForEach(cs => cs.DrugInfo = cl.Drug));
}
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
_eventAggregator.GetEvent<AddDrugEvent>().Subscribe(AddAction);
FindDrawerCount();
RequestData();
}
//每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
//这个方法用于拦截请求
public void OnNavigatedFrom(NavigationContext navigationContext)
{
// 取消消息订阅
_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
_eventAggregator.GetEvent<AddDrugEvent>().Unsubscribe(AddAction);
}
}
}

View File

@ -21,7 +21,7 @@ using System.Threading;
namespace DM_Weight.ViewModels
{
public class BindingChannelDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
public class BindingChannelDialogViewModel : BindableBase, IDialogAware
{
public string Title => "库位绑定";
@ -50,14 +50,14 @@ namespace DM_Weight.ViewModels
IEventAggregator _eventAggregator;
PortUtil _portUtil;
//ScreenUtil _screenUtil;
private SqlSugarScope _sqlSugarScope1;
public BindingChannelDialogViewModel(IEventAggregator eventAggregator, PortUtil portUtil, SqlSugarScope sqlSugarScope//, ScreenUtil screenUtil
////private SqlSugarScope SqlSugarHelper.Db;
public BindingChannelDialogViewModel(IEventAggregator eventAggregator, PortUtil portUtil//, ScreenUtil screenUtil
)
{
_eventAggregator = eventAggregator;
_portUtil = portUtil;
//_screenUtil = screenUtil;
this._sqlSugarScope1 = sqlSugarScope;
////this.SqlSugarHelper.Db = sqlSugarScope;
}
public int DrawerNo
@ -110,13 +110,13 @@ namespace DM_Weight.ViewModels
List<DrugInfo> DrugList = null;
if (!string.IsNullOrEmpty(pycode))
{
//DrugList = _sqlSugarScope1.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).Where(di => di.PyCode.Contains(pycode)).OrderBy(di => di.DrugId).ToList();
DrugList = _sqlSugarScope1.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).Where(di => di.PyCode.Contains(pycode)).OrderBy(di => di.DrugId).ToList();
//DrugList = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).Where(di => di.PyCode.Contains(pycode)).OrderBy(di => di.DrugId).ToList();
DrugList = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).Where(di => di.PyCode.Contains(pycode)).OrderBy(di => di.DrugId).ToList();
}
else
{
//DrugList = _sqlSugarScope1.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
DrugList = _sqlSugarScope1.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
//DrugList = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
DrugList = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
}
return DrugList;
}
@ -209,8 +209,8 @@ namespace DM_Weight.ViewModels
private void GetAllDrugInfos()
{
//var list = _sqlSugarScope1.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
var list = _sqlSugarScope1.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
//var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
DrugInfos = list;
DrugInfos_PY = list;
}
@ -219,14 +219,14 @@ namespace DM_Weight.ViewModels
{
Channels?.Clear();
int totalCount = 0;
//var list = _sqlSugarScope1.Queryable<ChannelStock>()
//var list = SqlSugarHelper.Db.Queryable<ChannelStock>()
// .Includes<DrugInfo>(cs => cs.DrugInfo)
// .WhereIF(DrawerNo > 0, cs => cs.DrawerNo == DrawerNo)
// .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
// .OrderBy(cs => cs.DrawerNo)
// .OrderBy(cs => cs.ColNo)
// .ToPageList(PageNum, PageSize, ref totalCount);
var list = _sqlSugarScope1.Queryable<ChannelStock>()
var list = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
.WhereIF(DrawerNo > 0, cs => cs.DrawerNo == DrawerNo)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
@ -268,7 +268,7 @@ namespace DM_Weight.ViewModels
{
if (DrugInfo != null)
{
int count = _sqlSugarScope1.Queryable<ChannelStock>().Where(cs => cs.DrugId.Equals(DrugInfo.DrugId.ToString())).Where(cs => cs.DrawerType != 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Count();
int count = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrugId.Equals(DrugInfo.DrugId.ToString())).Where(cs => cs.DrawerType != 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Count();
if (count == 0)
{
var item = SelectChannels[0];
@ -278,8 +278,8 @@ namespace DM_Weight.ViewModels
item.PosNo = 0;
}
item.DrugId = DrugInfo.DrugId.ToString();
//_sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand();
_sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand();
//SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand();
SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand();
GetChannelsByDrawerNo();
if (item.BoardType == 5)
@ -339,7 +339,7 @@ namespace DM_Weight.ViewModels
// item.ManuNo = DrugManuNo.ManuNo;
// item.DrugInfo = DrugInfo;
// item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate);
// _sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
// SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
// if (item.BoardType == 5)
// {
@ -369,7 +369,7 @@ namespace DM_Weight.ViewModels
// item.ManuNo = DrugManuNo.ManuNo;
// item.DrugInfo = DrugInfo;
// item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate);
// _sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
// SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
// if (item.BoardType == 5)
// {
@ -402,8 +402,8 @@ namespace DM_Weight.ViewModels
item.ManuNo = DrugManuNo.ManuNo;
item.DrugInfo = DrugInfo;
item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate);
//_sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
_sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
//SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
if (item.BoardType == 5)
{
@ -460,8 +460,8 @@ namespace DM_Weight.ViewModels
item.ManuNo = null;
item.EffDate = null;
item.DrugInfo = null;
//_sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
_sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
//SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
if (item.BoardType == 5)
{
// 清除显示屏库位信息
@ -499,8 +499,8 @@ namespace DM_Weight.ViewModels
item.ManuNo = null;
item.EffDate = null;
item.DrugInfo = null;
//_sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
_sqlSugarScope1.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
//SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate }).ExecuteCommand();
if (item.BoardType == 5)
{
// 清除显示屏库位信息
@ -532,7 +532,6 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => false;
string message = string.Empty;
private void DoMyPrismEvent(DeviceMsg msg)
{

View File

@ -0,0 +1,544 @@
using MaterialDesignThemes.Wpf;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.util;
using log4net;
using System.Threading;
using System.Reflection.Metadata.Ecma335;
namespace DM_Weight.ViewModels
{
public class BindingChannelNewDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
{
public string Title => "库位绑定";
public event Action<IDialogResult> RequestClose;
private int _drawerNo = 0;
private SolidColorBrush _colorBrush;
public SolidColorBrush SnackbarBackground
{
get => _colorBrush;
set => SetProperty(ref _colorBrush, value);
}
private ISnackbarMessageQueue _snackbarMessageQueue = new SnackbarMessageQueue(TimeSpan.FromSeconds(3));
public ISnackbarMessageQueue SnackbarMessageQueue
{
get => _snackbarMessageQueue;
set => SetProperty(ref _snackbarMessageQueue, value);
}
IEventAggregator _eventAggregator;
PortUtil _portUtil;
//ScreenUtil _screenUtil;
////private SqlSugarScope SqlSugarHelper.Db;
public static BindingChannelNewDialogViewModel vm;
public BindingChannelNewDialogViewModel(IEventAggregator eventAggregator, PortUtil portUtil//, ScreenUtil screenUtil
)
{
_eventAggregator = eventAggregator;
_portUtil = portUtil;
//_screenUtil = screenUtil;
////this.SqlSugarHelper.Db = sqlSugarScope;
vm = this;
}
public int DrawerNo
{
get => _drawerNo;
set
{
SetProperty(ref _drawerNo, value);
GetChannelsByDrawerNo();
}
}
private DrugInfo? _drugInfo;
public DrugInfo? DrugInfo
{
get => _drugInfo;
set
{
SetProperty(ref _drugInfo, value);
//if (_drugInfo != null)
//{
// DrugManuNos = _drugInfo.DrugManuNos.OrderByDescending(dm => dm.ManuNo).ToList();
//}
}
}
private List<DrugInfo>? _drugInfos;
public List<DrugInfo>? DrugInfos
{
get => _drugInfos;
set => SetProperty(ref _drugInfos, value);
}
////拼音码对应药品实体
//private DrugInfo? _durgInfo_for_py;
//public DrugInfo? DrugInfo_Py
//{
// get => _durgInfo_for_py;
// set
// {
// SetProperty(ref _durgInfo_for_py, value);
// if (_durgInfo_for_py != null)
// {
// DrugInfos = GetDrugByDrugPY(_durgInfo_for_py.PyCode);
// }
// else
// {
// DrugInfos = GetDrugByDrugPY("");
// }
// }
//}
//#region 根据药品拼音码查询药品名称
//private List<DrugInfo> GetDrugByDrugPY(string pycode)
//{
// List<DrugInfo> DrugList = null;
// if (!string.IsNullOrEmpty(pycode))
// {
// DrugList = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).Where(di => di.PyCode.Contains(pycode)).OrderBy(di => di.DrugId).ToList();
// }
// else
// {
// DrugList = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
// }
// return DrugList;
//}
//private List<DrugInfo>? _drugInfos_py;
//public List<DrugInfo>? DrugInfos_PY
//{
// get => _drugInfos_py;
// set => SetProperty(ref _drugInfos_py, value);
//}
//#endregion 根据药品拼音码查询药品名称
public void UpdateComboBoxItems(string text)
{
string str = @"SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,
d.manufactory,d.max_stock,CONCAT(drug_name,' ',drug_spec)as drug_name_spec FROM `drug_info` d";
if (string.IsNullOrEmpty(text))
{
DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
return;
}
if (DrugInfos != null)
{
DrugInfos.Clear();
}
DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text) || di.DrugId.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
}
//private List<DrugInfo>? _drugInfos;
//public List<DrugInfo>? DrugInfos
//{
// get => _drugInfos;
// set => SetProperty(ref _drugInfos, value);
//}
//private DrugManuNo? _drugManuNo;
//public DrugManuNo? DrugManuNo
//{
// get => _drugManuNo;
// set => SetProperty(ref _drugManuNo, value);
//}
//private List<DrugManuNo>? _drugManuNos;
//public List<DrugManuNo>? DrugManuNos
//{
// get => _drugManuNos;
// set => SetProperty(ref _drugManuNos, value);
//}
private List<ChannelList>? _channels;
public List<ChannelList>? Channels
{
get => _channels;
set => SetProperty(ref _channels, value);
}
private int _totalCount = 0;
public int TotalCount { get => _totalCount; set => SetProperty(ref _totalCount, value); }
private int _pageNum = 1;
public int PageNum
{
get => _pageNum;
set
{
SetProperty(ref _pageNum, value);
GetChannelsByDrawerNo();
}
}
private int _pageCount = 1;
public int PageCount
{
get => _pageCount;
set
{
SetProperty(ref _pageCount, value);
}
}
private int _pageSize = 8;
public int PageSize
{
get => _pageSize;
set
{
SetProperty(ref _pageSize, value);
}
}
public bool CanCloseDialog()
{
return true;
}
public void OnDialogClosed()
{
_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
}
private void GetAllDrugInfos()
{
//var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
//DrugInfos = list;
//DrugInfos_PY = list;
string str = "SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,d.manufactory,d.max_stock,CONCAT(drug_name,' ',drug_spec)as drug_name_spec FROM `drug_info` d";
DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
}
private void GetChannelsByDrawerNo()
{
Channels?.Clear();
int totalCount = 0;
var list = SqlSugarHelper.Db.Queryable<ChannelList>()
.Includes<DrugInfo>(cl => cl.Drug)
.Includes<ChannelStock>(cs => cs.channelStocks)
.WhereIF(DrawerNo > 0, cl => cl.DrawerNo == DrawerNo)
.Where(cl => cl.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
.OrderBy(cl => cl.DrawerNo)
.OrderBy(cl => cl.ColNo)
.ToPageList(PageNum, PageSize, ref totalCount);
if(list!=null&&list.Count>0)
{
for (int i = 0; i < list.Count; i++)
{
if(list[i].channelStocks!=null&& list[i].channelStocks.Count>0)
{
for (int j = 0; j < list[i].channelStocks.Count; j++)
{
list[i].totalCount += list[i].channelStocks[j].Quantity;
}
}
}
}
Channels = list;
TotalCount = totalCount;
}
public void OnDialogOpened(IDialogParameters parameters)
{
if (parameters.ContainsKey("DrawerNo"))
{
DrawerNo = parameters.GetValue<int>("DrawerNo");
}
GetAllDrugInfos();
GetChannelsByDrawerNo();
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
}
public DelegateCommand Query
{
get => new DelegateCommand(() =>
{
GetChannelsByDrawerNo();
});
}
public DelegateCommand BindingDrug
{
get => new DelegateCommand(async () =>
{
var SelectChannels = Channels.FindAll(item => item.IsSelected);
if (SelectChannels.All(it => it.DrawerType != 1))
{
if (SelectChannels.Count == 1)
{
if (DrugInfo != null)
{
int count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrugId.Equals(DrugInfo.DrugId.ToString())).Where(cs => cs.DrawerType != 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Count();
if (count == 0)
{
var item = SelectChannels[0];
if (item.DrugId == null || !DrugInfo.DrugId.ToString().Equals(item.DrugId))
{
item.PosNo = 0;
}
item.DrugId = DrugInfo.DrugId.ToString();
SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand();
GetChannelsByDrawerNo();
if (item.BoardType == 5)
{
_portUtil.WindowName = "BindingChannelDialog";
// 向显示屏写入库位信息
_portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
await Task.Delay(200);
_portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
await Task.Delay(200);
_portUtil.WriteChannelInfo(8, DrugInfo.Manufactory.Length>10? DrugInfo.Manufactory.Substring(0, 10): DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
await Task.Delay(200);
//_portUtil.WriteChannelInfo(6, DrugManuNo.EffDate==null?"": DrugManuNo.EffDate, item.DrawerNo, item.ColNo);
//await Task.Delay(200);
//_portUtil.WriteChannelInfo(5, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo);
//await Task.Delay(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
}
//_screenUtil.SetStockInfo(item, 1);
}
else
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue($"药品【{DrugInfo.DrugName}】已经绑定了回收库位不可再次绑定");
}
}
else
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("请选择库位需要绑定的药品信息");
}
}
else
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("每种药品只能绑定一个回收库位");
}
}
else
{
//if (DrugInfo != null && DrugManuNo != null)
//{
var c = SelectChannels.Count;
if (c > 0)
{
if(c>1)
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("同一药品不可绑多个库位");
return;
}
//else
//{
// int count = SqlSugarHelper.Db.Queryable<ChannelList>()
// .Where(cs => cs.DrugId.Equals(DrugInfo.DrugId.ToString()))
// .Where(cs => cs.DrawerType == 1)
// .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
// .Where(cs=>cs.DrawerNo=)
// .Count();
// if (count > 0)
// {
// SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
// SnackbarMessageQueue.Enqueue("该药品已绑定库位,不可绑定多个库位");
// return;
// }
//}
for (int i = 0; i < SelectChannels.Count; i++)
{
var item = SelectChannels[i];
int count = SqlSugarHelper.Db.Queryable<ChannelList>()
.Where(cs => cs.DrugId.Equals(DrugInfo.DrugId.ToString()))
.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
.Where(cs => cs.DrawerNo == item.DrawerNo)
.Count();
if (count > 0)
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("该药品已绑定库位,不可绑定多个库位");
return;
}
var channelStock = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.Chnguid == item.Id&&cs.Quantity>0).ToList();
if(channelStock.Count>0)
{
//有库存,不能解绑
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue($"库位{item.DrawerNo}-{item.ColNo}中还存在药品,不能绑定其他药品");
continue;
}
if (item.DrugId == null || !DrugInfo.DrugId.ToString().Equals(item.DrugId))
{
item.PosNo = 0;
}
item.DrugId = DrugInfo.DrugId.ToString();
//item.ManuNo = DrugManuNo.ManuNo;
item.Drug = DrugInfo;
//item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate);
SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.PosNo }).ExecuteCommand();
if (item.BoardType == 5)
{
_portUtil.WindowName = "BindingChannelDialog";
// 向显示屏写入库位信息
_portUtil.WriteChannelInfo(1, DrugInfo.DrugName, item.DrawerNo, item.ColNo);
await Task.Delay(200);
//Thread.Sleep(200);
_portUtil.WriteChannelInfo(2, DrugInfo.DrugSpec, item.DrawerNo, item.ColNo);
await Task.Delay(200);
//Thread.Sleep(200);
_portUtil.WriteChannelInfo(8, DrugInfo.Manufactory.Length > 10 ? DrugInfo.Manufactory.Substring(0, 10) : DrugInfo.Manufactory, item.DrawerNo, item.ColNo);
await Task.Delay(200);
//Thread.Sleep(200);
//_portUtil.WriteChannelInfo(6, DrugManuNo.ManuNo, item.DrawerNo, item.ColNo);
//await Task.Delay(200);
//Thread.Sleep(200);
//_portUtil.WriteChannelInfo(5, String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate), item.DrawerNo, item.ColNo);
////await Task.Delay(200);
//Thread.Sleep(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
}
}
GetChannelsByDrawerNo();
}
else
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("所选库位中无可绑定库位【库位还存在药品】");
}
//}
//else
//{
// SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
// SnackbarMessageQueue.Enqueue("请选择库位需要绑定的药品及批次信息");
//}
}
});
}
public DelegateCommand RemoveBinding
{
get => new DelegateCommand(async () =>
{
var SelectChannels = Channels.FindAll(item => item.IsSelected && item.DrugId != null);
var c = SelectChannels.Count;
if (c > 0)
{
SelectChannels.ForEach(async item =>
{
var channelStock = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.Chnguid == item.Id && cs.Quantity > 0).ToList();
if (channelStock.Count > 0)
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("所选库位中无可解绑药品【库位还存在药品】");
//该药品下的批次还有库存则不能解绑
return;
}
item.DrugId = null;
//item.ManuNo = null;
//item.EffDate = null;
item.Drug = null;
SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId }).ExecuteCommand();
SqlSugarHelper.Db.Updateable<ChannelStock>().SetColumns(it =>new ChannelStock { DrugId = null, ManuNo = null, EffDate = null} ).Where(it=>it.Chnguid==item.Id).ExecuteCommand();
if (item.BoardType == 5)
{
// 清除显示屏库位信息
_portUtil.ClearContent(item.DrawerNo, item.ColNo);
await Task.Delay(200);
_portUtil.ShowContent(item.DrawerNo, item.ColNo);
}
//_screenUtil.SetStockInfo(item, 1);
});
GetChannelsByDrawerNo();
}
else
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("所选库位中无可解绑药品");
}
});
}
public DelegateCommand BtnCloseCommand
{
get => new DelegateCommand(() =>
{
//DialogParameters parameters = new DialogParameters();
//parameters.Add("",);
// 关闭当前窗口
RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
});
}
public bool KeepAlive => true;
string message = string.Empty;
private void DoMyPrismEvent(DeviceMsg msg)
{
if (msg.WindowName == "BindingChannelDialog")
{
switch (msg.EventType)
{
case EventType.OPENERROR:
AlertMsg alertMsg = new AlertMsg
{
Message = msg.Message,
Type = MsgType.ERROR,
};
if (message != msg.Message)
{
message = msg.Message;
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
break;
}
}
}
}
}

View File

@ -29,7 +29,7 @@ namespace DM_Weight.ViewModels
{
public string Title => "交接班";
public bool KeepAlive => false;
public bool KeepAlive => true;
//交班人 发药人
public UserList Operator { get; set; }
private bool _operatorLogin = false;
@ -164,10 +164,10 @@ namespace DM_Weight.ViewModels
//{
DateTime dt = DateTime.Now;
//保存交接班信息(查询当前值班人的最后一条交接班信息(如有则修改状态,没有则插入一条)并写入一条接班人信息)
//var f = _sqlSugarScope1.UseTran(() =>
var f = _sqlSugarScope1.UseTran(() =>
//var f = SqlSugarHelper.Db.UseTran(() =>
var f = SqlSugarHelper.Db.UseTran(() =>
{
List<HkcChangeShifts> listHkcChangeShifts = _sqlSugarScope1.Queryable<HkcChangeShifts>()
List<HkcChangeShifts> listHkcChangeShifts = SqlSugarHelper.Db.Queryable<HkcChangeShifts>()
.Where(cs => cs.State == "0")
.WhereIF(Operator != null && !string.IsNullOrEmpty(Operator.UserName), cs => cs.FromOperator == Operator.UserName)
.WhereIF(Reviewer != null && !string.IsNullOrEmpty(Reviewer.UserName), cs => cs.FromRviewer == Reviewer.UserName)
@ -177,7 +177,7 @@ namespace DM_Weight.ViewModels
if (listHkcChangeShifts != null && listHkcChangeShifts.Count > 0)
{
//存在则修改,不存在则插入一条
_sqlSugarScope1.Updateable(new HkcChangeShifts()
SqlSugarHelper.Db.Updateable(new HkcChangeShifts()
{
Id = listHkcChangeShifts[0].Id,
ToOperator = JieOperator == null ? "" : JieOperator.UserName,
@ -188,7 +188,7 @@ namespace DM_Weight.ViewModels
}
else
{
_sqlSugarScope1.Insertable(new HkcChangeShifts()
SqlSugarHelper.Db.Insertable(new HkcChangeShifts()
{
FromOperator = Operator == null ? "" : Operator.UserName,
FromRviewer = Reviewer == null ? "" : Reviewer.UserName,
@ -201,7 +201,7 @@ namespace DM_Weight.ViewModels
}).ExecuteCommand();
}
_sqlSugarScope1.Insertable(new HkcChangeShifts()
SqlSugarHelper.Db.Insertable(new HkcChangeShifts()
{
FromOperator = JieOperator == null ? "" : JieOperator.UserName,
FromRviewer = JieReviewer == null ? "" : JieReviewer.UserName,
@ -225,7 +225,7 @@ namespace DM_Weight.ViewModels
ORDER BY d2.operation_time DESC,d2.id DESC LIMIT 1) AS beforeNum from (SELECT drug_id,manu_no, SUM(IF(d1.`type` = 1, d1.quantity, 0)) AS getNum,SUM(IF(d1.`type` = 2, d1.quantity, 0)) AS useNum FROM dm_machine_record d1
WHERE d1.`type` IN (1, 2) AND d1.`operation_time` >= @startDate and d1.`operation_time` <=@endDate and d1.machine_id=@machineId GROUP BY d1.Drug_ID ,d1.manu_no) d
LEFT JOIN drug_info drug on d.drug_id=drug.drug_id left JOIN channel_stock c on c.drug_id=d.drug_id and c.manu_no=d.manu_no AND c.machine_id=@machineId GROUP BY d.Drug_ID ,d.manu_no ";
List<ShiftsReport> shiftsReports = _sqlSugarScope1.SqlQueryable<dynamic>(strSql)
List<ShiftsReport> shiftsReports = SqlSugarHelper.Db.SqlQueryable<dynamic>(strSql)
.AddParameters(new
{
machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1",
@ -240,7 +240,7 @@ namespace DM_Weight.ViewModels
for (int i = 0; i < shiftsReports.Count; i++)
{
_sqlSugarScope1.Insertable(new ShiftsReport()
SqlSugarHelper.Db.Insertable(new ShiftsReport()
{
OptDate = dt,
DrugName = shiftsReports[i].DrugName,
@ -312,7 +312,7 @@ namespace DM_Weight.ViewModels
LoginBtnEnable = false;
if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password))
{
UserList userList = _sqlSugarScope1.Queryable<UserList>()
UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
.Includes<RoleDm>(u => u.Role)
.InnerJoin<RoleDm>((u, r) => u.RoleId == r.Id)
.First(u => u.UserName == username && ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId));
@ -508,7 +508,7 @@ namespace DM_Weight.ViewModels
{
if (msg.Message.Equals("LOGIN"))
{
UserList userList = _sqlSugarScope1.Queryable<UserList>()
UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
.Includes<RoleDm>(u => u.Role)
.First(u => u.Id == msg.Id);
@ -609,11 +609,11 @@ namespace DM_Weight.ViewModels
}
IEventAggregator _eventAggregator;
private SqlSugarScope _sqlSugarScope1;
public ChangeShiftsDialogViewModel(IEventAggregator eventAggregator,SqlSugarScope sqlSugarScope)
////private SqlSugarScope SqlSugarHelper.Db;
public ChangeShiftsDialogViewModel(IEventAggregator eventAggregator)
{
_eventAggregator = eventAggregator;
this._sqlSugarScope1 = sqlSugarScope;
////this.SqlSugarHelper.Db = sqlSugarScope;
}
public bool CanCloseDialog()
@ -631,8 +631,8 @@ namespace DM_Weight.ViewModels
HkcChangeShifts changeOperator = GetOperator();
if (changeOperator != null)
{
Operator = _sqlSugarScope1.Queryable<UserList>().Where(u => u.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Single(u => u.UserName == changeOperator.FromOperator);
Reviewer = _sqlSugarScope1.Queryable<UserList>().Where(u => u.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Single(u => u.UserName == changeOperator.FromRviewer);
Operator = SqlSugarHelper.Db.Queryable<UserList>().Where(u => u.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Single(u => u.UserName == changeOperator.FromOperator);
Reviewer = SqlSugarHelper.Db.Queryable<UserList>().Where(u => u.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).Single(u => u.UserName == changeOperator.FromRviewer);
}
FingerMsg = false;// !_fingerprintUtil.bIsConnected;
@ -642,11 +642,11 @@ namespace DM_Weight.ViewModels
private HkcChangeShifts GetOperator()
{
//查询发药人及审核人
HkcChangeShifts changeOperator = _sqlSugarScope1.Queryable<HkcChangeShifts>().Single(change => change.State == "0");
HkcChangeShifts changeOperator = SqlSugarHelper.Db.Queryable<HkcChangeShifts>().Single(change => change.State == "0");
//if (changeOperator != null)
//{
// Operator = _sqlSugarScope1.Queryable<UserList>().Single(u => u.UserName == changeOperator.FromOperator);
// Reviewer = _sqlSugarScope1.Queryable<UserList>().Single(u => u.UserName == changeOperator.ToOperator);
// Operator = SqlSugarHelper.Db.Queryable<UserList>().Single(u => u.UserName == changeOperator.FromOperator);
// Reviewer = SqlSugarHelper.Db.Queryable<UserList>().Single(u => u.UserName == changeOperator.ToOperator);
//}
return changeOperator;
}

View File

@ -104,7 +104,7 @@ namespace DM_Weight.ViewModels
set { SetProperty(ref hkcChangeShifts, value); }
}
public bool KeepAlive => false;
public bool KeepAlive => true;
IDialogService _dialogService;
//交接班
@ -124,11 +124,11 @@ namespace DM_Weight.ViewModels
{
GridReportUtil.PrintChangeShiftsReport(StartDate, EndDate);
}
private SqlSugarScope _sqlSugarScope1;
public ChangeShiftsListWindowViewModel(IDialogService dialogService,SqlSugarScope sqlSugarScope)
////private SqlSugarScope SqlSugarHelper.Db;
public ChangeShiftsListWindowViewModel(IDialogService dialogService)
{
_dialogService = dialogService;
this._sqlSugarScope1 = sqlSugarScope;
////this.SqlSugarHelper.Db = sqlSugarScope;
}
void RequestData()
{
@ -147,7 +147,7 @@ namespace DM_Weight.ViewModels
sqlStr += " and c.optdate<=@endOptDate ";
}
sqlStr+=" group by c.id";
HkcChangeShifts = _sqlSugarScope1.SqlQueryable<dynamic>(sqlStr)
HkcChangeShifts = SqlSugarHelper.Db.SqlQueryable<dynamic>(sqlStr)
.AddParameters(new
{
machineId = machineId,

View File

@ -102,7 +102,7 @@ namespace DM_Weight.ViewModels
set { SetProperty(ref machineRecords, value); }
}
public bool KeepAlive => false;
public bool KeepAlive => true;
IDialogService _dialogService;
//交接班
@ -124,7 +124,7 @@ namespace DM_Weight.ViewModels
{
int totalCount = 0;
string machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
//MachineRecords = _sqlSugarScope1.Queryable<MachineRecord>()
//MachineRecords = SqlSugarHelper.Db.Queryable<MachineRecord>()
// .Includes<DrugInfo>(mr => mr.DrugInfo)
// .Includes<UserList>(mr => mr.User)
// .Where(mr => mr.MachineId == machineId)

View File

@ -79,7 +79,7 @@ namespace DM_Weight.ViewModels
private PortUtil _portUtil;
IRegionManager _regionManager;
IEventAggregator _eventAggregator;
public bool KeepAlive => false;
public bool KeepAlive => true;
private bool _fingerMsg;
@ -88,13 +88,13 @@ namespace DM_Weight.ViewModels
get => _fingerMsg;
set => SetProperty(ref _fingerMsg, value);
}
private SqlSugarScope _sqlSugarScope1;
public ChangeShiftsWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil,SqlSugarScope sqlSugarScope)
////private SqlSugarScope SqlSugarHelper.Db;
public ChangeShiftsWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil)
{
_portUtil = portUtil;
_regionManager = regionManager;
_eventAggregator = eventAggregator;
this._sqlSugarScope1 = sqlSugarScope;
////this.SqlSugarHelper.Db = sqlSugarScope;
}
#region
@ -188,22 +188,22 @@ namespace DM_Weight.ViewModels
if ((JiaoBanFYRFlag || JiaoBanSHRFlag) && (JieBanFYRFlag || JieBanSHRFlag))
{
//保存交接班信息(查询当前值班人的最后一条交接班信息(如有则修改状态,没有则插入一条)并写入一条接班人信息)
var f = _sqlSugarScope1.UseTran(() =>
var f = SqlSugarHelper.Db.UseTran(() =>
{
List<HkcChangeShifts> listHkcChangeShifts = _sqlSugarScope1.Queryable<HkcChangeShifts>()
List<HkcChangeShifts> listHkcChangeShifts = SqlSugarHelper.Db.Queryable<HkcChangeShifts>()
.Where(cs => cs.State == "0")
.WhereIF(App.CurrentFaUserList != null && !string.IsNullOrEmpty(App.CurrentFaUserList.UserName), cs => cs.FromOperator == App.CurrentFaUserList.UserName)
.WhereIF(App.CurrentShenUserList != null && !string.IsNullOrEmpty(App.CurrentShenUserList.UserName), cs => cs.FromRviewer == App.CurrentShenUserList.UserName)
.OrderByDescending(cs => cs.OptState)
.ToList();
//List<MachineRecord> listMachineRecord=_sqlSugarScope1.Queryable<MachineRecord>()
//List<MachineRecord> listMachineRecord=SqlSugarHelper.Db.Queryable<MachineRecord>()
//.Where(m=>)
if (listHkcChangeShifts != null && listHkcChangeShifts.Count > 0)
{
//存在则修改,不存在则插入一条
_sqlSugarScope1.Updateable(new HkcChangeShifts()
SqlSugarHelper.Db.Updateable(new HkcChangeShifts()
{
Id = listHkcChangeShifts[0].Id,
ToOperator = Operator == null ? "" : Operator.UserName,
@ -215,7 +215,7 @@ namespace DM_Weight.ViewModels
}
else
{
_sqlSugarScope1.Insertable(new HkcChangeShifts()
SqlSugarHelper.Db.Insertable(new HkcChangeShifts()
{
FromOperator = App.CurrentFaUserList.UserName,
FromRviewer = App.CurrentShenUserList.UserName,
@ -227,7 +227,7 @@ namespace DM_Weight.ViewModels
}).ExecuteCommand();
}
_sqlSugarScope1.Insertable(new HkcChangeShifts()
SqlSugarHelper.Db.Insertable(new HkcChangeShifts()
{
FromOperator = App.CurrentFaUserList.UserName,
FromRviewer = App.CurrentShenUserList.UserName,
@ -266,7 +266,7 @@ namespace DM_Weight.ViewModels
if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(passWord))
{
{
UserList userList = _sqlSugarScope1.Queryable<UserList>()
UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
.Includes<RoleDm>(u => u.Role)
.InnerJoin<RoleDm>((u, r) => u.RoleId == r.Id)
.First(u => u.UserName == userName && ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId));
@ -350,7 +350,7 @@ namespace DM_Weight.ViewModels
if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(passWord))
{
{
UserList userList = _sqlSugarScope1.Queryable<UserList>()
UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
.Includes<RoleDm>(u => u.Role)
.InnerJoin<RoleDm>((u, r) => u.RoleId == r.Id)
.First(u => u.UserName == userName && ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId));
@ -419,7 +419,7 @@ namespace DM_Weight.ViewModels
{
if (msg.Message.Equals("LOGIN"))
{
UserList userList = _sqlSugarScope1.Queryable<UserList>()
UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
.Includes<RoleDm>(u => u.Role)
.First(u => u.Id == msg.Id);

View File

@ -0,0 +1,198 @@
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.Report;
using DM_Weight.util;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace DM_Weight.ViewModels
{
public class CheckRecordDetailDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
{
public string Title => "盘点记录明细";
private int _pageNum = 1;
public int PageNum
{
get => _pageNum;
set
{
SetProperty(ref _pageNum, value);
RequestData();
}
}
private int _pageCount = 1;
public int PageCount
{
get => _pageCount;
set
{
SetProperty(ref _pageCount, value);
}
}
private int _pageSize = 8;
public int PageSize
{
get => _pageSize;
set
{
SetProperty(ref _pageSize, value);
}
}
private int _totalCount = 0;
public int TotalCount
{
get => _totalCount;
set
{
SetProperty(ref _totalCount, value);
}
}
private DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
public DateTime? StartDate
{
get => _startDate;
set
{
if (value != null)
{
SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0));
}
else
{
SetProperty(ref _startDate, value);
}
RequestData();
}
}
private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
public DateTime? EndDate
{
get => _endDate;
set
{
if (value != null)
{
TimeSpan ershisi = new TimeSpan(23, 59, 59);
SetProperty(ref _endDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0, 23, 59, 59));
}
else
{
SetProperty(ref _endDate, value);
}
RequestData();
}
}
private string _optDate;
public string OptDate
{
get => _optDate;
set
{
SetProperty(ref _optDate, value);
}
}
private ObservableCollection<CheckRecordStock> _obsCheckRecordStock = new ObservableCollection<CheckRecordStock>();
public ObservableCollection<CheckRecordStock> obsCheckRecordStock
{
get => _obsCheckRecordStock;
set => SetProperty(ref _obsCheckRecordStock, value);
}
private CheckRecordStock _checkRecordStock = new CheckRecordStock();
public CheckRecordStock checkRecordStock
{
get => _checkRecordStock;
set => SetProperty(ref _checkRecordStock, value);
}
private List<CheckRecordStock>? _channelStocks = new();
public List<CheckRecordStock>? ChannelStocks
{
get => _channelStocks;
set => SetProperty(ref _channelStocks, value);
}
////private SqlSugarScope SqlSugarHelper.Db;
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
public event Action<IDialogResult> RequestClose;
public CheckRecordDetailDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService dialogService)
{
////this.SqlSugarHelper.Db = sqlSugarScope;
_portUtil = portUtil;
_eventAggregator = eventAggregator;
}
public void RequestData()
{
ChannelStocks.Clear();
obsCheckRecordStock.Clear();
//string strSql = "SELECT optDate AS optdate,U.User_name AS operatorUser,R.User_name AS reviewerUser,Drug_ID AS drugId,Drug_name AS drugName FROM check_stock C LEFT JOIN user_list U ON C.operator=U.ID LEFT JOIN user_list R ON C.reviewer=R.ID WHERE 1=1";
//if (StartDate != null)
//{
// strSql += " AND C.optDate=@OPTSTARTDATE ";
//}
//strSql += " GROUP BY C.optdate,Drug_id ORDER BY C.OPTDATE DESC";
List<CheckRecordStock> checkList = SqlSugarHelper.Db.Queryable<CheckRecordStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
.Where(cs => cs.optdate == OptDate).OrderByDescending(cs => cs.optdate).ToList();
ICollectionView vw = CollectionViewSource.GetDefaultView(checkList);
vw.GroupDescriptions.Add(new PropertyGroupDescription("DrugInfo"));
obsCheckRecordStock = new ObservableCollection<CheckRecordStock>(checkList);
ChannelStocks = checkList;
}
public bool CanCloseDialog()
{
return true;
}
public void OnDialogClosed()
{
}
public void OnDialogOpened(IDialogParameters parameters)
{
if (parameters.ContainsKey("OptDate"))
{
OptDate = parameters.GetValue<string>("OptDate");
}
RequestData();
}
public DelegateCommand BtnCloseCommand {
get => new DelegateCommand(() =>
{
// 关闭当前窗口
RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
});
}
public bool KeepAlive => true;
}
}

View File

@ -0,0 +1,211 @@
using DM_Weight.Models;
using DM_Weight.Port;
using DM_Weight.Report;
using DM_Weight.util;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace DM_Weight.ViewModels
{
public class CheckRecordNewWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
{
private int _pageNum = 1;
public int PageNum
{
get => _pageNum;
set
{
SetProperty(ref _pageNum, value);
RequestData();
}
}
private int _pageCount = 1;
public int PageCount
{
get => _pageCount;
set
{
SetProperty(ref _pageCount, value);
}
}
private int _pageSize = 8;
public int PageSize
{
get => _pageSize;
set
{
SetProperty(ref _pageSize, value);
}
}
private int _totalCount = 0;
public int TotalCount
{
get => _totalCount;
set
{
SetProperty(ref _totalCount, value);
}
}
private DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
public DateTime? StartDate
{
get => _startDate;
set
{
if (value != null)
{
SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0));
}
else
{
SetProperty(ref _startDate, value);
}
RequestData();
}
}
private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
public DateTime? EndDate
{
get => _endDate;
set
{
if (value != null)
{
TimeSpan ershisi = new TimeSpan(23, 59, 59);
SetProperty(ref _endDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0, 23, 59, 59));
}
else
{
SetProperty(ref _endDate, value);
}
RequestData();
}
}
public event Action<IDialogResult> RequestClose;
private ObservableCollection<CheckRecordStock> _obsCheckRecordStock = new ObservableCollection<CheckRecordStock>();
public ObservableCollection<CheckRecordStock> obsCheckRecordStock
{
get => _obsCheckRecordStock;
set=>SetProperty(ref _obsCheckRecordStock, value);
}
private CheckRecordStock _checkRecordStock=new CheckRecordStock();
public CheckRecordStock checkRecordStock
{
get => _checkRecordStock;
set=>SetProperty(ref _checkRecordStock, value);
}
////private SqlSugarScope SqlSugarHelper.Db;
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
IDialogService _dialogService;
public CheckRecordNewWindowViewModel(IDialogService DialogService, PortUtil portUtil, IEventAggregator eventAggregator, IDialogService dialogService)
{
_dialogService = DialogService;
////this.SqlSugarHelper.Db = sqlSugarScope;
_portUtil = portUtil;
_eventAggregator = eventAggregator;
}
public DelegateCommand DownLoadCommond
{
get => new DelegateCommand(() =>
{
GridReportUtil.PrintReportStockNew(StartDate, EndDate);
});
}
public DelegateCommand Query
{
get => new DelegateCommand(() =>
{
RequestData();
});
}
public void RequestData()
{
int totalCount = 0;
string strSql = @"SELECT optDate AS optdate,U.User_name AS operatorUser,R.User_name AS reviewerUser,Drug_spec AS drugSpec,Manufactory AS manufactory,Quantity FROM check_stock C
LEFT JOIN user_list U ON C.operator=U.ID LEFT JOIN user_list R ON C.reviewer=R.ID WHERE 1=1";
if(StartDate!=null)
{
strSql += " AND C.optDate>@OPTSTARTDATE ";
}
if(EndDate!=null)
{
strSql += " AND C.optDate<@OPTENDDATE ";
}
strSql += " GROUP BY C.optdate ORDER BY C.OPTDATE DESC";
List<CheckRecordStock> checkList = SqlSugarHelper.Db.SqlQueryable<CheckRecordStock>(strSql)
.AddParameters(new
{
OPTSTARTDATE = StartDate,
OPTENDDATE = EndDate
}).ToPageList(PageNum, PageSize, ref totalCount);
//SqlSugarHelper.Db.ThenMapper(checkList, item =>
//{
// //item.drugDetails = SqlSugarHelper.Db.Queryable<CheckRecordStock>().SetContext(x => x.optdate, () => item.optdate, item).ToList();
// item.manuNoDetails = SqlSugarHelper.Db.Queryable<CheckRecordStock>().SetContext(x => x.optdate, () => item.optdate, item).ToList();
//});
obsCheckRecordStock = new ObservableCollection<CheckRecordStock>(checkList);
}
public DelegateCommand RowSelected
{
get => new DelegateCommand(async () =>
{
if (checkRecordStock != null && checkRecordStock.optdate!=null)
{
// 此处延时1毫秒等待页面渲染
await Task.Delay(TimeSpan.FromMilliseconds(1));
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("OptDate", checkRecordStock.optdate);
DialogServiceExtensions.ShowDialogHost(_dialogService, "CheckRecordDetailDialog", dialogParameters, DoDialogResult, "RootDialog");
}
});
}
public bool KeepAlive => true;
private void DoDialogResult(IDialogResult dialogResult)
{
checkRecordStock = null;
RequestData();
}
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
public void OnNavigatedFrom(NavigationContext navigationContext)
{
}
public void OnNavigatedTo(NavigationContext navigationContext)
{
RequestData();
}
}
}

View File

@ -0,0 +1,604 @@
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.Report;
using DM_Weight.select;
using DM_Weight.util;
using log4net;
using log4net.Repository.Hierarchy;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Data;
namespace DM_Weight.ViewModels
{
public class CheckStockNew2WindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
{
//public static CheckStockNewWindowViewModel vm;
private readonly ILog logger = LogManager.GetLogger(typeof(CheckStockWindowViewModel));
public string drugId;
//public string Stock;
private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static List<OrderTakeSelect> StaticSelects = new()
{
new OrderTakeSelect
{
Code = "DrugName",
Name = "药品名称"
},
new OrderTakeSelect
{
Code = "PyCode",
Name = "拼音码"
},
new OrderTakeSelect
{
Code = "DrugBarcode",
Name = "药品条码"
},
new OrderTakeSelect
{
Code = "DrugId",
Name = "药品编码"
}
};
private List<OrderTakeSelect> _selects = StaticSelects;
public List<OrderTakeSelect> Selects
{
get { return _selects; }
set
{
SetProperty(ref _selects, value);
}
}
private OrderTakeSelect _selectedItem = StaticSelects[0];
/// <summary>
/// 查询条件 查询字段
/// </summary>
public OrderTakeSelect SelectedItem
{
get { return _selectedItem; }
set
{
SetProperty(ref _selectedItem, value);
RequestData();
}
}
private string? _searchValue;
/// <summary>
/// 查询条件 查询字段值
/// </summary>
public string? SearchValue
{
get { return _searchValue; }
set
{
SetProperty(ref _searchValue, value);
RequestData();
}
}
IDialogService _dialogService;
IEventAggregator _eventAggregator;
////private SqlSugarScope SqlSugarHelper.Db;
private PortUtil _portUtil;
private int _status;
public int Status { get => _status; set => SetProperty(ref _status, value); }
private int _drawerNo = 1;
public int DrawerNo
{
get => _drawerNo;
set => SetProperty(ref _drawerNo, value);
}
public long CurrentTimeMillis()
{
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
public CheckStockNew2WindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService dialogService)
{
_dialogService = dialogService;
////this.SqlSugarHelper.Db = sqlSugarScope;
_portUtil = portUtil;
_portUtil = portUtil;
_eventAggregator = eventAggregator;
//vm= this;
}
void DoMyPrismEvent(DeviceMsg msg)
{
if (msg.WindowName == "CheckStockNewWindow")
{
IGrouping<int, ChannelStock> grouping = enumerator.Current;
int DrawerNo = grouping.Key;
List<ChannelStock> channelStocks = grouping.ToList();
switch (msg.EventType)
{
// 抽屉打开
case EventType.DRAWEROPEN:
if (Status == 1)
{
if (channelStocks[0].process == 1)
{
channelStocks.ForEach(it => it.process = 2);
}
//Status = 2;
}
break;
// 抽屉关闭
case EventType.DRAWERCLOSE:
if (Status == 1)
{
if (channelStocks[0].process == 2)
{
channelStocks.ForEach(it => it.process = 3);
}
IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
int DrawerNoBefore = groupingBefore.Key;
if (enumerator.MoveNext())
{
IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
int DrawerNoAfter = groupingAfter.Key;
//if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
//{
// Thread.Sleep(50);
//}
logger.Info($"抽屉号DrawerNoBefore【{DrawerNoBefore}】抽屉号DrawerNoAfter【{DrawerNoAfter}】");
if (DrawerNoAfter == 17)
{
if (DrawerNoBefore == 17)
{
Thread.Sleep(1000);
}
else
{
Thread.Sleep(500);
}
}
else
{
Thread.Sleep(80);
}
logger.Info($"抽屉号DrawerNoBefore【{DrawerNoBefore}】抽屉号DrawerNoAfter【{DrawerNoAfter}】");
OpenOneByOne();
}
// 已经全部取出
else
{
Status = 3;
}
}
break;
// 数量变化
case EventType.UPDATEQUANTITY:
if (Status == 1)
{
logger.Info($"抽屉【{DrawerNo}】库位药品数量【{msg.Quantitys}】");
}
break;
// 打开失败
case EventType.OPENERROR:
AlertMsg alertMsg = new AlertMsg
{
Message = msg.Message,
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Status = 0;
break;
}
}
}
private ChannelStock? _selectedChannel;
public ChannelStock? SelectedChannel
{
get => _selectedChannel;
set => SetProperty(ref _selectedChannel, value);
}
private List<ChannelStock>? _channelStocks = new();
public List<ChannelStock>? ChannelStocks
{
get => _channelStocks;
set => SetProperty(ref _channelStocks, value);
}
private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
public DelegateCommand BindingChannelDialog
{
get => new DelegateCommand(() =>
{
DialogParameters dialogParameters = new DialogParameters();
DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelDialog", dialogParameters, DoDialogResult, "RootDialog");
});
}
public DelegateCommand QueryCommand
{
get => new DelegateCommand(() =>
{
RequestData();
});
}
/// <summary>
/// 盘点
/// </summary>
public DelegateCommand OpenDrawer
{
get => new DelegateCommand(() =>
{
if (Status == 0)
{
enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
//enumerable = ChannelStocks.GroupBy(cs => cs.Location, cs => cs);
enumerator = enumerable.GetEnumerator();
enumerator.MoveNext();
Status = 1;
OpenOneByOne();
}
});
}
private void OpenOneByOne()
{
IGrouping<int, ChannelStock> grouping = enumerator.Current;
int DrawerNo =grouping.Key;
List<ChannelStock> channelStocks = grouping.ToList();
channelStocks.ForEach(it => it.process = 1);
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
List<ChannelStock> singleChannels = channelStocks.GroupBy(it => new
{
it.DrawerNo,
it.ColNo
}).Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(itx => itx.Quantity);
ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
return ret;
}).ToList().FindAll(it => it.BoardType != 1);
// 发送取药数量
//singleChannels.ForEach(it =>
//{
// try
// {
// _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
// }
// catch (Exception ex)
// {
// AlertMsg alertMsg = new AlertMsg
// {
// Message = $"打开抽屉异常{ex.Message}",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// }
//});
_portUtil.WindowName = "CheckStockNewWindow";
_portUtil.Operate = true;
_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
_portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
_portUtil.DrawerNo = DrawerNo;
_portUtil.Start();
}
private bool _isFinishClick = false;
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(() =>
{
_isFinishClick = true;
//List<ChannelStock> record = ChannelStocks.FindAll(it => it.Quantity != it.CheckQuantity).ToList();
List<ChannelStock> record = ChannelStocks;
if (record.Count > 0)
{
string InvoiceId = "CHECK_" + CurrentTimeMillis();
var f = SqlSugarHelper.Db.UseTran(() =>
{
for (int i = 0; i < record.Count; i++)
{
ChannelStock it = record[i];
// 更新数据 库存信息
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.CheckQuantity,
ManuNo = it.ManuNo,
EffDate = it.EffDate,
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
// 保存数据 盘点记录
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = it.MachineId,
DrawerNo = it.DrawerNo,
ColNo = it.ColNo,
DrugId = it.DrugId,
ManuNo = it.ManuNo,
EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
Quantity = it.CheckQuantity - it.Quantity,
Type = 4,
InvoiceId = InvoiceId,
StockQuantity = nowChannels.Sum(it => it.Quantity),
CheckQuantity = it.CheckQuantity,
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
}).ExecuteCommand();
logger.Info($"库存盘点->库位【{it.DrawerNo}-{it.ColNo}】药品【{it.DrugInfo.DrugName}】盘点前库存【{it.Quantity}】,更改后【{it.CheckQuantity}】");
}
string machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
string strSql = $@"SELECT cl.`row_no` AS rowNo,cl.`col_no` AS colNo,cl.`quantity` AS quantity,cl.`manu_no` AS manuNo,cl.`eff_date` AS effDate,
di.`drug_name` AS drugName,di.`drug_spec` AS drugSpec,di.`pack_unit` AS packUnit,di.`manufactory` AS manufactory,di.`max_stock` maxStock,
cl.`drug_id` AS drugId,cl.`machine_id` AS MachineId FROM channel_stock cl INNER JOIN drug_info di ON di.`drug_id` = cl.`drug_id` WHERE cl.`machine_id` = '{machine_id}' AND cl.`drawer_type` = 1 ORDER BY cl.`drug_id`";
List<CheckRecordStock> checkRecordStockList = SqlSugarHelper.Db.SqlQueryable<dynamic>(strSql)
.AddParameters(new
{
machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1"
})
.Select(it => new CheckRecordStock())
.ToList();
List<CheckRecordStock> insertList = new List<CheckRecordStock>();
if (checkRecordStockList != null && checkRecordStockList.Count > 0)
{
for (int i = 0; i < checkRecordStockList.Count; i++)
{
if (!(insertList.Where(it => it.drugId == checkRecordStockList[i].drugId && it.manuNo == checkRecordStockList[i].manuNo).Count() > 0))
{
insertList.Add(checkRecordStockList[i]);
}
}
for (int j = 0; j < insertList.Count; j++)
{
CheckRecordStock cStock = insertList[j];
// 保存数据 盘点后药品总库存及批次库存数
SqlSugarHelper.Db.Insertable(new CheckRecordStock()
{
rowNo = cStock.rowNo,
colNo = cStock.colNo,
ManuQuantity = checkRecordStockList.Where(it => it.drugId == cStock.drugId && it.manuNo == cStock.manuNo).Sum(it => it.quantity),
manuNo = cStock.manuNo,
effDate = cStock.effDate,
drugName = cStock.drugName,
manufactory = cStock.manufactory,
drugSpec = cStock.drugSpec,
packUnit = cStock.packUnit,
maxStock = cStock.maxStock,
drugId = cStock.drugId,
MachineId = cStock.MachineId,
quantity = checkRecordStockList.Where(it => it.drugId == cStock.drugId).Sum(it => it.quantity),
optdate = DateTime.Now.ToString(),
operatorUser = HomeWindowViewModel.Operator?.Id.ToString(),
reviewerUser = HomeWindowViewModel.Reviewer?.Id.ToString()
}).ExecuteCommand();
}
}
return true;
});
if (f.Data)
{
// 更新屏显库存
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1)
.GroupBy(it => new
{
it.DrawerNo,
it.ColNo
}).Select(it =>
{
var ret = it.First();
ret.CheckQuantity = it.Sum(itx => itx.CheckQuantity);
//ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
return ret;
}).ToList();
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
singleChannels.ForEach(it =>
{
// 将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.CheckQuantity);
});
}
RequestData();
AlertMsg alertMsg = new AlertMsg
{
Message = "抽屉盘点完成,库存已更新",
Type = MsgType.SUCCESS,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
if (!f.IsSuccess)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "抽屉盘点完成,库存更新失败!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
Status = 0;
_isFinishClick = false;
}
else
{
_isFinishClick = false;
AlertMsg alertMsg = new AlertMsg
{
Message = "盘点完成,库存无改变",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Status = 0;
_isFinishClick = false;
}
}, () => Status == 3 && !_isFinishClick).ObservesProperty(() => Status);
}
// 取消按钮
public DelegateCommand CancleTake
{
get => new DelegateCommand(() =>
{
_portUtil.ResetData();
Status = 0;
});
}
public bool KeepAlive => true;
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
// dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
//if (dialogResult.Result == ButtonResult.OK)
//{
RequestData();
//}
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
///// <summary>
///// 导出账册
///// </summary>
//public DelegateCommand DownloadAccountBook
//{
// get => new DelegateCommand(() =>
// {
// if (!string.IsNullOrEmpty(Stock))
// {
// //根据库位信息查询出药品id
// string[] strStock = Stock.Split('-');
// if (strStock.Length >= 2)
// {
// //DrugId = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == Convert.ToInt32(strStock[0]) && cs.ColNo == Convert.ToInt32(strStock[1])).Select(cs => cs.DrugId).ToString();
// var list = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == Convert.ToInt32(strStock[0]) && cs.ColNo == Convert.ToInt32(strStock[1]) && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).ToList();
// if (list != null && list.Count > 0)
// {
// drugId = list[0].DrugId;
// }
// }
// }
// GridReportUtil.PrintReportAccountBook(StartDate, EndDate, drugId ?? "");
// });
//}
//public DelegateCommand DownLoadCommond
//{
// get => new DelegateCommand(() =>
// {
// GridReportUtil.PrintReportStockNew(StartDate, EndDate);
// });
//}
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
{
continuationCallback(true);
}
public void RequestData()
{
ChannelStocks.Clear();
List<ChannelStock> q = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
.InnerJoin<ChannelList>((cs, cl) => cs.Chnguid == cl.Id && cs.DrugId == cl.DrugId)
.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.DrugId != null)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
.WhereIF(!String.IsNullOrEmpty(SearchValue), cs => cs.DrugInfo.DrugName == SearchValue)
.OrderBy(cs => cs.DrawerNo)
.OrderBy(cs => cs.ColNo)
//.OrderBy(cs => cs.DrugId)
.ToList();
ChannelStocks = q.Select(it => { it.CheckQuantity = it.Quantity; return it; }).ToList();
ChannelStocks = q;
}
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
Task.Factory.StartNew(() => { RequestData(); });
//RequestData();
}
//每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
//这个方法用于拦截请求
public void OnNavigatedFrom(NavigationContext navigationContext)
{
// 取消消息订阅
_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
}
}
}

View File

@ -0,0 +1,647 @@
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.Report;
using DM_Weight.select;
using DM_Weight.util;
using log4net;
using log4net.Repository.Hierarchy;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Data;
namespace DM_Weight.ViewModels
{
public class CheckStockNewWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
{
//public static CheckStockNewWindowViewModel vm;
private readonly ILog logger = LogManager.GetLogger(typeof(CheckStockWindowViewModel));
public string drugId;
//public string Stock;
private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static List<OrderTakeSelect> StaticSelects = new()
{
new OrderTakeSelect
{
Code = "DrugName",
Name = "药品名称"
},
new OrderTakeSelect
{
Code = "PyCode",
Name = "拼音码"
},
new OrderTakeSelect
{
Code = "DrugBarcode",
Name = "药品条码"
},
new OrderTakeSelect
{
Code = "DrugId",
Name = "药品编码"
}
};
private List<OrderTakeSelect> _selects = StaticSelects;
public List<OrderTakeSelect> Selects
{
get { return _selects; }
set
{
SetProperty(ref _selects, value);
}
}
private OrderTakeSelect _selectedItem = StaticSelects[0];
/// <summary>
/// 查询条件 查询字段
/// </summary>
public OrderTakeSelect SelectedItem
{
get { return _selectedItem; }
set
{
SetProperty(ref _selectedItem, value);
RequestData();
}
}
private string? _searchValue;
/// <summary>
/// 查询条件 查询字段值
/// </summary>
public string? SearchValue
{
get { return _searchValue; }
set
{
SetProperty(ref _searchValue, value);
RequestData();
}
}
//private DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
//public DateTime? StartDate
//{
// get => _startDate;
// set
// {
// if (value != null)
// {
// SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0));
// }
// else
// {
// SetProperty(ref _startDate, value);
// }
// RequestData();
// }
//}
//private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
//public DateTime? EndDate
//{
// get => _endDate;
// set
// {
// if (value != null)
// {
// TimeSpan ershisi = new TimeSpan(23, 59, 59);
// SetProperty(ref _endDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0, 23, 59, 59));
// }
// else
// {
// SetProperty(ref _endDate, value);
// }
// RequestData();
// }
//}
IDialogService _dialogService;
IEventAggregator _eventAggregator;
////private SqlSugarScope SqlSugarHelper.Db;
private PortUtil _portUtil;
private int _status;
public int Status { get => _status; set => SetProperty(ref _status, value); }
private int _drawerNo = 1;
public int DrawerNo
{
get => _drawerNo;
set => SetProperty(ref _drawerNo, value);
}
public long CurrentTimeMillis()
{
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
public CheckStockNewWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService dialogService)
{
_dialogService = dialogService;
////this.SqlSugarHelper.Db = sqlSugarScope;
_portUtil = portUtil;
_portUtil = portUtil;
_eventAggregator = eventAggregator;
//vm= this;
}
void DoMyPrismEvent(DeviceMsg msg)
{
if (msg.WindowName == "CheckStockNewWindow")
{
IGrouping<string, ChannelStock> grouping = enumerator.Current;
int DrawerNo =Convert.ToInt32(grouping.Key.Substring(0, grouping.Key.IndexOf('-')));
List<ChannelStock> channelStocks = grouping.ToList();
switch (msg.EventType)
{
// 抽屉打开
case EventType.DRAWEROPEN:
if (Status == 1)
{
if (channelStocks[0].process == 1)
{
channelStocks.ForEach(it => it.process = 2);
}
//Status = 2;
}
break;
// 抽屉关闭
case EventType.DRAWERCLOSE:
if (Status == 1)
{
if (channelStocks[0].process == 2)
{
channelStocks.ForEach(it => it.process = 3);
}
IGrouping<string, ChannelStock> groupingBefore = enumerator.Current;
int DrawerNoBefore = Convert.ToInt32(groupingBefore.Key.Substring(0, groupingBefore.Key.IndexOf('-')));
if (enumerator.MoveNext())
{
IGrouping<string, ChannelStock> groupingAfter = enumerator.Current;
int DrawerNoAfter = Convert.ToInt32(groupingAfter.Key.Substring(0, groupingAfter.Key.IndexOf('-')));
//if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
//{
// Thread.Sleep(50);
//}
logger.Info($"抽屉号DrawerNoBefore【{DrawerNoBefore}】抽屉号DrawerNoAfter【{DrawerNoAfter}】");
if (DrawerNoAfter == 17)
{
if (DrawerNoBefore == 17)
{
Thread.Sleep(1000);
}
else
{
Thread.Sleep(500);
}
}
else
{
Thread.Sleep(80);
}
logger.Info($"抽屉号DrawerNoBefore【{DrawerNoBefore}】抽屉号DrawerNoAfter【{DrawerNoAfter}】");
OpenOneByOne();
}
// 已经全部取出
else
{
Status = 3;
}
}
break;
// 数量变化
case EventType.UPDATEQUANTITY:
if (Status == 1)
{
logger.Info($"抽屉【{DrawerNo}】库位药品数量【{msg.Quantitys}】");
}
break;
// 打开失败
case EventType.OPENERROR:
AlertMsg alertMsg = new AlertMsg
{
Message = msg.Message,
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Status = 0;
break;
}
}
}
private ChannelStock? _selectedChannel;
public ChannelStock? SelectedChannel
{
get => _selectedChannel;
set => SetProperty(ref _selectedChannel, value);
}
private List<ChannelStock>? _channelStocks = new();
public List<ChannelStock>? ChannelStocks
{
get => _channelStocks;
set => SetProperty(ref _channelStocks, value);
}
private IEnumerable<IGrouping<string, ChannelStock>> enumerable;
private IEnumerator<IGrouping<string, ChannelStock>> enumerator;
public DelegateCommand BindingChannelDialog
{
get => new DelegateCommand(() =>
{
DialogParameters dialogParameters = new DialogParameters();
DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelDialog", dialogParameters, DoDialogResult, "RootDialog");
});
}
public DelegateCommand QueryCommand
{
get => new DelegateCommand(() =>
{
RequestData();
});
}
/// <summary>
/// 盘点
/// </summary>
public DelegateCommand OpenDrawer
{
get => new DelegateCommand(() =>
{
if (Status == 0)
{
//enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
enumerable = ChannelStocks.GroupBy(cs => cs.Location, cs => cs);
enumerator = enumerable.GetEnumerator();
enumerator.MoveNext();
Status = 1;
OpenOneByOne();
}
});
}
private void OpenOneByOne()
{
IGrouping<string, ChannelStock> grouping = enumerator.Current;
int DrawerNo =Convert.ToInt32(grouping.Key.Substring(0,grouping.Key.IndexOf('-')));
List<ChannelStock> channelStocks = grouping.ToList();
channelStocks.ForEach(it => it.process = 1);
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
List<ChannelStock> singleChannels = channelStocks.GroupBy(it => new
{
it.DrawerNo,
it.ColNo
}).Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(itx => itx.Quantity);
ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
return ret;
}).ToList().FindAll(it => it.BoardType != 1);
// 发送取药数量
//singleChannels.ForEach(it =>
//{
// try
// {
// _portUtil.TakeQuantity(DrawerNo, it.ColNo, it.TakeQuantity, it.Quantity - it.TakeQuantity);
// }
// catch (Exception ex)
// {
// AlertMsg alertMsg = new AlertMsg
// {
// Message = $"打开抽屉异常{ex.Message}",
// Type = MsgType.ERROR,
// };
// _eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
// }
//});
_portUtil.WindowName = "CheckStockNewWindow";
_portUtil.Operate = true;
_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
_portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
_portUtil.DrawerNo = DrawerNo;
_portUtil.Start();
}
private bool _isFinishClick = false;
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(() =>
{
_isFinishClick = true;
//List<ChannelStock> record = ChannelStocks.FindAll(it => it.Quantity != it.CheckQuantity).ToList();
List<ChannelStock> record = ChannelStocks;
if (record.Count > 0)
{
string InvoiceId = "CHECK_" + CurrentTimeMillis();
var f = SqlSugarHelper.Db.UseTran(() =>
{
for (int i = 0; i < record.Count; i++)
{
ChannelStock it = record[i];
// 更新数据 库存信息
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.CheckQuantity,
ManuNo = it.ManuNo,
EffDate = it.EffDate,
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
// 保存数据 盘点记录
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = it.MachineId,
DrawerNo = it.DrawerNo,
ColNo = it.ColNo,
DrugId = it.DrugId,
ManuNo = it.ManuNo,
EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
Quantity = it.CheckQuantity - it.Quantity,
Type = 4,
InvoiceId = InvoiceId,
StockQuantity = nowChannels.Sum(it => it.Quantity),
CheckQuantity = it.CheckQuantity,
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
}).ExecuteCommand();
logger.Info($"库存盘点->库位【{it.DrawerNo}-{it.ColNo}】药品【{it.DrugInfo.DrugName}】盘点前库存【{it.Quantity}】,更改后【{it.CheckQuantity}】");
}
string machine_id = (ConfigurationManager.AppSettings["machineId"] ?? "DM1");
string strSql = $@"SELECT cl.`row_no` AS rowNo,cl.`col_no` AS colNo,cl.`quantity` AS quantity,cl.`manu_no` AS manuNo,cl.`eff_date` AS effDate,
di.`drug_name` AS drugName,di.`drug_spec` AS drugSpec,di.`pack_unit` AS packUnit,di.`manufactory` AS manufactory,di.`max_stock` maxStock,
cl.`drug_id` AS drugId,cl.`machine_id` AS MachineId FROM channel_stock cl INNER JOIN drug_info di ON di.`drug_id` = cl.`drug_id` WHERE cl.`machine_id` = '{machine_id}' AND cl.`drawer_type` = 1 ORDER BY cl.`drug_id`";
List<CheckRecordStock> checkRecordStockList = SqlSugarHelper.Db.SqlQueryable<dynamic>(strSql)
.AddParameters(new
{
machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1"
})
.Select(it => new CheckRecordStock())
.ToList();
List<CheckRecordStock> insertList = new List<CheckRecordStock>();
if (checkRecordStockList != null && checkRecordStockList.Count > 0)
{
for (int i = 0; i < checkRecordStockList.Count; i++)
{
if (!(insertList.Where(it => it.drugId == checkRecordStockList[i].drugId && it.manuNo == checkRecordStockList[i].manuNo).Count() > 0))
{
insertList.Add(checkRecordStockList[i]);
}
}
for (int j = 0; j < insertList.Count; j++)
{
CheckRecordStock cStock = insertList[j];
// 保存数据 盘点后药品总库存及批次库存数
SqlSugarHelper.Db.Insertable(new CheckRecordStock()
{
rowNo = cStock.rowNo,
colNo = cStock.colNo,
ManuQuantity = checkRecordStockList.Where(it => it.drugId == cStock.drugId && it.manuNo == cStock.manuNo).Sum(it => it.quantity),
manuNo = cStock.manuNo,
effDate = cStock.effDate,
drugName = cStock.drugName,
manufactory = cStock.manufactory,
drugSpec = cStock.drugSpec,
packUnit = cStock.packUnit,
maxStock = cStock.maxStock,
drugId = cStock.drugId,
MachineId = cStock.MachineId,
quantity = checkRecordStockList.Where(it => it.drugId == cStock.drugId).Sum(it => it.quantity),
optdate = DateTime.Now.ToString(),
operatorUser = HomeWindowViewModel.Operator?.Id.ToString(),
reviewerUser = HomeWindowViewModel.Reviewer?.Id.ToString()
}).ExecuteCommand();
}
}
return true;
});
if (f.Data)
{
// 更新屏显库存
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1)
.GroupBy(it => new
{
it.DrawerNo,
it.ColNo
}).Select(it =>
{
var ret = it.First();
ret.CheckQuantity = it.Sum(itx => itx.CheckQuantity);
//ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
return ret;
}).ToList();
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
singleChannels.ForEach(it =>
{
// 将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.CheckQuantity);
});
}
RequestData();
AlertMsg alertMsg = new AlertMsg
{
Message = "抽屉盘点完成,库存已更新",
Type = MsgType.SUCCESS,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
if (!f.IsSuccess)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "抽屉盘点完成,库存更新失败!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
Status = 0;
_isFinishClick = false;
}
else
{
_isFinishClick = false;
AlertMsg alertMsg = new AlertMsg
{
Message = "盘点完成,库存无改变",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Status = 0;
_isFinishClick = false;
}
}, () => Status == 3 && !_isFinishClick).ObservesProperty(() => Status);
}
// 取消按钮
public DelegateCommand CancleTake
{
get => new DelegateCommand(() =>
{
_portUtil.ResetData();
Status = 0;
});
}
public bool KeepAlive => true;
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
// dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
//if (dialogResult.Result == ButtonResult.OK)
//{
RequestData();
//}
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
///// <summary>
///// 导出账册
///// </summary>
//public DelegateCommand DownloadAccountBook
//{
// get => new DelegateCommand(() =>
// {
// if (!string.IsNullOrEmpty(Stock))
// {
// //根据库位信息查询出药品id
// string[] strStock = Stock.Split('-');
// if (strStock.Length >= 2)
// {
// //DrugId = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == Convert.ToInt32(strStock[0]) && cs.ColNo == Convert.ToInt32(strStock[1])).Select(cs => cs.DrugId).ToString();
// var list = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == Convert.ToInt32(strStock[0]) && cs.ColNo == Convert.ToInt32(strStock[1]) && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).ToList();
// if (list != null && list.Count > 0)
// {
// drugId = list[0].DrugId;
// }
// }
// }
// GridReportUtil.PrintReportAccountBook(StartDate, EndDate, drugId ?? "");
// });
//}
//public DelegateCommand DownLoadCommond
//{
// get => new DelegateCommand(() =>
// {
// GridReportUtil.PrintReportStockNew(StartDate, EndDate);
// });
//}
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
{
continuationCallback(true);
}
public void RequestData()
{
ChannelStocks.Clear();
ChannelStocks.Clear();
List<ChannelStock> q = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
.InnerJoin<ChannelList>((cs, cl) => cs.Chnguid == cl.Id && cs.DrugId == cl.DrugId)
.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.DrugId != null)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
.WhereIF(!String.IsNullOrEmpty(SearchValue), cs => cs.DrugInfo.DrugName == SearchValue)
.OrderBy(cs => cs.DrawerNo)
.OrderBy(cs => cs.ColNo)
//.OrderBy(cs => cs.DrugId)
.ToList();
ChannelStocks = q.Select(it => { it.CheckQuantity = it.Quantity; return it; }).ToList();
ChannelStocks = q;
}
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
Task.Factory.StartNew(() => { RequestData(); });
//RequestData();
}
//每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
//这个方法用于拦截请求
public void OnNavigatedFrom(NavigationContext navigationContext)
{
// 取消消息订阅
_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
}
}
}

View File

@ -33,12 +33,12 @@ namespace DM_Weight.ViewModels
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
private SqlSugarScope _sqlSugarScope1;
public CheckStockWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator,SqlSugarScope sqlSugarScope)
////private SqlSugarScope SqlSugarHelper.Db;
public CheckStockWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
{
_portUtil = portUtil;
_eventAggregator = eventAggregator;
this._sqlSugarScope1= sqlSugarScope;
//this.SqlSugarHelper.Db= sqlSugarScope;
}
void DoMyPrismEvent(DeviceMsg msg)
@ -151,7 +151,7 @@ namespace DM_Weight.ViewModels
if (record.Count > 0)
{
string InvoiceId = "CHECK_" + CurrentTimeMillis();
var f = _sqlSugarScope1.UseTran(() =>
var f = SqlSugarHelper.Db.UseTran(() =>
{
for (int i = 0; i < record.Count; i++)
@ -160,7 +160,7 @@ namespace DM_Weight.ViewModels
// 更新数据 库存信息
_sqlSugarScope1.Updateable(new ChannelStock()
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.CheckQuantity,
ManuNo = it.ManuNo,
@ -168,14 +168,14 @@ namespace DM_Weight.ViewModels
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
// 保存数据 盘点记录
_sqlSugarScope1.Insertable(new MachineRecord()
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = it.MachineId,
DrawerNo = it.DrawerNo,
@ -258,16 +258,17 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => true;
public long CurrentTimeMillis()
{
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
public bool KeepAlive => false;
public void FindDrawerCount()
{
int count = _sqlSugarScope1.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
int count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType != 3)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
Is8Drawer = count < 9;
Is16Drawer = count >= 16;
@ -284,7 +285,7 @@ namespace DM_Weight.ViewModels
public void RequestData()
{
List<ChannelStock> queryData = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes(cs => cs.DrugInfo)
.Where(cs => cs.DrawerNo == DrawerNo)
.Where(cs => cs.DrugId != null)

View File

@ -49,16 +49,17 @@ namespace DM_Weight.ViewModels
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
private SqlSugarScope _sqlSugarScope1;
public DrawerAddDrugWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator,SqlSugarScope sqlSugarScope)
////private SqlSugarScope SqlSugarHelper.Db;
public DrawerAddDrugWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
{
_portUtil = portUtil;
_eventAggregator = eventAggregator;
this._sqlSugarScope1= sqlSugarScope;
//this.SqlSugarHelper.Db= sqlSugarScope;
}
void DoMyPrismEvent(DeviceMsg msg)
{
logger.Info("抽屉加药页面_DoMyPrismEvent");
if (msg.WindowName == "DrawerAddDrugWindow")
{
switch (msg.EventType)
@ -142,13 +143,26 @@ namespace DM_Weight.ViewModels
try
{
//var groupQuery = (from t in ChannelStocks
// group t by new { t.ColNo, t.BoardType }
// into grp
// select new { grp.Key.ColNo, grp.Key.BoardType, quantity = grp.Sum(t => t.Quantity) }).ToList();
// singleChannelsFor = singleChannelsFor.GroupBy(it => it.ColNo)
// .Select(it => new
// {
// Quantity = it.Sum(itx => itx.Quantity),
// AddQuantity = it.Sum(itx => itx.AddQuantity)
//})
// .ToList()
// .FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
_portUtil.WindowName = "DrawerAddDrugWindow";
_portUtil.Operate = true;
_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
_portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
_portUtil.ColNos = new int[] { };// singleChannels.Select(it => it.ColNo).ToArray();
_portUtil.DrawerNo = DrawerNo;
_portUtil.Start();
@ -177,7 +191,7 @@ namespace DM_Weight.ViewModels
{
//string InvoiceId = "DRAWER_" + CurrentTimeMillis();
string InvoiceId = PZH;
var f = _sqlSugarScope1.UseTran(() =>
var f = SqlSugarHelper.Db.UseTran(() =>
{
for (int i = 0; i < record.Count; i++)
@ -187,7 +201,7 @@ namespace DM_Weight.ViewModels
it.EffDate = it.drugManuNo.EffDate;
// 更新数据 库存信息
_sqlSugarScope1.Updateable(new ChannelStock()
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity + it.AddQuantity,
ManuNo = it.ManuNo,
@ -195,14 +209,14 @@ namespace DM_Weight.ViewModels
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
// 保存数据 入库记录
_sqlSugarScope1.Insertable(new MachineRecord()
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = it.MachineId,
DrawerNo = it.DrawerNo,
@ -211,13 +225,15 @@ namespace DM_Weight.ViewModels
ManuNo = it.ManuNo,
EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer=HomeWindowViewModel.Reviewer?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
Quantity = it.AddQuantity,
Type = 1,
InvoiceId = InvoiceId,
StockQuantity = nowChannels.Sum(it => it.Quantity),
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
SupplierDept = ConfigurationManager.AppSettings["supplierDept"].ToString(),
ReceiveDept = ConfigurationManager.AppSettings["receiveDept"].ToString()
}).ExecuteCommand();
}
return true;
@ -225,12 +241,22 @@ namespace DM_Weight.ViewModels
if (f.Data)
{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = ChannelStocks.Where(it => it.BoardType != 1)
.GroupBy(it => it.ColNo)
.Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(it => it.Quantity);
ret.AddQuantity = it.Sum(it => it.AddQuantity);
return ret;
}).ToList();
singleChannels = singleChannels.Where(it => it.AddQuantity > 0).ToList();
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
//将库位多批次的总库存数更新标签
singleChannels.ForEach(it =>
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity+it.AddQuantity);
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
});
}
RequestData();
@ -288,15 +314,16 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => true;
public long CurrentTimeMillis()
{
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
public bool KeepAlive => false;
public void FindDrawerCount()
{
int count = _sqlSugarScope1.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
int count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType != 3)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
Is8Drawer = count < 9;
Is16Drawer = count >= 16;
@ -314,8 +341,13 @@ namespace DM_Weight.ViewModels
public void RequestData()
{
List<ChannelStock> queryData = _sqlSugarScope1.Queryable<ChannelStock>()
.Includes(cs => cs.DrugInfo,di=>di.DrugManuNos)
if (ChannelStocks != null)
{
ChannelStocks.Clear();
}
List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes(cs => cs.DrugInfo, di => di.DrugManuNos)
.InnerJoin<ChannelList>((cs, cl) => cs.Chnguid==cl.Id &&cs.DrugId==cl.DrugId)
.Where(cs => cs.DrawerNo == DrawerNo)
.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
@ -328,7 +360,7 @@ namespace DM_Weight.ViewModels
return cs;
}).ToList();
//obChannelStock = new ObservableCollection<ChannelStock>(ChannelStocks);
//obChannelStock = new ObservableCollection<ChannelStock>(ChannelStocks);
}
//接收导航传过来的参数 现在是在此处初始化了表格数据

View File

@ -44,17 +44,18 @@ namespace DM_Weight.ViewModels
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
private SqlSugarScope _sqlSugarScope1;
public DrawerTakeDrugWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator,SqlSugarScope sqlSugarScope)
////private SqlSugarScope SqlSugarHelper.Db;
public DrawerTakeDrugWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
{
_portUtil = portUtil;
_eventAggregator = eventAggregator;
this._sqlSugarScope1= sqlSugarScope;
//this.SqlSugarHelper.Db= sqlSugarScope;
}
void DoMyPrismEvent(DeviceMsg msg)
{
if(msg.WindowName == "DrawerTakeDrugWindow")
logger.Info($"抽屉取药页面_DoMyPrismEvent:{msg.WindowName}");
if (msg.WindowName == "DrawerTakeDrugWindow")
{
switch (msg.EventType)
{
@ -139,16 +140,18 @@ namespace DM_Weight.ViewModels
Status = 1;
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
//var groupQuery = (from t in ChannelStocks
// group t by new { t.ColNo, t.BoardType }
// into grp
// select new { grp.Key.ColNo, grp.Key.BoardType, quantity = grp.Sum(t => t.Quantity) }).ToList();
List<ChannelStock> singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
_portUtil.WindowName = "DrawerTakeDrugWindow";
_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
_portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
_portUtil.ColNos = new int[] { };// groupQuery.Select(it => it.ColNo).ToArray();
_portUtil.DrawerNo = DrawerNo;
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, () => _portUtil.Start())
;
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, () => _portUtil.Start());
}
});
@ -168,8 +171,9 @@ namespace DM_Weight.ViewModels
logger.Info("点击完成按钮,库位数据:" + JsonConvert.SerializeObject(record));
if (record.Count > 0)
{
logger.Info("record.Count>0");
string InvoiceId = "DRAWER_" + CurrentTimeMillis();
var f = _sqlSugarScope1.UseTran(() =>
var f = SqlSugarHelper.Db.UseTran(() =>
{
for (int i = 0; i < record.Count; i++)
@ -178,22 +182,24 @@ namespace DM_Weight.ViewModels
// 更新数据 库存信息
_sqlSugarScope1.Updateable(new ChannelStock()
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity - it.TakeQuantity,
ManuNo = it.ManuNo,
EffDate = it.EffDate,
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
logger.Info("Updateable_ChannelStock完成");
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
logger.Info("Queryable_ChannelStock完成");
// 保存数据 出库记录
_sqlSugarScope1.Insertable(new MachineRecord()
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = it.MachineId,
DrawerNo = it.DrawerNo,
@ -208,28 +214,46 @@ namespace DM_Weight.ViewModels
Type = 2,
InvoiceId = InvoiceId,
StockQuantity = nowChannels.Sum(it => it.Quantity),
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
SupplierDept = ConfigurationManager.AppSettings["supplierDept"].ToString(),
ReceiveDept = ConfigurationManager.AppSettings["receiveDept"].ToString()
}).ExecuteCommand();
logger.Info("Insert_MachineRecord完成");
logger.Info($"抽屉取药保存->库位【{it.DrawerNo}-{it.ColNo}】取出药品【{it.DrugInfo.DrugName}】个数【{it.TakeQuantity}】,取药前库存【{it.Quantity}】");
}
return true;
});
if (f.Data)
if (f.Data)
{
logger.Info("更新屏显库存singleChannels");
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = ChannelStocks.Where(it => it.BoardType != 1)
.GroupBy(it => it.ColNo)
.Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(itx => itx.Quantity);
ret.TakeQuantity = it.Sum(itx => itx.TakeQuantity);
return ret;
}).ToList();
singleChannels = singleChannels.Where(it => it.TakeQuantity > 0).ToList();
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
//将库位多批次的总库存数更新标签
//_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) - singleChannels.Sum(it => it.TakeQuantity));
singleChannels.ForEach(it =>
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
_portUtil.WriteQuantityAsync(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
});
}
logger.Info("更新屏显库存singleChannels_完成");
RequestData();
AlertMsg alertMsg = new AlertMsg
{
Message = "抽屉取药完成,库存已更新",
Message = $"抽屉取药完成,库存已更新",
Type = MsgType.SUCCESS,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
@ -238,7 +262,7 @@ namespace DM_Weight.ViewModels
{
AlertMsg alertMsg = new AlertMsg
{
Message = "抽屉取药完成,库存更新失败!",
Message = $"抽屉取药完成,库存更新失败!{f.ErrorMessage}",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
@ -272,16 +296,16 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => true;
public long CurrentTimeMillis()
{
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
public bool KeepAlive => false;
public void FindDrawerCount()
{
int count = _sqlSugarScope1.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
int count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType != 3)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
Is8Drawer = count < 9;
Is16Drawer = count >= 16;
@ -298,7 +322,7 @@ namespace DM_Weight.ViewModels
public void RequestData()
{
List<ChannelStock> queryData = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes(cs => cs.DrugInfo)
.Where(cs => cs.DrawerNo == DrawerNo)
.Where(cs => cs.DrugId != null)

View File

@ -13,6 +13,8 @@ using DM_Weight.util;
using log4net.Repository.Hierarchy;
using log4net;
using SqlSugar;
using DM_Weight.msg;
using Prism.Events;
namespace DM_Weight.ViewModels
{
@ -165,11 +167,12 @@ namespace DM_Weight.ViewModels
set { SetProperty(ref _selectedManuno, value ?? new()); }
}
public bool KeepAlive => false;
private SqlSugarScope _sqlSugarScope1;
public DrugListWindowViewModel(SqlSugarScope sqlSugarScope)
//private SqlSugarScope SqlSugarHelper.Db;
IEventAggregator _eventAggregator;
public DrugListWindowViewModel(IEventAggregator eventAggregator)
{
this._sqlSugarScope1 = sqlSugarScope;
_eventAggregator = eventAggregator;
}
public DelegateCommand Query
@ -188,7 +191,7 @@ namespace DM_Weight.ViewModels
{
//SelectedDrug.DrugId = 0;
_sqlSugarScope1.Insertable(SelectedDrug).ExecuteCommand();
SqlSugarHelper.Db.Insertable(SelectedDrug).ExecuteCommand();
RequestData();
}
catch (Exception ex)
@ -204,7 +207,7 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand(() =>
{
_sqlSugarScope1.Updateable(SelectedDrug).UpdateColumns(d => new { d.DrugName, d.Manufactory, d.PyCode, d.PackUnit, d.MaxStock, d.DrugSpec }).ExecuteCommand();
SqlSugarHelper.Db.Updateable(SelectedDrug).UpdateColumns(d => new { d.DrugName, d.Manufactory, d.PyCode, d.PackUnit, d.MaxStock, d.DrugSpec }).ExecuteCommand();
RequestData();
}, () => SelectedDrug.DrugId !=null).ObservesProperty(() => SelectedDrug);
}
@ -213,13 +216,55 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand(() =>
{
if (!string.IsNullOrEmpty(SelectedManuno.EffDate) && !string.IsNullOrEmpty(SelectedManuno.ManuNo))
try
{
SelectedManuno.Id = Guid.NewGuid().ToString();
SelectedManuno.DrugId = SelectedDrug.DrugId.ToString();
SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
_sqlSugarScope1.Insertable(SelectedManuno).ExecuteCommand();
GetManuNos();
if (!string.IsNullOrEmpty(SelectedManuno.EffDate) && !string.IsNullOrEmpty(SelectedManuno.ManuNo))
{
string dt = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
int repeatCount = SqlSugarHelper.Db.Queryable<DrugManuNo>().Where(dm => dm.DrugId == SelectedDrug.DrugId && dm.EffDate == dt && dm.ManuNo == SelectedManuno.ManuNo).Count();
if (repeatCount > 0)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "批次重复,请勿重复添加!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
else
{
SelectedManuno.Id = Guid.NewGuid().ToString();
SelectedManuno.DrugId = SelectedDrug.DrugId.ToString();
SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
SqlSugarHelper.Db.Insertable(SelectedManuno).ExecuteCommand(); GetManuNos();
AlertMsg alertMsg = new AlertMsg
{
Message = "保存成功!",
Type = MsgType.SUCCESS,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
}
else
{
AlertMsg alertMsg = new AlertMsg
{
Message = "请输入批次及效期!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
}
catch (Exception ex)
{
AlertMsg alertMsg = new AlertMsg
{
Message = $"添加失败{ex.Message}",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
}, () => SelectedDrug.DrugId !=null).ObservesProperty(() => SelectedDrug);
@ -229,12 +274,47 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand(() =>
{
SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
_sqlSugarScope1.Updateable(SelectedManuno).UpdateColumns(m => new { m.ManuNo, m.EffDate }).ExecuteCommand();
GetManuNos();
try
{
string dt = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
int repeatCount = SqlSugarHelper.Db.Queryable<DrugManuNo>().Where(dm => dm.DrugId == SelectedDrug.DrugId && dm.EffDate == dt && dm.ManuNo == SelectedManuno.ManuNo).Count();
if (repeatCount > 0)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "批次重复,请勿重复添加!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
else
{
SelectedManuno.EffDate = DateTime.Parse(SelectedManuno.EffDate).ToString("yyyy-MM-dd");
SqlSugarHelper.Db.Updateable(SelectedManuno).UpdateColumns(m => new { m.ManuNo, m.EffDate }).ExecuteCommand();
GetManuNos();
AlertMsg alertMsg = new AlertMsg
{
Message = "修改成功!",
Type = MsgType.SUCCESS,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
}
catch (Exception ex)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "修改失败!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
}, () => !string.IsNullOrEmpty(SelectedManuno.DrugId)).ObservesProperty(() => SelectedManuno);
}
public bool KeepAlive => true;
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
@ -252,7 +332,7 @@ namespace DM_Weight.ViewModels
void GetManuNos()
{
Manunos = _sqlSugarScope1.Queryable<DrugManuNo>()
Manunos = SqlSugarHelper.Db.Queryable<DrugManuNo>()
.WhereIF(SelectedDrug != null, (di) => di.DrugId.Equals(SelectedDrug.DrugId))
.Select(di => di)
.ToList();
@ -261,7 +341,7 @@ namespace DM_Weight.ViewModels
void RequestData()
{
int totalCount = 0;
DrugInfos = _sqlSugarScope1.Queryable<DrugInfo>()
DrugInfos = SqlSugarHelper.Db.Queryable<DrugInfo>()
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (di) => di.DrugId.ToString().Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (di) => di.DrugName.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (di) => di.PyCode.Contains(SearchValue))

View File

@ -23,12 +23,12 @@ namespace DM_Weight.ViewModels
private readonly FingerprintUtil _fingerprintUtil;
IEventAggregator _eventAggregator;
private SqlSugarScope _sqlSugarScope1;
//private SqlSugarScope SqlSugarHelper.Db;
public EditUserDialogViewModel(FingerprintUtil fingerprintUtil, IEventAggregator eventAggregator,SqlSugarScope sqlSugarScope)
{
_fingerprintUtil = fingerprintUtil;
_eventAggregator = eventAggregator;
this._sqlSugarScope1 = sqlSugarScope;
//this.SqlSugarHelper.Db = sqlSugarScope;
}
private UserList _userList = new UserList();
@ -80,7 +80,7 @@ namespace DM_Weight.ViewModels
public bool KeepAlive => false;
public bool KeepAlive => true;
private string _title = "编辑用户";
@ -105,7 +105,7 @@ namespace DM_Weight.ViewModels
{
// 旧密码输入正确
UserList.PassWord = MD5.GetMD5Hash(NewPass);
_sqlSugarScope1.Updateable<UserList>(UserList).UpdateColumns(u => new { u.PassWord }).ExecuteCommand();
SqlSugarHelper.Db.Updateable<UserList>(UserList).UpdateColumns(u => new { u.PassWord }).ExecuteCommand();
// 关闭当前窗口
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
}
@ -123,13 +123,13 @@ namespace DM_Weight.ViewModels
// 没有写密码
if (string.IsNullOrEmpty(NewPass))
{
_sqlSugarScope1.Updateable<UserList>(UserList).UpdateColumns(u => new { u.Nickname, u.UserName, u.UserBarcode, u.RoleId }).ExecuteCommand();
SqlSugarHelper.Db.Updateable<UserList>(UserList).UpdateColumns(u => new { u.Nickname, u.UserName, u.UserBarcode, u.RoleId }).ExecuteCommand();
}
// 更改了密码
else
{
UserList.PassWord = MD5.GetMD5Hash(NewPass);
_sqlSugarScope1.Updateable<UserList>(UserList).UpdateColumns(u => new { u.Nickname, u.UserName, u.PassWord, u.UserBarcode, u.RoleId }).ExecuteCommand();
SqlSugarHelper.Db.Updateable<UserList>(UserList).UpdateColumns(u => new { u.Nickname, u.UserName, u.PassWord, u.UserBarcode, u.RoleId }).ExecuteCommand();
}
}
else
@ -137,7 +137,7 @@ namespace DM_Weight.ViewModels
UserList.PassWord = MD5.GetMD5Hash(NewPass);
UserList.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
// 插入
_sqlSugarScope1.Insertable<UserList>(UserList).InsertColumns(u => new { u.Id, u.Nickname, u.UserName, u.PassWord, u.UserBarcode, u.RoleId, u.MachineId }).ExecuteCommand();
SqlSugarHelper.Db.Insertable<UserList>(UserList).InsertColumns(u => new { u.Id, u.Nickname, u.UserName, u.PassWord, u.UserBarcode, u.RoleId, u.MachineId }).ExecuteCommand();
}
RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
}
@ -157,7 +157,7 @@ namespace DM_Weight.ViewModels
void GetAllRole()
{
Roles = _sqlSugarScope1.Queryable<RoleDm>().Where(r => r.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM1")).OrderBy(r => r.Id).ToList();
Roles = SqlSugarHelper.Db.Queryable<RoleDm>().Where(r => r.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM1")).OrderBy(r => r.Id).ToList();
RaisePropertyChanged("Roles");
}

View File

@ -63,7 +63,7 @@ namespace DM_Weight.ViewModels
set => SetProperty(ref _fingerIndex, value);
}
public bool KeepAlive => false;
public bool KeepAlive => true;
private int _status = 0;

View File

@ -52,65 +52,122 @@ namespace DM_Weight.ViewModels
get { return _selectedChildMenu; }
set
{
if (!_portUtil.Operate)
{
if (value != null)
{
if (value.PremissionPath.Equals("TakeRecordWindow"))
{
//定义传参变量
NavigationParameters keys = new NavigationParameters();
//if (!_portUtil.Operate)
//{
//if (value != null)
//{
// if (value.PremissionPath.Equals("TakeRecordWindow"))
// {
// //定义传参变量
// NavigationParameters keys = new NavigationParameters();
//添加参数,键值对格式
keys.Add("Type", 2);
_regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
}
else if (value.PremissionPath.Equals("AddRecordWindow"))
{
//定义传参变量
NavigationParameters keys = new NavigationParameters();
// //添加参数,键值对格式
// keys.Add("Type", 2);
// _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
// }
// else if (value.PremissionPath.Equals("AddRecordWindow"))
// {
// //定义传参变量
// NavigationParameters keys = new NavigationParameters();
//添加参数,键值对格式
keys.Add("Type", 1);
_regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
}
else if (value.PremissionPath.Equals("ReturnRecordWindow"))
{
//定义传参变量
NavigationParameters keys = new NavigationParameters();
// //添加参数,键值对格式
// keys.Add("Type", 1);
// _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
// }
// else if (value.PremissionPath.Equals("ReturnRecordWindow"))
// {
// //定义传参变量
// NavigationParameters keys = new NavigationParameters();
//添加参数,键值对格式
keys.Add("Type", 3);
_regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
}
else if (value.PremissionPath.Equals("RetrunEmptyRecordWindow"))
{
//定义传参变量
NavigationParameters keys = new NavigationParameters();
// //添加参数,键值对格式
// keys.Add("Type", 3);
// _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
// }
// else if (value.PremissionPath.Equals("RetrunEmptyRecordWindow"))
// {
// //定义传参变量
// NavigationParameters keys = new NavigationParameters();
//添加参数,键值对格式
keys.Add("Type", 3);
_regionManager.RequestNavigate("ContentRegion", value.PremissionPath, keys);
}
else if (value.PremissionPath.Equals("CheckRecordWindow"))
{
//定义传参变量
NavigationParameters keys = new NavigationParameters();
// //添加参数,键值对格式
// keys.Add("Type", 3);
// _regionManager.RequestNavigate("ContentRegion", value.PremissionPath, keys);
// }
// else if (value.PremissionPath.Equals("CheckRecordWindow"))
// {
// //定义传参变量
// NavigationParameters keys = new NavigationParameters();
//添加参数,键值对格式
keys.Add("Type", 4);
_regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
}
else
{
_regionManager.RequestNavigate("ContentRegion", value.PremissionPath);
}
}
// //添加参数,键值对格式
// keys.Add("Type", 4);
// _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
// }
// else
// {
// _regionManager.RequestNavigate("ContentRegion", value.PremissionPath);
// }
//}
SetProperty(ref _selectedChildMenu, value);
//}
}
}
private void SelectChildNavigate(PremissionDm SelectedChildMenu)
{
if (!_portUtil.Operate)
{
if (SelectedChildMenu != null)
{
if (SelectedChildMenu.PremissionPath.Equals("TakeRecordWindow"))
{
//定义传参变量
NavigationParameters keys = new NavigationParameters();
//添加参数,键值对格式
keys.Add("Type", 2);
_regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
}
else if (SelectedChildMenu.PremissionPath.Equals("AddRecordWindow"))
{
//定义传参变量
NavigationParameters keys = new NavigationParameters();
//添加参数,键值对格式
keys.Add("Type", 1);
_regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
}
else if (SelectedChildMenu.PremissionPath.Equals("ReturnRecordWindow"))
{
//定义传参变量
NavigationParameters keys = new NavigationParameters();
//添加参数,键值对格式
keys.Add("Type", 3);
_regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
}
else if (SelectedChildMenu.PremissionPath.Equals("RetrunEmptyRecordWindow"))
{
//定义传参变量
NavigationParameters keys = new NavigationParameters();
//添加参数,键值对格式
keys.Add("Type", 3);
_regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath, keys);
}
else if (SelectedChildMenu.PremissionPath.Equals("CheckRecordWindow"))
{
//定义传参变量
NavigationParameters keys = new NavigationParameters();
//添加参数,键值对格式
keys.Add("Type", 4);
_regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
}
else
{
_regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath);
}
}
}
}
public PremissionDm? SelectedMenu
{
get { return _selectedMenu; }
@ -134,15 +191,17 @@ namespace DM_Weight.ViewModels
}
}
private DelegateCommand<ListBox> _selectionCommon;
public DelegateCommand<ListBox> SelectionCommon
#region
private DelegateCommand _selectionCommon;
public DelegateCommand SelectionCommon
{
get => _selectionCommon ?? (_selectionCommon = new DelegateCommand<ListBox>(SelectionMethod));
get => _selectionCommon ?? (_selectionCommon = new DelegateCommand(SelectionMethod));
}
private void SelectionMethod(ListBox viewName)
private void SelectionMethod()
{
SelectedMenu = viewName.SelectedItem as PremissionDm;
if (SelectedMenu.PremissionName == "退出")
logger.Info("开始进入父菜单");
//SelectedMenu = viewName.SelectedItem as PremissionDm;
if (SelectedMenu!=null&&SelectedMenu.PremissionName == "退出")
{
logger.Info($"用户【{Operator?.Nickname}】退出登录");
Operator = null;
@ -152,9 +211,27 @@ namespace DM_Weight.ViewModels
else
{
//SelectedMenu.Children = SelectedMenu.Children;
SelectedChildMenu = SelectedMenu.Children[0];
//SelectedChildMenu = SelectedMenu.Children[0];
if (!_portUtil.Operate)
{
_regionManager.RequestNavigate("ContentRegion", SelectedMenu.Children[0].PremissionPath);
}
}
logger.Info("结束父菜单");
}
#endregion
#region
private DelegateCommand _selectionChildCommon;
public DelegateCommand SelectionChildCommon
{
get => _selectionChildCommon ?? (_selectionChildCommon = new DelegateCommand(SelectionChildMethod));
}
private void SelectionChildMethod()
{
SelectChildNavigate(SelectedChildMenu);
}
#endregion
public List<PremissionDm> PremissionDmList { get { return _premissionDmList; } set { SetProperty(ref _premissionDmList, value); } }
@ -169,9 +246,8 @@ namespace DM_Weight.ViewModels
private bool _is16Drawer;
public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); }
public bool KeepAlive => false;
private PortUtil _portUtil;
private SqlSugarScope _sqlSugarScope1;
//private SqlSugarScope SqlSugarHelper.Db;
IEventAggregator _eventAggregator;
public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container, SqlSugarScope sqlSugarScope, IEventAggregator eventAggregator)
{
@ -179,7 +255,7 @@ namespace DM_Weight.ViewModels
_regionManager = iRegionManager;
_dialogService = dialogService;
_container = container;
this._sqlSugarScope1 = sqlSugarScope;
//this.SqlSugarHelper.Db = sqlSugarScope;
this._eventAggregator = eventAggregator;
}
@ -237,6 +313,9 @@ namespace DM_Weight.ViewModels
get => new DelegateCommand(ShiftsAction);
}
public bool KeepAlive => false;
private void ShiftsAction()
{
_regionManager.RequestNavigate("ContentRegion", "ChangeShiftsWindow");
@ -244,7 +323,7 @@ namespace DM_Weight.ViewModels
public void FindDrawerCount()
{
int count = _sqlSugarScope1.Queryable<ChannelStock>().Where(cs => cs.DrawerType != 3)
int count = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType != 3)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrawerNo).Select(cs => SqlFunc.AggregateCount(cs.DrawerNo)).Count();
Is16Drawer = count == 16;
@ -289,11 +368,12 @@ namespace DM_Weight.ViewModels
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
//_sqlSugarScope1.SqlQueryable<PremissionDm>(sql)
//SqlSugarHelper.Db.SqlQueryable<PremissionDm>(sql)
//.ToTree(pd => pd.Children, pd => pd.ParentId, 0);
PremissionDmList = premissions;
SelectedMenu = premissions[0];
SelectedChildMenu = premissions[0].Children[0];
_regionManager.RequestNavigate("ContentRegion", premissions[0].Children[0].PremissionPath);
FindDrawerCount();
int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
@ -334,5 +414,111 @@ namespace DM_Weight.ViewModels
public void OnNavigatedFrom(NavigationContext navigationContext)
{
}
//取药
private DelegateCommand _takeCommand;
public DelegateCommand TakeCommand
{
get => new DelegateCommand(() =>
{
TakeMethod();
});
}
//=>_takeCommand??= new DelegateCommand(TakeMethod);
private void TakeMethod()
{
SelectedMenu = PremissionDmList[0];
if (SelectedMenu.PremissionName == "退出")
{
logger.Info($"用户【{Operator?.Nickname}】退出登录");
Operator = null;
Reviewer = null;
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
}
else
{
//SelectedMenu.Children = SelectedMenu.Children;
SelectedChildMenu = SelectedMenu.Children[0];
}
}
//加药
private DelegateCommand _addCommand;
public DelegateCommand AddCommand => _addCommand ??= new DelegateCommand(AddMethod);
private void AddMethod()
{
SelectedMenu = PremissionDmList[1];
if (SelectedMenu.PremissionName == "退出")
{
logger.Info($"用户【{Operator?.Nickname}】退出登录");
Operator = null;
Reviewer = null;
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
}
else
{
//SelectedMenu.Children = SelectedMenu.Children;
SelectedChildMenu = SelectedMenu.Children[0];
}
}
//还药
private DelegateCommand _returnCommand;
public DelegateCommand ReturnCommand => _returnCommand ??= new DelegateCommand(ReturnMethod);
private void ReturnMethod()
{
SelectedMenu = PremissionDmList[2];
if (SelectedMenu.PremissionName == "退出")
{
logger.Info($"用户【{Operator?.Nickname}】退出登录");
Operator = null;
Reviewer = null;
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
}
else
{
//SelectedMenu.Children = SelectedMenu.Children;
SelectedChildMenu = SelectedMenu.Children[0];
}
}
private DelegateCommand _stockCommand;
public DelegateCommand StockCommand => _stockCommand ??= new DelegateCommand(StockMethod);
private void StockMethod()
{
SelectedMenu = PremissionDmList[3];
if (SelectedMenu.PremissionName == "退出")
{
logger.Info($"用户【{Operator?.Nickname}】退出登录");
Operator = null;
Reviewer = null;
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
}
else
{
//SelectedMenu.Children = SelectedMenu.Children;
SelectedChildMenu = SelectedMenu.Children[0];
}
}
private DelegateCommand _settingCommand;
public DelegateCommand SettingCommand => _settingCommand ??= new DelegateCommand(SettingMethod);
private void SettingMethod()
{
SelectedMenu = PremissionDmList[4];
if (SelectedMenu.PremissionName == "退出")
{
logger.Info($"用户【{Operator?.Nickname}】退出登录");
Operator = null;
Reviewer = null;
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
}
else
{
//SelectedMenu.Children = SelectedMenu.Children;
SelectedChildMenu = SelectedMenu.Children[0];
}
}
}
}

View File

@ -12,6 +12,7 @@ using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading;
@ -34,12 +35,12 @@ namespace DM_Weight.ViewModels
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
private SqlSugarScope _sqlSugarScope1;
public InvoiceAddDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, SqlSugarScope sqlSugarScope)
////private SqlSugarScope SqlSugarHelper.Db;
public InvoiceAddDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
{
_portUtil = portUtil;
_eventAggregator = eventAggregator;
this._sqlSugarScope1 = sqlSugarScope;
////this.SqlSugarHelper.Db = sqlSugarScope;
}
void DoMyPrismEvent(DeviceMsg msg)
@ -201,6 +202,16 @@ namespace DM_Weight.ViewModels
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
List<ChannelStock> ChannelLst = channelStocks.Where(it => it.BoardType != 1)
.GroupBy(it => it.ColNo)
.Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(itx => itx.Quantity);
ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
return ret;
}).ToList();
// 发送加药数量
singleChannels.ForEach(it =>
{
@ -232,9 +243,9 @@ namespace DM_Weight.ViewModels
_isFinishClick = true;
List<ChannelStock> record = ChannelStocks.ToList();
string InvoiceId = Invoice.InvoiceNo;
var f = _sqlSugarScope1.UseTran(() =>
var f = SqlSugarHelper.Db.UseTran(() =>
{
_sqlSugarScope1.Updateable(new InOutInvoice()
SqlSugarHelper.Db.Updateable(new InOutInvoice()
{
Status = 1,
InvoiceNo = Invoice.InvoiceNo
@ -242,29 +253,82 @@ namespace DM_Weight.ViewModels
for (int i = 0; i < record.Count; i++)
{
ChannelStock it = record[i];
if (it.BoardType == 6 && it.PosNo == 0)
{
_portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
}
// 更新数据 库存信息
_sqlSugarScope1.Updateable(new ChannelStock()
if (it.Id != null)
{
Quantity = it.Quantity + it.AddQuantity,
PosNo = 1,
ManuNo = it.ManuNo,
EffDate = it.EffDate,
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
// 更新数据 库存信息
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity + it.AddQuantity,
ManuNo = it.ManuNo,
EffDate = it.EffDate,
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
}
else
{
//如果批号重复则不让添加
List<ChannelStock> csCount = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == it.DrawerNo && cs.ColNo==it.ColNo&&cs.ManuNo == it.ManuNo && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")&&cs.Quantity>0).ToList();
if (csCount.Count > 0)
{
//repeatList.Add(it.ManuNo);
//stockRepeats.Add(it);
continue;
}
//查询现有库位中是否有库存为0的记录如果有直接update
List<ChannelStock> recordList = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == it.DrawerNo && cs.ColNo == it.ColNo && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.Quantity <= 0).ToList();
if (recordList.Count > 0)
{
// 更新数据 库存信息
//SqlSugarHelper.Db.Updateable(new ChannelStock()
//{
// Quantity = recordList[0].Quantity + it.AddQuantity,
// ManuNo = recordList[0].ManuNo,
// EffDate = recordList[0].EffDate,
// Id = recordList[0].Id,
//}).UpdateColumns(it => new { recordList[0].Quantity, recordList[0].ManuNo, recordList[0].EffDate }).ExecuteCommand();
SqlSugarHelper.Db.Updateable<ChannelStock>() .SetColumns(item=>new ChannelStock()
{
Quantity = recordList[0].Quantity + it.AddQuantity,
ManuNo = recordList[0].ManuNo,
EffDate = recordList[0].EffDate,
Id = recordList[0].Id,
}).Where(item => item.Id == item.Id).ExecuteCommand();
}
else
{
// 更新数据 库存信息
SqlSugarHelper.Db.Insertable(new ChannelStock()
{
Quantity = it.AddQuantity,
Chnguid = it.Chnguid,
ManuNo = it.ManuNo,
EffDate = it.EffDate,
DrawerNo = it.DrawerNo,
ColNo = it.ColNo,
DrugId = it.DrugId,
DrawerType = it.DrawerType,
BoardType = it.BoardType,
Id = Guid.NewGuid().ToString(),
MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1"
}).ExecuteCommand();
}
}
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
// 保存数据 出/入库记录
_sqlSugarScope1.Insertable(new MachineRecord()
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = it.MachineId,
DrawerNo = it.DrawerNo,
@ -279,7 +343,9 @@ namespace DM_Weight.ViewModels
Type = 1,
InvoiceId = InvoiceId,
StockQuantity = nowChannels.Sum(it => it.Quantity),
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
SupplierDept = Invoice.PharmacyName1?? ConfigurationManager.AppSettings["supplierDept"].ToString(),
ReceiveDept = Invoice.PharmacyName2 ?? ConfigurationManager.AppSettings["receiveDept"].ToString()
}).ExecuteCommand();
}
return true;
@ -287,13 +353,25 @@ namespace DM_Weight.ViewModels
if (f.Data)
{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
.GroupBy(it => it.ColNo)
.Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(itx => itx.Quantity);
ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
return ret;
}).ToList();
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
singleChannels.ForEach(it =>
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
});
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) + singleChannels.Sum(it => it.AddQuantity));
//singleChannels.ForEach(it =>
//{
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
//});
}
@ -354,6 +432,6 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => false;
public bool KeepAlive => true;
}
}

View File

@ -0,0 +1,626 @@
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.select;
using DM_Weight.util;
using log4net;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;
using System.Windows.Data;
using Unity;
namespace DM_Weight.ViewModels
{
public class InvoiceInNewWindow2ViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
{
private readonly ILog logger = LogManager.GetLogger(typeof(InvoiceInWindowViewModel));
private int _pageNum = 1;
public int PageNum
{
get => _pageNum;
set
{
SetProperty(ref _pageNum, value);
RequestData();
}
}
private int _pageCount = 1;
public int PageCount
{
get => _pageCount;
set
{
SetProperty(ref _pageCount, value);
}
}
private int _pageSize = 8;
public int PageSize
{
get => _pageSize;
set
{
SetProperty(ref _pageSize, value);
}
}
private int _totalCount = 0;
public int TotalCount
{
get => _totalCount;
set
{
SetProperty(ref _totalCount, value);
}
}
private int _status = 0;
public int Status { get => _status; set => SetProperty(ref _status, value); }
IDialogService _dialogService;
IEventAggregator _eventAggregator;
private DelegateCommand _rowSelected;
public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(GetChannelByInvoice);
//private SqlSugarScope SqlSugarHelper.Db;
private PortUtil _portUtil;
public InvoiceInNewWindow2ViewModel(PortUtil portUtil, IDialogService DialogService, IEventAggregator eventAggregator, SqlSugarScope sqlSugarScope)
{
_portUtil = portUtil;
_dialogService = DialogService;
_eventAggregator = eventAggregator;
//this.SqlSugarHelper.Db = sqlSugarScope;
}
public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
{
new OrderTakeSelect
{
Code = "invoiceNo",
Name = "凭证单号"
}
};
private List<OrderTakeSelect> _orderTakeSelects = StaticOrderTakeSelects;
public List<OrderTakeSelect> OrderTakeSelects
{
get { return _orderTakeSelects; }
set
{
SetProperty(ref _orderTakeSelects, value);
}
}
private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
/// <summary>
/// 查询条件 查询字段
/// </summary>
public OrderTakeSelect SelectedItem
{
get { return _selectedItem; }
set
{
SetProperty(ref _selectedItem, value);
RequestData();
}
}
private Invoice? _selectedInvoice;
public Invoice? SelectedInvoice
{
get { return _selectedInvoice; }
set
{
SetProperty(ref _selectedInvoice, value);
//OpenOrderDialog();
}
}
private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
/// <summary>
/// 查询条件 处方日期
/// </summary>
public string OrderDate
{
get { return _orderDate; }
set
{
if (!String.IsNullOrEmpty(value))
{
SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
}
else
{
SetProperty(ref _orderDate, value);
}
RequestData();
}
}
private string? _searchValue;
/// <summary>
/// 查询条件 查询字段值
/// </summary>
public string? SearchValue
{
get { return _searchValue; }
set
{
SetProperty(ref _searchValue, value);
RequestData();
}
}
private List<Invoice> _invoices = new();
public List<Invoice> Invoices { get { return _invoices; } set { SetProperty(ref _invoices, value); } }
private List<InOutInvoice> _inOutInvoices = new();
public List<InOutInvoice> InOutInvoices { get { return _inOutInvoices; } set { SetProperty(ref _inOutInvoices, value); } }
public bool KeepAlive => true;
private ObservableCollection<ChannelList>? _channelLsts = new();
public ObservableCollection<ChannelList>? ChannelLsts
{
get => _channelLsts;
set => SetProperty(ref _channelLsts, value);
}
private List<ChannelStock> _channelStocks = new List<ChannelStock>();
public List<ChannelStock> ChannelStocks
{
get => _channelStocks;
set => SetProperty(ref _channelStocks, value);
}
private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
private string WindowName = "InvoiceAddWindow";
//private List<ChannelStock> _channelStocks = new();
//public List<ChannelStock> ChannelStocks { get { return _channelStocks; } set { SetProperty(ref _channelStocks, value); } }
private List<ChannelStock> _addChannels = new();
public List<ChannelStock> AddChannels { get { return _addChannels; } set { SetProperty(ref _addChannels, value); } }
//左侧点击事件
public void GetChannelByInvoice()
{
//ChannelStocks.Clear();
ChannelLsts.Clear();
InOutInvoices.Clear();
List<ChannelStock> iChannelStock = new List<ChannelStock>();
if (SelectedInvoice != null)
{
string strSql = @"SELECT sum(Quantity) AS SumQuantity, COUNT(ID) AS CountNum,INVOICE_NO AS InvoiceNo,drug_id AS DrugId,QUANTITY AS quantity,drug_manu_no AS drugManuNo FROM IN_OUT_INVOICE WHERE INVOICE_NO=@INVOICE_NO GROUP BY INVOICE_NO,DRUG_ID";
var invoices = SqlSugarHelper.Db.SqlQueryable<InOutInvoice>(strSql)
.AddParameters(new
{
INVOICE_NO = SelectedInvoice.InvoiceNo
})
.Select(it => new InOutInvoice())
.Select("*").ToList();
//if(iList!=null&&iList.Count>0)
//{
// for (int i = 0; i < iList.Count; i++)
// {
// if (iList[i].Count>1)
// {
// for (int j = 0; j < iList[i].Count; j++)
// {
// }
// }
// }
//}
//var invoices = SqlSugarHelper.Db.Queryable<InOutInvoice>()
// .Includes<DrugInfo>(i => i.DrugInfo)
// .InnerJoin(SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (i, t) => i.DrugId == t.DrugId)
// .Where(i => i.InvoiceNo == SelectedInvoice.InvoiceNo)
// .ToList();
for (int i = 0; i < invoices.Count; i++)
{
List<ChannelList> queryData = SqlSugarHelper.Db.Queryable<ChannelList>()
.Includes(cl => cl.Drug, di => di.DrugManuNos)
.Includes(cl => cl.channelStocks, dr => dr.DrugInfo, d => d.DrugManuNos)
.Where(cl => cl.DrugId == invoices[i].DrugId)
.Where(cl => cl.DrawerType == 1)
.Where(cl => cl.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
//.Where(cl => cl.DrugId != null)
//.WhereIF(!string.IsNullOrEmpty(invoices[i].DrugManuNo), cl => cl.drugManuNo.Equals(invoices[i].DrugManuNo))
.OrderBy(cl => cl.ColNo)
.ToList();
List<ChannelList> channelLst = queryData.Select(cl =>
{
cl.channelStocks = cl.channelStocks.Select(cs =>
{
cs.drugManuNo = cl.Drug.DrugManuNos.Find(it => it.ManuNo.Equals(cs.ManuNo));
return cs;
}).ToList();
return cl;
}).OrderBy(cl => cl.ColNo).ToList();
channelLst.ForEach(cl => cl.channelStocks.ForEach(cs => cs.DrugInfo = cl.Drug));
if (channelLst.Count > 0)
{
if (channelLst[0].channelStocks.Count > 0)
{
//for (int j = 0; j < channelLst[0].channelStocks.Count; j++)
{
var invoicesManuNo = SqlSugarHelper.Db.Queryable<InOutInvoice>()
.Where(iManuNo => iManuNo.InvoiceNo == invoices[i].InvoiceNo && iManuNo.DrugId == invoices[i].DrugId).ToList();
for (int k = 0; k < invoicesManuNo.Count; k++)
{
List<ChannelStock> stockLst = channelLst[0].channelStocks.Where(cs => cs.ManuNo == invoicesManuNo[k].DrugManuNo).ToList();
if (stockLst != null && stockLst.Count > 0)
{
channelLst[0].channelStocks.Where(cs => cs.ManuNo == invoicesManuNo[k].DrugManuNo).ToList()[0].AddQuantity = invoicesManuNo[k].quantity; //.AddQuantity = invoicesManuNo[k].quantity;
}
else
{
ChannelStock cls = new ChannelStock();
DrugManuNo drugManu = new DrugManuNo();
cls.DrugInfo = channelLst[0].Drug;
List<DrugManuNo> drugManuNoList = channelLst[0].Drug.DrugManuNos;// SqlSugarHelper.Db.Queryable<DrugManuNo>().Where(dmn=>dmn.DrugId== invoicesManuNo[k].DrugId).ToList();
//if (channelLst[0].channelStocks.Count > 0)
//{
// //channelLst[0].channelStocks[0].AddQuantity = invoices[i].quantity;
// cls.drugManuNo = channelLst[0].channelStocks[0].drugManuNo;
//}
//else
{
//drugManu = cls.DrugInfo.DrugManuNos[0];
if (drugManuNoList != null&& drugManuNoList.Count>0)
{
cls.DrugInfo.DrugManuNos = drugManuNoList;
cls.drugManuNo = drugManuNoList.Where(dmn => dmn.ManuNo == invoicesManuNo[k].DrugManuNo).First();
}
else
{
AlertMsg alertMsg = new AlertMsg
{
Message = "该药品下没有批次,请先添加批次",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
}
cls.Chnguid = null;
cls.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
cls.DrawerNo = channelLst[0].DrawerNo;
cls.BoardType = channelLst[0].BoardType;
cls.DrawerType = channelLst[0].DrawerType;
cls.ColNo = channelLst[0].ColNo;
cls.DrugId = channelLst[0].DrugId;
cls.AddQuantity = invoicesManuNo[k].quantity;
cls.ManuNo = invoicesManuNo[k].DrugManuNo;
channelLst[0].channelStocks.Add(cls);
}
}
}
}
else
{
List<ChannelStock> CSList = new List<ChannelStock>();
if (!string.IsNullOrEmpty(invoices[i].DrugManuNo))
{
//List<ChannelStock> stockLst = channelLst[i].channelStocks.Where(cs => cs.ManuNo == invoices[i].DrugManuNo).ToList();
//if (stockLst != null && stockLst.Count > 0)
//{
// channelLst[i].channelStocks[i].AddQuantity = invoices[i].quantity;
//}
//else
{
ChannelStock cls = new ChannelStock();
DrugManuNo drugManu = new DrugManuNo();
cls.DrugInfo = channelLst[0].Drug;
if (channelLst[0].channelStocks.Count > 0)
{
channelLst[0].channelStocks[0].AddQuantity = invoices[i].quantity;
cls.drugManuNo = channelLst[0].channelStocks[0].drugManuNo;
}
else
{
//drugManu= cls.DrugInfo.DrugManuNos[0];
if (cls.DrugInfo.DrugManuNos.Count > 0)
{
//cls.drugManuNo = cls.DrugInfo.DrugManuNos[0];
cls.drugManuNo = cls.DrugInfo.DrugManuNos.Where(dm => dm.ManuNo == invoices[i].DrugManuNo).First();
}
else
{
AlertMsg alertMsg = new AlertMsg
{
Message = "该药品下没有批次,请先添加批次",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
}
cls.Chnguid = channelLst[0].Id;
cls.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
cls.DrawerNo = channelLst[0].DrawerNo;
cls.BoardType = channelLst[0].BoardType;
cls.DrawerType = channelLst[0].DrawerType;
cls.ColNo = channelLst[0].ColNo;
cls.DrugId = channelLst[0].DrugId;
cls.AddQuantity = invoices[i].quantity;
List<ChannelStock> stockList = new List<ChannelStock>();
stockList.AddRange(channelLst[0].channelStocks);
stockList.Add(cls);
channelLst[0].channelStocks = stockList;
}
}
}
}
else
{
//药品未绑定库位,需要先绑药
AlertMsg alertMsg = new AlertMsg
{
Message = "药品未绑定库位,请先绑定库位",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
InOutInvoice copy = TransExpV2<InOutInvoice, InOutInvoice>.Trans(invoices[i]);
InOutInvoices.Add(copy);
ChannelLsts.AddRange(channelLst);
}
}
}
public DelegateCommand OpenInvoiceAdd
{
get => new DelegateCommand(() =>
{
Status = 1;
bool flag = true;
var list = ChannelLsts.GroupBy(cl => cl.DrugId).ToList();
if (list != null && list.Count == InOutInvoices.Count)
{
for (int i = 0; i < InOutInvoices.Count; i++)
{
InOutInvoice invoices = InOutInvoices[i];
//if (invoices.quantity != ChannelStocks.FindAll(it => it.DrugId == invoices.DrugId).Sum(it => it.AddQuantity))
if (invoices.SumQuantity != ChannelLsts[i].channelStocks.FindAll(it => it.DrugId == invoices.DrugId).Sum(it => it.AddQuantity))
{
flag = false;
break;
}
}
}
if (flag)
{
ChannelStocks.Clear();
foreach (ChannelList lst in ChannelLsts)
{
ChannelStocks.AddRange(lst.channelStocks);
}
AddChannels = ChannelStocks.FindAll(it => it.AddQuantity != 0);
//AddChannels = ChannelLsts[i].channelStocks.FindAll(it => it.AddQuantity != 0);
if (AddChannels.Count > 0)
{
for (int i = 0; i < AddChannels.Count; i++)
{
AddChannels[i].ManuNo = AddChannels[i].drugManuNo.ManuNo;
AddChannels[i].EffDate = AddChannels[i].drugManuNo.EffDate;
}
AddChannels.Sort((a, b) =>
{
if ((a.DrawerNo - b.DrawerNo) == 0)
{
return a.ColNo - b.ColNo;
}
return a.DrawerNo - b.DrawerNo;
});
}
//enumerable = ChannelStocks.GroupBy(cs => cs.DrawerNo, cs => cs);
//enumerator = enumerable.GetEnumerator();
//enumerator.MoveNext();
//OpenOneByOne();
OpenOrderDialog();
}
else
{
AlertMsg alertMsg = new AlertMsg
{
Message = "库位添加数量小于应添加数量",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
}, () => SelectedInvoice != null).ObservesProperty(() => SelectedInvoice);
}
public async void OpenOrderDialog()
{
if (SelectedInvoice != null && SelectedInvoice.Status == 0)
{
// 此处延时1毫秒等待页面渲染
await Task.Delay(TimeSpan.FromMilliseconds(1));
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("invoice", SelectedInvoice);
dialogParameters.Add("ChannelStocks", AddChannels);
DialogServiceExtensions.ShowDialogHost(_dialogService, "InvoiceAddDialog", dialogParameters, DoDialogResult, "RootDialog");
}
}
public DelegateCommand QueryCommand
{
get => new DelegateCommand(() =>
{
RequestData();
});
}
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
// dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
//if (dialogResult.Result == ButtonResult.OK)
{
SelectedInvoice = null;
RequestData();
}
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
{
continuationCallback(true);
}
public void RequestData()
{
Invoices.Clear();
int totalCount = 0;
var sb = new StringBuilder();
//sb.Append("select i.invoice_no as InvoiceNo, i.invoice_date as InvoiceDate, COUNT(i.id) as `Count`, SUM(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name as PharmacyName2 from in_out_invoice i");
sb.Append(" SELECT count(1) as Count, i.InvoiceNo, i.InvoiceDate, sum(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name PharmacyName2 from ");
sb.Append(" (SELECT drug_id,in_pharmacy_id,out_pharmacy_id, invoice_no as InvoiceNo, DATE_FORMAT(Invoice_Date,'%Y-%m-%d') as InvoiceDate, SUM(quantity) as quantity ");
sb.Append(" FROM in_out_invoice where status=@Status and type!=@type and cancel_flag=@CancelFlag GROUP BY invoice_no,drug_id) i ");
sb.Append(" inner join ( select c.drug_id as drug_id from channel_list c where c.machine_id = '" + (ConfigurationManager.AppSettings["machineId"] ?? "DM1") + "' group by c.drug_id ) di on di.drug_id = i.drug_id");
sb.Append(" left join pharmacy_info p1 on p1.pharmacy_id = i.in_pharmacy_id");
sb.Append(" left join pharmacy_info p2 on p2.pharmacy_id = i.out_pharmacy_id where 1=1");
//sb.Append(" where i.status=@Status ");
//sb.Append(" and i.type!=@type ");
//sb.Append(" and i.cancel_flag=@CancelFlag ");
if (OrderDate != null)
{
sb.Append(" and i.InvoiceDate = @CreateTime ");
}
if (!String.IsNullOrEmpty(SearchValue))
{
sb.Append(" and i.InvoiceNo = @InvoiceNo ");
}
if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]))
{
sb.Append(" and i.in_pharmacy_id = @OutPharmacyId ");
}
//sb.Append(" group by i.invoice_no");
sb.Append(" GROUP BY i.InvoiceNo order by i.InvoiceDate ");
Invoices = SqlSugarHelper.Db.SqlQueryable<dynamic>(sb.ToString())
.AddParameters(new
{
Status = 0,
type = 2,
CancelFlag = 0,
CreateTime = OrderDate,
InvoiceNo = SearchValue,
OutPharmacyId = ConfigurationManager.AppSettings["storage"]
})
.Select(it => new Invoice())
.Select("*")
.ToPageList(PageNum, PageSize, ref totalCount);
TotalCount = totalCount;
PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
}
//添加批次
public void AddAction(ChannelList channelLS)
{
if (channelLS != null)
{
ChannelStock cls = new ChannelStock();
DrugManuNo drugManu = new DrugManuNo();
cls.DrugInfo = channelLS.Drug;
if (channelLS.channelStocks.Count > 0)
{
cls.drugManuNo = channelLS.channelStocks[0].drugManuNo;
}
else
{
//drugManu= cls.DrugInfo.DrugManuNos[0];
if (cls.DrugInfo.DrugManuNos.Count > 0)
{
cls.drugManuNo = cls.DrugInfo.DrugManuNos[0];
}
else
{
AlertMsg alertMsg = new AlertMsg
{
Message = "该药品下没有批次,请先添加批次",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
}
//cls.Id = "";
cls.Chnguid = channelLS.Id;
cls.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
cls.DrawerNo = channelLS.DrawerNo;
cls.BoardType = channelLS.BoardType;
cls.DrawerType = channelLS.DrawerType;
cls.ColNo = channelLS.ColNo;
cls.DrugId = channelLS.DrugId;
cls.AddQuantity = 0;
List<ChannelStock> stockList = new List<ChannelStock>();
stockList.AddRange(channelLS.channelStocks);
stockList.Add(cls);
channelLS.channelStocks = stockList;
}
}
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
_eventAggregator.GetEvent<AddDrugEvent>().Subscribe(AddAction);
RequestData();
}
//每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
//这个方法用于拦截请求
public void OnNavigatedFrom(NavigationContext navigationContext)
{
_eventAggregator.GetEvent<AddDrugEvent>().Unsubscribe(AddAction);
}
}
}

View File

@ -0,0 +1,754 @@
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.Port;
using DM_Weight.select;
using DM_Weight.util;
using log4net;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DM_Weight.ViewModels
{
public class InvoiceInNewWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
{
private readonly ILog logger = LogManager.GetLogger(typeof(InvoiceInWindowViewModel));
private int _pageNum = 1;
public int PageNum
{
get => _pageNum;
set
{
SetProperty(ref _pageNum, value);
RequestData();
}
}
private int _pageCount = 1;
public int PageCount
{
get => _pageCount;
set
{
SetProperty(ref _pageCount, value);
}
}
private int _pageSize = 8;
public int PageSize
{
get => _pageSize;
set
{
SetProperty(ref _pageSize, value);
}
}
private int _totalCount = 0;
public int TotalCount
{
get => _totalCount;
set
{
SetProperty(ref _totalCount, value);
}
}
private int _status = 0;
public int Status { get => _status; set => SetProperty(ref _status, value); }
IDialogService _dialogService;
IEventAggregator _eventAggregator;
private DelegateCommand _rowSelected;
public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(GetChannelByInvoice);
////private SqlSugarScope SqlSugarHelper.Db;
private PortUtil _portUtil;
public InvoiceInNewWindowViewModel(PortUtil portUtil, IDialogService DialogService, IEventAggregator eventAggregator)
{
_portUtil = portUtil;
_dialogService = DialogService;
_eventAggregator = eventAggregator;
////this.SqlSugarHelper.Db = sqlSugarScope;
}
void DoMyPrismEvent(DeviceMsg msg)
{
if (msg.WindowName.Equals(WindowName))
{
IGrouping<int, ChannelStock> grouping = enumerator.Current;
int DrawerNo = grouping.Key;
List<ChannelStock> channelStocks = grouping.ToList();
switch (msg.EventType)
{
// 抽屉打开
case EventType.DRAWEROPEN:
if (Status == 1)
{
if (channelStocks[0].process == 1)
{
channelStocks.ForEach(it => it.process = 2);
}
}
break;
// 抽屉关闭
case EventType.DRAWERCLOSE:
if (Status == 1)
{
if (channelStocks[0].process == 2)
{
channelStocks.ForEach(it => it.process = 3);
}
IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
int DrawerNoBefore = groupingBefore.Key;
if (enumerator.MoveNext())
{
IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
int DrawerNoAfter = groupingAfter.Key;
if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
{
Thread.Sleep(50);
}
OpenOneByOne();
}
// 已经全部取出
else
{
Status = 3;
}
}
break;
// 数量变化
case EventType.UPDATEQUANTITY:
if (Status == 1)
{
logger.Info($"抽屉【{DrawerNo}】库位药品数量【{msg.Quantitys}】");
}
break;
// 打开失败
case EventType.OPENERROR:
AlertMsg alertMsg = new AlertMsg
{
Message = msg.Message,
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Status = 0;
break;
}
}
}
public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
{
new OrderTakeSelect
{
Code = "invoiceNo",
Name = "凭证单号"
}
};
private List<OrderTakeSelect> _orderTakeSelects = StaticOrderTakeSelects;
public List<OrderTakeSelect> OrderTakeSelects
{
get { return _orderTakeSelects; }
set
{
SetProperty(ref _orderTakeSelects, value);
}
}
private OrderTakeSelect _selectedItem = StaticOrderTakeSelects[0];
/// <summary>
/// 查询条件 查询字段
/// </summary>
public OrderTakeSelect SelectedItem
{
get { return _selectedItem; }
set
{
SetProperty(ref _selectedItem, value);
RequestData();
}
}
private Invoice? _selectedInvoice;
public Invoice? SelectedInvoice
{
get { return _selectedInvoice; }
set
{
SetProperty(ref _selectedInvoice, value);
//OpenOrderDialog();
}
}
private string _orderDate = DateTime.Now.ToString("yyyy-MM-dd");
/// <summary>
/// 查询条件 处方日期
/// </summary>
public string OrderDate
{
get { return _orderDate; }
set
{
if (!String.IsNullOrEmpty(value))
{
SetProperty(ref _orderDate, DateTime.Parse(value).ToString("yyyy-MM-dd"));
}
else
{
SetProperty(ref _orderDate, value);
}
RequestData();
}
}
private string? _searchValue;
/// <summary>
/// 查询条件 查询字段值
/// </summary>
public string? SearchValue
{
get { return _searchValue; }
set
{
SetProperty(ref _searchValue, value);
RequestData();
}
}
private List<Invoice> _invoices = new();
public List<Invoice> Invoices { get { return _invoices; } set { SetProperty(ref _invoices, value); } }
private List<InOutInvoice> _inOutInvoices = new();
public List<InOutInvoice> InOutInvoices { get { return _inOutInvoices; } set { SetProperty(ref _inOutInvoices, value); } }
private ObservableCollection<ChannelList>? _channelLsts = new();
public ObservableCollection<ChannelList>? ChannelLsts
{
get => _channelLsts;
set => SetProperty(ref _channelLsts, value);
}
private List<ChannelStock> _channelStocks = new List<ChannelStock>();
public List<ChannelStock> ChannelStocks
{
get => _channelStocks;
set => SetProperty(ref _channelStocks, value);
}
private IEnumerable<IGrouping<int, ChannelStock>> enumerable;
private IEnumerator<IGrouping<int, ChannelStock>> enumerator;
private string WindowName = "InvoiceAddWindow";
//private List<ChannelStock> _channelStocks = new();
//public List<ChannelStock> ChannelStocks { get { return _channelStocks; } set { SetProperty(ref _channelStocks, value); } }
private List<ChannelStock> _addChannels = new();
public List<ChannelStock> AddChannels { get { return _addChannels; } set { SetProperty(ref _addChannels, value); } }
//左侧点击事件
public void GetChannelByInvoice()
{
//ChannelStocks.Clear();
ChannelLsts.Clear();
InOutInvoices.Clear();
List<ChannelStock> iChannelStock = new List<ChannelStock>();
if (SelectedInvoice != null)
{
//先查询有几种药
string strSql = @"SELECT sum(Quantity) AS SumQuantity, COUNT(ID) AS CountNum,INVOICE_NO AS InvoiceNo,drug_id AS DrugId,QUANTITY AS quantity,drug_manu_no AS drugManuNo FROM IN_OUT_INVOICE WHERE INVOICE_NO=@INVOICE_NO GROUP BY INVOICE_NO,DRUG_ID";
var invoices = SqlSugarHelper.Db.SqlQueryable<InOutInvoice>(strSql)
.AddParameters(new
{
INVOICE_NO = SelectedInvoice.InvoiceNo
})
.Select(it => new InOutInvoice())
.Select("*").ToList();
for (int i = 0; i < invoices.Count; i++)
{
//查询药品是否绑定
List<ChannelList> channelL = SqlSugarHelper.Db.Queryable<ChannelList>()
.Includes(cl => cl.Drug, di => di.DrugManuNos)
//.Includes(cl => cl.channelStocks, dr => dr.DrugInfo, d => d.DrugManuNos)
.Where(cl => cl.DrugId == invoices[i].DrugId && cl.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM1")).ToList();
ChannelList channelLst = channelL.Count > 0 ? channelL[0] : null;
if (channelLst == null || channelLst.Id is null)
{
//药品未绑定库位,需要先绑药
//AlertMsg alertMsg = new AlertMsg
//{
// Message = "药品未绑定库位,请先绑定库位",
// Type = MsgType.ERROR,
//};
//_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
continue;
}
ChannelStock stock = new ChannelStock();
//查询每种药有多少个批次
var invoicesManuNo = SqlSugarHelper.Db.Queryable<InOutInvoice>()
.Where(iManuNo => iManuNo.InvoiceNo == invoices[i].InvoiceNo && iManuNo.DrugId == invoices[i].DrugId).ToList();
for (int j = 0; j < invoicesManuNo.Count; j++)
{
//查询是否有库存
List<ChannelStock> stockList = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.ManuNo == invoicesManuNo[j].DrugManuNo && cs.DrugId == invoicesManuNo[j].DrugId && cs.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM1")).ToList();
stock = stockList.Count > 0 ? stockList[0] : new ChannelStock();
List<DrugManuNo> manuNoList = SqlSugarHelper.Db.Queryable<DrugManuNo>().Where(dm => dm.ManuNo == invoicesManuNo[j].DrugManuNo && dm.DrugId == invoicesManuNo[j].DrugId).ToList();
if (stock == null || stock.Id is null)
{
if (manuNoList == null || manuNoList.Count <= 0)
{
//药品批次不存在
AlertMsg alertMsg = new AlertMsg
{
Message = $"药品批次{invoicesManuNo[j].DrugManuNo}不存在,请核对药品批次信息!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
continue;
}
//没有库存写入一条数据
stock.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
stock.DrawerNo = channelLst.DrawerNo;
stock.BoardType = channelLst.BoardType;
stock.DrawerType = channelLst.DrawerType;
stock.ColNo = channelLst.ColNo;
stock.DrugId = channelLst.DrugId;
stock.ManuNo = invoicesManuNo[j].DrugManuNo;
stock.EffDate = manuNoList[0].EffDate;
stock.Chnguid = channelLst.Id;
}
stock.AddQuantity = invoicesManuNo[j].quantity;
if (channelLst.channelStocks == null)
{
channelLst.channelStocks = new List<ChannelStock>();
}
channelLst.channelStocks.Add(stock);
}
InOutInvoice copy = TransExpV2<InOutInvoice, InOutInvoice>.Trans(invoices[i]);
InOutInvoices.Add(copy);
ChannelLsts.Add(channelLst);
}
}
}
public DelegateCommand OpenInvoiceAdd
{
get => new DelegateCommand(() =>
{
bool flag = true;
ChannelStocks.Clear();
foreach (ChannelList lst in ChannelLsts)
{
ChannelStocks.AddRange(lst.channelStocks);
}
AddChannels = ChannelStocks.FindAll(it => it.AddQuantity != 0);
enumerable = AddChannels.GroupBy(cs => cs.DrawerNo, cs => cs);
enumerator = enumerable.GetEnumerator();
OpenDrawer(AddChannels);
}, () => SelectedInvoice != null).ObservesProperty(() => SelectedInvoice);
}
private void OpenDrawer(List<ChannelStock> AddChannels)
{
if (Status == 0)
{
enumerator.MoveNext();
Status = 1;
OpenOneByOne();
}
}
private async void OpenOneByOne()
{
IGrouping<int, ChannelStock> grouping = enumerator.Current;
int DrawerNo = grouping.Key;
List<ChannelStock> channelStocks = grouping.ToList();
channelStocks.ForEach(it => it.process = 1);
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
List<ChannelStock> singleChannels = channelStocks.GroupBy(it => new
{
it.DrawerNo,
it.ColNo
}).Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(itx => itx.Quantity);
ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
return ret;
}).ToList().FindAll(it => it.BoardType != 1);
_portUtil.WindowName = WindowName;
_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
_portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
_portUtil.DrawerNo = DrawerNo;
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
List<ChannelStock> ChannelLst = channelStocks.Where(it => it.BoardType != 1)
.GroupBy(it => it.ColNo)
.Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(itx => itx.Quantity);
ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
return ret;
}).ToList();
// 发送加药数量
singleChannels.ForEach(it =>
{
_portUtil.TakeQuantity(DrawerNo, it.ColNo, it.AddQuantity, it.Quantity + it.AddQuantity);
});
}
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 6)
{
for (int i = 0; i < singleChannels.Count; i++)
{
ChannelStock it = singleChannels[i];
_portUtil.ClearCount(it.DrawerNo, it.ColNo);
await Task.Delay(50);
}
}
_portUtil.Start();
}
private bool _isFinishClick = false;
// 完成按钮
public DelegateCommand TakeFinish
{
get => new DelegateCommand(async () =>
{
if (!_isFinishClick)
{
_isFinishClick = true;
List<ChannelStock> record = ChannelStocks.ToList();
string InvoiceId = SelectedInvoice.InvoiceNo;
var f = SqlSugarHelper.Db.UseTran(() =>
{
SqlSugarHelper.Db.Updateable(new InOutInvoice()
{
Status = 1,
InvoiceNo = SelectedInvoice.InvoiceNo
}).UpdateColumns(it => new { it.Status }).WhereColumns(it => new { it.InvoiceNo }).ExecuteCommand();
for (int i = 0; i < record.Count; i++)
{
ChannelStock it = record[i];
if (it.BoardType == 6 && it.PosNo == 0)
{
_portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
}
if (it.Id != null)
{
// 更新数据 库存信息
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity + it.AddQuantity,
ManuNo = it.ManuNo,
EffDate = it.EffDate,
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
}
else
{
//如果批号重复则不让添加
List<ChannelStock> csCount = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == it.DrawerNo && cs.ColNo == it.ColNo && cs.ManuNo == it.ManuNo && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.Quantity > 0).ToList();
if (csCount.Count > 0)
{
//repeatList.Add(it.ManuNo);
//stockRepeats.Add(it);
continue;
}
//查询现有库位中是否有库存为0的记录如果有直接update
ChannelStock recordHistory = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == it.DrawerNo && cs.ColNo == it.ColNo && cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.Quantity <= 0).First();
if (recordHistory!=null&& recordHistory.Id!=null)
{
SqlSugarHelper.Db.Updateable<ChannelStock>().SetColumns(item => new ChannelStock()
{
Quantity = it.AddQuantity,
ManuNo = it.ManuNo,
EffDate = it.EffDate
}).Where(item => item.Id == recordHistory.Id).ExecuteCommand();
}
else
{
// 更新数据 库存信息
SqlSugarHelper.Db.Insertable(new ChannelStock()
{
Quantity = it.AddQuantity,
Chnguid = it.Chnguid,
ManuNo = it.ManuNo,
EffDate = it.EffDate,
DrawerNo = it.DrawerNo,
ColNo = it.ColNo,
DrugId = it.DrugId,
DrawerType = it.DrawerType,
BoardType = it.BoardType,
Id = Guid.NewGuid().ToString(),
MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1"
}).ExecuteCommand();
}
}
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
// 保存数据 出/入库记录
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = it.MachineId,
DrawerNo = it.DrawerNo,
ColNo = it.ColNo,
DrugId = it.DrugId,
ManuNo = it.ManuNo,
EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
Quantity = it.AddQuantity,
Type = 1,
InvoiceId = InvoiceId,
StockQuantity = nowChannels.Sum(it => it.Quantity),
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
SupplierDept = SelectedInvoice.PharmacyName1 ?? ConfigurationManager.AppSettings["supplierDept"].ToString(),
ReceiveDept = SelectedInvoice.PharmacyName2 ?? ConfigurationManager.AppSettings["receiveDept"].ToString()
}).ExecuteCommand();
}
if (ChannelLsts != null && ChannelLsts.Count > 0)
{
for (int i = 0; i < ChannelLsts.Count; i++)
{
//根据ChannelLsts中的库位删除该库位库存为0的记录
SqlSugarHelper.Db.Deleteable<ChannelStock>()
.Where(cs => cs.Quantity <= 0 && cs.DrawerNo == ChannelLsts[i].channelStocks[0].DrawerNo && cs.ColNo == ChannelLsts[i].channelStocks[0].ColNo).ExecuteCommand();
}
}
return true;
});
if (f.Data)
{
// 更新屏显库存
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
.GroupBy(it => new { it.DrawerNo, it.ColNo })
.Select(it =>
{
var ret = it.First();
//ret.Quantity = it.Sum(itx => itx.Quantity);
//ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
return ret;
})
.ToList();
if (singleChannels != null && singleChannels.Count > 0)
{
for (int i = 0; i < singleChannels.Count; i++)
{
if (singleChannels[i].BoardType == 5)
{
List<ChannelStock> channelStockEffDate = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId==singleChannels[i].MachineId)
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
.OrderBy(cs => cs.EffDate).ToList();
int totalQuantity = channelStockEffDate.Sum(it => it.Quantity);
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo, totalQuantity);
Thread.Sleep(200);
_portUtil.WriteChannelInfo(6, channelStockEffDate[0].EffDate == null ? "" : channelStockEffDate[0].EffDate, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
Thread.Sleep(200);
_portUtil.WriteChannelInfo(5, channelStockEffDate[0].ManuNo, channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
Thread.Sleep(200);
_portUtil.ShowContent(channelStockEffDate[0].DrawerNo, channelStockEffDate[0].ColNo);
}
}
}
AlertMsg alertMsg = new AlertMsg
{
Message = "操作完成,库存已更新",
Type = MsgType.SUCCESS,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
if (!f.IsSuccess)
{
AlertMsg alertMsg = new AlertMsg
{
Message = "库存更新失败!",
Type = MsgType.ERROR,
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
Status = 0;
_isFinishClick = false;
}
RequestData();
});
}
// 取消按钮
public DelegateCommand CancleTake
{
get => new DelegateCommand(() =>
{
RequestData();
_portUtil.ResetData();
Status = 0;
});
}
public async void OpenOrderDialog()
{
//if (SelectedInvoice != null && SelectedInvoice.Status == 0)
//{
// // 此处延时1毫秒等待页面渲染
// await Task.Delay(TimeSpan.FromMilliseconds(1));
// DialogParameters dialogParameters = new DialogParameters();
// dialogParameters.Add("invoice", SelectedInvoice);
// dialogParameters.Add("ChannelStocks", AddChannels);
// DialogServiceExtensions.ShowDialogHost(_dialogService, "InvoiceAddDialog", dialogParameters, DoDialogResult, "RootDialog");
//}
}
public DelegateCommand QueryCommand
{
get => new DelegateCommand(() =>
{
RequestData();
});
}
public bool KeepAlive => true;
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
// dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
//if (dialogResult.Result == ButtonResult.OK)
{
SelectedInvoice = null;
RequestData();
}
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
{
continuationCallback(true);
}
public void RequestData()
{
Invoices.Clear();
int totalCount = 0;
var sb = new StringBuilder();
//sb.Append("select i.invoice_no as InvoiceNo, i.invoice_date as InvoiceDate, COUNT(i.id) as `Count`, SUM(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name as PharmacyName2 from in_out_invoice i");
sb.Append(" SELECT count(1) as Count, i.InvoiceNo, i.InvoiceDate, sum(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name PharmacyName2 from ");
sb.Append(" (SELECT drug_id,in_pharmacy_id,out_pharmacy_id, invoice_no as InvoiceNo, DATE_FORMAT(Invoice_Date,'%Y-%m-%d') as InvoiceDate, SUM(quantity) as quantity ");
sb.Append(" FROM in_out_invoice where status=@Status and type!=@type and cancel_flag=@CancelFlag GROUP BY invoice_no,drug_id) i ");
sb.Append(" inner join ( select c.drug_id as drug_id from channel_list c where c.machine_id = '" + (ConfigurationManager.AppSettings["machineId"] ?? "DM1") + "' group by c.drug_id ) di on di.drug_id = i.drug_id");
sb.Append(" left join pharmacy_info p1 on p1.pharmacy_id = i.in_pharmacy_id");
sb.Append(" left join pharmacy_info p2 on p2.pharmacy_id = i.out_pharmacy_id where 1=1");
//sb.Append(" where i.status=@Status ");
//sb.Append(" and i.type!=@type ");
//sb.Append(" and i.cancel_flag=@CancelFlag ");
if (OrderDate != null)
{
sb.Append(" and i.InvoiceDate = @CreateTime ");
}
if (!String.IsNullOrEmpty(SearchValue))
{
sb.Append(" and i.InvoiceNo = @InvoiceNo ");
}
if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]))
{
sb.Append(" and i.in_pharmacy_id = @OutPharmacyId ");
}
//sb.Append(" group by i.invoice_no");
sb.Append(" GROUP BY i.InvoiceNo order by i.InvoiceDate ");
Invoices = SqlSugarHelper.Db.SqlQueryable<dynamic>(sb.ToString())
.AddParameters(new
{
Status = 0,
type = 2,
CancelFlag = 0,
CreateTime = OrderDate,
InvoiceNo = SearchValue,
OutPharmacyId = ConfigurationManager.AppSettings["storage"]
})
.Select(it => new Invoice())
.Select("*")
.ToPageList(PageNum, PageSize, ref totalCount);
TotalCount = totalCount;
PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
}
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
RequestData();
}
//每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
//这个方法用于拦截请求
public void OnNavigatedFrom(NavigationContext navigationContext)
{
_eventAggregator.GetEvent<PortUtilEvent>().Unsubscribe(DoMyPrismEvent);
}
}
}

View File

@ -77,12 +77,12 @@ namespace DM_Weight.ViewModels
private DelegateCommand _rowSelected;
public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(GetChannelByInvoice);
private SqlSugarScope _sqlSugarScope1;
public InvoiceInWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator,SqlSugarScope sqlSugarScope)
//private SqlSugarScope SqlSugarHelper.Db;
public InvoiceInWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
{
_dialogService = DialogService;
_eventAggregator = eventAggregator;
this._sqlSugarScope1= sqlSugarScope;
//this.SqlSugarHelper.Db= sqlSugarScope;
}
public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
@ -179,7 +179,6 @@ namespace DM_Weight.ViewModels
public List<InOutInvoice> InOutInvoices { get { return _inOutInvoices; } set { SetProperty(ref _inOutInvoices, value); } }
public bool KeepAlive => false;
private List<ChannelStock> _channelStocks = new();
@ -198,14 +197,14 @@ namespace DM_Weight.ViewModels
List<ChannelStock> i = new List<ChannelStock>();
if (SelectedInvoice != null)
{
var invoices = _sqlSugarScope1.Queryable<InOutInvoice>()
var invoices = SqlSugarHelper.Db.Queryable<InOutInvoice>()
.Includes<DrugInfo>(i => i.DrugInfo)
.InnerJoin(_sqlSugarScope1.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (i, t) => i.DrugId == t.DrugId)
.InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (i, t) => i.DrugId == t.DrugId)
.Where(i => i.InvoiceNo == SelectedInvoice.InvoiceNo)
.ToList();
foreach (var invoice in invoices)
{
List<ChannelStock> q = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> q = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
.WhereIF(!string.IsNullOrEmpty(invoice.DrugEffDate), cs => cs.EffDate.Equals(invoice.DrugEffDate))
.WhereIF(!string.IsNullOrEmpty(invoice.DrugManuNo), cs => cs.ManuNo.Equals(invoice.DrugManuNo))
@ -300,6 +299,8 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => true;
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
@ -325,28 +326,31 @@ namespace DM_Weight.ViewModels
int totalCount = 0;
var sb = new StringBuilder();
sb.Append("select i.invoice_no as InvoiceNo, i.invoice_date as InvoiceDate, COUNT(i.id) as `Count`, SUM(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name as PharmacyName2 from in_out_invoice i");
//sb.Append("select i.invoice_no as InvoiceNo, i.invoice_date as InvoiceDate, COUNT(i.id) as `Count`, SUM(i.quantity) as quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name as PharmacyName2 from in_out_invoice i");
sb.Append(" SELECT i.InvoiceNo, i.InvoiceDate, i.Count, i.quantity, p1.pharmacy_name as PharmacyName1, p2.pharmacy_name PharmacyName2 from ");
sb.Append(" (SELECT drug_id,in_pharmacy_id,out_pharmacy_id, invoice_no as InvoiceNo, invoice_date as InvoiceDate, COUNT(id) as `Count`, SUM(quantity) as quantity ");
sb.Append(" FROM in_out_invoice where status=@Status and type!=@type and cancel_flag=@CancelFlag GROUP BY invoice_no) i ");
sb.Append(" inner join ( select c.drug_id as drug_id from channel_stock c where c.machine_id = '" + (ConfigurationManager.AppSettings["machineId"] ?? "DM1") + "' group by c.drug_id ) di on di.drug_id = i.drug_id");
sb.Append(" left join pharmacy_info p1 on p1.pharmacy_id = i.in_pharmacy_id");
sb.Append(" left join pharmacy_info p2 on p2.pharmacy_id = i.out_pharmacy_id");
sb.Append(" where i.status=@Status ");
sb.Append(" and i.type!=@type ");
sb.Append(" and i.cancel_flag=@CancelFlag ");
//sb.Append(" where i.status=@Status ");
//sb.Append(" and i.type!=@type ");
//sb.Append(" and i.cancel_flag=@CancelFlag ");
if (OrderDate != null)
{
sb.Append(" and i.invoice_date = @CreateTime ");
sb.Append(" and i.InvoiceDate = @CreateTime ");
}
if (!String.IsNullOrEmpty(SearchValue))
{
sb.Append(" and i.invoice_no = @InvoiceNo ");
sb.Append(" and i.InvoiceNo = @InvoiceNo ");
}
if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["storage"]))
{
sb.Append(" and i.in_pharmacy_id = @OutPharmacyId ");
}
sb.Append(" group by i.invoice_no");
sb.Append(" order by i.invoice_date ");
Invoices = _sqlSugarScope1.SqlQueryable<dynamic>(sb.ToString())
//sb.Append(" group by i.invoice_no");
sb.Append(" order by i.InvoiceDate ");
Invoices = SqlSugarHelper.Db.SqlQueryable<dynamic>(sb.ToString())
.AddParameters(new
{
Status = 0,

View File

@ -67,11 +67,11 @@ namespace DM_Weight.ViewModels
private DelegateCommand _rowSelected;
public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
private SqlSugarScope _sqlSugarScope1;
public InvoiceOutWindowViewModel(IDialogService DialogService,SqlSugarScope sqlSugarScope)
//private SqlSugarScope SqlSugarHelper.Db;
public InvoiceOutWindowViewModel(IDialogService DialogService)
{
_dialogService = DialogService;
this._sqlSugarScope1= sqlSugarScope;
//this.SqlSugarHelper.Db= sqlSugarScope;
}
public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
@ -163,7 +163,6 @@ namespace DM_Weight.ViewModels
public List<Invoice> Invoices { get { return _invoices; } set { SetProperty(ref _invoices, value); } }
public bool KeepAlive => false;
public async void OpenOrderDialog()
{
@ -186,6 +185,8 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => true;
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
@ -232,7 +233,7 @@ namespace DM_Weight.ViewModels
}
sb.Append(" group by i.invoice_no");
sb.Append(" order by i.invoice_date ");
Invoices = _sqlSugarScope1.SqlQueryable<dynamic>(sb.ToString())
Invoices = SqlSugarHelper.Db.SqlQueryable<dynamic>(sb.ToString())
.AddParameters(new
{
Status = 0,

View File

@ -38,13 +38,13 @@ namespace DM_Weight.ViewModels
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
IDialogService _dialogService;
private SqlSugarScope _sqlSugarScope1;
//private SqlSugarScope SqlSugarHelper.Db;
public InvoiceTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService, SqlSugarScope sqlSugarScope)
{
_dialogService = DialogService;
_portUtil = portUtil;
_eventAggregator = eventAggregator;
this._sqlSugarScope1 = sqlSugarScope;
//this.SqlSugarHelper.Db = sqlSugarScope;
}
void DoMyPrismEvent(DeviceMsg msg)
@ -171,9 +171,9 @@ namespace DM_Weight.ViewModels
public void RequestData()
{
invoices = _sqlSugarScope1.Queryable<InOutInvoice>()
invoices = SqlSugarHelper.Db.Queryable<InOutInvoice>()
.Includes<DrugInfo>(i => i.DrugInfo)
.InnerJoin(_sqlSugarScope1.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs =>cs.DrugId),(i,t) => i.DrugId == t.DrugId)
.InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs =>cs.DrugId),(i,t) => i.DrugId == t.DrugId)
.Where(i => i.InvoiceNo == Invoice.InvoiceNo)
.ToList();
@ -183,8 +183,9 @@ namespace DM_Weight.ViewModels
{
InOutInvoice invoice = invoices[i];
List<ChannelStock> HasQChannels = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
.InnerJoin<ChannelList>((cs, cl) => cs.Chnguid == cl.Id && cs.DrugId == cl.DrugId)
.Where(cs => cs.Quantity > 0)
.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
@ -298,9 +299,9 @@ namespace DM_Weight.ViewModels
if (record.Count > 0)
{
string InvoiceId = Invoice.InvoiceNo;
var f = _sqlSugarScope1.UseTran(() =>
var f = SqlSugarHelper.Db.UseTran(() =>
{
_sqlSugarScope1.Updateable(new InOutInvoice()
SqlSugarHelper.Db.Updateable(new InOutInvoice()
{
Status = 1,
InvoiceNo = Invoice.InvoiceNo
@ -310,7 +311,7 @@ namespace DM_Weight.ViewModels
{
ChannelStock it = record[i];
// 更新数据 库存信息
_sqlSugarScope1.Updateable(new ChannelStock()
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity - it.TakeQuantity,
ManuNo = it.ManuNo,
@ -318,14 +319,14 @@ namespace DM_Weight.ViewModels
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
// 保存数据 出库记录
_sqlSugarScope1.Insertable(new MachineRecord()
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = it.MachineId,
DrawerNo = it.DrawerNo,
@ -340,7 +341,9 @@ namespace DM_Weight.ViewModels
Type = 2,
InvoiceId = InvoiceId,
StockQuantity = nowChannels.Sum(it => it.Quantity),
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
SupplierDept = Invoice.PharmacyName1 ?? ConfigurationManager.AppSettings["supplierDept"].ToString(),
ReceiveDept = Invoice.PharmacyName2 ?? ConfigurationManager.AppSettings["receiveDept"].ToString()
}).ExecuteCommand();
}
return true;
@ -348,13 +351,25 @@ namespace DM_Weight.ViewModels
if (f.Data)
{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
.GroupBy(it => it.ColNo)
.Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(itx => itx.Quantity);
ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
return ret;
}).ToList();
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
singleChannels.ForEach(it =>
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
});
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) - singleChannels.Sum(it => it.AddQuantity));
//singleChannels.ForEach(it =>
//{
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
//});
}
AlertMsg alertMsg = new AlertMsg
{
@ -423,6 +438,6 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => false;
public bool KeepAlive => true;
}
}

View File

@ -25,6 +25,7 @@ using Microsoft.Win32;
using System.Xml;
using System.Diagnostics;
using SqlSugar;
using DM_Weight.Services;
namespace DM_Weight.ViewModels
{
@ -62,8 +63,11 @@ namespace DM_Weight.ViewModels
public string Username { get { return username; } set { SetProperty(ref username, value); } }
public UserList Operator { get; set; }
public UserList Reviewer { get; set; }
private UserList _operator;
public UserList Operator { get=> _operator; set=> SetProperty(ref _operator,value); }
private UserList _reviewer;
public UserList Reviewer { get=> _reviewer; set=>SetProperty(ref _reviewer,value); }
public bool DrawerPortMsg
{
@ -81,7 +85,7 @@ namespace DM_Weight.ViewModels
get => _fingerMsg;
set => SetProperty(ref _fingerMsg, value);
}
private SqlSugarScope _sqlSugarScope1;
////private SqlSugarScope SqlSugarHelper.Db;
//public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil, FingerprintUtil fingerprintUtil)
//{
// _fingerprintUtil = fingerprintUtil;
@ -89,13 +93,13 @@ namespace DM_Weight.ViewModels
// _regionManager = regionManager;
// _eventAggregator = eventAggregator;
//}
public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil,SqlSugarScope sqlSugarScope)
public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil, FingerprintUtil fingerprintUtil)
{
//_fingerprintUtil = fingerprintUtil;
_fingerprintUtil = fingerprintUtil;
_portUtil = portUtil;
_regionManager = regionManager;
_eventAggregator = eventAggregator;
_sqlSugarScope1= sqlSugarScope;
//SqlSugarHelper.Db = sqlSugarScope;
}
private DelegateCommand? _loginCommand;
@ -109,7 +113,7 @@ _exitCommand ??= new DelegateCommand(Exit);
public bool KeepAlive => false;
void Login()
void Login()
{
LoginBtnEnable = false;
if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password))
@ -142,15 +146,15 @@ _exitCommand ??= new DelegateCommand(Exit);
}
else
{
//UserList userList = _sqlSugarScope1.Queryable<UserList>()
UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
// .Includes<RoleDm>(u => u.Role)
// .First(u => u.UserName == username && ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId));
UserList userList = _sqlSugarScope1.Queryable<UserList>()
.Includes<RoleDm>(u => u.Role)
.InnerJoin<RoleDm>((u,r) => u.RoleId==r.Id)
.First(u => u.UserName == username && ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId));
.First(u => u.UserName == username && ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId));
//UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
// .Includes<RoleDm>(u => u.Role)
// .InnerJoin<RoleDm>((u, r) => u.RoleId == r.Id)
// .First(u => u.UserName == username && ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId));
if (userList == null)
{
@ -213,17 +217,21 @@ _exitCommand ??= new DelegateCommand(Exit);
// 单人登录模式
if (SingleLogin)
{
logger.Info($"SetUser:单人登录模式");
App.CurrentFaUserList = user;
//添加参数,键值对格式
keys.Add("operator", user);
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{
logger.Info($"SetUser:单人登录模式,页面跳转");
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
}));
}
// 双人登录模式
else
{
logger.Info($"SetUser:双人登录模式");
// 如果已经录入了发药人,已经有一个用户登录
if (keys.ContainsKey("operator"))
{
@ -231,11 +239,13 @@ _exitCommand ??= new DelegateCommand(Exit);
{
keys.Add("reviewer", user);
Reviewer = user;
logger.Info($"Reviewer:{Reviewer.Nickname}");
RaisePropertyChanged("Reviewer");
App.CurrentShenUserList= user;
App.CurrentShenUserList = user;
//_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{
logger.Info($"SetUser:双人登录模式,页面跳转");
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
}));
}
@ -256,13 +266,16 @@ _exitCommand ??= new DelegateCommand(Exit);
{
keys.Add("operator", user);
Operator = user;
logger.Info($"Operator:{Operator.Nickname}");
RaisePropertyChanged("Operator");
App.CurrentFaUserList= user;
App.CurrentFaUserList = user;
//_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
}));
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{
logger.Info($"SetUser:双人登录模式,页面跳转");
_regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
}));
}
else
@ -284,17 +297,21 @@ _exitCommand ??= new DelegateCommand(Exit);
Operator = user;
RaisePropertyChanged("Operator");
App.CurrentFaUserList = user;
logger.Info($"SetUser:双人登录模式,user{user.Nickname}Operator{Operator.Nickname}");
}
else
{
keys.Add("reviewer", user);
Reviewer = user;
logger.Info($"SetUser:双人登录模式,user{user.Nickname}Reviewer{Reviewer.Nickname}");
RaisePropertyChanged("Reviewer");
App.CurrentShenUserList = user;
}
Username = string.Empty;
Password =string.Empty;
Password = string.Empty;
}
logger.Info($"SetUser:双人登录模式,user{user.Nickname}Operator{Operator?.Nickname}Reviewer{Reviewer?.Nickname}");
}
}
@ -308,49 +325,61 @@ _exitCommand ??= new DelegateCommand(Exit);
void LoginEvent(FingerprintMsg msg)
{
logger.Info(msg.ToString());
if (msg.Message.Equals("CONNECT"))
try
{
FingerMsg = !msg.Result;
}
if (LoginBtnEnable)
{
if (msg.Message.Equals("LOGIN"))
logger.Info(msg.ToString());
if (msg.Message.Equals("CONNECT"))
{
UserList userList = _sqlSugarScope1.Queryable<UserList>()
FingerMsg = !msg.Result;
}
logger.Info($"LoginBtnEnable:{LoginBtnEnable}");
if (LoginBtnEnable)
{
logger.Info($"msg.Message.Equals:{msg.Message}");
if (msg.Message.Equals("LOGIN"))
{
UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
.Includes<RoleDm>(u => u.Role)
.First(u => u.Id == msg.Id);
.Includes<RoleDm>(u => u.Role)
.First(u => u.Id == msg.Id);
//UserList userList = new UserService().CheckUserByFingerPrinter(msg.Id);
if (userList == null)
{
AlertMsg alertMsg = new AlertMsg
logger.Info($"userList是空{userList == null}");
if (userList == null)
{
Message = "无此用户",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Username = "";
Password = "";
}
else if (userList.Role == null)
{
AlertMsg alertMsg = new AlertMsg
AlertMsg alertMsg = new AlertMsg
{
Message = "无此用户",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Username = "";
Password = "";
}
else if (userList.Role == null)
{
Message = "用户还未设置权限,请联系管理员",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Username = "";
Password = "";
}
else
{
SetUser(userList);
AlertMsg alertMsg = new AlertMsg
{
Message = "用户还未设置权限,请联系管理员",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
Username = "";
Password = "";
}
else
{
SetUser(userList);
}
}
}
}
}
catch (Exception e)
{
logger.Info($"LoginEvent存在异常:{e.Message}");
}
}
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
@ -364,7 +393,7 @@ _exitCommand ??= new DelegateCommand(Exit);
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
FingerMsg = false;// !_fingerprintUtil.bIsConnected;
FingerMsg = !_fingerprintUtil.bIsConnected;//false;
_eventAggregator.GetEvent<FingerprintEvent>().Subscribe(LoginEvent);
}

View File

@ -20,6 +20,8 @@ using System.Configuration;
using System.Reflection.PortableExecutable;
using DM_Weight.msg;
using Prism.Events;
using Prism.Services.Dialogs;
using System.Threading.Channels;
namespace DM_Weight.ViewModels
{
@ -143,17 +145,24 @@ namespace DM_Weight.ViewModels
get { return machineRecords; }
set { SetProperty(ref machineRecords, value); }
}
//盘点记录 导出账册 选中的数据
private List<MachineRecord>? selectMachineRecords;
public List<MachineRecord>? SelectMachineRecords
{
get => selectMachineRecords;
set { SetProperty(ref selectMachineRecords, value);}
}
public List<string>? OldInvoiceIdLst = new List<string>();
private SqlSugarScope _sqlSugarScope1;
//private SqlSugarScope SqlSugarHelper.Db;
public MachineRecordWindowViewModel(IEventAggregator eventAggregator, SqlSugarScope sqlSugarScope)
{
vm = this;
_eventAggregator = eventAggregator;
this._sqlSugarScope1 = sqlSugarScope;
//this.SqlSugarHelper.Db = sqlSugarScope;
}
public bool KeepAlive => false;
public DelegateCommand Query
{
@ -167,18 +176,27 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand(() =>
{
GridReportUtil.PrintReportMechineRecord(Type, StartDate, EndDate);
//if (Type == 4)
//{
// if (SelectMachineRecords != null && SelectMachineRecords.Count > 0)
// {
// GridReportUtil.PrintReportMechineRecordForSelect(SelectMachineRecords);
// }
//}
//else
{
GridReportUtil.PrintReportMechineRecord(Type, StartDate, EndDate);
}
});
}
public DelegateCommand DownloadAccountBook
{
get => new DelegateCommand(() =>
{
GridReportUtil.PrintReportAccountBook(StartDate, EndDate, DrugInfo == null ? "" : DrugInfo.DrugId);
//public DelegateCommand DownloadAccountBook
//{
// get => new DelegateCommand(() =>
// {
// GridReportUtil.PrintReportAccountBook(StartDate, EndDate, DrugInfo == null ? "" : DrugInfo.DrugId);
});
}
// });
//}
public DelegateCommand SaveCommand
{
@ -190,14 +208,14 @@ namespace DM_Weight.ViewModels
}
private void UpdatPZHSave()
{
var f = _sqlSugarScope1.UseTran(() =>
var f = SqlSugarHelper.Db.UseTran(() =>
{
for (int i = 0; i < MachineRecords.Count; i++)
{
string oldInvoiceId = OldInvoiceIdLst[i];
string oldInvoiceId = OldInvoiceIdLst[i];
// 更新数据 库存信息
_sqlSugarScope1.Updateable(new MachineRecord()
SqlSugarHelper.Db.Updateable(new MachineRecord()
{
Id = MachineRecords[i].Id,
InvoiceId = MachineRecords[i].InvoiceId
@ -254,7 +272,7 @@ namespace DM_Weight.ViewModels
{
int totalCount = 0;
string machineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
MachineRecords = _sqlSugarScope1.Queryable<MachineRecord>()
MachineRecords = SqlSugarHelper.Db.Queryable<MachineRecord>()
.Includes<DrugInfo>(mr => mr.DrugInfo)
.Includes<UserList>(mr => mr.User)
.Where(mr => mr.MachineId == machineId)
@ -285,7 +303,7 @@ namespace DM_Weight.ViewModels
private void GetAllDrugInfos()
{
string str = "SELECT d.drug_id,d.py_code,d.drug_barcode,d.drug_name,d.drug_brand_name,d.drug_spec,d.dosage,d.pack_unit,d.manufactory,d.max_stock,CONCAT(drug_name,' ',drug_spec)as drug_name_spec FROM `drug_info` d";
DrugInfos = _sqlSugarScope1.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
}
public void UpdateComboBoxItems(string text)
@ -294,7 +312,7 @@ namespace DM_Weight.ViewModels
d.manufactory,d.max_stock,CONCAT(drug_name,' ',drug_spec)as drug_name_spec FROM `drug_info` d";
if (string.IsNullOrEmpty(text))
{
DrugInfos = _sqlSugarScope1.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
return;
}
if (DrugInfos != null)
@ -302,8 +320,27 @@ namespace DM_Weight.ViewModels
DrugInfos.Clear();
}
DrugInfos = _sqlSugarScope1.SqlQueryable<DrugInfo>(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text) || di.DrugId.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
DrugInfos = SqlSugarHelper.Db.SqlQueryable<DrugInfo>(str).Where(di => di.DrugName.Contains(text) || di.PyCode.Contains(text) || di.DrugId.Contains(text)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
}
public DelegateCommand RowSelected
{
get => new DelegateCommand(() =>
{
if (MachineRecords != null)
{
SelectMachineRecords = MachineRecords.Select(x =>
{
x.IsSelected = !x.IsSelected;
return x;
}).ToList();
}
});
}
public bool KeepAlive => true;
}
}

View File

@ -62,33 +62,30 @@ namespace DM_Weight.ViewModels
// this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
// _screenUtil = screenUtil;
//}
private FingerprintUtil _fingerprintUtil;
IRegionManager _regionManager;
IUnityContainer _container;
PortUtil _portUtil;
private List<ChannelStock> _channelStocks = new List<ChannelStock>();
private SqlSugarScope _sqlSugarScope1;
public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, FingerprintUtil fingerprintUtil, ScreenUtil screenUtil, PortUtil portUtil,SqlSugarScope sqlSugarScope)
//private SqlSugarScope SqlSugarHelper.Db;
public MainWindowViewModel(IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator, ScreenUtil screenUtil, PortUtil portUtil)
{
//_portUtil = portUtil;
this.eventAggregator = eventAggregator;
this.eventAggregator.GetEvent<SnackbarEvent>().Subscribe(doMyPrismEvent2);
_screenUtil = screenUtil;
_fingerprintUtil = fingerprintUtil;
_regionManager = regionManager;
_container = container;
_portUtil = portUtil;
this._sqlSugarScope1=sqlSugarScope;
//this.SqlSugarHelper.Db=sqlSugarScope;
System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
{
_container.RegisterType<object, LoginWindow>("LoginWindow");
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
}));
Task.Factory.StartNew(()=>BindStock());
Task.Factory.StartNew(() => BindStock());
}
void doMyPrismEvent2(AlertMsg msg)
@ -96,13 +93,13 @@ namespace DM_Weight.ViewModels
switch (msg.Type)
{
case MsgType.INFO:
this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
break;
case MsgType.ERROR:
this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
break;
default:
this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#00e676"));
break;
}
SnackbarMessageQueue.Enqueue(msg.Message);
@ -110,8 +107,13 @@ namespace DM_Weight.ViewModels
//写标签数量
async Task BindStock()
{
List<ChannelStock> singleChannels = _sqlSugarScope1.Queryable<ChannelStock>().Where(cs => cs.BoardType == 5).Where(cs => cs.DrugId !=null).ToList();
List<ChannelStock> singleChannels = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.BoardType == 5&&cs.Quantity>0).Where(cs => cs.DrugId !=null).ToList();
singleChannels = singleChannels.GroupBy(cs => new { cs.DrawerNo, cs.ColNo })
.Select(cs => {
var ret = cs.First();
ret.Quantity = cs.Sum(xt => xt.Quantity);
return ret;
}).ToList();
for (int i = 0; i < singleChannels.Count; i++)
{
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, singleChannels[i].Quantity);

View File

@ -0,0 +1,33 @@
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.ViewModels
{
public class MaskDialogViewModel : BindableBase, IDialogAware
{
public string Title => throw new NotImplementedException();
public event Action<IDialogResult> RequestClose;
public bool CanCloseDialog()
{
return true;
}
public void OnDialogClosed()
{
}
public void OnDialogOpened(IDialogParameters parameters)
{
}
}
}

View File

@ -38,13 +38,13 @@ namespace DM_Weight.ViewModels
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
IDialogService _dialogService;
private SqlSugarScope _sqlSugarScope1;
//private SqlSugarScope SqlSugarHelper.Db;
public OrderReturnDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService, SqlSugarScope sqlSugarScope)
{
_dialogService = DialogService;
_portUtil = portUtil;
_eventAggregator = eventAggregator;
this._sqlSugarScope1 = sqlSugarScope;
//this.SqlSugarHelper.Db = sqlSugarScope;
}
void DoMyPrismEvent(DeviceMsg msg)
@ -172,9 +172,9 @@ namespace DM_Weight.ViewModels
public void RequestData()
{
orderDetails = _sqlSugarScope1.Queryable<OrderDetail>()
orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
.Includes<DrugInfo>(od => od.DrugInfo)
.InnerJoin(_sqlSugarScope1.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
.InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
.Where(od => od.OrderNo == OrderInfo.OrderNo)
.ToList();
@ -184,7 +184,7 @@ namespace DM_Weight.ViewModels
{
OrderDetail orderDetail = orderDetails[i];
List<ChannelStock> HasQChannels = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
@ -266,7 +266,17 @@ namespace DM_Weight.ViewModels
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = channelStocks
.GroupBy(it => new { it.DrawerNo, it.ColNo })
.Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(it => it.Quantity);
ret.TakeQuantity = it.Sum(it => it.TakeQuantity);
return ret;
})
.ToList()
.FindAll(it => it.BoardType != 1);
// 发送还药数量
singleChannels.ForEach(it =>
@ -295,9 +305,9 @@ namespace DM_Weight.ViewModels
//if (record.Count > 0)
//{
string InvoiceId = OrderInfo.OrderNo;
var f = _sqlSugarScope1.UseTran(() =>
var f = SqlSugarHelper.Db.UseTran(() =>
{
_sqlSugarScope1.Updateable(new OrderInfo()
SqlSugarHelper.Db.Updateable(new OrderInfo()
{
DmStatus = 2,
OrderNo = OrderInfo.OrderNo
@ -306,7 +316,7 @@ namespace DM_Weight.ViewModels
{
ChannelStock it = record[i];
// 更新数据 库存信息
_sqlSugarScope1.Updateable(new ChannelStock()
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
//Quantity = it.Quantity + it.TakeQuantity,
Quantity = it.Quantity + it.ReturnQuantity,
@ -315,14 +325,14 @@ namespace DM_Weight.ViewModels
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
// 保存数据 还药记录
_sqlSugarScope1.Insertable(new MachineRecord()
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = it.MachineId,
DrawerNo = it.DrawerNo,
@ -346,14 +356,41 @@ namespace DM_Weight.ViewModels
if (f.Data)
{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
.GroupBy(it => new { it.DrawerNo, it.ColNo })
.Select(it =>
{
var ret = it.First();
//ret.Quantity = it.Sum(itx => itx.Quantity);
//ret.TakeQuantity = it.Sum(itx => itx.TakeQuantity);
return ret;
}).ToList();
//if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
//{
//将库位多批次的总库存数更新标签
//singleChannels.ForEach(it =>
//{
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.TakeQuantity);
//});
//}
if (singleChannels.Count > 0)
{
singleChannels.ForEach(it =>
for (int i = 0; i < singleChannels.Count; i++)
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.TakeQuantity);
});
if (singleChannels[i].BoardType == 5)
{
int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
.Sum(it => it.Quantity);
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
}
}
}
AlertMsg alertMsg = new AlertMsg
{
Message = "处方退药完成,库存已更新",
@ -412,6 +449,6 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => false;
public bool KeepAlive => true;
}
}

View File

@ -38,13 +38,13 @@ namespace DM_Weight.ViewModels
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
IDialogService _dialogService;
private SqlSugarScope _sqlSugarScope1;
//private SqlSugarScope SqlSugarHelper.Db;
public OrderTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, IDialogService DialogService, SqlSugarScope sqlSugarScope)
{
_dialogService = DialogService;
_portUtil = portUtil;
_eventAggregator = eventAggregator;
this._sqlSugarScope1 = sqlSugarScope;
//this.SqlSugarHelper.Db = sqlSugarScope;
}
void DoMyPrismEvent(DeviceMsg msg)
@ -79,15 +79,15 @@ namespace DM_Weight.ViewModels
{
channelStocks.ForEach(it => it.process = 3);
}
IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
int DrawerNoBefore = groupingBefore.Key;
//IGrouping<int, ChannelStock> groupingBefore = enumerator.Current;
//int DrawerNoBefore = groupingBefore.Key;
if (enumerator.MoveNext())
{
IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
int DrawerNoAfter = groupingAfter.Key;
if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
//IGrouping<int, ChannelStock> groupingAfter = enumerator.Current;
//int DrawerNoAfter = groupingAfter.Key;
//if (DrawerNoBefore < 9 && DrawerNoAfter > 8)
{
Thread.Sleep(50);
Thread.Sleep(80);
}
OpenOneByOne();
}
@ -171,9 +171,9 @@ namespace DM_Weight.ViewModels
public void RequestData()
{
orderDetails = _sqlSugarScope1.Queryable<OrderDetail>()
orderDetails = SqlSugarHelper.Db.Queryable<OrderDetail>()
.Includes<DrugInfo>(od => od.DrugInfo)
.InnerJoin(_sqlSugarScope1.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
.InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (od, t) => od.DrugId == t.DrugId)
.Where(od => od.OrderNo == OrderInfo.OrderNo)
.ToList();
@ -183,8 +183,9 @@ namespace DM_Weight.ViewModels
{
OrderDetail orderDetail = orderDetails[i];
List<ChannelStock> HasQChannels = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> HasQChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
.InnerJoin<ChannelList>((cs, cl) => cs.Chnguid == cl.Id && cs.DrugId == cl.DrugId)
.Where(cs => cs.Quantity > 0)
.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
@ -193,6 +194,7 @@ namespace DM_Weight.ViewModels
.Where(cs => cs.DrugId == orderDetail.DrugId)
.OrderBy(cs => cs.EffDate)
.OrderBy(cs => cs.DrawerNo)
.OrderBy(cs=> cs.ManuNo)
.ToList();
int total = HasQChannels.Sum(it => it.Quantity);
int TakeQ = orderDetail.Quantity;
@ -269,7 +271,18 @@ namespace DM_Weight.ViewModels
channelStocks.ForEach(it => it.process = 1);
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
//List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = channelStocks
.GroupBy(it => new { it.DrawerNo, it.ColNo })
.Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(it => it.Quantity);
ret.TakeQuantity = it.Sum(it => it.TakeQuantity);
return ret;
})
.ToList()
.FindAll(it => it.BoardType != 1);
// 发送取药数量
singleChannels.ForEach(it =>
@ -291,8 +304,8 @@ namespace DM_Weight.ViewModels
});
_portUtil.WindowName = "OrderTakeDrugWindow";
_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
_portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
_portUtil.ColNos = new int[] { };// singleChannels.Select(it => it.ColNo).ToArray();
//_portUtil.Stocks = singleChannels.Select(it => it.Quantity).ToArray();
_portUtil.DrawerNo = DrawerNo;
_portUtil.Start();
}
@ -310,15 +323,15 @@ namespace DM_Weight.ViewModels
if (record.Count > 0)
{
string InvoiceId = OrderInfo.OrderNo;
var f = _sqlSugarScope1.UseTran(() =>
var f = SqlSugarHelper.Db.UseTran(() =>
{
_sqlSugarScope1.Updateable(new OrderInfo()
SqlSugarHelper.Db.Updateable(new OrderInfo()
{
DmStatus = 1,
OrderNo = OrderInfo.OrderNo
}).UpdateColumns(it => new { it.DmStatus }).WhereColumns(it => new { it.OrderNo }).ExecuteCommand();
_sqlSugarScope1.Insertable(new OrderFinish()
SqlSugarHelper.Db.Insertable(new OrderFinish()
{
OrderNo = OrderInfo.OrderNo,
PatientId = OrderInfo.PatientId,
@ -331,7 +344,7 @@ namespace DM_Weight.ViewModels
{
ChannelStock it = record[i];
// 更新数据 库存信息
_sqlSugarScope1.Updateable(new ChannelStock()
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity - it.TakeQuantity,
ManuNo = it.ManuNo,
@ -339,14 +352,14 @@ namespace DM_Weight.ViewModels
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
// 保存数据 出库记录
_sqlSugarScope1.Insertable(new MachineRecord()
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = it.MachineId,
DrawerNo = it.DrawerNo,
@ -361,7 +374,9 @@ namespace DM_Weight.ViewModels
Type = 2,
InvoiceId = InvoiceId,
StockQuantity = nowChannels.Sum(it => it.Quantity),
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
SupplierDept = ConfigurationManager.AppSettings["receiveDept"].ToString(),
ReceiveDept = OrderInfo.DeptName
}).ExecuteCommand();
}
return true;
@ -369,13 +384,38 @@ namespace DM_Weight.ViewModels
if (f.Data)
{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
.GroupBy(it => it.ColNo)
.Select(it =>
{
var ret = it.First();
//ret.Quantity = it.Sum(itx => itx.Quantity);
//ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
return ret;
}).ToList();
//if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
//{
//singleChannels.ForEach(it =>
//{
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
//});
//}
if(singleChannels.Count > 0)
{
singleChannels.ForEach(it =>
for (int i = 0; i < singleChannels.Count; i++)
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
});
if (singleChannels[i].BoardType == 5)
{
int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
.Sum(it => it.Quantity);
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
}
}
}
AlertMsg alertMsg = new AlertMsg
{
@ -445,6 +485,6 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => false;
public bool KeepAlive => true;
}
}

View File

@ -16,6 +16,10 @@ using DM_Weight.util;
using DM_Weight.msg;
using Prism.Events;
using SqlSugar;
using System.Threading;
using System.Timers;
using log4net.Repository.Hierarchy;
using log4net;
namespace DM_Weight.ViewModels
{
@ -70,12 +74,15 @@ namespace DM_Weight.ViewModels
private DelegateCommand _rowSelected;
public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
private SqlSugarScope _sqlSugarScope1;
public OrderTakeDrugWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator,SqlSugarScope sqlSugarScope)
//private SqlSugarScope SqlSugarHelper.Db;
private readonly ILog logger = LogManager.GetLogger(typeof(OrderTakeDrugWindowViewModel));
public OrderTakeDrugWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
{
logger.Info("进入OrderTakeDrugWindowViewModel构造函数");
_dialogService = DialogService;
_eventAggregator = eventAggregator;
this._sqlSugarScope1= sqlSugarScope;
//this.SqlSugarHelper.Db= sqlSugarScope;
}
public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
@ -168,31 +175,30 @@ namespace DM_Weight.ViewModels
public List<OrderInfo> OrderInfos { get { return _orderInfos; } set { SetProperty(ref _orderInfos, value); } }
public bool KeepAlive => false;
public async void OpenOrderDialog()
{
if (SelectedOrder != null && SelectedOrder.DmStatus == 0 && SelectedOrder.CancelFlag == 0 && SelectedOrder.HisDispFlag == 0)
{
// 此处延时1毫秒等待页面渲染
// 此处延时1毫秒等待页面渲染(规避工控机上手指点击弹出的页面上的按钮无效问题)
await Task.Delay(TimeSpan.FromMilliseconds(1));
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("orderInfo", SelectedOrder);
DialogServiceExtensions.ShowDialogHost(_dialogService, "OrderTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
}
}
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
// dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
//if(dialogResult.Result == ButtonResult.OK)
//{
//dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
if (dialogResult.Result == ButtonResult.OK)
{
SelectedOrder = null;
RequestData();
//}
}
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
@ -211,13 +217,17 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => true;
public void RequestData()
{
logger.Info("开始OrderTakeDrugWindowViewModel_查询数据");
OrderInfos.Clear();
int totalCount = 0;
List<OrderInfo> queryData = _sqlSugarScope1.Queryable<OrderInfo>()
List<OrderInfo> queryData = SqlSugarHelper.Db.Queryable<OrderInfo>()
.InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
.InnerJoin(_sqlSugarScope1.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
.InnerJoin(SqlSugarHelper.Db.Queryable<ChannelList>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
.WhereIF(OrderDate != null, oi => oi.RecvDate.ToString("yyyy-MM-dd") == OrderDate)
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("OrderNo"), oi => oi.OrderNo == SearchValue)
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
@ -232,13 +242,22 @@ namespace DM_Weight.ViewModels
OrderInfos = queryData;
TotalCount = totalCount;
PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
logger.Info("结束OrderTakeDrugWindowViewModel_查询数据");
}
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
logger.Info("进入OrderTakeDrugWindowViewModel_OnNavigatedTo");
_eventAggregator.GetEvent<PortUtilEvent>().Subscribe(DoMyPrismEvent);
RequestData();
//RequestData();
Task.Factory.StartNew(() => RequestData());
logger.Info("结束OrderTakeDrugWindowViewModel_OnNavigatedTo");
//Task t = new Task(() => { RequestData(); });
//t.Start();
}
//每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建

View File

@ -42,12 +42,12 @@ namespace DM_Weight.ViewModels
get { return _machineRecord; }
set { SetProperty(ref _machineRecord, value); }
}
private SqlSugarScope _sqlSugarScope1;
//private SqlSugarScope SqlSugarHelper.Db;
public ReturnDrugDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, SqlSugarScope sqlSugarScope)
{
_portUtil = portUtil;
_eventAggregator = eventAggregator;
this._sqlSugarScope1 = sqlSugarScope;
//this.SqlSugarHelper.Db = sqlSugarScope;
}
void DoMyPrismEvent(DeviceMsg msg)
@ -175,7 +175,7 @@ namespace DM_Weight.ViewModels
public void RequestData()
{
List<ChannelStock> queryData = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.DrugId == MachineRecord.DrugId)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
.WhereIF(MachineRecord.ManuNo != null,cs => cs.ManuNo == MachineRecord.ManuNo)
@ -229,24 +229,24 @@ namespace DM_Weight.ViewModels
{
IsFinishClick = true;
string InvoiceId = "RETURN_" + CurrentTimeMillis();
var f = _sqlSugarScope1.UseTran(() =>
var f = SqlSugarHelper.Db.UseTran(() =>
{
// 更新数据 库存信息
_sqlSugarScope1.Updateable(new ChannelStock()
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = ChannelStock.Quantity + ReturnQuantity,
Id = ChannelStock.Id,
}).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(ChannelStock.MachineId))
.Where(cs => cs.DrugId.Equals(ChannelStock.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
// 更新数据 取药记录 设置还药数量、状态
_sqlSugarScope1.Updateable(new MachineRecord()
SqlSugarHelper.Db.Updateable(new MachineRecord()
{
ReturnQuantity1 = MachineRecord.ReturnQuantity1 + ReturnQuantity,
Id = MachineRecord.Id,
@ -254,7 +254,7 @@ namespace DM_Weight.ViewModels
}).UpdateColumns(it => new { it.ReturnQuantity1, it.Status }).ExecuteCommand();
// 保存数据 还药记录
_sqlSugarScope1.Insertable(new MachineRecord()
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = ChannelStock.MachineId,
DrawerNo = ChannelStock.DrawerNo,
@ -279,7 +279,14 @@ namespace DM_Weight.ViewModels
// 更新屏显库存
if (ChannelStock.BoardType == 5)
{
_portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity);
//_portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, ChannelStock.Quantity + ReturnQuantity);
int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(ChannelStock.MachineId))
.Where(cs => cs.DrawerNo == ChannelStock.DrawerNo)
.Where(cs => cs.ColNo == ChannelStock.ColNo)
.Sum(it => it.Quantity);
_portUtil.WriteQuantity(ChannelStock.DrawerNo, ChannelStock.ColNo, totalQuantity);
}
AlertMsg alertMsg = new AlertMsg
@ -330,7 +337,7 @@ namespace DM_Weight.ViewModels
}, () => Status == 0).ObservesProperty(() => Status);
}
public bool KeepAlive => false;
public bool KeepAlive => true;
}
}

View File

@ -76,11 +76,11 @@ namespace DM_Weight.ViewModels
private DelegateCommand _rowSelected;
public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
private SqlSugarScope _sqlSugarScope1;
//private SqlSugarScope SqlSugarHelper.Db;
public ReturnDrugWindow2ViewModel(IDialogService DialogService,SqlSugarScope sqlSugarScope)
{
_dialogService = DialogService;
this._sqlSugarScope1 = sqlSugarScope;
//this.SqlSugarHelper.Db = sqlSugarScope;
}
public static List<OrderTakeSelect> StaticOrderTakeSelects = new()
@ -177,7 +177,7 @@ namespace DM_Weight.ViewModels
public List<OrderInfo> OrderInfos { get { return _orderInfos; } set { SetProperty(ref _orderInfos, value); } }
public bool KeepAlive => false;
public bool KeepAlive => true;
public async void OpenOrderDialog()
{
@ -216,9 +216,9 @@ namespace DM_Weight.ViewModels
{
OrderInfos.Clear();
int totalCount = 0;
List<OrderInfo> queryData = _sqlSugarScope1.Queryable<OrderInfo>()
List<OrderInfo> queryData = SqlSugarHelper.Db.Queryable<OrderInfo>()
.InnerJoin<OrderDetail>((oi, od) => oi.OrderNo == od.OrderNo)
.InnerJoin(_sqlSugarScope1.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
.InnerJoin(SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).GroupBy(cs => cs.DrugId), (oi, od, t) => od.DrugId == t.DrugId)
.WhereIF(OrderDate != null, oi => oi.OrderDate.ToString("yyyy-MM-dd") == OrderDate)
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("OrderNo"), oi => oi.OrderNo == SearchValue)
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PatientId"), oi => oi.PatientId == SearchValue)
@ -238,7 +238,7 @@ namespace DM_Weight.ViewModels
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
RequestData();
Task.Factory.StartNew(() => RequestData());
}
//每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建

View File

@ -23,11 +23,11 @@ namespace DM_Weight.ViewModels
private DelegateCommand _rowSelected;
public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
private SqlSugarScope _sqlSugarScope1;
//private SqlSugarScope SqlSugarHelper.Db;
public ReturnDrugWindowViewModel(IDialogService DialogService, SqlSugarScope sqlSugarScope)
{
_dialogService = DialogService;
this._sqlSugarScope1 = sqlSugarScope;
//this.SqlSugarHelper.Db = sqlSugarScope;
}
public static List<OrderTakeSelect> StaticSelects = new()
@ -134,6 +134,7 @@ namespace DM_Weight.ViewModels
public List<MachineRecord> MachineRecords { get { return _machineRecords; } set { SetProperty(ref _machineRecords, value); } }
public bool KeepAlive => true;
public async void OpenOrderDialog()
{
@ -162,7 +163,6 @@ namespace DM_Weight.ViewModels
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
public bool KeepAlive => false;
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
@ -173,7 +173,7 @@ namespace DM_Weight.ViewModels
public void RequestData()
{
List<MachineRecord> queryData = _sqlSugarScope1.Queryable<MachineRecord>()
List<MachineRecord> queryData = SqlSugarHelper.Db.Queryable<MachineRecord>()
.Includes<DrugInfo>(mr => mr.DrugInfo)
.Includes<UserList>(mr => mr.User)
.Where(mr => mr.Type == 2)
@ -192,7 +192,7 @@ namespace DM_Weight.ViewModels
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
RequestData();
Task.Factory.StartNew(() => RequestData());
}
//每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建

View File

@ -39,12 +39,12 @@ namespace DM_Weight.ViewModels
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
private SqlSugarScope _sqlSugarScope1;
//private SqlSugarScope SqlSugarHelper.Db;
public ReturnEmptyDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, SqlSugarScope sqlSugarScope)
{
_portUtil = portUtil;
_eventAggregator = eventAggregator;
this._sqlSugarScope1 = sqlSugarScope;
//this.SqlSugarHelper.Db = sqlSugarScope;
}
void DoMyPrismEvent(DeviceMsg msg)
@ -170,7 +170,7 @@ namespace DM_Weight.ViewModels
public void RequestData()
{
List<MachineRecord> queryData = _sqlSugarScope1.Queryable<MachineRecord>()
List<MachineRecord> queryData = SqlSugarHelper.Db.Queryable<MachineRecord>()
.Includes<UserList>(mr => mr.User)
.Where(mr => mr.DrugId == ChannelStock.DrugId)
.Where(mr => mr.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
@ -247,18 +247,18 @@ namespace DM_Weight.ViewModels
if (records.Count > 0 && records.Sum(it => it.Quantity - it.ReturnQuantity1) == ReturnQuantity)
{
string InvoiceId = "RETURN_" + CurrentTimeMillis();
var f = _sqlSugarScope1.UseTran(() =>
var f = SqlSugarHelper.Db.UseTran(() =>
{
// 更新数据 库存信息
_sqlSugarScope1.Updateable(new ChannelStock()
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = ChannelStock.Quantity + ReturnQuantity,
Id = ChannelStock.Id,
}).UpdateColumns(it => new { it.Quantity }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(ChannelStock.MachineId))
.Where(cs => cs.DrugId.Equals(ChannelStock.DrugId))
.Where(cs => cs.DrawerType == 1)
@ -268,7 +268,7 @@ namespace DM_Weight.ViewModels
{
MachineRecord _MachineRecord = records[i];
// 更新数据 取药记录 设置还药数量、状态
_sqlSugarScope1.Updateable(new MachineRecord()
SqlSugarHelper.Db.Updateable(new MachineRecord()
{
ReturnQuantity2 = _MachineRecord.Quantity - _MachineRecord.ReturnQuantity1,
Id = _MachineRecord.Id,
@ -276,7 +276,7 @@ namespace DM_Weight.ViewModels
}).UpdateColumns(it => new { it.ReturnQuantity1, it.Status }).ExecuteCommand();
// 保存数据 还药空瓶记录
_sqlSugarScope1.Insertable(new MachineRecord()
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = ChannelStock.MachineId,
DrawerNo = ChannelStock.DrawerNo,
@ -371,6 +371,6 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => false;
public bool KeepAlive => true;
}
}

View File

@ -35,11 +35,11 @@ namespace DM_Weight.ViewModels
}
IDialogService _dialogService;
private SqlSugarScope _sqlSugarScope1;
//private SqlSugarScope SqlSugarHelper.Db;
public ReturnEmptyWindowViewModel(IDialogService dialogService, SqlSugarScope sqlSugarScope)
{
_dialogService = dialogService;
this._sqlSugarScope1 = sqlSugarScope;
//this.SqlSugarHelper.Db = sqlSugarScope;
}
public DelegateCommand RowSelected
@ -71,7 +71,6 @@ namespace DM_Weight.ViewModels
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
public bool KeepAlive => false;
public DelegateCommand Query
@ -82,6 +81,8 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => true;
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
{
@ -99,7 +100,7 @@ namespace DM_Weight.ViewModels
void RequestData()
{
Channels = _sqlSugarScope1.Queryable<ChannelStock>()
Channels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.LeftJoin<DrugInfo>((cs,di) => cs.DrugId == di.DrugId.ToString())
.Where((cs) => cs.DrawerType != 1)
.Select((cs, di) => new ChannelStock{

View File

@ -30,11 +30,11 @@ namespace DM_Weight.ViewModels
get { return _roleList; }
set { SetProperty(ref _roleList, value); }
}
private SqlSugarScope _sqlSugarScope1;
//private SqlSugarScope SqlSugarHelper.Db;
public RoleManagerWindowViewModel(SqlSugarScope sqlSugarScope)
{
//_allPremissions = Clone<PremissionDm>(defaultAll);
this._sqlSugarScope1 = sqlSugarScope;
//this.SqlSugarHelper.Db = sqlSugarScope;
}
public static ObservableCollection<T> Clone<T>(object List)
@ -214,17 +214,23 @@ namespace DM_Weight.ViewModels
PremissionImage = "/Images/TbJiay.png",
};
ObservableCollection<PremissionDm> jiayaoChild = new ObservableCollection<PremissionDm>();
PremissionDm jiayao1 = new PremissionDm
PremissionDm jiayao2 = new PremissionDm
{
Id = 21,
PremissionName = "自选加药",
PremissionPath = "SelfAddWindow",
};
PremissionDm jiayao2 = new PremissionDm
//PremissionDm jiayao2 = new PremissionDm
//{
// Id = 22,
// PremissionName = "调拨入库",
// PremissionPath = "InvoiceInWindow",
//};
PremissionDm jiayao1 = new PremissionDm
{
Id = 22,
PremissionName = "调拨入库",
PremissionPath = "InvoiceInWindow",
PremissionPath = "InvoiceInNewWindow",
};
PremissionDm jiayao3 = new PremissionDm
{
@ -234,13 +240,20 @@ namespace DM_Weight.ViewModels
};
PremissionDm jiayao4 = new PremissionDm
{
Id = 24,
Id = 25,
PremissionName = "加药记录",
PremissionPath = "AddRecordWindow",
};
PremissionDm jiayao5 = new PremissionDm
{
Id = 24,
PremissionName = "多批次抽屉加药",
PremissionPath = "AddDrugControl",
};
jiayaoChild.Add(jiayao1);
jiayaoChild.Add(jiayao2);
jiayaoChild.Add(jiayao3);
jiayaoChild.Add(jiayao5);
jiayaoChild.Add(jiayao4);
jiayao.Children = jiayaoChild;
defaultAll.Add(jiayao);
@ -301,13 +314,20 @@ namespace DM_Weight.ViewModels
{
Id = 42,
PremissionName = "库存盘点",
PremissionPath = "CheckStockWindow",
PremissionPath = "CheckStockNewWindow",// "CheckStockWindow",
};
//PremissionDm kuguan3 = new PremissionDm
//{
// Id = 43,
// PremissionName = "盘点记录",
// PremissionPath = "CheckRecordWindow",
//};
PremissionDm kuguan3 = new PremissionDm
{
Id = 43,
PremissionName = "盘点记录",
PremissionPath = "CheckRecordWindow",
PremissionPath = "CheckRecordNewWindow",
};
PremissionDm kuguan4 = new PremissionDm
{
@ -321,11 +341,25 @@ namespace DM_Weight.ViewModels
PremissionName = "交接班记录",
PremissionPath = "ChangeShiftsListWindow",
};
PremissionDm kuguan6 = new PremissionDm
{
Id = 46,
PremissionName = "账册",
PremissionPath = "AccountWindow",
};
//PremissionDm kuguan7 = new PremissionDm
//{
// Id = 47,
// PremissionName = "库存盘点",
// PremissionPath = "CheckStockNew2Window",
//};
kuguanChild.Add(kuguan1);
kuguanChild.Add(kuguan2);
kuguanChild.Add(kuguan3);
kuguanChild.Add(kuguan4);
kuguanChild.Add(kuguan5);
kuguanChild.Add(kuguan6);
//kuguanChild.Add(kuguan7);
kuguan.Children = kuguanChild;
defaultAll.Add(kuguan);
#endregion
@ -400,7 +434,6 @@ namespace DM_Weight.ViewModels
set => SetProperty(ref _rightPremission, value);
}
public bool KeepAlive => false;
public T DeepCopyByReflect<T>(T obj)
{
@ -664,14 +697,14 @@ namespace DM_Weight.ViewModels
Role.Id = 0;
Role.MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1";
Role.Permissions = RightPremissions.ToList();
List<RoleDm> roleList = _sqlSugarScope1.Queryable<RoleDm>().Where(r => r.RoleName == Role.RoleName).ToList();
List<RoleDm> roleList = SqlSugarHelper.Db.Queryable<RoleDm>().Where(r => r.RoleName == Role.RoleName).ToList();
if(roleList.Count>0)
{
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("该角色已存在!");
return;
}
_sqlSugarScope1.Insertable<RoleDm>(Role).ExecuteCommand();
SqlSugarHelper.Db.Insertable<RoleDm>(Role).ExecuteCommand();
RequestData();
});
}
@ -681,11 +714,13 @@ namespace DM_Weight.ViewModels
get => new DelegateCommand(() =>
{
Role.Permissions = RightPremissions.ToList();
_sqlSugarScope1.Updateable<RoleDm>(Role).ExecuteCommand();
SqlSugarHelper.Db.Updateable<RoleDm>(Role).ExecuteCommand();
RequestData();
});
}
public bool KeepAlive => true;
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
{
@ -704,7 +739,7 @@ namespace DM_Weight.ViewModels
void RequestData()
{
RoleList = _sqlSugarScope1.Queryable<RoleDm>()
RoleList = SqlSugarHelper.Db.Queryable<RoleDm>()
.Where(di => di.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
.WhereIF(!String.IsNullOrEmpty(SearchValue), (di) => di.RoleName.Contains(SearchValue??""))
.Select(r => r)

View File

@ -19,6 +19,7 @@ using DM_Weight.util;
using DM_Weight.Views;
using System.Threading;
using SqlSugar;
using System.Configuration;
namespace DM_Weight.ViewModels
{
@ -41,12 +42,12 @@ namespace DM_Weight.ViewModels
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
private SqlSugarScope _sqlSugarScope1;
public SelfAddDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, SqlSugarScope sqlSugarScope)
////private SqlSugarScope SqlSugarHelper.Db;
public SelfAddDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
{
_portUtil = portUtil;
_eventAggregator = eventAggregator;
this._sqlSugarScope1 = sqlSugarScope;
////this.SqlSugarHelper.Db = sqlSugarScope;
}
void DoMyPrismEvent(DeviceMsg msg)
@ -192,7 +193,18 @@ namespace DM_Weight.ViewModels
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = channelStocks
.GroupBy(it => new {
it.DrawerNo, it.ColNo
})
.Select(it => {
var ret = it.First();
ret.Quantity = it.Sum(it => it.Quantity);
ret.AddQuantity = it.Sum(it => it.AddQuantity);
return ret;
})
.ToList()
.FindAll(it => it.BoardType != 1);
_portUtil.WindowName = WindowName;
_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
@ -202,6 +214,18 @@ namespace DM_Weight.ViewModels
if((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
{
//List<ChannelStock> ChannelLst = channelStocks.Where(it => it.BoardType != 1)
// .GroupBy(it => it.ColNo)
// .Select(it =>
// {
// var ret = it.First();
// ret.Quantity = it.Sum(itx => itx.Quantity);
// ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
// return ret;
// }).ToList();
////将库位多批次的总库存数更新标签
//_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) + singleChannels.Sum(it => it.AddQuantity));
// 发送加药数量
singleChannels.ForEach(it =>
{
@ -234,7 +258,7 @@ namespace DM_Weight.ViewModels
List<ChannelStock> record = ChannelStocks.ToList();
//string InvoiceId = "SELF_" + CurrentTimeMillis();
string InvoiceId = PZH;
var f = _sqlSugarScope1.UseTran(() =>
var f = SqlSugarHelper.Db.UseTran(() =>
{
for (int i = 0; i < record.Count; i++)
{
@ -244,7 +268,7 @@ namespace DM_Weight.ViewModels
_portUtil.SetNumCount(it.DrawerNo, it.ColNo, it.AddQuantity);
}
// 更新数据 库存信息
_sqlSugarScope1.Updateable(new ChannelStock()
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity + it.AddQuantity,
PosNo = 1,
@ -253,14 +277,14 @@ namespace DM_Weight.ViewModels
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
// 保存数据 出/入库记录
_sqlSugarScope1.Insertable(new MachineRecord()
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = it.MachineId,
DrawerNo = it.DrawerNo,
@ -275,7 +299,9 @@ namespace DM_Weight.ViewModels
Type = 1,
InvoiceId = InvoiceId,
StockQuantity = nowChannels.Sum(it => it.Quantity),
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
SupplierDept = ConfigurationManager.AppSettings["supplierDept"].ToString(),
ReceiveDept = ConfigurationManager.AppSettings["receiveDept"].ToString()
}).ExecuteCommand();
}
return true;
@ -283,15 +309,43 @@ namespace DM_Weight.ViewModels
if (f.Data)
{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = record.Where(it => it.BoardType != 1)
.GroupBy(it => new { it.DrawerNo,it.ColNo })
.Select(it =>
{
var ret = it.First();
//ret.Quantity = it.Sum(itx => itx.Quantity);
//ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
return ret;
}).ToList();
//if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
//{
// //将库位多批次的总库存数更新标签
// //_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) + singleChannels.Sum(it => it.AddQuantity));
// singleChannels.ForEach(it =>
// {
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
// });
//}
if(singleChannels!=null&& singleChannels.Count>0)
{
singleChannels.ForEach(it =>
for (int i = 0; i < singleChannels.Count; i++)
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity + it.AddQuantity);
});
if (singleChannels[i].BoardType == 5)
{
int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
.Sum(it => it.Quantity);
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
}
}
}
AlertMsg alertMsg = new AlertMsg
{
@ -350,6 +404,6 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => false;
public bool KeepAlive => true;
}
}

View File

@ -0,0 +1,211 @@
using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DM_Weight.Models;
using DM_Weight.select;
using DM_Weight.util;
using Prism.Events;
using DM_Weight.msg;
using log4net;
namespace DM_Weight.ViewModels
{
public class SelfAddWindowViewModel_Copy : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
{
IDialogService _dialogService;
IEventAggregator _eventAggregator;
public static List<OrderTakeSelect> StaticSelects = new()
{
new OrderTakeSelect
{
Code = "DrugName",
Name = "药品名称"
},
new OrderTakeSelect
{
Code = "PyCode",
Name = "拼音码"
},
new OrderTakeSelect
{
Code = "DrugBarcode",
Name = "药品条码"
},
new OrderTakeSelect
{
Code = "DrugId",
Name = "药品编码"
}
};
////private SqlSugarScope SqlSugarHelper.Db;
private readonly ILog logger = LogManager.GetLogger(typeof(SelfAddWindowViewModel));
public SelfAddWindowViewModel_Copy(IDialogService DialogService,IEventAggregator eventAggregator)
{
logger.Info("进入SelfAddWindowViewModel构造函数");
_dialogService = DialogService;
_eventAggregator = eventAggregator;
////this.SqlSugarHelper.Db = sqlSugarScope;
}
private List<OrderTakeSelect> _selects = StaticSelects;
public List<OrderTakeSelect> Selects
{
get { return _selects; }
set
{
SetProperty(ref _selects, value);
}
}
private OrderTakeSelect _selectedItem = StaticSelects[0];
/// <summary>
/// 查询条件 查询字段
/// </summary>
public OrderTakeSelect SelectedItem
{
get { return _selectedItem; }
set
{
SetProperty(ref _selectedItem, value);
RequestChannelData();
}
}
private string? _searchValue;
/// <summary>
/// 查询条件 查询字段值
/// </summary>
public string? SearchValue
{
get { return _searchValue; }
set
{
SetProperty(ref _searchValue, value);
RequestChannelData();
}
}
private List<ChannelStock> _channelStocks = new();
public List<ChannelStock> ChannelStocks { get { return _channelStocks; } set { SetProperty(ref _channelStocks, value); } }
public DelegateCommand QueryCommand
{
get => new DelegateCommand(() =>
{
RequestChannelData();
});
}
public DelegateCommand OpenSelfDialog
{
get => new DelegateCommand(() =>
{
List<ChannelStock> addChannels = ChannelStocks.FindAll(it => it.AddQuantity > 0).ToList();
if (addChannels.Count > 0)
{
addChannels.Sort((a, b) =>
{
if ((a.DrawerNo - b.DrawerNo) == 0)
{
return a.ColNo - b.ColNo;
}
return a.DrawerNo - b.DrawerNo;
});
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("ChannelStocks", addChannels);
DialogServiceExtensions.ShowDialogHost(_dialogService, "SelfAddDialog", dialogParameters, DoDialogResult, "RootDialog");
}
else
{
AlertMsg alertMsg = new AlertMsg
{
Message = "请填写加药数量",
Type = MsgType.ERROR
};
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
});
}
public bool KeepAlive => true;
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
// dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
if (dialogResult.Result == ButtonResult.OK)
{
RequestChannelData();
}
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
{
continuationCallback(true);
}
public void RequestChannelData()
{
logger.Info("开始SelfAddWindowViewModel_查询数据");
List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
.InnerJoin<ChannelList>((cs, cl) => cs.Chnguid == cl.Id && cs.DrugId == cl.DrugId)
.Where(cs => cs.DrugId != null)
.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (cs) => cs.DrugId.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cs) => cs.DrugInfo.DrugName.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cs) => cs.DrugInfo.PyCode.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cs) => cs.DrugInfo.DrugBarcode.Contains(SearchValue))
.OrderBy(cs => cs.DrugId)
.OrderBy(cs => cs.DrawerNo)
.OrderBy(cs => cs.ColNo)
.ToList();
ChannelStocks = queryData;
logger.Info("结束SelfAddWindowViewModel_查询数据");
}
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
logger.Info("进入SelfAddWindowViewModel_OnNavigatedTo");
Task.Factory.StartNew(() => RequestChannelData());
logger.Info("结束SelfAddWindowViewModel_OnNavigatedTo");
}
//每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建
public bool IsNavigationTarget(NavigationContext navigationContext)
{
return true;
}
//这个方法用于拦截请求
public void OnNavigatedFrom(NavigationContext navigationContext)
{
}
}
}

View File

@ -14,6 +14,8 @@ using DM_Weight.select;
using DM_Weight.util;
using Prism.Events;
using DM_Weight.msg;
using log4net;
using System.Windows.Documents;
namespace DM_Weight.ViewModels
{
@ -45,15 +47,17 @@ namespace DM_Weight.ViewModels
Name = "药品编码"
}
};
private SqlSugarScope _sqlSugarScope1;
public SelfAddWindowViewModel(IDialogService DialogService,IEventAggregator eventAggregator, SqlSugarScope sqlSugarScope)
////private SqlSugarScope SqlSugarHelper.Db;
private readonly ILog logger = LogManager.GetLogger(typeof(SelfAddWindowViewModel));
public SelfAddWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
{
logger.Info("进入SelfAddWindowViewModel构造函数");
_dialogService = DialogService;
_eventAggregator = eventAggregator;
this._sqlSugarScope1 = sqlSugarScope;
////this.SqlSugarHelper.Db = sqlSugarScope;
}
private List<OrderTakeSelect> _selects = StaticSelects;
@ -78,7 +82,7 @@ namespace DM_Weight.ViewModels
SetProperty(ref _selectedItem, value);
RequestChannelData();
}
}
}
private string? _searchValue;
@ -115,7 +119,18 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand(() =>
{
List<ChannelStock> addChannels = ChannelStocks.FindAll(it => it.AddQuantity > 0).ToList();
List<ChannelStock> addChannels = Drugs.Aggregate(new List<ChannelStock>(), (a, b) =>
{
a.AddRange(b.channelStocks.FindAll(it => it.AddQuantity > 0).Select(cs =>
{
cs.DrugInfo = b;
return cs;
}).ToList());
return a;
});
//List<ChannelStock> addChannels = ChannelStocks.FindAll(it => it.AddQuantity > 0).ToList();
if (addChannels.Count > 0)
{
addChannels.Sort((a, b) =>
@ -142,6 +157,8 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => true;
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
@ -153,7 +170,6 @@ namespace DM_Weight.ViewModels
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
public bool KeepAlive => false;
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
@ -162,29 +178,57 @@ namespace DM_Weight.ViewModels
}
private List<DrugInfo> _drugs = new();
public List<DrugInfo> Drugs
{
get => _drugs;
set => SetProperty(ref _drugs, value);
}
private DrugInfo? _drug;
public DrugInfo? Drug
{
get => _drug;
set => SetProperty(ref _drug, value);
}
public void RequestChannelData()
{
List<ChannelStock> queryData = _sqlSugarScope1.Queryable<ChannelStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
.Where(cs => cs.DrugId != null)
.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
logger.Info("开始SelfAddWindowViewModel_查询数据");
//List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
// .Includes<DrugInfo>(cs => cs.DrugInfo)
// .InnerJoin<ChannelList>((cs, cl) => cs.Chnguid == cl.Id && cs.DrugId == cl.DrugId)
// .Where(cs => cs.DrugId != null)
// .Where(cs => cs.DrawerType == 1)
// .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
// .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (cs) => cs.DrugId.Contains(SearchValue))
// .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cs) => cs.DrugInfo.DrugName.Contains(SearchValue))
// .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cs) => cs.DrugInfo.PyCode.Contains(SearchValue))
// .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cs) => cs.DrugInfo.DrugBarcode.Contains(SearchValue))
// .OrderBy(cs => cs.DrugId)
// .OrderBy(cs => cs.DrawerNo)
// .OrderBy(cs => cs.ColNo)
// .ToList();
//ChannelStocks = queryData;
List<DrugInfo> q = SqlSugarHelper.Db.Queryable<DrugInfo>()
.Includes<ChannelStock>(di => di.channelStocks.Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.DrugId != null).OrderBy(cs => cs.DrawerNo).OrderBy(cs => cs.ColNo).ToList())
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (cs) => cs.DrugId.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cs) => cs.DrugInfo.DrugName.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cs) => cs.DrugInfo.PyCode.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cs) => cs.DrugInfo.DrugBarcode.Contains(SearchValue))
.OrderBy(cs => cs.DrugId)
.OrderBy(cs => cs.DrawerNo)
.OrderBy(cs => cs.ColNo)
.ToList();
ChannelStocks = queryData;
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cs) => cs.DrugName.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cs) => cs.PyCode.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cs) => cs.DrugBarcode.Contains(SearchValue))
.Where(di => di.channelStocks.Any(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.DrugId != null))
.OrderBy(cs => cs.DrugId)
.ToList();
Drugs = q;
logger.Info("结束SelfAddWindowViewModel_查询数据");
}
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
RequestChannelData();
logger.Info("进入SelfAddWindowViewModel_OnNavigatedTo");
Task.Factory.StartNew(() => RequestChannelData());
logger.Info("结束SelfAddWindowViewModel_OnNavigatedTo");
}
//每次导航的时候该实列用不用重新创建true是不重新创建,false是重新创建

View File

@ -17,6 +17,7 @@ using DM_Weight.Port;
using DM_Weight.util;
using System.Threading;
using SqlSugar;
using System.Configuration;
namespace DM_Weight.ViewModels
{
@ -35,12 +36,12 @@ namespace DM_Weight.ViewModels
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
private SqlSugarScope _sqlSugarScope1;
//private SqlSugarScope SqlSugarHelper.Db;
public SelfTakeDialogViewModel(PortUtil portUtil, IEventAggregator eventAggregator, SqlSugarScope sqlSugarScope)
{
_portUtil = portUtil;
_eventAggregator = eventAggregator;
this._sqlSugarScope1 = sqlSugarScope;
//this.SqlSugarHelper.Db = sqlSugarScope;
}
void DoMyPrismEvent(DeviceMsg msg)
@ -184,7 +185,17 @@ namespace DM_Weight.ViewModels
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
List<ChannelStock> singleChannels = channelStocks.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = channelStocks
.GroupBy(it => new { it.DrawerNo, it.ColNo })
.Select(it =>
{
var ret = it.First();
ret.Quantity = it.Sum(it => it.Quantity);
ret.TakeQuantity = it.Sum(it => it.TakeQuantity);
return ret;
})
.ToList()
.FindAll(it => it.BoardType != 1);
// 发送取药数量
@ -211,13 +222,13 @@ namespace DM_Weight.ViewModels
_isFinishClick = true;
List<ChannelStock> record = ChannelStocks.ToList();
string InvoiceId = "SELF_" + CurrentTimeMillis();
var f = _sqlSugarScope1.UseTran(() =>
var f = SqlSugarHelper.Db.UseTran(() =>
{
for (int i = 0; i < record.Count; i++)
{
ChannelStock it = record[i];
// 更新数据 库存信息
_sqlSugarScope1.Updateable(new ChannelStock()
SqlSugarHelper.Db.Updateable(new ChannelStock()
{
Quantity = it.Quantity - it.TakeQuantity,
ManuNo = it.ManuNo,
@ -225,14 +236,14 @@ namespace DM_Weight.ViewModels
Id = it.Id,
}).UpdateColumns(it => new { it.Quantity, it.ManuNo, it.EffDate }).ExecuteCommand();
// 获取更新完库存后的药品库存
List<ChannelStock> nowChannels = _sqlSugarScope1.Queryable<ChannelStock>()
List<ChannelStock> nowChannels = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId.Equals(it.MachineId))
.Where(cs => cs.DrugId.Equals(it.DrugId))
.Where(cs => cs.DrawerType == 1)
.ToList();
// 保存数据 出/入库记录
_sqlSugarScope1.Insertable(new MachineRecord()
SqlSugarHelper.Db.Insertable(new MachineRecord()
{
MachineId = it.MachineId,
DrawerNo = it.DrawerNo,
@ -247,7 +258,9 @@ namespace DM_Weight.ViewModels
Type = 2,
InvoiceId = InvoiceId,
StockQuantity = nowChannels.Sum(it => it.Quantity),
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity)
ManunoQuantity = nowChannels.FindAll(it2 => it2.ManuNo == it.ManuNo).Sum(it => it.Quantity),
SupplierDept = ConfigurationManager.AppSettings["supplierDept"].ToString(),
ReceiveDept = ConfigurationManager.AppSettings["receiveDept"].ToString()
}).ExecuteCommand();
}
return true;
@ -255,13 +268,41 @@ namespace DM_Weight.ViewModels
if (f.Data)
{
// 更新屏显库存
List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
//List<ChannelStock> singleChannels = record.FindAll(it => it.BoardType != 1);
List<ChannelStock> singleChannels = ChannelStocks.Where(it => it.BoardType != 1)
.GroupBy(it =>new { it.DrawerNo, it.ColNo })
.Select(it =>
{
var ret = it.First();
//ret.Quantity = it.Sum(itx => itx.Quantity);
//ret.AddQuantity = it.Sum(itx => itx.AddQuantity);
return ret;
}).ToList();
//if ((singleChannels.Count > 0 ? singleChannels[0].BoardType : 1) == 5)
//{
// //将库位多批次的总库存数更新标签
// //_portUtil.WriteQuantity(singleChannels[0].DrawerNo, singleChannels[0].ColNo, singleChannels.Sum(it => it.Quantity) + singleChannels.Sum(it => it.AddQuantity));
// singleChannels.ForEach(it =>
// {
// _portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
// });
//}
if(singleChannels!=null&&singleChannels.Count>0)
{
singleChannels.ForEach(it =>
for (int i = 0; i < singleChannels.Count; i++)
{
_portUtil.WriteQuantity(it.DrawerNo, it.ColNo, it.Quantity - it.TakeQuantity);
});
if (singleChannels[i].BoardType == 5)
{
int totalQuantity = SqlSugarHelper.Db.Queryable<ChannelStock>()
.Where(cs => cs.MachineId == singleChannels[i].MachineId)
.Where(cs => cs.DrawerNo == singleChannels[i].DrawerNo)
.Where(cs => cs.ColNo == singleChannels[i].ColNo)
.Sum(it => it.Quantity);
//将库位多批次的总库存数更新标签
_portUtil.WriteQuantity(singleChannels[i].DrawerNo, singleChannels[i].ColNo, totalQuantity);
}
}
}
AlertMsg alertMsg = new AlertMsg
@ -320,6 +361,6 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => false;
public bool KeepAlive => true;
}
}

View File

@ -45,12 +45,12 @@ namespace DM_Weight.ViewModels
Name = "药品编码"
}
};
private SqlSugarScope _sqlSugarScope1;
//private SqlSugarScope SqlSugarHelper.Db;
public SelfTakeDrugWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator, SqlSugarScope sqlSugarScope)
{
_dialogService = DialogService;
_eventAggregator= eventAggregator;
this._sqlSugarScope1 = sqlSugarScope;
//this.SqlSugarHelper.Db = sqlSugarScope;
}
@ -105,7 +105,17 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand(() =>
{
List<ChannelStock> takeChannels = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
//List<ChannelStock> takeChannels = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
List<ChannelStock> takeChannels = Drugs.Aggregate(new List<ChannelStock>(), (a, b) =>
{
a.AddRange(b.channelStocks.FindAll(it => it.TakeQuantity > 0).Select(cs => {
cs.DrugInfo = b;
return cs;
}).ToList());
return a;
});
if (takeChannels.Count > 0)
{
takeChannels.Sort((a, b) =>
@ -133,6 +143,8 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => true;
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
@ -144,7 +156,6 @@ namespace DM_Weight.ViewModels
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
public bool KeepAlive => false;
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
@ -152,25 +163,50 @@ namespace DM_Weight.ViewModels
continuationCallback(true);
}
private List<DrugInfo> _drugs = new();
public List<DrugInfo> Drugs
{
get => _drugs;
set => SetProperty(ref _drugs, value);
}
private DrugInfo? _drug;
public DrugInfo? Drug
{
get => _drug;
set => SetProperty(ref _drug, value);
}
public void RequestChannelData()
{
List<ChannelStock> queryData = _sqlSugarScope1.Queryable<ChannelStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
.Where(cs => cs.DrugId != null)
.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.Quantity > 0)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (cs) => cs.DrugId.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cs) => cs.DrugInfo.DrugName.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cs) => cs.DrugInfo.PyCode.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cs) => cs.DrugInfo.DrugBarcode.Contains(SearchValue))
.OrderBy(cs => cs.DrugId)
.OrderBy(cs => cs.DrawerNo)
.OrderBy(cs => cs.ColNo)
.ToList();
ChannelStocks = queryData;
//List<ChannelStock> queryData = SqlSugarHelper.Db.Queryable<ChannelStock>()
// .Includes<DrugInfo>(cs => cs.DrugInfo)
// .Where(cs => cs.DrugId != null)
// .Where(cs => cs.DrawerType == 1)
// .Where(cs => cs.Quantity > 0)
// .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
// .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (cs) => cs.DrugId.Contains(SearchValue))
// .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cs) => cs.DrugInfo.DrugName.Contains(SearchValue))
// .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cs) => cs.DrugInfo.PyCode.Contains(SearchValue))
// .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cs) => cs.DrugInfo.DrugBarcode.Contains(SearchValue))
// .OrderBy(cs => cs.DrugId)
// .OrderBy(cs => cs.DrawerNo)
// .OrderBy(cs => cs.ColNo)
// .ToList();
//ChannelStocks = queryData;
List<DrugInfo> q = SqlSugarHelper.Db.Queryable<DrugInfo>()
.Includes<ChannelStock>(di => di.channelStocks.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.DrugId != null&&cs.Quantity>0).OrderBy(cs => cs.DrawerNo).OrderBy(cs => cs.ColNo).ToList())
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (cs) => cs.DrugId.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cs) => cs.DrugName.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cs) => cs.PyCode.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cs) => cs.DrugBarcode.Contains(SearchValue))
.Where(di => di.channelStocks.Any(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.DrugId != null))
.OrderBy(cs => cs.DrugId)
.ToList();
Drugs = q.Where(di => di.channelStocks.Count() > 0).ToList();
}
//接收导航传过来的参数 现在是在此处初始化了表格数据

View File

@ -14,7 +14,6 @@ namespace DM_Weight.ViewModels
{
public class SettingWindowViewModel : BindableBase, IRegionMemberLifetime
{
public bool KeepAlive => false;
public static List<OrderTakeSelect> defaultKeyValuePairs = new()
{
new OrderTakeSelect() { Code = "operator", Name = "操作人" },
@ -69,6 +68,9 @@ namespace DM_Weight.ViewModels
}
});
}
public bool KeepAlive => true;
//手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题
public string ReadAppSetting(string key)
{

View File

@ -0,0 +1,136 @@
using DM_Weight.Models;
using DM_Weight.Report;
using DM_Weight.util;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.ViewModels
{
public class StockListAccountDialogViewModel : BindableBase, IDialogAware
{
public string Title => "导出账册";
/// <summary>
/// 药品库位号
/// </summary>
private string _stock;
public string Stock
{
get => _stock;
set => SetProperty(ref _stock, value);
}
/// <summary>
/// 药品ID
/// </summary>
private string _drug_id;
public string DrugId
{
get => _drug_id;
set => SetProperty(ref _drug_id, value);
}
/// <summary>
/// 开始时间
/// </summary>
private DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
public DateTime? StartDate
{
get => _startDate;
set
{
if (value != null)
{
SetProperty(ref _startDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0));
}
else
{
SetProperty(ref _startDate, value);
}
}
}
/// <summary>
/// 结束时间
/// </summary>
private DateTime? _endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
public DateTime? EndDate
{
get => _endDate;
set
{
if (value != null)
{
TimeSpan ershisi = new TimeSpan(23, 59, 59);
SetProperty(ref _endDate, new DateTime(value?.Year ?? 0, value?.Month ?? 0, value?.Day ?? 0, 23, 59, 59));
}
else
{
SetProperty(ref _endDate, value);
}
}
}
//private SqlSugarScope SqlSugarHelper.Db;
public StockListAccountDialogViewModel(SqlSugarScope sqlSugarScope)
{
//this.SqlSugarHelper.Db = sqlSugarScope;
}
public DelegateCommand DownloadAccountBook
{
get => new DelegateCommand(() =>
{
GridReportUtil.PrintReportAccountBook(StartDate, EndDate,0, DrugId ?? "");
// 关闭当前窗口
RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
});
}
public DelegateCommand BtnCloseCommand
{
get => new DelegateCommand(() =>
{
// 关闭当前窗口
RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
});
}
public event Action<IDialogResult> RequestClose;
public bool CanCloseDialog()
{
return true;
}
public void OnDialogClosed()
{
}
public void OnDialogOpened(IDialogParameters parameters)
{
if (parameters.ContainsKey("Stock"))
{
Stock = parameters.GetValue<string>("Stock");
if (!string.IsNullOrEmpty(Stock))
{
//根据库位信息查询出药品id
string[] strStock = Stock.Split('-');
if (strStock.Length >= 2)
{
//DrugId = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == Convert.ToInt32(strStock[0]) && cs.ColNo == Convert.ToInt32(strStock[1])).Select(cs => cs.DrugId).ToString();
var list = SqlSugarHelper.Db.Queryable<ChannelStock>().Where(cs => cs.DrawerNo == Convert.ToInt32(strStock[0]) && cs.ColNo == Convert.ToInt32(strStock[1])&& cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1")).ToList();
if(list!=null&&list.Count>0)
{
DrugId = list[0].DrugId;
}
}
}
}
}
}
}

View File

@ -16,12 +16,17 @@ using DM_Weight.select;
using DM_Weight.util;
using System.ComponentModel;
using System.Windows.Data;
using System.Runtime.InteropServices;
using System.Threading;
using log4net.Repository.Hierarchy;
using log4net;
namespace DM_Weight.ViewModels
{
public class StockListWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
{
//public static StockListWindowViewModel vm;
public string drugId;
public static List<OrderTakeSelect> StaticSelects = new()
{
new OrderTakeSelect
@ -85,13 +90,15 @@ namespace DM_Weight.ViewModels
RequestData();
}
}
IDialogService _dialogService;
private SqlSugarScope _sqlSugarScope1;
public StockListWindowViewModel(IDialogService dialogService, SqlSugarScope sqlSugarScope)
////private SqlSugarScope SqlSugarHelper.Db;
private readonly ILog logger = LogManager.GetLogger(typeof(StockListWindowViewModel));
public StockListWindowViewModel(IDialogService dialogService)
{
logger.Info("进入StockListWindowViewModel构造函数");
_dialogService = dialogService;
this._sqlSugarScope1 = sqlSugarScope;
////this.SqlSugarHelper.Db = sqlSugarScope;
//vm = this;
}
private ChannelStock? _selectedChannel;
@ -114,7 +121,8 @@ namespace DM_Weight.ViewModels
get => new DelegateCommand(() =>
{
DialogParameters dialogParameters = new DialogParameters();
DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelDialog", dialogParameters, DoDialogResult, "RootDialog");
//DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelDialog", dialogParameters, DoDialogResult, "RootDialog");
DialogServiceExtensions.ShowDialogHost(_dialogService, "BindingChannelNewDialog", dialogParameters, DoDialogResult, "RootDialog");
});
}
@ -126,6 +134,22 @@ namespace DM_Weight.ViewModels
RequestData();
});
}
/// <summary>
/// 导出账册
/// </summary>
public DelegateCommand DownloadAccountBook
{
get => new DelegateCommand(() =>
{
AccountAction();
});
}
private void AccountAction()
{
DialogParameters dialogParameters = new DialogParameters();
dialogParameters.Add("Stock", drugId);
DialogServiceExtensions.ShowDialogHost(_dialogService, "StockListAccountDialog", dialogParameters, "RootDialog");
}
private void DoDialogResult(IDialogResult dialogResult)
{
@ -133,7 +157,7 @@ namespace DM_Weight.ViewModels
// dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
//if (dialogResult.Result == ButtonResult.OK)
//{
RequestData();
RequestData();
//}
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
@ -146,43 +170,99 @@ namespace DM_Weight.ViewModels
});
}
public DelegateCommand<object> ClickCommand
{
get => new DelegateCommand<object>((SelectedChannel) =>
{
if (SelectedChannel != null)
{
}
});
}
public bool KeepAlive => true;
public bool KeepAlive => false;
//这个方法用于拦截请求,continuationCallback(true)就是不拦截continuationCallback(false)拦截本次操作
public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
{
continuationCallback(true);
}
private List<DrugInfo>? _drugs = new();
public List<DrugInfo>? Drugs
{
get => _drugs;
set => SetProperty(ref _drugs, value);
}
private DrugInfo? _drug;
public DrugInfo? Drug
{
get => _drug;
set => SetProperty(ref _drug, value);
}
public void RequestData()
{
ChannelStocks.Clear();
List<ChannelStock> q = _sqlSugarScope1.Queryable<ChannelStock>()
.Includes<DrugInfo>(cs => cs.DrugInfo)
.Where(cs => cs.DrawerType == 1)
.Where(cs =>cs.DrugId != null)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
.WhereIF(!String.IsNullOrEmpty(SearchValue),cs => cs.DrugInfo.DrugName == SearchValue)
.OrderBy(cs => cs.DrugId)
.OrderBy(cs => cs.DrawerNo)
.OrderBy(cs => cs.ColNo)
.ToList();
logger.Info("开始StockListWindowViewModel_查询数据");
//ChannelStocks.Clear();
//List<ChannelStock> q = new List<ChannelStock>();
//Task.Factory.StartNew(() =>
//{
// List<ChannelStock> q = SqlSugarHelper.Db.Queryable<ChannelStock>()
// .Includes<DrugInfo>(cs => cs.DrugInfo)
// .InnerJoin<ChannelList>((cs, cl) => cs.Chnguid == cl.Id && cs.DrugId == cl.DrugId)
// .Where(cs => cs.DrawerType == 1)
// .Where(cs => cs.DrugId != null)
// .Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
ICollectionView vw = CollectionViewSource.GetDefaultView(q);
vw.GroupDescriptions.Add(new PropertyGroupDescription("DrugInfo"));
ChannelStocks = q;
// .WhereIF(!String.IsNullOrEmpty(SearchValue), cs => cs.DrugInfo.DrugName == SearchValue)
// .OrderBy(cs => cs.DrawerNo)
// .OrderBy(cs => cs.ColNo)
// .OrderBy(cs => cs.DrugId)
// .ToList();
////});
//ChannelStocks = q.Select(it => { it.CheckQuantity = it.Quantity; return it; }).ToList();
//ICollectionView vw = CollectionViewSource.GetDefaultView(q);
//vw.GroupDescriptions.Add(new PropertyGroupDescription("DrugInfo"));
//ChannelStocks = q;
//List<DrugInfo> q = SqlSugarHelper.Db.Queryable<DrugInfo>()
// .Includes<ChannelStock>(di => di.channelStocks.Where(cs => cs.DrawerType == 1).Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.DrugId != null).OrderBy(cs => cs.DrawerNo).OrderBy(cs => cs.ColNo).ToList())
// .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (cs) => cs.DrugId.Contains(SearchValue))
// .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cs) => cs.DrugName.Contains(SearchValue))
// .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cs) => cs.PyCode.Contains(SearchValue))
// .WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cs) => cs.DrugBarcode.Contains(SearchValue))
// .Where(di => di.channelStocks.Any(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.DrugId != null))
// .OrderBy(cs => cs.DrugId)
// .ToList();
//Drugs = q;
List<DrugInfo> q = SqlSugarHelper.Db.Queryable<DrugInfo>()
.Includes<ChannelStock>(di => di.channelStocks.Where(cs => cs.DrawerType == 1)
.Where(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.DrugId != null).OrderBy(cs => cs.DrawerNo).OrderBy(cs => cs.ColNo).ToList())
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugId"), (cs) => cs.DrugId.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugName"), (cs) => cs.DrugName.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("PyCode"), (cs) => cs.PyCode.Contains(SearchValue))
.WhereIF(!String.IsNullOrEmpty(SearchValue) && SelectedItem.Code.Equals("DrugBarcode"), (cs) => cs.DrugBarcode.Contains(SearchValue))
.Where(di => di.channelStocks.Any(cs => cs.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1") && cs.DrugId != null))
.OrderBy(cs => cs.DrugId)
.ToList();
Drugs = q;
logger.Info("结束StockListWindowViewModel_查询数据");
}
//接收导航传过来的参数 现在是在此处初始化了表格数据
public void OnNavigatedTo(NavigationContext navigationContext)
{
RequestData();
logger.Info("进入StockListWindowViewModel_OnNavigatedTo");
//RequestData();
Task.Factory.StartNew(() => RequestData());
logger.Info("结束StockListWindowViewModel_OnNavigatedTo");
}
@ -197,5 +277,21 @@ namespace DM_Weight.ViewModels
{
}
public DelegateCommand RowSelected
{
get => new DelegateCommand(() =>
{
//if (ChannelStocks != null)
//{
// SelectMachineRecords = ChannelStocks.Select(x =>
// {
// x.IsSelected = !x.IsSelected;
// return x;
// }).ToList();
//}
});
}
}
}

View File

@ -1,22 +0,0 @@
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.ViewModels
{
public class TestCheckBoxViewModel:BindableBase
{
public DelegateCommand cbxCommand
{
get =>new DelegateCommand(()=>{
});
}
}
}

View File

@ -74,11 +74,11 @@ namespace DM_Weight.ViewModels
set { SetProperty(ref _user, value); }
}
private readonly IDialogService _dialogService;
private SqlSugarScope _sqlSugarScope1;
//private SqlSugarScope SqlSugarHelper.Db;
public UserManagerWindowViewModel(IDialogService dialogService, SqlSugarScope sqlSugarScope)
{
_dialogService = dialogService;
this._sqlSugarScope1 = sqlSugarScope;
//this.SqlSugarHelper.Db = sqlSugarScope;
}
@ -96,7 +96,6 @@ namespace DM_Weight.ViewModels
RequestData();
}
}
public bool KeepAlive => false;
public DelegateCommand Query
@ -138,6 +137,8 @@ namespace DM_Weight.ViewModels
});
}
public bool KeepAlive => true;
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
@ -176,7 +177,7 @@ namespace DM_Weight.ViewModels
void RequestData()
{
int totalcount = 0;
UserList = _sqlSugarScope1.Queryable<UserList>()
UserList = SqlSugarHelper.Db.Queryable<UserList>()
.Includes<RoleDm>(ul => ul.Role)
.Where(ul => ul.MachineId.Equals(ConfigurationManager.AppSettings["machineId"] ?? "DM1"))
.WhereIF(!String.IsNullOrEmpty(SearchValue) , (di) => di.Nickname.Contains(SearchValue))

View File

@ -0,0 +1,257 @@
<UserControl x:Class="DM_Weight.Views.AccountWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DM_Weight.Views"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:prism="http://prismlibrary.com/"
xmlns:convert="clr-namespace:DM_Weight.Converter"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" Loaded="UserControl_Loaded">
<UserControl.Resources>
<Style x:Key="st" TargetType="GridViewColumnHeader">
<Style.Setters>
<Setter Property="Height">
<Setter.Value>55</Setter.Value>
</Setter>
<Setter Property="Background">
<Setter.Value>#31ccec</Setter.Value>
</Setter>
<Setter Property="Foreground">
<Setter.Value>white</Setter.Value>
</Setter>
</Style.Setters>
</Style>
<convert:MachineTypeConverter x:Key="MachineTypeConverter"/>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Margin="0 6 0 6" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.5*" />
<ColumnDefinition Width="1.5*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<DatePicker
Grid.Column="0"
SelectedDate="{Binding StartDate, TargetNullValue=''}"
Margin="6 0 0 0"
materialDesign:HintAssist.Hint="开始时间"
Style="{StaticResource MaterialDesignOutlinedDatePicker}"
/>
<DatePicker
Grid.Column="1"
SelectedDate="{Binding EndDate}"
Margin="6 0 0 0"
materialDesign:HintAssist.Hint="结束时间"
Style="{StaticResource MaterialDesignOutlinedDatePicker}"
/>
<!--<ComboBox
Margin="12 0 0 0"
Grid.Column="2"
materialDesign:HintAssist.Hint="药品名称"
IsEditable="True"
ItemsSource="{Binding DrugInfos}"
SelectedItem="{Binding DrugInfo}"
DisplayMemberPath="DrugName"
/>-->
<ComboBox
Margin="6 0 6 0"
Grid.Column="2"
materialDesign:HintAssist.Hint="药品名称/拼音码/药品编码"
ItemsSource="{Binding DrugInfos}"
SelectedItem="{Binding DrugInfo}"
DisplayMemberPath="DrugName" IsEditable="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
/>
<ComboBox
Margin="12 0 0 0"
Grid.Column="3"
materialDesign:HintAssist.Hint="账册类型"
IsEditable="True"
ItemsSource="{Binding AccountTypeList}"
SelectedItem="{Binding AccountType}"
DisplayMemberPath="AccountTypeName"
/>
<StackPanel Grid.Column="4" Orientation="Horizontal" HorizontalAlignment="Right">
<Button
Margin="0 0 3 0"
VerticalAlignment="Center"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="导出" Command="{Binding DayAccountBook}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="生成日结存" />
</StackPanel>
</Button>
<Button
Margin="0 0 3 0"
VerticalAlignment="Center"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="导出" Command="{Binding DownloadAccountBook}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="download" />
<TextBlock Text="导出账册" />
</StackPanel>
</Button>
<Button
Margin="0 0 6 0"
VerticalAlignment="Center"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="刷新" Command="{Binding Query}">
<materialDesign:PackIcon
Kind="Refresh" />
</Button>
</StackPanel>
</Grid>
<DataGrid x:Name="dgv1"
Grid.Row="1"
materialDesign:DataGridAssist.ColumnHeaderPadding="15"
ItemsSource="{Binding AccountList}"
materialDesign:DataGridAssist.EnableEditBoxAssist="False"
IsSynchronizedWithCurrentItem="True"
materialDesign:DataGridAssist.CellPadding="13"
CanUserAddRows="False"
AutoGenerateColumns="False" >
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
<Setter Property="Background" Value="#31ccec" />
<Setter Property="Foreground" Value="white" />
<Setter Property="Height" Value="56" />
<Setter Property="BorderBrush" Value="white"/>
<Setter Property="BorderThickness" Value="0.6"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Background" Value="Transparent"/>
<!--<Setter Property="HorizontalAlignment" Value="Left"/>-->
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
<!--GroupStyle to group data-->
<!--<DataGrid.GroupStyle>
<GroupStyle>
--><!--Group DataItems into DataGroup-->
<!--<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="True"
materialDesign:ExpanderAssist.HeaderBackground="PaleTurquoise">
<Expander.Header >
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name.DrugName,StringFormat=药品:{0}}" FontWeight="Bold" />
<TextBlock FontWeight="Bold" Text="{Binding Path=Name.DrugSpec,StringFormat=规格:{0}}" />
<TextBlock FontWeight="Bold" Text="{Binding Path=Name.Manufactory,StringFormat=厂家:{0}}" />
<TextBlock FontWeight="Bold" Text="{Binding Path=Name.MaxStock,StringFormat=基数:{0}}" />
<TextBlock FontWeight="Bold" Text="{Binding Path=Items,Converter={StaticResource GroupSumConverter}}" />
</StackPanel>
</Expander.Header>
<ItemsPresenter/>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>--><!--
</GroupStyle>
</DataGrid.GroupStyle>-->
<DataGrid.Columns>
<DataGridTextColumn Width="80"
Binding="{Binding OperationTime}"
Header="日期"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="150"
Binding="{Binding DrugName}"
Header="药品名称"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="130"
Binding="{Binding DrugSpec}"
Header="规格"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="200"
Binding="{Binding Manufactory}"
Header="厂家"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="100"
Binding="{Binding InvoiceId}"
Header="凭证号"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="130"
Binding="{Binding ManuNo}"
Header="批号"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="100"
Binding="{Binding EffDate, StringFormat='yy/MM/dd'}"
Header="有效期"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="75"
Binding="{Binding InQuantity}"
Header="借入数"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="75"
Binding="{Binding OutQuantity}"
Header="发出数"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="75"
Binding="{Binding StockQuantity}"
Header="总结存"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="75"
Binding="{Binding OperatorName}"
Header="发药人"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="75"
Binding="{Binding ReviewerName}"
Header="复核人"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="100"
Binding="{Binding SupplierDept}"
Header="供应单位"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="100"
Binding="{Binding ReceiveDept}"
Header="领用部门"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
</DataGrid.Columns>
</DataGrid>
<!--<pagination:Pagination Grid.Row="2"
CurrentPage="{Binding PageNum}"
PageSize="{Binding PageSize}"
TotalPages="{Binding TotalCount}"
InfoTextIsEnabel="True"
/>-->
</Grid>
</UserControl>

View File

@ -0,0 +1,53 @@
using DM_Weight.msg;
using DM_Weight.ViewModels;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views
{
/// <summary>
/// AccountWindow.xaml 的交互逻辑
/// </summary>
public partial class AccountWindow : UserControl
{
AccountWindowViewModel vms;
public AccountWindow()
{
InitializeComponent();
}
/// <summary>
/// 药品名称下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ComboBox_KeyUp(object sender, KeyEventArgs e)
{
ComboBox comboBox = sender as ComboBox;
vms.UpdateComboBoxItems(comboBox.Text);
if (this.vms.DrugInfos.Count > 0)
{
comboBox.IsDropDownOpen = true;
}
TextBox textBox = (TextBox)comboBox.Template.FindName("PART_EditableTextBox", comboBox);
textBox.SelectionStart = textBox.Text.Length;
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
vms = AccountWindowViewModel.vm;
}
}
}

View File

@ -0,0 +1,395 @@
<UserControl x:Class="DM_Weight.Views.AddDrugControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DM_Weight.Views"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:convert="clr-namespace:DM_Weight.Converter"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<convert:QuantityCountConverter x:Key="QuantityCountConverter" />
<convert:BoardTypeConverter x:Key="BoardTypeConverter" />
<convert:DrawerSelectConverter x:Key="DrawerSelectConverter" />
<convert:StatusConverter x:Key="StatusConverter" />
<convert:InputQuantityConverter x:Key="InputQuantityConverter" />
<Style x:Key="st" TargetType="GridViewColumnHeader">
<Style.Setters>
<Setter Property="Height">
<Setter.Value>55</Setter.Value>
</Setter>
<Setter Property="Background">
<Setter.Value>#31ccec</Setter.Value>
</Setter>
<Setter Property="Foreground">
<Setter.Value>white</Setter.Value>
</Setter>
</Style.Setters>
</Style>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid Margin="0" Grid.Column="0" Width="280" Height="570" Visibility="{Binding Is8Drawer, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid.Background>
<ImageBrush ImageSource="/Images/box.png" />
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="200" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.Resources>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignPaperLightButton}">
<Setter Property="Foreground" Value="#00a0ea" />
<Setter Property="BorderBrush" Value="#00a0ea" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#d1e7f5" />
<Setter Property="BorderBrush" Value="#d1e7f5" />
</Trigger>
<DataTrigger Value="True">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource DrawerSelectConverter}">
<Binding RelativeSource="{ RelativeSource Mode=Self }" Path="Content" />
<Binding Path="DrawerNo" />
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="Background" Value="#d1e7f5" />
<Setter Property="BorderBrush" Value="#d1e7f5" />
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<Button Grid.Row="0" Width="210" Content="1" Command="{Binding UpdateDrawerNo}" CommandParameter="1" />
<Button Grid.Row="1" Width="210" Content="2" Command="{Binding UpdateDrawerNo}" CommandParameter="2" />
<Button Grid.Row="2" Width="210" Content="3" Command="{Binding UpdateDrawerNo}" CommandParameter="3" />
<Button Grid.Row="3" Width="210" Content="4" Command="{Binding UpdateDrawerNo}" CommandParameter="4" />
<Button Grid.Row="4" Width="210" Content="5" Command="{Binding UpdateDrawerNo}" CommandParameter="5" />
<Button Grid.Row="5" Width="210" Content="6" Command="{Binding UpdateDrawerNo}" CommandParameter="6" />
<Button Grid.Row="6" Width="210" Content="7" Command="{Binding UpdateDrawerNo}" CommandParameter="7" />
<Button Grid.Row="7" Width="210" Content="8" Command="{Binding UpdateDrawerNo}" CommandParameter="8" />
</Grid>
</Grid>
<Grid Margin="0" Grid.Column="1" Width="300" Height="570" Visibility="{Binding Is16Drawer, Converter={StaticResource BooleanToVisibilityConverter}}">
<Grid.Resources>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource MaterialDesignPaperLightButton}">
<Setter Property="Foreground" Value="#00a0ea" />
<Setter Property="BorderBrush" Value="#00a0ea" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#d1e7f5" />
<Setter Property="BorderBrush" Value="#d1e7f5" />
</Trigger>
<DataTrigger Value="True">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource DrawerSelectConverter}">
<Binding RelativeSource="{ RelativeSource Mode=Self }" Path="Content" />
<Binding Path="DrawerNo" />
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="Background" Value="#d1e7f5" />
<Setter Property="BorderBrush" Value="#d1e7f5" />
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<Grid.Background>
<ImageBrush ImageSource="/Images/box-16.jpg" />
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="200" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Margin="10 0 0 0" Visibility="{Binding Is17Drawer, Converter={StaticResource BooleanToVisibilityConverter}}" Grid.Row="0">
<Button Width="110" Content="17" HorizontalAlignment="Left" Command="{Binding UpdateDrawerNo}" CommandParameter="17" />
</Grid>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Grid.Column="0" Width="120" Content="1" Command="{Binding UpdateDrawerNo}" CommandParameter="1" />
<Button Grid.Row="1" Grid.Column="0" Width="120" Content="2" Command="{Binding UpdateDrawerNo}" CommandParameter="2" />
<Button Grid.Row="2" Grid.Column="0" Width="120" Content="3" Command="{Binding UpdateDrawerNo}" CommandParameter="3" />
<Button Grid.Row="3" Grid.Column="0" Width="120" Content="4" Command="{Binding UpdateDrawerNo}" CommandParameter="4" />
<Button Grid.Row="4" Grid.Column="0" Width="120" Content="5" Command="{Binding UpdateDrawerNo}" CommandParameter="5" />
<Button Grid.Row="5" Grid.Column="0" Width="120" Content="6" Command="{Binding UpdateDrawerNo}" CommandParameter="6" />
<Button Grid.Row="6" Grid.Column="0" Width="120" Content="7" Command="{Binding UpdateDrawerNo}" CommandParameter="7" />
<Button Grid.Row="7" Grid.Column="0" Width="120" Content="8" Command="{Binding UpdateDrawerNo}" CommandParameter="8" />
<Button Grid.Row="0" Grid.Column="1" Width="120" Content="9" Command="{Binding UpdateDrawerNo}" CommandParameter="9" />
<Button Grid.Row="1" Grid.Column="1" Width="120" Content="10" Command="{Binding UpdateDrawerNo}" CommandParameter="10" />
<Button Grid.Row="2" Grid.Column="1" Width="120" Content="11" Command="{Binding UpdateDrawerNo}" CommandParameter="11" />
<Button Grid.Row="3" Grid.Column="1" Width="120" Content="12" Command="{Binding UpdateDrawerNo}" CommandParameter="12" />
<Button Grid.Row="4" Grid.Column="1" Width="120" Content="13" Command="{Binding UpdateDrawerNo}" CommandParameter="13" />
<Button Grid.Row="5" Grid.Column="1" Width="120" Content="14" Command="{Binding UpdateDrawerNo}" CommandParameter="14" />
<Button Grid.Row="6" Grid.Column="1" Width="120" Content="15" Command="{Binding UpdateDrawerNo}" CommandParameter="15" />
<Button Grid.Row="7" Grid.Column="1" Width="120" Content="16" Command="{Binding UpdateDrawerNo}" CommandParameter="16" />
</Grid>
</Grid>
<Grid Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="6" Orientation="Horizontal" HorizontalAlignment="Right">
<Button
Margin="0 0 3 0"
VerticalAlignment="Center"
Command="{Binding OpenDrawer}"
Visibility="{Binding Status,Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnVisible}"
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="加药" />
<TextBox Text="{Binding PZH, UpdateSourceTrigger=PropertyChanged}" materialDesign:HintAssist.Hint="凭证号"
materialDesign:HintAssist.IsFloating="True" Width="100"
Margin="0 0 3 0"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
/>
<Button
Margin="0 0 3 0"
VerticalAlignment="Center"
Command="{Binding TakeFinish}"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="完成" />
<Button
Margin="0 0 6 0"
VerticalAlignment="Center"
Command="{Binding CancleTake}"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="取消" />
</StackPanel>
<ScrollViewer Grid.Row="1" Margin="6">
<ItemsControl
ItemsSource="{Binding ChannelLsts}"
Grid.IsSharedSizeScope="True"
>
<!--<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
-->
<!--<UniformGrid Columns="4" />-->
<!--
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>-->
<ItemsControl.ItemTemplate>
<DataTemplate>
<!--<materialDesign:Card
Background="{StaticResource MaterialDesignLightBackground}"
Margin="4"
Padding="0">-->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border BorderBrush="White" BorderThickness="1">
<StackPanel Orientation="Horizontal" Background="#31ccec" Grid.Column="0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<TextBlock TextWrapping="Wrap" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="0 10 0 0 " Text="{Binding Drug.DrugName}"/>
<TextBlock TextWrapping="Wrap" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="0 0 0 1 " Text="{Binding Drug.DrugSpec}"/>
<Button Grid.Row="2" Padding="0 0 0 1 " Style="{x:Null}" BorderBrush="{x:Null}" Background="{x:Null}" Click="Button_Click" CommandParameter="{Binding}">
<Button.Content>
<Border Width="32" Height="32" CornerRadius="16" Background="CornflowerBlue" VerticalAlignment="Center" HorizontalAlignment="Center">
<Path Data="M0 11L22 11M11 0L11 22" Stroke="WhiteSmoke" StrokeThickness="4" VerticalAlignment="Center" HorizontalAlignment="Center"></Path>
</Border>
</Button.Content>
</Button>
</Grid>
</StackPanel>
</Border>
<DataGrid
Margin="0"
Grid.Column="1"
materialDesign:DataGridAssist.ColumnHeaderPadding="15"
ItemsSource="{Binding channelStocks}"
materialDesign:DataGridAssist.EnableEditBoxAssist="False"
materialDesign:DataGridAssist.CellPadding="13"
SelectionUnit="Cell"
CanUserAddRows="False"
AutoGenerateColumns="False">
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
<Setter Property="Background" Value="#31ccec" />
<Setter Property="Foreground" Value="white" />
<Setter Property="Height" Value="56" />
<Setter Property="BorderBrush" Value="white"/>
<Setter Property="BorderThickness" Value="0.6"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="HorizontalAlignment" Value="Center"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Width="80"
Binding="{Binding ColNo}"
Header="库位"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<!--<DataGridTextColumn Width="180"
Binding="{Binding DrugInfo.DrugName}"
Header="药品名称"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>-->
<DataGridTextColumn Width="150"
Binding="{Binding DrugInfo.DrugSpec}"
Header="规格"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTemplateColumn Width="200" IsReadOnly="True"
Header="批次">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox
Style="{StaticResource MaterialDesignDataGridComboBox}"
ItemsSource="{Binding DrugInfo.DrugManuNos}"
SelectedItem="{Binding drugManuNo,UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="ManuNo"
IsEnabled="{Binding Quantity,Converter={StaticResource QuantityCountConverter}}">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Width="100"
Binding="{Binding drugManuNo.EffDate}"
Header="效期"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="100"
Binding="{Binding Quantity}"
Header="库存"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTemplateColumn Width="100"
Header="添加数量">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" IsReadOnly="{Binding BoardType, Converter={StaticResource InputQuantityConverter}}">
<TextBox.Text>
<Binding Path="AddQuantity" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<ExceptionValidationRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<!--<ListView Padding="0 6 0 0" Grid.Column="1"
materialDesign:ListViewAssist.ListViewItemPadding="15"
ItemsSource="{Binding channelStocks}" SelectedItem="{Binding channelStock}"
materialDesign:ListViewAssist.HeaderRowBackground="#31ccec">
<ListView.Resources>
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
<Setter Property="Background" Value="#31ccec" />
<Setter Property="Foreground" Value="white" />
<Setter Property="BorderBrush" Value="white"/>
<Setter Property="BorderThickness" Value="0.6"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
</ListView.Resources>
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource st}">
<GridView.Columns>
<GridViewColumn Width="80" Header="库位" DisplayMemberBinding="{Binding ColNo}" />
<GridViewColumn Width="130" Header="批次">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ComboBox Style="{StaticResource MaterialDesignComboBox}"
ItemsSource="{Binding DrugInfo.DrugManuNos}" SelectedItem="{Binding drugManuNo,UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="ManuNo" IsEnabled="{Binding Quantity,Converter={StaticResource QuantityCountConverter}}">
</ComboBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="130" Header="效期" DisplayMemberBinding="{Binding drugManuNo.EffDate}" />
<GridViewColumn Width="80" Header="库存" DisplayMemberBinding="{Binding Quantity}" />
<GridViewColumn Width="80" Header="添加数量">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Width="80" Padding="10" Grid.Column="1"
Text="{Binding AddQuantity}"
materialDesign:HintAssist.Hint="添加数量"
Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>-->
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Grid>
</UserControl>

View File

@ -0,0 +1,41 @@
using DM_Weight.Models;
using DM_Weight.msg;
using DM_Weight.ViewModels;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views
{
/// <summary>
/// AddDrugControl.xaml 的交互逻辑
/// </summary>
public partial class AddDrugControl : UserControl
{
IEventAggregator _eventAggregator;
public AddDrugControl(IEventAggregator eventAggregator)
{
InitializeComponent();
_eventAggregator= eventAggregator;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Button btn = (Button)sender;
ChannelList cls = (ChannelList)btn.CommandParameter;
//vms.AddAction(cls);
_eventAggregator.GetEvent<AddDrugEvent>().Publish(cls);
}
}
}

View File

@ -0,0 +1,203 @@
<UserControl x:Class="DM_Weight.Views.CheckRecordNewWindow"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DM_Weight.Views"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:prism="http://prismlibrary.com/"
xmlns:convert="clr-namespace:DM_Weight.Converter"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Style x:Key="st" TargetType="GridViewColumnHeader">
<Style.Setters>
<Setter Property="Height">
<Setter.Value>55</Setter.Value>
</Setter>
<Setter Property="Background">
<Setter.Value>#31ccec</Setter.Value>
</Setter>
<Setter Property="Foreground">
<Setter.Value>white</Setter.Value>
</Setter>
</Style.Setters>
</Style>
<convert:MachineTypeConverter x:Key="MachineTypeConverter"/>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Margin="0 6 0 6" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.5*" />
<ColumnDefinition Width="1.5*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<DatePicker
Grid.Column="0"
SelectedDate="{Binding StartDate, TargetNullValue=''}"
Margin="6 0 0 0"
materialDesign:HintAssist.Hint="开始时间"
Style="{StaticResource MaterialDesignOutlinedDatePicker}"
/>
<DatePicker
Grid.Column="1"
SelectedDate="{Binding EndDate}"
Margin="6 0 0 0"
materialDesign:HintAssist.Hint="结束时间"
Style="{StaticResource MaterialDesignOutlinedDatePicker}"
/>
<StackPanel Grid.Column="4" Orientation="Horizontal" HorizontalAlignment="Right">
<Button
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Command="{Binding DownLoadCommond}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="download"/>
<TextBlock Text="盘点记录"/>
</StackPanel>
</Button>
<Button
Margin="0 0 6 0"
VerticalAlignment="Center"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="刷新" Command="{Binding Query}">
<materialDesign:PackIcon
Kind="Refresh" />
</Button>
</StackPanel>
</Grid>
<!--<ScrollViewer Grid.Row="1" Margin="0">
<ItemsControl
ItemsSource="{Binding obsCheckRecordStock}"
Grid.IsSharedSizeScope="True">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border BorderBrush="White" BorderThickness="1">
<StackPanel Orientation="Horizontal" Background="#31ccec" Grid.Column="0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<TextBlock TextWrapping="Wrap" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center" Padding="50 10 0 0 "
Text="{Binding optdate,StringFormat='yyyy-MM-dd HH:mm:ss'}"/>
<TextBlock TextWrapping="Wrap" Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Center" Padding="50 0 0 0 "
Text="{Binding operatorUser,StringFormat=操作人:{0}}"/>
<TextBlock TextWrapping="Wrap" Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Center" Padding="50 0 0 0 "
Text="{Binding reviewerUser,StringFormat=审核人:{0}}"/>
</Grid>
</StackPanel>
</Border>
<DataGrid
x:Name="GridName"
Margin="0"
Grid.Column="1"
materialDesign:DataGridAssist.ColumnHeaderPadding="15"
ItemsSource="{Binding manuNoDetails}"
materialDesign:DataGridAssist.EnableEditBoxAssist="False"
materialDesign:DataGridAssist.CellPadding="15"
SelectionUnit="Cell"
CanUserAddRows="False"
AutoGenerateColumns="False">
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
<Setter Property="Background" Value="#31ccec" />
<Setter Property="Foreground" Value="white" />
<Setter Property="Height" Value="60" />
<Setter Property="BorderBrush" Value="white"/>
<Setter Property="BorderThickness" Value="0.6"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="HorizontalAlignment" Value="Center"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Width="100" Binding="{Binding drugName}" Header="药品名称" IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="100" Binding="{Binding drugSpec}" Header="规格" IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="150" Binding="{Binding manufactory}" Header="厂家"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="60" Binding="{Binding quantity}" Header="总库存" IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="100" Binding="{Binding manuNo}" Header="批次" IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="150" Binding="{Binding effDate}" Header="效期"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="60" Binding="{Binding ManuQuantity}" Header="数量" IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>-->
<ListView Grid.Row="1" ItemsSource="{Binding obsCheckRecordStock,UpdateSourceTrigger=PropertyChanged}"
SelectedItem="{Binding checkRecordStock}"
materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
materialDesign:DataGridAssist.ColumnHeaderPadding="10"
materialDesign:ListViewAssist.ListViewItemPadding="13">
<ListView.Resources>
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
<Setter Property="Foreground" Value="White" />
</Style>
</ListView.Resources>
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding RowSelected}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource st}">
<GridViewColumn Width="100"
Header="时间"
DisplayMemberBinding="{Binding optdate, StringFormat='yyyy-MM-dd HH:mm:ss'}" />
<GridViewColumn Width="100"
Header="操作人"
DisplayMemberBinding="{Binding operatorUser}"/>
<GridViewColumn Width="100"
Header="审核人"
DisplayMemberBinding="{Binding reviewerUser}"/>
</GridView>
</ListView.View>
</ListView>
<pagination:Pagination Grid.Row="2"
CurrentPage="{Binding PageNum}"
PageSize="{Binding PageSize}"
TotalPages="{Binding TotalCount}"
InfoTextIsEnabel="True"
/>
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views
{
/// <summary>
/// CheckRecordWindow.xaml 的交互逻辑
/// </summary>
public partial class CheckRecordNewWindow : UserControl
{
public CheckRecordNewWindow()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,195 @@
<UserControl x:Class="DM_Weight.Views.CheckStockNew2Window"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DM_Weight.Views"
xmlns:util="clr-namespace:DM_Weight.util"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:convert="clr-namespace:DM_Weight.Converter"
xmlns:prism="http://prismlibrary.com/"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.Resources>
<!--<convert:GroupSumConverter x:Key="GroupSumConverter" />
<convert:TotalCountConverter x:Key="TotalCountConverter" />
<convert:DrawerSelectConverter x:Key="DrawerSelectConverter" />-->
<convert:StatusConverter x:Key="StatusConverter" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Margin="0 6 0 6" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="6*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button
Margin="0 0 3 0"
VerticalAlignment="Center"
Command="{Binding OpenDrawer}"
Visibility="{Binding Status,Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnVisible}"
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="盘点" />
<Button
Margin="0 0 3 0"
VerticalAlignment="Center"
Command="{Binding TakeFinish}"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="完成" />
<Button
Margin="0 0 6 0"
VerticalAlignment="Center"
Command="{Binding CancleTake}"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="取消" />
<Button
Margin="6 0 6 0"
VerticalAlignment="Center"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="刷新" Command="{Binding QueryCommand}">
<materialDesign:PackIcon
Kind="Refresh" />
</Button>
</StackPanel>
</Grid>
<!--<DataGrid x:Name="dgv1"
Grid.Row="1"
materialDesign:DataGridAssist.ColumnHeaderPadding="15"
ItemsSource="{Binding ChannelStocks}"
SelectedItem="SelectedChannel"
materialDesign:DataGridAssist.EnableEditBoxAssist="False"
IsSynchronizedWithCurrentItem="True"
materialDesign:DataGridAssist.CellPadding="13"
CanUserAddRows="False"
AutoGenerateColumns="False">
--><!--<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource MaterialDesignDataGridRow}">
<EventSetter Event="GotFocus" Handler="Item_GotFocus"/>
</Style>
</DataGrid.RowStyle>--><!--
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
<Setter Property="Background" Value="#31ccec" />
<Setter Property="Foreground" Value="white" />
<Setter Property="Height" Value="56" />
<Setter Property="BorderBrush" Value="white"/>
<Setter Property="BorderThickness" Value="0.6"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Background" Value="Transparent"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn IsReadOnly="True" Header="药品" Binding="{Binding DrugInfo.DrugName}"/>
<DataGridTextColumn IsReadOnly="True" Header="规格" Binding="{Binding DrugInfo.DrugSpec}"/>
<DataGridTextColumn
Binding="{Binding Location}"
Header="库位"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn
Binding="{Binding ManuNo}"
Header="批次"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn
Binding="{Binding EffDate}"
Header="效期"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="100"
Binding="{Binding Quantity}"
Header="库存"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTemplateColumn Width="141"
Header="盘点数量">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}">
<TextBox.Text>
<Binding Path="CheckQuantity" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<ExceptionValidationRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>-->
<ListView Grid.Row="1"
ItemsSource="{Binding ChannelStocks}"
materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
materialDesign:DataGridAssist.ColumnHeaderPadding="8"
>
<ListView.Resources>
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
<Setter Property="Foreground" Value="White" />
</Style>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn Header="药品" DisplayMemberBinding="{Binding DrugInfo.DrugName}"/>
<GridViewColumn Header="规格" DisplayMemberBinding="{Binding DrugInfo.DrugSpec}"/>
<GridViewColumn
DisplayMemberBinding="{Binding Location}"
Header="库位"/>
<GridViewColumn
DisplayMemberBinding="{Binding ManuNo}"
Header="批次"/>
<GridViewColumn
DisplayMemberBinding="{Binding EffDate}"
Header="效期"/>
<GridViewColumn Width="100"
DisplayMemberBinding="{Binding Quantity}"
Header="库存"/>
<GridViewColumn Width="141"
Header="盘点数量">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}">
<TextBox.Text>
<Binding Path="CheckQuantity" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<ExceptionValidationRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Grid>
</UserControl>

View File

@ -0,0 +1,60 @@
using DM_Weight.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views
{
/// <summary>
/// CheckStockNewWindow.xaml 的交互逻辑
/// </summary>
public partial class CheckStockNew2Window : UserControl
{
//CheckStockNewWindowViewModel vms;
public CheckStockNew2Window()
{
InitializeComponent();
}
//private void UserControl_Loaded(object sender, RoutedEventArgs e)
//{
// vms = CheckStockNewWindowViewModel.vm;
//}
///// <summary>
///// 选中行事件
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
//{
// if (dgv1.SelectedIndex >= 0)
// {
// TextBlock txt = dgv1.Columns[0].GetCellContent(dgv1.Items[dgv1.SelectedIndex]) as TextBlock;
// if (txt != null)
// {
// vms.Stock = txt.Text;
// }
// }
//}
//private void Item_GotFocus(object sender, RoutedEventArgs e)
//{
// var item = (DataGridRow)sender;
// FrameworkElement objElement = dgv1.Columns[0].GetCellContent(item);
// if (objElement != null)
// {
// TextBlock objChk = (TextBlock)objElement;
// vms.Stock = objChk.Text;
// }
//}
}
}

View File

@ -0,0 +1,220 @@
<UserControl x:Class="DM_Weight.Views.CheckStockNewWindow"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DM_Weight.Views"
xmlns:util="clr-namespace:DM_Weight.util"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:convert="clr-namespace:DM_Weight.Converter"
xmlns:prism="http://prismlibrary.com/"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.Resources>
<!--<CollectionViewSource x:Key="GroupedDataList" Source="{Binding ChannelStocks}">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="DrugInfo" />
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
<convert:GroupSumConverter x:Key="GroupSumConverter" />
<convert:DrawerSelectConverter x:Key="DrawerSelectConverter" />-->
<convert:StatusConverter x:Key="StatusConverter" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Margin="0 6 0 6" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="6*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button
Margin="0 0 3 0"
VerticalAlignment="Center"
Command="{Binding OpenDrawer}"
Visibility="{Binding Status,Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnVisible}"
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="盘点" />
<Button
Margin="0 0 3 0"
VerticalAlignment="Center"
Command="{Binding TakeFinish}"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="完成" />
<Button
Margin="0 0 6 0"
VerticalAlignment="Center"
Command="{Binding CancleTake}"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="取消" />
<Button
Margin="6 0 6 0"
VerticalAlignment="Center"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="刷新" Command="{Binding QueryCommand}">
<materialDesign:PackIcon
Kind="Refresh" />
</Button>
</StackPanel>
</Grid>
<DataGrid x:Name="dgv1"
Grid.Row="1"
materialDesign:DataGridAssist.ColumnHeaderPadding="15"
ItemsSource="{Binding ChannelStocks}"
SelectedItem="SelectedChannel"
materialDesign:DataGridAssist.EnableEditBoxAssist="False"
IsSynchronizedWithCurrentItem="True"
materialDesign:DataGridAssist.CellPadding="13"
CanUserAddRows="False"
AutoGenerateColumns="False">
<!--<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource MaterialDesignDataGridRow}">
<EventSetter Event="GotFocus" Handler="Item_GotFocus"/>
</Style>
</DataGrid.RowStyle>-->
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
<Setter Property="Background" Value="#31ccec" />
<Setter Property="Foreground" Value="white" />
<Setter Property="Height" Value="56" />
<Setter Property="BorderBrush" Value="white"/>
<Setter Property="BorderThickness" Value="0.6"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Background" Value="Transparent"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn IsReadOnly="True" Header="药品" Binding="{Binding DrugInfo.DrugName}"/>
<DataGridTextColumn IsReadOnly="True" Header="规格" Binding="{Binding DrugInfo.DrugSpec}"/>
<DataGridTextColumn
Binding="{Binding Location}"
Header="库位"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn
Binding="{Binding ManuNo}"
Header="批次"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn
Binding="{Binding EffDate}"
Header="效期"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="100"
Binding="{Binding Quantity}"
Header="库存"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTemplateColumn Width="141"
Header="盘点数量">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}">
<TextBox.Text>
<Binding Path="CheckQuantity" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<ExceptionValidationRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<!--<ListView Grid.Row="1"
ItemsSource="{Binding DrugList}"
materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
materialDesign:DataGridAssist.ColumnHeaderPadding="8"
>
<ListView.Resources>
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
<Setter Property="Foreground" Value="White" />
</Style>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn
Header="药品编码"
DisplayMemberBinding="{Binding DrugId}"/>
<GridViewColumn
Header="药品名称"
DisplayMemberBinding="{Binding DrugName}"/>
<GridViewColumn
DisplayMemberBinding="{Binding DrugSpec}"
Header="规格"/>
<GridViewColumn
DisplayMemberBinding="{Binding ManuFactory}"
Header="厂家"/>
<GridViewColumn
DisplayMemberBinding="{Binding StockQuantity}"
Header="库存"/>
<GridViewColumn
Header="批次" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="ManuNo" materialDesign:ListBoxItemAssist.ShowSelection="False">
</ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn
Header="效期" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="EffDate" materialDesign:ListBoxItemAssist.ShowSelection="False">
</ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn
Header="数量" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="Quantity" materialDesign:ListBoxItemAssist.ShowSelection="False">
</ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn
Header="库位" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<ListBox ItemsSource="{Binding channelStocks}" DisplayMemberPath="Location" materialDesign:ListBoxItemAssist.ShowSelection="False">
</ListBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>-->
</Grid>
</UserControl>

View File

@ -0,0 +1,60 @@
using DM_Weight.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views
{
/// <summary>
/// CheckStockNewWindow.xaml 的交互逻辑
/// </summary>
public partial class CheckStockNewWindow : UserControl
{
//CheckStockNewWindowViewModel vms;
public CheckStockNewWindow()
{
InitializeComponent();
}
//private void UserControl_Loaded(object sender, RoutedEventArgs e)
//{
// vms = CheckStockNewWindowViewModel.vm;
//}
///// <summary>
///// 选中行事件
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
//{
// if (dgv1.SelectedIndex >= 0)
// {
// TextBlock txt = dgv1.Columns[0].GetCellContent(dgv1.Items[dgv1.SelectedIndex]) as TextBlock;
// if (txt != null)
// {
// vms.Stock = txt.Text;
// }
// }
//}
//private void Item_GotFocus(object sender, RoutedEventArgs e)
//{
// var item = (DataGridRow)sender;
// FrameworkElement objElement = dgv1.Columns[0].GetCellContent(item);
// if (objElement != null)
// {
// TextBlock objChk = (TextBlock)objElement;
// vms.Stock = objChk.Text;
// }
//}
}
}

View File

@ -0,0 +1,237 @@
<UserControl xmlns:pagination="clr-namespace:DM_Weight.Components.pagination" x:Class="DM_Weight.Views.Dialog.BindingChannelNewDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DM_Weight.Views.Dialog"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:convert="clr-namespace:DM_Weight.Converter"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
MinWidth="880"
MinHeight="479"
Width="Auto"
Height="Auto"
mc:Ignorable="d" >
<UserControl.Resources>
<convert:BoardTypeConverter x:Key="BoardTypeConverter" />
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<!--<RowDefinition Height="Auto" />-->
</Grid.RowDefinitions>
<Grid Background="#03a9f4" Grid.Row="0">
<TextBlock VerticalAlignment="Center" Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}" Margin="16 4 16 4" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Text="{Binding Title}" />
<Button
Style="{StaticResource MaterialDesignIconForegroundButton}"
Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
HorizontalAlignment="Right"
Command="{Binding BtnCloseCommand}"
ToolTip="关闭" Cursor="Hand"
>
<materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
</Button>
</Grid>
<Grid Grid.Row="1" Margin="0 4 0 4">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!--<ComboBox
Margin="6 0 6 0"
Grid.Column="0"
materialDesign:HintAssist.Hint="拼音码"
IsEditable="True"
ItemsSource="{Binding DrugInfos_PY}"
SelectedItem="{Binding DrugInfo_Py}"
DisplayMemberPath="PyCode"
/>-->
<!--<ComboBox
Margin="6 0 6 0"
Grid.Column="1"
materialDesign:HintAssist.Hint="药品名称"
IsEditable="True"
ItemsSource="{Binding DrugInfos}"
SelectedItem="{Binding DrugInfo}"
DisplayMemberPath="DrugName"
/>-->
<ComboBox
Margin="6 0 6 0"
Grid.Column="0"
materialDesign:HintAssist.Hint="药品名称/拼音码/药品编码"
ItemsSource="{Binding DrugInfos}"
SelectedItem="{Binding DrugInfo}"
DisplayMemberPath="drug_name_spec" IsEditable="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
/>
<StackPanel HorizontalAlignment="Right" Grid.Column="3" Orientation="Horizontal">
<Button
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="绑定库位"
Content="绑定"
Command="{Binding BindingDrug}"/>
<Button
Margin="6 0 6 0"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="解除绑定"
Content="解绑"
Command="{Binding RemoveBinding}" />
<Button
Margin="0 0 6 0"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="刷新"
Command="{Binding Query}"
Content="{materialDesign:PackIcon Refresh}"/>
</StackPanel>
</Grid>
<ItemsControl
Grid.Row="2"
ItemsSource="{Binding Channels}"
Grid.IsSharedSizeScope="True"
Margin="12 0 12 0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="4"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<materialDesign:Card
Background="{StaticResource MaterialDesignLightBackground}"
Margin="4"
Padding="0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Background="#31ccec" >
<CheckBox
materialDesign:CheckBoxAssist.CheckBoxSize="30"
VerticalAlignment="Center"
IsChecked="{Binding IsSelected}" />
<TextBlock
Style="{StaticResource MaterialDesignHeadline5TextBlock}"
Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
Padding="8"
Text="{Binding Location}" />
<TextBlock
Style="{StaticResource MaterialDesignHeadline5TextBlock}"
Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
Padding="8"
HorizontalAlignment="Right">
<TextBlock.Text>
<MultiBinding Converter="{StaticResource BoardTypeConverter}">
<Binding Path="BoardType" />
<Binding Path="DrawerType" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</StackPanel>
<Grid Grid.Row="1" x:Name="Border">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.Resources>
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource MaterialDesignSubtitle1TextBlock}">
<Setter Property="Padding" Value="6" />
</Style>
</Grid.Resources>
<TextBlock
HorizontalAlignment="Left"
Grid.Row="0"
Grid.Column="0"
Text="药品:" />
<WrapPanel
Grid.Row="0"
Grid.Column="1"
HorizontalAlignment="Right"
Orientation="Horizontal">
<TextBlock Text="{Binding Drug.DrugName}"/>
<!--<TextBlock
Text="{Binding totalCount, StringFormat=总库存({0})}" />-->
</WrapPanel>
<TextBlock
HorizontalAlignment="Left"
Grid.Row="1"
Grid.Column="0"
Text="规格" />
<TextBlock
HorizontalAlignment="Right"
Grid.Row="1"
Grid.Column="1"
Text="{Binding Drug.DrugSpec}" />
<TextBlock
HorizontalAlignment="Left"
Grid.Row="2"
Grid.Column="0"
Text="总库存:" />
<TextBlock
HorizontalAlignment="Right"
Grid.Row="2"
Grid.Column="1"
Text="{Binding totalCount}" />
<!--<TextBlock
HorizontalAlignment="Left"
Grid.Row="1"
Grid.Column="0"
Text="批次:" />
<TextBlock
HorizontalAlignment="Right"
Grid.Row="1"
Grid.Column="1"
Text="{Binding ManuNo}" />
<TextBlock
HorizontalAlignment="Left"
Grid.Row="2"
Grid.Column="0"
Text="效期:" />
<TextBlock
HorizontalAlignment="Right"
Grid.Row="2"
Grid.Column="1"
Text="{Binding EffDate}" />-->
</Grid>
</Grid>
</materialDesign:Card>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsSelected}" Value="True">
<Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
<Setter TargetName="Border" Property="Background" Value="#90caf9" />
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="0.95" ScaleY="0.95" />
</Setter.Value>
</Setter>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<pagination:Pagination Grid.Row="3"
CurrentPage="{Binding PageNum}"
PageSize="{Binding PageSize}"
TotalPages="{Binding TotalCount}"
InfoTextIsEnabel="True"
/>
<materialDesign:Snackbar
Background="{Binding SnackbarBackground}"
MessageQueue="{Binding SnackbarMessageQueue}"/>
</Grid>
</UserControl>

View File

@ -0,0 +1,48 @@
using DM_Weight.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views.Dialog
{
/// <summary>
/// BindingChannelNewDialog.xaml 的交互逻辑
/// </summary>
public partial class BindingChannelNewDialog : UserControl
{
BindingChannelNewDialogViewModel vms;
public BindingChannelNewDialog()
{
InitializeComponent();
vms = BindingChannelNewDialogViewModel.vm;
}
/// <summary>
/// 药品名称下拉框
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ComboBox_KeyUp(object sender, KeyEventArgs e)
{
ComboBox comboBox = sender as ComboBox;
vms.UpdateComboBoxItems(comboBox.Text);
if (this.vms.DrugInfos.Count > 0)
{
comboBox.IsDropDownOpen = true;
}
TextBox textBox = (TextBox)comboBox.Template.FindName("PART_EditableTextBox", comboBox);
textBox.SelectionStart = textBox.Text.Length;
}
}
}

View File

@ -0,0 +1,122 @@
<UserControl x:Class="DM_Weight.Views.Dialog.CheckRecordDetailDialog"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DM_Weight.Views"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:prism="http://prismlibrary.com/"
xmlns:convert="clr-namespace:DM_Weight.Converter"
mc:Ignorable="d"
Width="Auto"
Height="Auto">
<Grid>
<Grid.Resources>
<convert:GroupSumConverter x:Key="GroupSumConverter" />
<convert:DrawerSelectConverter x:Key="DrawerSelectConverter" />
<convert:StatusConverter x:Key="StatusConverter" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid Background="#03a9f4" Grid.Row="0">
<TextBlock VerticalAlignment="Center" Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}" Margin="16 4 16 4" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Text="{Binding Title}" />
<Button
Style="{StaticResource MaterialDesignIconForegroundButton}"
Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
HorizontalAlignment="Right"
Command="{Binding BtnCloseCommand}"
ToolTip="关闭" Cursor="Hand"
>
<materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
</Button>
</Grid>
<DataGrid x:Name="dgv1"
Grid.Row="1"
materialDesign:DataGridAssist.ColumnHeaderPadding="15"
ItemsSource="{Binding ChannelStocks}"
SelectedItem="SelectedChannel"
materialDesign:DataGridAssist.EnableEditBoxAssist="False"
IsSynchronizedWithCurrentItem="True"
materialDesign:DataGridAssist.CellPadding="13"
CanUserAddRows="False"
AutoGenerateColumns="False" >
<!--<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource MaterialDesignDataGridRow}">
<EventSetter Event="GotFocus" Handler="Item_GotFocus"/>
</Style>
</DataGrid.RowStyle>-->
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
<Setter Property="Background" Value="#31ccec" />
<Setter Property="Foreground" Value="white" />
<Setter Property="Height" Value="56" />
<Setter Property="BorderBrush" Value="white"/>
<Setter Property="BorderThickness" Value="0.6"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Background" Value="Transparent"/>
<!--<Setter Property="HorizontalAlignment" Value="Left"/>-->
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
<!--GroupStyle to group data-->
<DataGrid.GroupStyle>
<GroupStyle>
<!--Group DataItems into DataGroup-->
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="True"
materialDesign:ExpanderAssist.HeaderBackground="PaleTurquoise">
<Expander.Header >
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Name.DrugName,StringFormat=药品:{0}}" FontWeight="Bold" />
<TextBlock FontWeight="Bold" Text="{Binding Path=Name.DrugSpec,StringFormat=规格:{0}}" />
<TextBlock FontWeight="Bold" Text="{Binding Path=Name.Manufactory,StringFormat=厂家:{0}}" />
<TextBlock FontWeight="Bold" Text="{Binding Path=Items[0].quantity,StringFormat=总库存:{0}}" />
<!--<TextBlock FontWeight="Bold" Text="{Binding Path=Items,Converter={StaticResource GroupSumConverter}}" />-->
</StackPanel>
</Expander.Header>
<ItemsPresenter/>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</DataGrid.GroupStyle>
<DataGrid.Columns>
<DataGridTextColumn Width="250"
Binding="{Binding manuNo}"
Header="批次"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="250"
Binding="{Binding effDate}"
Header="效期"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="241"
Binding="{Binding ManuQuantity}"
Header="库存"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views.Dialog
{
/// <summary>
/// CheckRecordDetailDialog.xaml 的交互逻辑
/// </summary>
public partial class CheckRecordDetailDialog : UserControl
{
public CheckRecordDetailDialog()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,12 @@
<UserControl x:Class="DM_Weight.Views.Dialog.MaskDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DM_Weight.Views.Dialog"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views.Dialog
{
/// <summary>
/// MaskDialog.xaml 的交互逻辑
/// </summary>
public partial class MaskDialog : UserControl
{
public MaskDialog()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,59 @@
<UserControl x:Class="DM_Weight.Views.Dialog.StockListAccountDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DM_Weight.Views.Dialog"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid Margin="0 0 0 6" Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="2*" />
<RowDefinition Height="2*" />
<RowDefinition Height="2*" />
<RowDefinition Height="4*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*" />
<ColumnDefinition Width="5*" />
</Grid.ColumnDefinitions>
<Grid Background="#03a9f4" Grid.Row="0" Grid.ColumnSpan="3">
<TextBlock VerticalAlignment="Center" Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}" Margin="16 4 16 4" Style="{StaticResource MaterialDesignHeadline5TextBlock}" Text="{Binding Title}" />
<Button
Style="{StaticResource MaterialDesignIconForegroundButton}"
Foreground="{DynamicResource PrimaryHueDarkForegroundBrush}"
HorizontalAlignment="Right"
Command="{Binding BtnCloseCommand}"
ToolTip="关闭" Cursor="Hand"
>
<materialDesign:PackIcon Kind="Close" Width="34" Height="34" />
</Button>
</Grid>
<DatePicker
Grid.Column="0" Grid.Row="1"
SelectedDate="{Binding StartDate, TargetNullValue=''}"
Margin="10"
materialDesign:HintAssist.Hint="开始时间"
Style="{StaticResource MaterialDesignOutlinedDatePicker}"
/>
<DatePicker Grid.Row="1"
Grid.Column="1"
SelectedDate="{Binding EndDate}"
Margin="10"
materialDesign:HintAssist.Hint="结束时间"
Style="{StaticResource MaterialDesignOutlinedDatePicker}"
/>
<Button Grid.ColumnSpan="2" Grid.Row="2"
Margin="6"
VerticalAlignment="Center"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
ToolTip="导出" Command="{Binding DownloadAccountBook}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="确定" />
</StackPanel>
</Button>
</Grid>
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views.Dialog
{
/// <summary>
/// StockListAccountDialog.xaml 的交互逻辑
/// </summary>
public partial class StockListAccountDialog : UserControl
{
public StockListAccountDialog()
{
InitializeComponent();
}
}
}

View File

@ -229,11 +229,16 @@
Header="规格"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<!--<DataGridTextColumn Width="100"
<DataGridTextColumn Width="100"
Binding="{Binding ManuNo}"
Header="批次"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>-->
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="100"
Binding="{Binding EffDate}"
Header="效期"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<!--<materialDesign:DataGridComboBoxColumn
Header="批次/效期"
Width="200"
@ -243,7 +248,7 @@
>
</materialDesign:DataGridComboBoxColumn>-->
<DataGridTemplateColumn Width="200" IsReadOnly="True"
<!--<DataGridTemplateColumn Width="200" IsReadOnly="True"
Header="批次">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
@ -263,7 +268,7 @@
Binding="{Binding drugManuNo.EffDate}"
Header="效期"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>-->
<DataGridTextColumn Width="100"
Binding="{Binding Quantity}"
Header="库存"

View File

@ -17,6 +17,7 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<!--<RowDefinition Height="Auto"></RowDefinition>-->
<RowDefinition></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
@ -26,10 +27,11 @@
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Margin="30 0 30 0" HorizontalAlignment="Left" Width="Auto" Height="26" Source="/Images/logo.png" />
<ListBox Name="ListBoxName" Grid.Column="1" ItemsSource="{Binding PremissionDmList}" HorizontalAlignment="Right" Cursor="Hand">
<ListBox Name="ListBoxName" Grid.Column="1" SelectedItem="{Binding SelectedMenu}" ItemsSource="{Binding PremissionDmList}" HorizontalAlignment="Right">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding SelectionCommon}" CommandParameter="{Binding ElementName=ListBoxName}"/>
<!--<i:InvokeCommandAction Command="{Binding SelectionCommon}" CommandParameter="{Binding ElementName=ListBoxName}"/>-->
<i:InvokeCommandAction Command="{Binding SelectionCommon}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<ListBox.ItemsPanel>
@ -46,7 +48,22 @@
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
<!--<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Content="取药" Grid.Column="0" Command="{Binding TakeCommand}" />
<Button Content="加药" Grid.Column="1" Command="{Binding AddCommand}"/>
<Button Content="还药" Grid.Column="2" Command="{Binding ReturnCommand}"/>
<Button Content="库存管理" Grid.Column="3" Command="{Binding StockCommand}"/>
<Button Content="系统设置" Grid.Column="4" Command="{Binding SettingCommand}"/>
</Grid>-->
<Grid Grid.Row="1" Margin="8,6,8,6">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
@ -59,7 +76,11 @@
<materialDesign:Card Grid.Row="0" Grid.ColumnSpan="2">
<ListBox ItemsSource="{Binding SelectedMenu.Children}" SelectedItem="{ Binding SelectedChildMenu }" HorizontalAlignment="left" Cursor="Hand">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding SelectionChildCommon}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" IsItemsHost="True"/>
@ -74,16 +95,6 @@
</ListBox.ItemTemplate>
</ListBox>
</materialDesign:Card>
<!--<materialDesign:Card Grid.Row="0" Grid.Column="1">-->
<!--<Button HorizontalAlignment="Right"
Grid.Column="1"
Style="{StaticResource MaterialDesignRaisedButton}"
materialDesign:ButtonAssist.CornerRadius="5"
Command="{ Binding ShiftsCommand }"
Background="#42a5f5"
BorderBrush="#42a5f5" Cursor="Hand" IsDefault="True" Content="交接班"/>-->
<!--</materialDesign:Card>-->
<materialDesign:Card Grid.Row="1" Margin="0 8 0 8" Grid.ColumnSpan="2">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled" Focusable="True">

View File

@ -0,0 +1,309 @@
<UserControl x:Class="DM_Weight.Views.InvoiceInNewWindow"
xmlns:pagination="clr-namespace:DM_Weight.Components.pagination"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:prism="http://prismlibrary.com/"
xmlns:convert="clr-namespace:DM_Weight.Converter"
xmlns:local="clr-namespace:DM_Weight.Views"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Style x:Key="st" TargetType="GridViewColumnHeader">
<Style.Setters>
<Setter Property="Height">
<Setter.Value>55</Setter.Value>
</Setter>
<Setter Property="Background">
<Setter.Value>#31ccec</Setter.Value>
</Setter>
<Setter Property="Foreground">
<Setter.Value>white</Setter.Value>
</Setter>
</Style.Setters>
</Style>
</UserControl.Resources>
<Grid>
<Grid.Resources>
<convert:GroupSumConverter x:Key="GroupSumConverter" />
<convert:QuantityCountConverter x:Key="QuantityCountConverter" />
<convert:StatusConverter x:Key="StatusConverter" />
<convert:InputQuantityConverter x:Key="InputQuantityConverter" />
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="7*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Margin="0 6 0 6" Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="4*" />
</Grid.ColumnDefinitions>
<ComboBox
Grid.Column="0"
Margin="6 0 0 0"
Style="{StaticResource MaterialDesignOutlinedComboBox}"
SelectedItem="{Binding SelectedItem}"
DisplayMemberPath="Name"
ItemsSource="{Binding OrderTakeSelects}"
/>
<TextBox
Grid.Column="1"
Text="{Binding SearchValue, UpdateSourceTrigger=PropertyChanged}"
materialDesign:HintAssist.Hint="{Binding SelectedItem.Name}"
materialDesign:HintAssist.IsFloating="True"
Margin="6 0 0 0"
Style="{StaticResource MaterialDesignOutlinedTextBox}"/>
<DatePicker
Grid.Column="2"
SelectedDate="{Binding OrderDate, StringFormat=yyyy-MM-dd, TargetNullValue='',UpdateSourceTrigger=PropertyChanged}"
SelectedDateFormat="Short"
Margin="6 0 0 0"
materialDesign:HintAssist.Hint="日期"
Style="{StaticResource MaterialDesignOutlinedDatePicker}" />
</Grid>
<ListView Grid.Row="1"
ItemsSource="{Binding Invoices}"
SelectedItem="{Binding SelectedInvoice}"
materialDesign:ListViewAssist.HeaderRowBackground="#31ccec"
materialDesign:DataGridAssist.ColumnHeaderPadding="10"
materialDesign:ListViewAssist.ListViewItemPadding="13">
<ListView.Resources>
<Style TargetType="{x:Type GridViewColumnHeader}" BasedOn="{StaticResource {x:Type GridViewColumnHeader}}">
<Setter Property="Foreground" Value="White" />
</Style>
</ListView.Resources>
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding RowSelected}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource st}">
<GridViewColumn Width="100"
Header="凭证单号"
DisplayMemberBinding="{Binding InvoiceNo}"/>
<GridViewColumn Width="70"
Header="时间"
DisplayMemberBinding="{Binding InvoiceDate, StringFormat=yyyy-MM-dd}" />
<GridViewColumn Width="60" DisplayMemberBinding="{Binding Count}" Header="药品种类">
<!--<GridViewColumn.Header>
<TextBlock Text= "" TextWrapping="Wrap"/>
</GridViewColumn.Header>-->
</GridViewColumn>
<GridViewColumn Width="60"
DisplayMemberBinding="{Binding Quantity}" Header="药品总数">
<!--<GridViewColumn.Header>
<TextBlock Text="" TextWrapping="Wrap"/>
</GridViewColumn.Header>-->
</GridViewColumn>
<!--<GridViewColumn
DisplayMemberBinding="{Binding Status}"
Header="状态"/>-->
</GridView>
</ListView.View>
</ListView>
<pagination:Pagination Grid.Row="2"
CurrentPage="{Binding PageNum}"
PageSize="{Binding PageSize}"
TotalPages="{Binding TotalCount}"
InfoTextIsEnabel="True"
/>
</Grid>
<Grid Grid.Column="1" Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="61" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button
Margin="0 0 3 0"
VerticalAlignment="Center"
Command="{Binding OpenInvoiceAdd}"
Visibility="{Binding Status,Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnVisible}"
materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=opearBtnLoading}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="入库" />
<Button
Margin="0 0 3 0"
VerticalAlignment="Center"
Command="{Binding TakeFinish}"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CompleteBtn}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="完成" />
<Button
Margin="0 0 6 0"
VerticalAlignment="Center"
Command="{Binding CancleTake}"
Visibility="{Binding Status, Converter={StaticResource StatusConverter}, ConverterParameter=CancelBtn}"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Content="取消" />
<!--<Button
Margin="0 0 6 0"
VerticalAlignment="Center"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Command="{Binding OpenInvoiceAdd}"
Content="入库"
/>-->
<Button
Margin="0 0 6 0"
VerticalAlignment="Center"
Style="{StaticResource MaterialDesignOutlinedLightButton}"
Command="{Binding QueryCommand}"
ToolTip="刷新">
<materialDesign:PackIcon
Kind="Refresh" />
</Button>
</StackPanel>
<ScrollViewer Grid.Row="1" Margin="0">
<ItemsControl
ItemsSource="{Binding ChannelLsts,UpdateSourceTrigger=PropertyChanged}"
Grid.IsSharedSizeScope="True">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border BorderBrush="White" BorderThickness="1">
<StackPanel Orientation="Horizontal" Background="#31ccec" Grid.Column="0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions>
<TextBlock TextWrapping="Wrap" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="0 10 0 0 " Text="{Binding Drug.DrugName}"/>
<TextBlock TextWrapping="Wrap" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="0 0 0 1 " Text="{Binding Drug.DrugSpec}"/>
<!--<Button Grid.Row="2" Padding="0 0 0 1 " Style="{x:Null}" BorderBrush="{x:Null}" Background="{x:Null}" Click="Button_Click" CommandParameter="{Binding}">
<Button.Content>
<Border Width="32" Height="32" CornerRadius="16" Background="CornflowerBlue" VerticalAlignment="Center" HorizontalAlignment="Center">
<Path Data="M0 11L22 11M11 0L11 22" Stroke="WhiteSmoke" StrokeThickness="4" VerticalAlignment="Center" HorizontalAlignment="Center"></Path>
</Border>
</Button.Content>
</Button>-->
</Grid>
</StackPanel>
</Border>
<DataGrid
Margin="0"
Grid.Column="1"
materialDesign:DataGridAssist.ColumnHeaderPadding="15"
ItemsSource="{Binding channelStocks}"
materialDesign:DataGridAssist.EnableEditBoxAssist="False"
materialDesign:DataGridAssist.CellPadding="15"
SelectionUnit="Cell"
CanUserAddRows="False"
AutoGenerateColumns="False">
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
<Setter Property="Background" Value="#31ccec" />
<Setter Property="Foreground" Value="white" />
<Setter Property="Height" Value="60" />
<Setter Property="BorderBrush" Value="white"/>
<Setter Property="BorderThickness" Value="0.6"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
<Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}">
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="HorizontalAlignment" Value="Center"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Width="60"
Binding="{Binding Location}"
Header="库位"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="150" Binding="{Binding ManuNo}" Header="批次" IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="100" Binding="{Binding EffDate}" Header="效期" IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<!--<DataGridTextColumn Width="60"
<DataGridTemplateColumn Width="180" IsReadOnly="True"
Header="批次">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox
Style="{StaticResource MaterialDesignDataGridComboBox}"
ItemsSource="{Binding DrugInfo.DrugManuNos}"
SelectedItem="{Binding drugManuNo,UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="ManuNo"
IsEnabled="{Binding Quantity,Converter={StaticResource QuantityCountConverter}}">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>-->
<!--<DataGridTextColumn Width="100"
Binding="{Binding drugManuNo.EffDate}"
Header="效期"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>-->
<DataGridTextColumn Width="60"
Binding="{Binding Quantity}"
Header="库存"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<DataGridTextColumn Width="100"
Binding="{Binding AddQuantity}"
Header="添加数量"
IsReadOnly="True"
ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"/>
<!--<DataGridTemplateColumn Width="60">
<DataGridTemplateColumn.Header>
<TextBlock Text="添加数量" TextWrapping="Wrap"/>
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Style="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}">
<TextBox.Text>
<Binding Path="AddQuantity" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<ExceptionValidationRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>-->
</DataGrid.Columns>
</DataGrid>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Grid>
</UserControl>

View File

@ -0,0 +1,40 @@
using DM_Weight.Models;
using DM_Weight.msg;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DM_Weight.Views
{
/// <summary>
/// InvoiceInNewWindow.xaml 的交互逻辑
/// </summary>
public partial class InvoiceInNewWindow : UserControl
{
IEventAggregator _eventAggregator;
public InvoiceInNewWindow(IEventAggregator eventAggregator)
{
InitializeComponent();
_eventAggregator = eventAggregator;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Button btn = (Button)sender;
ChannelList cls = (ChannelList)btn.CommandParameter;
//vms.AddAction(cls);
_eventAggregator.GetEvent<AddDrugEvent>().Publish(cls);
}
}
}

View File

@ -179,7 +179,7 @@
FontSize="14"
FontWeight="Bold"
Foreground="{DynamicResource MaterialDesignPaper}"
Grid.Row="0" Grid.Column="2" Text="{Binding Operator.Nickname}" />
Grid.Row="0" Grid.Column="2" Text="{Binding Operator.Nickname,UpdateSourceTrigger=PropertyChanged}" />
<TextBlock
FontSize="14"
FontWeight="Bold"
@ -189,7 +189,7 @@
FontSize="14"
FontWeight="Bold"
Foreground="{DynamicResource MaterialDesignPaper}"
Grid.Row="1" Grid.Column="2" Text="{Binding Reviewer.Nickname}" />
Grid.Row="1" Grid.Column="2" Text="{Binding Reviewer.Nickname,UpdateSourceTrigger=PropertyChanged}" />
</Grid>
</Grid>
</Grid>

Some files were not shown because too many files have changed in this diff Show More