同上,刚刚未提交上去

This commit is contained in:
maqiao 2024-11-05 08:49:56 +08:00
parent 21082a6e17
commit 5e9198cf59
11 changed files with 209 additions and 91 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=xiangxiang_xianchang;userid=root;password=root" />
<add name="database" connectionString="server=127.0.0.1;port=3306;database=xx_xiangchang2;userid=root;password=root" />
</connectionStrings>
<!--<runtime>
--><!--配置之后Appdomain.CurrentDomain.UnhandledException 事件的 IsTerminating 就变成了 false 啦!也就是说,程序并不会因为这次的异常而崩溃退出。--><!--
@ -99,7 +99,7 @@
<!-- 指纹机号码 -->
<add key="machineNumber" value="1"/>
<!-- 指纹机ip -->
<add key="fingerIp" value="192.168.1.201"/>
<add key="fingerIp" value="192.168.50.201"/>
<!-- 多处方取药 0:不启用 1启用-->
<add key="MultiOrder" value="1"/>

View File

@ -96,6 +96,8 @@ namespace DM_Weight.Models
get=> _base;
set { SetProperty(ref _base, value); }
}
[SugarColumn(IsIgnore = true)]
public string drug_name_spec { get; set; }

View File

@ -74,8 +74,9 @@ namespace DM_Weight.Port
});
return bools;
}
public void OpenBoxDoor(int boxNum)
public bool OpenBoxDoor(int boxNum)
{
bool bFlag=false;
Policy.Handle<Exception>().Retry(3, ((exception, retryCount) =>
{
this.Dispose();
@ -86,7 +87,9 @@ namespace DM_Weight.Port
{
master.WriteSingleRegister(1, (ushort)boxNum, 14);
Console.WriteLine($"开门指令已发送{(ushort)boxNum}");
bFlag = true;
});
return bFlag;
}
private void Dispose()
{

View File

@ -163,8 +163,11 @@ namespace DM_Weight.ViewModels
}
private void RequestDrug()
{
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();
}
public DelegateCommand BindingDrug
{

View File

@ -389,10 +389,10 @@ namespace DM_Weight.ViewModels
Button9Color = Brushes.Yellow;
break;
case 10:
Button9Color = Brushes.Yellow;
Button10Color = Brushes.Yellow;
break;
case 11:
Button9Color = Brushes.Yellow;
Button11Color = Brushes.Yellow;
break;
case 12:
Button12Color = Brushes.Yellow;

View File

@ -36,7 +36,7 @@ namespace DM_Weight.ViewModels
set => SetProperty(ref _userList, value);
}
public UserList DMUserList;
public UserList DMUserList=new UserList();
private string UserName;
public List<RoleDm> Roles { get; set; }

View File

@ -68,86 +68,169 @@ namespace DM_Weight.ViewModels
get { return _selectedChildMenu; }
set
{
if (!_portUtil.Operate)
//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", 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", 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 if (value.PremissionPath.Equals("SettingMainWindow") || value.PremissionPath.Equals("SettingWindow"))
// {
// if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
// {
// _regionManager.RequestNavigate("ContentRegion", "SettingMainWindow");
// }
// else
// {
// _regionManager.RequestNavigate("ContentRegion", "SettingWindow");
// }
// }
// else
// {
// _regionManager.RequestNavigate("ContentRegion", value.PremissionPath);
// }
// }
// }
SetProperty(ref _selectedChildMenu, value);
//}
}
}
private void SelectChildNavigate(PremissionDm SelectedChildMenu)
{
if (!_portUtil.Operate)
{
if (SelectedChildMenu != null)
{
if (value != null)
if (SelectedChildMenu.PremissionPath.Equals("TakeRecordWindow"))
{
if (value.PremissionPath.Equals("TakeRecordWindow"))
{
//定义传参变量
NavigationParameters keys = new NavigationParameters();
//定义传参变量
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 (SelectedChildMenu.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 (SelectedChildMenu.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 (SelectedChildMenu.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", SelectedChildMenu.PremissionPath, keys);
}
else if (SelectedChildMenu.PremissionPath.Equals("CheckRecordWindow"))
{
//定义传参变量
NavigationParameters keys = new NavigationParameters();
//添加参数,键值对格式
keys.Add("Type", 4);
_regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
}
else
//添加参数,键值对格式
keys.Add("Type", 4);
_regionManager.RequestNavigate("ContentRegion", "MachineRecordWindow", keys);
}
else
{
if (SelectedChildMenu.PremissionPath.Equals("ReturnDrugWindow") || SelectedChildMenu.PremissionPath.Equals("ReturnDrugWindow2"))
{
if (value.PremissionPath.Equals("ReturnDrugWindow") || value.PremissionPath.Equals("ReturnDrugWindow2"))
if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1"))
{
if (ConfigurationManager.AppSettings["returnDrugMode"].ToString().Equals("1"))
{
_regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2");
}
else
{
_regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow");
}
}
else if (value.PremissionPath.Equals("SettingMainWindow") || value.PremissionPath.Equals("SettingWindow"))
{
if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0)
{
_regionManager.RequestNavigate("ContentRegion", "SettingMainWindow");
}
else
{
_regionManager.RequestNavigate("ContentRegion", "SettingWindow");
}
_regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow2");
}
else
{
_regionManager.RequestNavigate("ContentRegion", value.PremissionPath);
_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
{
_regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath);
}
}
SetProperty(ref _selectedChildMenu, value);
}
}
}
@ -195,10 +278,24 @@ 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);
}
}
}
#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); } }
public UserList UserList { get { return _userList; } set { SetProperty(ref _userList, value); } }
@ -431,6 +528,7 @@ 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

@ -325,10 +325,10 @@ namespace DM_Weight.ViewModels
Button9Color = Brushes.Yellow;
break;
case 10:
Button9Color = Brushes.Yellow;
Button10Color = Brushes.Yellow;
break;
case 11:
Button9Color = Brushes.Yellow;
Button11Color = Brushes.Yellow;
break;
case 12:
Button12Color = Brushes.Yellow;

View File

@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
@ -115,7 +116,7 @@ namespace DM_Weight.ViewModels
{
if (_userLists == null)
{
_userLists = SqlSugarHelper.Db.Queryable<UserList>().Where(us => us.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5")).Select(us => new BindUserList() { UserId = Convert.ToInt32(us.UserBarcode), UserName = us.Nickname }).ToList();
_userLists = SqlSugarHelper.Db.Queryable<UserList>().Where(us => us.MachineId == (ConfigurationManager.AppSettings["machineId"] ?? "DM5")).Select(us => new BindUserList() { UserId = us.UserBarcode, UserName = us.Nickname }).ToList();
_userListSelectedItem = _userLists[0];
}
}
@ -146,6 +147,7 @@ namespace DM_Weight.ViewModels
{
get => new DelegateCommand<string>((DrawerNo) =>
{
UserListSelectedItem = null;
this.DrawerNo = Convert.ToInt32(DrawerNo);
ChannelList cnl = SqlSugarHelper.Db.Queryable<ChannelList>().Where(cl => cl.MachineId == "DM5" && cl.DrawerNo.ToString() == DrawerNo).First();
if (cnl != null && cnl.DrawerType != null)
@ -158,23 +160,24 @@ namespace DM_Weight.ViewModels
{
//药箱归属药师,把药师信息显示出来
UserStatus = Visibility.Visible;
UserListSelectedItem = _userLists.Where(sul => sul.UserId.ToString() == cnl.BelongUser).FirstOrDefault();
if (!string.IsNullOrEmpty(cnl.BelongUser))
{
UserListSelectedItem = _userLists.Where(sul => sul.UserId!=null&&sul.UserId.ToString() == cnl.BelongUser).FirstOrDefault();
}
if (UserListSelectedItem == null)
{
if (UserLists.Where(us => us.UserName == "请选择药师").Count() <= 0)
{
BindUserList nullBind = new BindUserList();
nullBind.UserId = 0;
//nullBind.UserId = null;
nullBind.UserName = "请选择药师";
_userLists.Add(nullBind);
}
UserListSelectedItem = UserLists.Where(us => us.UserName == "请选择药师").FirstOrDefault();
}
else
{
UserListSelectedItem = UserLists[0];
}
}
else
{
@ -210,7 +213,12 @@ namespace DM_Weight.ViewModels
Type = 55,
InvoiceId = $"打开{DrawerNo}号药箱",
}).ExecuteCommand();
ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo - 1);
bool bFlag = ModbusHelper.GetInstance().OpenBoxDoor(DrawerNo - 1);
if (bFlag)
{
IsEnable = true;
Status = 0;
}
}
});
}
@ -229,15 +237,15 @@ namespace DM_Weight.ViewModels
{
//药箱 归属药师
iUpdate=SqlSugarHelper.Db.Updateable(new ChannelList() { BelongUser = UserListSelectedItem.UserId.ToString(), DrawerType = BoxTypeSelectedItem.TypeValue, Id = channelList.Id }).UpdateColumns(cl => new { cl.BelongUser, cl.DrawerType }).ExecuteCommand();
iUpdate = SqlSugarHelper.Db.Updateable(new ChannelList() { BelongUser = UserListSelectedItem.UserId.ToString(), DrawerType = BoxTypeSelectedItem.TypeValue, Id = channelList.Id }).UpdateColumns(cl => new { cl.BelongUser, cl.DrawerType }).ExecuteCommand();
}
else
{
//药箱属于公共药箱
iUpdate=SqlSugarHelper.Db.Updateable(new ChannelList() { DrawerType = BoxTypeSelectedItem.TypeValue, Id = channelList.Id }).UpdateColumns(cl => new { cl.DrawerType }).ExecuteCommand();
iUpdate = SqlSugarHelper.Db.Updateable(new ChannelList() { DrawerType = BoxTypeSelectedItem.TypeValue, Id = channelList.Id }).UpdateColumns(cl => new { cl.DrawerType }).ExecuteCommand();
}
if(iUpdate>0)
if (iUpdate > 0)
{
//提示请选择药箱
AlertMsg alertMsg = new AlertMsg
@ -364,7 +372,7 @@ namespace DM_Weight.ViewModels
public class BindUserList
{
public int UserId { get; set; }
public string UserId { get; set; }
public string UserName { get; set; }
}
}

View File

@ -156,7 +156,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"
/>
<TextBox
Grid.Column="1"

View File

@ -56,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"/>