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.
Aucma.Scada/Aucma.Scada.UI/viewModel/AssemblyPlan/QuantityIssuedViewModel.cs

94 lines
2.6 KiB
C#

using Aucma.Scada.Business;
using Aucma.Scada.Model.domain;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace Aucma.Scada.UI.viewModel.AssemblyPlan
{
public class QuantityIssuedViewModel : ViewModelBase
{
private AssemblyPlanBusiness assemblyPlanBusiness = AssemblyPlanBusiness.Instance;
public QuantityIssuedViewModel(ProductPlanInfo productPlanInfo)
{
PlanInfoTransmitCommand = new RelayCommand(PlanInfoTransmit);
ClearTransmitAmountCommand = new RelayCommand(ClearTransmitAmount);
KeypadButtonCommand = new RelayCommand<object>(obj => KeypadButton(obj));
CloseWindowCommand = new RelayCommand<object>(t => CloseWindow(t));
PlanInfo = productPlanInfo;
}
private ProductPlanInfo _PlanInfo = new ProductPlanInfo();
public ProductPlanInfo PlanInfo
{
get { return _PlanInfo; }
set { _PlanInfo = value; RaisePropertyChanged(nameof(PlanInfo)); }
}
private string _TransmitAmount = string.Empty;
public string TransmitAmount
{
get { return _TransmitAmount; }
set { _TransmitAmount = value; RaisePropertyChanged(nameof(TransmitAmount)); }
}
public RelayCommand PlanInfoTransmitCommand { get; set; }
public RelayCommand ClearTransmitAmountCommand { get; set; }
public RelayCommand<object> KeypadButtonCommand { get;set; }
public RelayCommand<object> CloseWindowCommand { get; set; }
private void PlanInfoTransmit()
{
bool result = assemblyPlanBusiness.PlanTransmitByProductPlan(_PlanInfo.planCode, Convert.ToInt32(_TransmitAmount));
if (result)
{
MessageBox.Show("执行计划维护成功");
}
}
private void ClearTransmitAmount()
{
string amount = _TransmitAmount.ToString();
if(amount.Length > 0)
{
TransmitAmount = amount.Substring(0, amount.Length - 1);
}
}
private void KeypadButton(object obj)
{
var info = obj as string;
TransmitAmount += info;
}
private void CloseWindow(object parameter)
{
var window = parameter as Window;
if (window != null)
{
window.Close();
}
}
}
}