更新菜单,选择药品时显示批次、厂家信息

This commit is contained in:
maqiao 2024-11-18 08:58:58 +08:00
parent 5682e11660
commit f824236252
10 changed files with 236 additions and 112 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=xiangtan;userid=root;password=root" />
<add name="database" connectionString="server=127.0.0.1;port=3306;database=xiangtan_xc;userid=root;password=root" />
</connectionStrings>
<!--<runtime>
-->
@ -14,7 +14,7 @@
<appSettings>
<!-- 设备id -->
<add key="machineId" value="DM3" />
<add key="machineId" value="DM1" />
<!--请领药库-->
<add key="colloctedId" value="住院,DM2,门诊,DM22" />
<!-- 供应单位 -->

View File

@ -17,9 +17,9 @@ namespace DM_Weight.Models
private int _baseId = 0;
[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
public int BaseId { get=> _baseId; set { SetProperty(ref _baseId, value); } }
private long _drugId = 0;
private string _drugId;
[SugarColumn(ColumnName = "drugid")]
public long DrugId { get => _drugId; set { SetProperty(ref _drugId, value); } }
public string DrugId { get => _drugId; set { SetProperty(ref _drugId, value); } }
private string _machineId = "";
[SugarColumn(ColumnName = "machine_id")]
public string MachineId { get => _machineId; set { SetProperty(ref _machineId, value); } }

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using Prism.Mvvm;
using SqlSugar;
namespace DM_Weight.Models
@ -20,7 +21,7 @@ namespace DM_Weight.Models
/// ҩƷID
///</summary>
[SugarColumn(ColumnName = "drug_id", IsPrimaryKey = true)]
public long DrugId { get; set; }
public string DrugId { get; set; }
/// <summary>
/// ƴ
///</summary>
@ -90,7 +91,8 @@ namespace DM_Weight.Models
set { SetProperty(ref _base, value); }
}
[SugarColumn(IsIgnore = true)]
public string drug_name_spec { get; set; }
}
}

View File

@ -165,8 +165,10 @@ namespace DM_Weight.ViewModels
private void GetAllDrugInfos()
{
var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
DrugInfos = list;
//var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
//DrugInfos = 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,' / ',manufactory) 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()
@ -280,7 +282,7 @@ namespace DM_Weight.ViewModels
item.DrugId = DrugInfo.DrugId.ToString();
item.ManuNo = DrugManuNo.ManuNo;
item.DrugInfo = DrugInfo;
item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate);
item.EffDate = String.Format("{0:yyyy-MM-dd}", DrugManuNo.EffDate).Substring(0, 10);
SqlSugarHelper.Db.Updateable(item).UpdateColumns(it => new { it.DrugId, it.ManuNo, it.EffDate, it.PosNo }).ExecuteCommand();
if (item.BoardType == 5)
@ -391,7 +393,7 @@ namespace DM_Weight.ViewModels
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";
d.manufactory,d.max_stock,CONCAT(drug_name,' / ',drug_spec,' / ',manufactory) 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();

View File

@ -208,9 +208,11 @@ namespace DM_Weight.ViewModels
private void GetAllDrugInfos()
{
var list = SqlSugarHelper.Db.Queryable<DrugInfo>().Includes<DrugManuNo>(di => di.DrugManuNos).OrderBy(di => di.DrugId).ToList();
DrugInfos = list;
//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,' / ',manufactory) 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()
@ -468,7 +470,7 @@ namespace DM_Weight.ViewModels
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";
d.manufactory,d.max_stock,CONCAT(drug_name,' / ',drug_spec,' / ',manufactory) 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();

View File

@ -199,7 +199,7 @@ namespace DM_Weight.ViewModels
//查询最大药品id并+1赋值给新增药品
long maxDrugId = SqlSugarHelper.Db.Queryable<DrugInfo>().Max(it => it.DrugId);
string maxDrugId = SqlSugarHelper.Db.Queryable<DrugInfo>().Max(it => it.DrugId);
SelectedDrug.DrugId = maxDrugId + 1;
var f = SqlSugarHelper.Db.UseTran(() =>
{
@ -207,7 +207,7 @@ namespace DM_Weight.ViewModels
SqlSugarHelper.Db.Insertable(new DrugBase()
{
DrugId = SelectedDrug.DrugId,
DrugId = SelectedDrug.DrugId.ToString(),
MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1",
BaseQuantity = SelectedDrug.drugBase.BaseQuantity
}).ExecuteCommand();
@ -246,7 +246,7 @@ namespace DM_Weight.ViewModels
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
return;
}
}, () => SelectedDrug.DrugId <= 0).ObservesProperty(() => SelectedDrug);
}, () => SelectedDrug.DrugId ==null).ObservesProperty(() => SelectedDrug);
}
public DelegateCommand EditDrugCommand
@ -262,7 +262,7 @@ namespace DM_Weight.ViewModels
{
SqlSugarHelper.Db.Insertable(new DrugBase()
{
DrugId = SelectedDrug.DrugId,
DrugId = SelectedDrug.DrugId.ToString(),
MachineId = ConfigurationManager.AppSettings["machineId"] ?? "DM1",
BaseQuantity = SelectedDrug.drugBase.BaseQuantity
}).ExecuteCommand();
@ -276,7 +276,7 @@ namespace DM_Weight.ViewModels
{
SqlSugarHelper.Db.Insertable(new DrugBase()
{
DrugId = SelectedDrug.DrugId,
DrugId = SelectedDrug.DrugId.ToString(),
MachineId = ConfigurationManager.AppSettings["machineId"]??"DM1",
BaseQuantity = SelectedDrug.drugBase.BaseQuantity
}).ExecuteCommand();
@ -306,7 +306,7 @@ namespace DM_Weight.ViewModels
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
}
RequestData();
}, () => SelectedDrug.DrugId > 0).ObservesProperty(() => SelectedDrug);
}, () => SelectedDrug.DrugId==null).ObservesProperty(() => SelectedDrug);
}
public DelegateCommand AddManuCommand
@ -322,7 +322,7 @@ namespace DM_Weight.ViewModels
GetManuNos();
}
}, () => SelectedDrug.DrugId > 0).ObservesProperty(() => SelectedDrug);
}, () => SelectedDrug.DrugId == null).ObservesProperty(() => SelectedDrug);
}
public DelegateCommand EditManuCommand

View File

@ -78,76 +78,76 @@ 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
{
if (value.PremissionPath.Equals("ReturnDrugWindow") || value.PremissionPath.Equals("ReturnDrugWindow2"))
{
if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1"))
{
_regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2");
}
else
{
_regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow");
}
}
else
{
_regionManager.RequestNavigate("ContentRegion", value.PremissionPath);
}
}
}
// //添加参数,键值对格式
// keys.Add("Type", 4);
// _regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
// }
// else
// {
// if (value.PremissionPath.Equals("ReturnDrugWindow") || value.PremissionPath.Equals("ReturnDrugWindow2"))
// {
// if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1"))
// {
// _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2");
// }
// else
// {
// _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow");
// }
// }
// else
// {
// _regionManager.RequestNavigate("ContentRegion", value.PremissionPath);
// }
// }
// }
SetProperty(ref _selectedChildMenu, value);
}
//}
}
}
@ -183,19 +183,41 @@ namespace DM_Weight.ViewModels
}
}
private DelegateCommand<ListBox> _selectionCommon;
public DelegateCommand<ListBox> SelectionCommon
private DelegateCommand _selectionCommon;
public DelegateCommand SelectionCommon
{
get => _selectionCommon ?? (_selectionCommon = new DelegateCommand<ListBox>(SelectionMethod));
//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 == "退出")
//SelectedMenu = viewName.SelectedItem as PremissionDm;
//if (SelectedMenu.PremissionName == "退出")
//{
// if (!_portUtil.Operate)
// {
// _chkFunction.HIKStopDVRRecord();
// logger.Info($"用户【{Operator?.Nickname}】退出登录");
// Operator = null;
// Reviewer = null;
// _regionManager.RequestNavigate("MainRegion", "LoginWindow");
// }
// else
// {
// logger.Info($"未关闭抽屉操作退出");
// SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
// SnackbarMessageQueue.Enqueue("请关闭抽屉后再退出");
// return;
// }
//}
//else
//{
// //SelectedMenu.Children = SelectedMenu.Children;
// SelectedChildMenu = SelectedMenu.Children[0];
//}
logger.Info("开始进入父菜单");
if (SelectedMenu != null && SelectedMenu.PremissionName == "退出")
{
if (!_portUtil.Operate)
{
_chkFunction.HIKStopDVRRecord();
logger.Info($"用户【{Operator?.Nickname}】退出登录");
Operator = null;
Reviewer = null;
@ -203,19 +225,108 @@ namespace DM_Weight.ViewModels
}
else
{
logger.Info($"未关闭抽屉操作退出");
SnackbarBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#b71c1c"));
SnackbarMessageQueue.Enqueue("请关闭抽屉后再退出");
return;
if (!_portUtil.Operate)
{
_regionManager.RequestNavigate("ContentRegion", SelectedMenu.Children[0].PremissionPath);
}
}
logger.Info("结束父菜单");
}
#region
private DelegateCommand _selectionChildCommon;
public DelegateCommand SelectionChildCommon
{
get => _selectionChildCommon ?? (_selectionChildCommon = new DelegateCommand(SelectionChildMethod));
}
private void SelectionChildMethod()
{
SelectChildNavigate(SelectedChildMenu);
}
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
{
if (SelectedChildMenu.PremissionPath.Equals("ReturnDrugWindow") || SelectedChildMenu.PremissionPath.Equals("ReturnDrugWindow2"))
{
if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1"))
{
_regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2");
}
else
{
_regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow");
}
}
else if (SelectedChildMenu.PremissionPath.Equals("SettingMainWindow") || SelectedChildMenu.PremissionPath.Equals("SettingWindow"))
{
//if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"])>0)
//{
// _regionManager.RequestNavigate("ContentRegion", "SettingMainWindow");
//}
//else
{
_regionManager.RequestNavigate("ContentRegion", "SettingWindow");
}
}
else
{
//SelectedMenu.Children = SelectedMenu.Children;
SelectedChildMenu = SelectedMenu.Children[0];
_regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath);
}
}
}
}
}
#endregion
public List<PremissionDm> PremissionDmList { get { return _premissionDmList; } set { SetProperty(ref _premissionDmList, value); } }
public UserList UserList { get { return _userList; } set { SetProperty(ref _userList, value); } }
@ -350,6 +461,8 @@ namespace DM_Weight.ViewModels
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");

View File

@ -52,7 +52,7 @@
IsEditable="True"
ItemsSource="{Binding DrugInfos}"
SelectedItem="{Binding DrugInfo}"
DisplayMemberPath="DrugName" IsEnabled="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
DisplayMemberPath="drug_name_spec" IsEnabled="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
/>
<ComboBox
Grid.Column="1"

View File

@ -71,7 +71,7 @@
IsEditable="True"
ItemsSource="{Binding DrugInfos}"
SelectedItem="{Binding DrugInfo}"
DisplayMemberPath="DrugName" IsEnabled="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
DisplayMemberPath="drug_name_spec" IsEnabled="True" IsTextSearchEnabled="False" KeyUp="ComboBox_KeyUp"
/>
<StackPanel HorizontalAlignment="Right" Grid.Column="3" Orientation="Horizontal">
<Button

View File

@ -26,10 +26,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" Cursor="Hand">
<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>
@ -55,7 +56,11 @@
<materialDesign:Card Grid.Row="0">
<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"/>