123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- 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<Information> InfNew { get; set; }
- private readonly IMapper _mapper;
- private readonly List<Information> _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<FunctionEventArgs<int>> 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<Information>();
- _infNew = new List<Information>();
- _mapper = mapper;
- //
- QueryCommand = new DelegateCommand(query);
- this.repository = repository;
- }
- /// <summary>
- /// 页码改变
- /// </summary>
- private void PageUpdated(FunctionEventArgs<int> 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<Information>(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<Information>(c => c.ProNo == prono && c.CreateTime >= SelectedStartDate && c.CreateTime <= endTime);
- list.Reverse();
- var dtos = _mapper.Map<List<Information>>(list);
- _infNew.AddRange(dtos);
- }
- InfNew = _infNew.Take(PageCount).ToList();
- MaxCount = _infNew.Count / PageCount + 1;
- }
- catch (Exception ex)
- {
- MessageBox.Show("StatementPage:" + ex.Message);
- }
- }
- }
- }
|