using OxyPlot.Axes; using OxyPlot.Legends; using OxyPlot.Series; using OxyPlot; using Prism.Commands; using Prism.Ioc; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Prism.Mvvm; using Repository; using Repository.Entiies; using System.Data; using System.Windows.Forms; using TickStyle = OxyPlot.Axes.TickStyle; using AutoMapper; using HandyControl.Data; namespace LogoForceTestApp.Modules.MainModule.ViewModels { public class StatementPageViewModel : BindableBase { public List InfNew { get; set; } private readonly IMapper _mapper; private readonly List _infNew; public int PageIndex { get; set; } = 1; public int MaxCount { get; set; } = 1; public int PageCount { get; set; } = 20; public DateTime SelectedStartDate { get; set; } public DateTime SelectedEndDate { get; set; } public DelegateCommand> PageUpdatedCmd => new(PageUpdated); private readonly IRepository repository; public string ProCode { get; set; } public DelegateCommand QueryCommand { get; set; } public StatementPageViewModel(IMapper mapper, IRepository repository) { SelectedStartDate = DateTime.Today; SelectedEndDate = DateTime.Today; InfNew = new List(); _infNew = new List(); _mapper = mapper; // QueryCommand = new DelegateCommand(query); this.repository = repository; } /// /// 页码改变 /// private void PageUpdated(FunctionEventArgs info) { InfNew = _infNew.Skip((info.Info - 1) * PageCount).Take(PageCount).Reverse().ToList(); } public double GeneralTime { get; set; } public int AllNumber { get; set; } string prono; private void query() { try { if (SelectedEndDate < SelectedStartDate || SelectedStartDate == default) { MessageBox.Show("请选择正确的日期", "提示"); return; } _infNew.Clear(); var endTime = SelectedEndDate.AddDays(1); if (ProCode != "") { var res = repository.GetAllQuery(c => c.ProCode == ProCode && c.CreateTime >= SelectedStartDate && c.CreateTime <= endTime); if (res[0].ProNo != "") { prono = res[0].ProNo; } else { prono = res[1].ProNo; } var list = repository.GetAllQuery(c => c.ProNo == prono && c.CreateTime >= SelectedStartDate && c.CreateTime <= endTime); list.Reverse(); var dtos = _mapper.Map>(list); _infNew.AddRange(dtos); } InfNew = _infNew.Take(PageCount).ToList(); MaxCount = _infNew.Count / PageCount + 1; } catch (Exception ex) { MessageBox.Show("StatementPage:" + ex.Message); } } } }