Files
wcs/货架标准上位机/ViewModels/ShelfInfoAddOrUpdateViewModel.cs
2025-01-16 19:45:09 +08:00

129 lines
3.3 KiB
C#

using Ping9719.WpfEx.Mvvm;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using WCS.Model;
using WCS.Model.ApiModel.Home;
using WCS.Model.ApiModel.StoreInfo;
using .Tool;
namespace .ViewModel
{
public class ShelfInfoAddOrUpdateViewModel : BindableBase
{
#region Property
public ShelfInfoAddOrUpdateViewModel()
{
ShelfTypeItems = GetBaseData.GetShelfType();
if (ShelfTypeItems != null && ShelfTypeItems.Count > 0)
SelectedShelfTypeItem = ShelfTypeItems.First();
}
public void SetValues(ShelfInfoModel shelfInfoModel)
{
if (shelfInfoModel == null)
{
shelfInfoModel = new ShelfInfoModel();
}
ShelfId = shelfInfoModel.Id;
var item = ShelfTypeItems.FirstOrDefault(t => t.Id == shelfInfoModel.ShelfTypeId);
if (item != null)
{
SelectedShelfTypeItem = item;
}
ShelfCode = shelfInfoModel.ShelfCode;
ShelfSize = shelfInfoModel.ShelfSize;
Remark = shelfInfoModel.Remark;
IsEnable = shelfInfoModel.IsEnable;
}
public ShelfInfoModel GetValues()
{
return new ShelfInfoModel()
{
Id = ShelfId,
ShelfTypeId = SelectedShelfTypeItem.Id,
ShelfTypeName = SelectedShelfTypeItem.ShelfTypeName,
ShelfCode = ShelfCode,
ShelfSize = ShelfSize,
Remark = Remark,
IsEnable = IsEnable,
};
}
private List<OrderTypeModel> shelfTypeItems;
public List<OrderTypeModel> ShelfTypeItems
{
get { return shelfTypeItems; }
set
{
SetProperty(ref shelfTypeItems, value);
}
}
private OrderTypeModel selectedShelfTypeItem;
public OrderTypeModel SelectedShelfTypeItem
{
get { return selectedShelfTypeItem; }
set
{
SetProperty(ref selectedShelfTypeItem, value);
}
}
private int shelfId;
public int ShelfId
{
get { return shelfId; }
set
{
SetProperty(ref shelfId, value);
}
}
private string shelfCode;
public string ShelfCode
{
get { return shelfCode; }
set
{
SetProperty(ref shelfCode, value);
}
}
private string shelfSize;
public string ShelfSize
{
get { return shelfSize; }
set
{
SetProperty(ref shelfSize, value);
}
}
private string remark;
public string Remark
{
get { return remark; }
set
{
SetProperty(ref remark, value);
}
}
private bool isEnable;
public bool IsEnable
{
get { return isEnable; }
set
{
SetProperty(ref isEnable, value);
}
}
#endregion
}
}