165 lines
4.2 KiB
C#
165 lines
4.2 KiB
C#
using Community;
|
|
using DAL;
|
|
using Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ViewModel
|
|
{
|
|
/// <summary>
|
|
/// ERP连接管理类
|
|
/// </summary>
|
|
public class ERPManageVM : NotificationObject
|
|
{
|
|
MainWindowDAL dal { get; set; }
|
|
|
|
#region ERP连接对象
|
|
private ERP_ParameterClass eRP;
|
|
/// <summary>
|
|
/// ERP连接对象
|
|
/// </summary>
|
|
public ERP_ParameterClass ERP
|
|
{
|
|
get { return eRP; }
|
|
set
|
|
{
|
|
eRP = value;
|
|
RaisePropertyChanged("ERP");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 验证返回的信息
|
|
private MesReturnValue mesReturnInfo;
|
|
|
|
/// <summary>
|
|
/// 验证返回的信息
|
|
/// </summary>
|
|
public MesReturnValue MesReturnInfo
|
|
{
|
|
get { return mesReturnInfo; }
|
|
set
|
|
{
|
|
mesReturnInfo = value;
|
|
RaisePropertyChanged("MesReturnInfo");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 数据上传信息
|
|
private DataUpload upDataInfo;
|
|
/// <summary>
|
|
/// 数据上传信息
|
|
/// </summary>
|
|
public DataUpload UpDataInfo
|
|
{
|
|
get { return upDataInfo; }
|
|
set
|
|
{
|
|
upDataInfo = value;
|
|
RaisePropertyChanged("UpDataInfo");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 各方法
|
|
|
|
/// <summary>
|
|
/// 连接测试
|
|
/// </summary>
|
|
public DelegateCommand ConnTestCommand { get; set; }
|
|
/// <summary>
|
|
/// 数据上传测试
|
|
/// </summary>
|
|
public DelegateCommand DataUoloadCommand { get; set; }
|
|
|
|
/// <summary>
|
|
/// 保存连接参数
|
|
/// </summary>
|
|
public DelegateCommand SaveConnPerCommand { get; set; }
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// <param name="softID">软件ID</param>
|
|
public ERPManageVM(int softID, MainWindowDAL mdal)
|
|
{
|
|
dal = mdal;
|
|
ERP = dal.GetERP(softID);
|
|
|
|
UpDataInfo = new DataUpload();
|
|
|
|
ConnTestCommand = new DelegateCommand();
|
|
ConnTestCommand.ExecuteAction = new Action<object>(ConnTestEmpty);
|
|
DataUoloadCommand = new DelegateCommand();
|
|
DataUoloadCommand.ExecuteAction = new Action<object>(DataUoloadEmpty);
|
|
SaveConnPerCommand = new DelegateCommand();
|
|
SaveConnPerCommand.ExecuteAction = new Action<object>(SaveConnPer);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存连接参数
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
private void SaveConnPer(object obj)
|
|
{
|
|
ERP.State.StatuInfo = "";
|
|
if (ERP.ID < 0)
|
|
{
|
|
if (dal.AddERPPer(ERP) > 0)
|
|
{
|
|
ERP.State.StatuInfo = "保存成功";
|
|
}
|
|
else
|
|
{
|
|
ERP.State.StatuInfo = "保存失败";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (dal.UpdateERP(ERP) > 0)
|
|
{
|
|
ERP.State.StatuInfo = "更新保存成功";
|
|
}
|
|
else
|
|
{
|
|
ERP.State.StatuInfo = "更新保存失败";
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 数据上传的点击事件方法
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
private void DataUoloadEmpty(object obj)
|
|
{
|
|
if(string.IsNullOrEmpty(ERP.SnCode))
|
|
{
|
|
ERP.State.StatuInfo = "SN不能为空";
|
|
return;
|
|
}
|
|
|
|
UpDataInfo.SNList = ERP.SnCode.ToString();
|
|
UpDataInfo.WPNO = ERP.StationCode;
|
|
ERP.JsonStr = ERP.DataUoload(UpDataInfo);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 连接测试的点击事件方法
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
private void ConnTestEmpty(object obj)
|
|
{
|
|
ERP.ConnTest();
|
|
|
|
}
|
|
}
|
|
}
|