XiangTan_DM/DM_Weight/ViewModels/UseAccountWindowViewModel.cs

75 lines
2.2 KiB
C#

using DM_Weight.Report;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DM_Weight.ViewModels
{
public class UseAccountWindowViewModel:BindableBase
{
private DateTime? _startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
private DateTime? nowDate = 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);
}
}
}
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);
}
}
}
private string _name;
public string Name { get => _name; set { SetProperty(ref _name, value); } }
private static readonly DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public long CurrentTimeMillis()
{
return (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
}
/// <summary>
/// 导出账册
/// </summary>
public DelegateCommand DownloadAccountBook
{
get => new DelegateCommand(() =>
{
GridReportUtil.UserAccount(StartDate, EndDate, Name ?? "");
});
}
public bool KeepAlive => true;
}
}