You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
6.4 KiB
C#

1 year ago
using Aucma.Core.PrintTo.Models;
using Aucma.Core.PrintTo.Views;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using MaterialDesignThemes.Wpf;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.Metrics;
using System.Drawing.Imaging;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
/*
*
*
*/
1 year ago
namespace Aucma.Core.PrintTo.ViewModels
{
public partial class HomeWindowViewModel : ObservableObject
{
public HomeWindowViewModel()
{
LoadData();
}
#region 加载DataGrid数据
private void LoadData()
{
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-07", material_code = "2135556", material_name = "内胆" });
}
#endregion
#region 查询按钮
/// <summary>
/// 查询
/// </summary>
[RelayCommand]
private void QueryString(string queryStr)
{
System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
{
if (!string.IsNullOrEmpty(queryStr))
{
Datalist.Clear();
//Datalist.Add(new OrderInfo() { OrderTime = "2023-10-06", material_code = "123456", material_name = "箱体", PrintName = queryStr });
}
else
{
Datalist.Clear();
LoadData();
}
//Datalist.Insert(0, Datalist[Datalist.Count - 1]);
//Datalist.RemoveAt(Datalist.Count - 1);
}));
}
#endregion
#region 打印
/// <summary>
/// 打印
/// </summary>
[RelayCommand]
private void Print()
{
MessageBox.Show("打印");
PrintToDevView window=new PrintToDevView();
window.ShowDialog();
}
#endregion
#region 重打
/// <summary>
///重打
/// </summary>
[RelayCommand]
private void Reprint()
{
MessageBox.Show("重打");
// OrderInfo info = new OrderInfo();
}
#endregion
#region 补打
/// <summary>
///补打
/// </summary>
[RelayCommand]
private void SupplementaryPrint()
{
MessageBox.Show("补打");
// OrderInfo info = new OrderInfo();
}
#endregion
#region 续打
/// <summary>
///续打
/// </summary>
[RelayCommand]
private void ContinuedPrint()
{
MessageBox.Show("续打");
// OrderInfo info = new OrderInfo();
}
#endregion
#region 初始化datagrid
private ObservableCollection<OrderInfo> datalist = new ObservableCollection<OrderInfo>();
public ObservableCollection<OrderInfo> Datalist
{
get { return datalist; }
set
{
datalist = value;
OnPropertyChanged();//属性通知
}
}
#endregion
#region 获取当前行数据 赋值到textbox
private OrderInfo selectedCells;
public OrderInfo SelectedCells
{
get { return selectedCells; }
set
{
selectedCells = value;
SetProperty(ref selectedCells, value);
}
}
#endregion
}
}