|
|
|
|
using GalaSoft.MvvmLight.Command;
|
|
|
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.IdentityModel.Protocols;
|
|
|
|
|
using SlnMesnac.Business.business;
|
|
|
|
|
using SlnMesnac.Model.domain;
|
|
|
|
|
using SlnMesnac.Repository.service;
|
|
|
|
|
using SlnMesnac.WPF.Views;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
|
|
|
|
namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
{
|
|
|
|
|
public class ExecuteViewModel : INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
public ObservableCollection<string> OrderCodeComboBoxItems { get; set; }
|
|
|
|
|
public ObservableCollection<string> PlanCodeComboBoxItems { get; set; }
|
|
|
|
|
public ObservableCollection<string> MaterialNameComboBoxItems { get; set; }
|
|
|
|
|
private ProdPlanInfoService _prodPlanInfoService;
|
|
|
|
|
private List<ProdPLanInfo> prodPlanInfos;
|
|
|
|
|
private string StationCode;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 按钮文字转换事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换班命令
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ICommand HandoverCommand { get; private set; }
|
|
|
|
|
|
|
|
|
|
public ExecuteViewModel()
|
|
|
|
|
{
|
|
|
|
|
_prodPlanInfoService = App.ServiceProvider.GetService<ProdPlanInfoService>();
|
|
|
|
|
// 读取appsettings.json配置文件
|
|
|
|
|
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
|
|
|
|
.SetBasePath(System.AppContext.BaseDirectory)
|
|
|
|
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
|
|
|
|
|
IConfigurationRoot configuration = configurationBuilder.Build();
|
|
|
|
|
// 从配置文件中获取ProductLineNameTextBlock的值
|
|
|
|
|
stationTextBlock = configuration.GetSection("AppConfig")["ProductLineName"];
|
|
|
|
|
StationCode = configuration.GetSection("AppConfig")["ProductLineCode"];
|
|
|
|
|
HandoverCommand = new RelayCommand(Handover);
|
|
|
|
|
SearchCommand = new RelayCommand(Search);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 换班弹窗
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Handover()
|
|
|
|
|
{
|
|
|
|
|
var handOverWin = new HandOverWin();
|
|
|
|
|
handOverWin.WindowStartupLocation = WindowStartupLocation.CenterScreen; // 让窗体出现在屏幕中央
|
|
|
|
|
|
|
|
|
|
handOverWin.ShowDialog();//窗体出现后禁止后面的用户控件
|
|
|
|
|
//其他操作
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检索命令
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ICommand SearchCommand { get; private set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检索事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Search()
|
|
|
|
|
{
|
|
|
|
|
// 在这里执行其他操作,可以通过InputText获取用户输入的信息
|
|
|
|
|
Console.WriteLine("用户输入的信息:" + OrderCodeTextBox + PlanCodeTextBox + MaterialCodeTextBox);
|
|
|
|
|
//ProductLineNameTextBlock = ConfigurationManager.AppSettings["ProductLineNameTextBlock"];
|
|
|
|
|
List<ProdPLanInfo> list = _prodPlanInfoService.GetRecordStaffAttendancesByConditions(OrderCodeTextBox, PlanCodeTextBox, MaterialCodeTextBox, StationCode);
|
|
|
|
|
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
|
|
|
|
|
{
|
|
|
|
|
ProdPLanInfoDataGrid.Clear();
|
|
|
|
|
list.ForEach(item =>
|
|
|
|
|
{
|
|
|
|
|
ProdPLanInfoDataGrid.Add(item);
|
|
|
|
|
});
|
|
|
|
|
}));
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 订单
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string orderCodeTextBox;
|
|
|
|
|
public string OrderCodeTextBox
|
|
|
|
|
{
|
|
|
|
|
get { return orderCodeTextBox; }
|
|
|
|
|
set { orderCodeTextBox = value; OnPropertyChanged("OrderCodeTextBox"); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工单
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string planCodeTextBox;
|
|
|
|
|
public string PlanCodeTextBox
|
|
|
|
|
{
|
|
|
|
|
get { return planCodeTextBox; }
|
|
|
|
|
set { planCodeTextBox = value; OnPropertyChanged("PlanCodeTextBox"); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 原料
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string materialCodeTextBox;
|
|
|
|
|
public string MaterialCodeTextBox
|
|
|
|
|
{
|
|
|
|
|
get { return materialCodeTextBox; }
|
|
|
|
|
set { materialCodeTextBox = value; OnPropertyChanged("MaterialNameTextBox"); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工位
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string stationTextBlock;
|
|
|
|
|
public string StationTextBox
|
|
|
|
|
{
|
|
|
|
|
get { return stationTextBlock; }
|
|
|
|
|
set { stationTextBlock = value; new PropertyChangedEventArgs(nameof(StationTextBox)); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// DataGrid
|
|
|
|
|
/// </summary>
|
|
|
|
|
private ObservableCollection<ProdPLanInfo> prodPLanInfoDataGrid = new ObservableCollection<ProdPLanInfo>();
|
|
|
|
|
public ObservableCollection<ProdPLanInfo> ProdPLanInfoDataGrid
|
|
|
|
|
{
|
|
|
|
|
get { return prodPLanInfoDataGrid; }
|
|
|
|
|
set { prodPLanInfoDataGrid = value; OnPropertyChanged("ProdPLanInfoDataGrid"); }
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
|
|
|
|
{
|
|
|
|
|
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|