77 lines
2.2 KiB
C#
77 lines
2.2 KiB
C#
using DM_Weight.Models;
|
|
using DM_Weight.util;
|
|
using Prism.Mvvm;
|
|
using Prism.Regions;
|
|
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 BindBoxDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
|
|
{
|
|
public string Title =>"手术间药品绑定";
|
|
|
|
public bool KeepAlive => false;
|
|
|
|
|
|
private int _drawerNo = 0;
|
|
public int DrawerNo
|
|
{
|
|
get => _drawerNo;
|
|
set
|
|
{
|
|
SetProperty(ref _drawerNo, value);
|
|
}
|
|
}
|
|
private List<DrugInfo>? _drugInfos;
|
|
|
|
public List<DrugInfo>? DrugInfos
|
|
{
|
|
get => _drugInfos;
|
|
set => SetProperty(ref _drugInfos, value);
|
|
}
|
|
|
|
public static BindBoxDialogViewModel vm;
|
|
|
|
public event Action<IDialogResult> RequestClose;
|
|
|
|
public bool CanCloseDialog()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public void OnDialogClosed()
|
|
{
|
|
|
|
}
|
|
|
|
public void OnDialogOpened(IDialogParameters parameters)
|
|
{
|
|
if (parameters.ContainsKey("DrawerNo"))
|
|
{
|
|
DrawerNo = parameters.GetValue<int>("DrawerNo");
|
|
}
|
|
}
|
|
|
|
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)).OrderBy(di => di.DrugName).OrderBy(di => di.DrugId).ToList();
|
|
}
|
|
}
|
|
}
|