83 lines
2.9 KiB
C#
83 lines
2.9 KiB
C#
using DM_Weight.Models;
|
|
using DM_Weight.util;
|
|
using Prism.Events;
|
|
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 AddNewMenuDialogViewModel : BindableBase, IDialogAware, IRegionMemberLifetime
|
|
{
|
|
public bool KeepAlive => false;
|
|
|
|
public string Title => "添加套餐";
|
|
private List<DrugInfo>? _drugInfos;
|
|
|
|
public List<DrugInfo>? DrugInfos
|
|
{
|
|
get => _drugInfos;
|
|
set => SetProperty(ref _drugInfos, value);
|
|
}
|
|
public static AddNewMenuDialogViewModel vm;
|
|
|
|
IEventAggregator _eventAggregator;
|
|
public AddNewMenuDialogViewModel(IEventAggregator eventAggregator)
|
|
{
|
|
_eventAggregator = eventAggregator;
|
|
vm = this;
|
|
}
|
|
|
|
public event Action<IDialogResult> RequestClose;
|
|
|
|
public bool CanCloseDialog()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public bool IsNavigationTarget(NavigationContext navigationContext)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public void OnDialogClosed()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public void OnDialogOpened(IDialogParameters parameters)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
private void GetAllDrugInfos()
|
|
{
|
|
//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();
|
|
//DrugInfos_PY = list;
|
|
}
|
|
|
|
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,' / ',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();
|
|
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();
|
|
}
|
|
}
|
|
}
|