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.
161 lines
5.5 KiB
C#
161 lines
5.5 KiB
C#
using Admin.Core.IService;
|
|
using Admin.Core.Model;
|
|
using Aucma.Core.BoxFoam.Models;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using CommunityToolkit.Mvvm.Messaging;
|
|
using log4net;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
|
|
namespace Aucma.Core.BoxFoam.ViewModels
|
|
{
|
|
public partial class QuantityIssuedViewModel : ObservableObject
|
|
{
|
|
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(QuantityIssuedViewModel));
|
|
private IBaseBomInfoServices _bomInfoServices;
|
|
private IBaseSpaceDetailServices _spaceDetailServices;
|
|
protected readonly IExecutePlanInfoServices? _executePlanInfoServices;
|
|
protected readonly IBoxFoamPlanServices? _boxFoamPlanServices;
|
|
#region 构造函数
|
|
public QuantityIssuedViewModel(ProductPlanInfoModel productPlanInfo, string objId)
|
|
{
|
|
_boxFoamPlanServices = App.ServiceProvider.GetService<IBoxFoamPlanServices>();
|
|
_planInfo = productPlanInfo;
|
|
_objId = objId;
|
|
}
|
|
#endregion
|
|
|
|
#region 属性
|
|
private ProductPlanInfoModel _planInfo = new ProductPlanInfoModel();
|
|
public ProductPlanInfoModel PlanInfo
|
|
{
|
|
get => _planInfo;
|
|
set => SetProperty(ref _planInfo, value);
|
|
}
|
|
private string _TransmitAmount = string.Empty;
|
|
public string TransmitAmount
|
|
{
|
|
get => _TransmitAmount;
|
|
set => SetProperty(ref _TransmitAmount, value);
|
|
}
|
|
|
|
private string _objId = string.Empty;
|
|
public string ObjId
|
|
{
|
|
get => _objId;
|
|
set => SetProperty(ref _objId, value);
|
|
}
|
|
#endregion
|
|
|
|
#region 清除
|
|
/// <summary>
|
|
/// 清除
|
|
/// </summary>
|
|
[RelayCommand]
|
|
private void ClearTransmitAmount()
|
|
{
|
|
string amount = _TransmitAmount.ToString();
|
|
if (amount.Length > 0)
|
|
{
|
|
TransmitAmount = amount.Substring(0, amount.Length - 1);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region KeypadButton
|
|
[RelayCommand]
|
|
private void KeypadButton(object obj)
|
|
{
|
|
var info = obj as string;
|
|
|
|
TransmitAmount += info;
|
|
}
|
|
#endregion
|
|
|
|
#region 关闭
|
|
/// <summary>
|
|
/// 关闭
|
|
/// </summary>
|
|
/// <param name="parameter"></param>
|
|
[RelayCommand]
|
|
private void CloseWindow(object parameter)
|
|
{
|
|
var window = parameter as Window;
|
|
if (window != null)
|
|
{
|
|
window.Close();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 保存数据
|
|
/// <summary>
|
|
/// 保存数据
|
|
/// </summary>
|
|
[RelayCommand]
|
|
private void AddPlanInfo()
|
|
{
|
|
var productPlanInfo = _planInfo;
|
|
if (_planInfo != null)
|
|
{
|
|
var task = _boxFoamPlanServices.FirstAsync(d => d.ObjId ==int.Parse(_objId)).Result;
|
|
if (task != null)
|
|
{
|
|
task.MaterialCode = _planInfo.MaterialCode;
|
|
task.MaterialName = _planInfo.MaterialName;
|
|
task.PlanAmount = Convert.ToInt32(TransmitAmount);
|
|
var result = _boxFoamPlanServices.UpdateAsync(task).Result;
|
|
if (result)
|
|
{
|
|
MessageBox.Show("任务添加成功!", "系统提醒");
|
|
WeakReferenceMessenger.Default.Send<string>("RefreshTask");//刷新任务界面
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("任务添加失败!", "系统提醒");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//task.MaterialCode = _planInfo.MaterialCode;
|
|
//task.MaterialName = _planInfo.MaterialName;
|
|
//task.PlanAmount = Convert.ToInt32(TransmitAmount);
|
|
//var plan = _boxFoamPlanServices.AddAsync(task).Result;
|
|
//if (plan)
|
|
//{
|
|
// MessageBox.Show("任务添加成功!", "系统提醒");
|
|
// WeakReferenceMessenger.Default.Send<string>("RefreshTask");//刷新任务界面
|
|
//}
|
|
//else
|
|
//{
|
|
// MessageBox.Show("任务添加失败!", "系统提醒");
|
|
//}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
BoxFoamPlan plan = new BoxFoamPlan();
|
|
plan.MaterialCode = _planInfo.MaterialCode;
|
|
plan.MaterialName = _planInfo.MaterialName;
|
|
plan.PlanAmount = Convert.ToInt32(TransmitAmount);
|
|
var result = _boxFoamPlanServices.AddAsync(plan).Result;
|
|
if (result > 0)
|
|
{
|
|
MessageBox.Show("任务添加成功!", "系统提醒");
|
|
WeakReferenceMessenger.Default.Send<string>("RefreshTask");//刷新任务界面
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("任务添加失败!", "系统提醒");
|
|
}
|
|
MessageBox.Show("任务添加失败,加载为空", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|