229 lines
7.6 KiB
C#
229 lines
7.6 KiB
C#
|
using DM_Weight.Models;
|
|||
|
using DM_Weight.Port;
|
|||
|
using DM_Weight.Report;
|
|||
|
using DM_Weight.Services;
|
|||
|
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.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows.Data;
|
|||
|
|
|||
|
namespace DM_Weight.ViewModels
|
|||
|
{
|
|||
|
public class CheckRecordNewWindowViewModel : BindableBase, INavigationAware, IRegionMemberLifetime
|
|||
|
{
|
|||
|
private readonly ILog logger = LogManager.GetLogger(typeof(CheckRecordNewWindowViewModel));
|
|||
|
|
|||
|
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;
|
|||
|
SqlHelperService _sqlHelperService;
|
|||
|
public CheckRecordNewWindowViewModel(IDialogService DialogService, PortUtil portUtil, IEventAggregator eventAggregator, IDialogService dialogService,SqlHelperService sqlHelperService)
|
|||
|
{
|
|||
|
_dialogService = DialogService;
|
|||
|
////this.SqlSugarHelper.Db = sqlSugarScope;
|
|||
|
_portUtil = portUtil;
|
|||
|
_eventAggregator = eventAggregator;
|
|||
|
_sqlHelperService = sqlHelperService;
|
|||
|
}
|
|||
|
public DelegateCommand DownLoadCommond
|
|||
|
{
|
|||
|
get => new DelegateCommand(() =>
|
|||
|
{
|
|||
|
GridReportUtil.PrintReportStockNew(StartDate, EndDate);
|
|||
|
});
|
|||
|
|
|||
|
//get => new DelegateCommand(() =>
|
|||
|
//{
|
|||
|
// //DialogParameters dialogParameters = new DialogParameters();
|
|||
|
// //dialogParameters.Add("orderInfo", SelectedOrder);
|
|||
|
// DialogServiceExtensions.ShowDialogHost(_dialogService, "PrintPdfView", null, DoDialogResult, "RootDialog");
|
|||
|
//});
|
|||
|
|
|||
|
}
|
|||
|
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);
|
|||
|
|
|||
|
List<CheckRecordStock> checkList =_sqlHelperService.CheckRecordInfo(StartDate, EndDate, 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();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|