using HotelPms.Client.Blazor.Util;
|
using HotelPms.Data.UseInfo;
|
using HotelPms.Share.Util;
|
using Microsoft.AspNetCore.Components.Forms;
|
using Microsoft.JSInterop;
|
using MudBlazor;
|
using System.Text.Json.Serialization;
|
using static HotelPms.Client.Blazor.Util.SystemEnum;
|
|
namespace HotelPms.Client.Blazor.Models
|
{
|
/// <summary>
|
/// 利用日毎
|
/// 空白行が必要のため、
|
/// 全部文字列にする
|
/// </summary>
|
public class RoomTypeInputRow : EditRow
|
{
|
public enum ColType : int
|
{
|
ID = 0,
|
Name,
|
Count,
|
}
|
|
public RoomTypeInputRow()
|
{
|
Cells.Add(new ViewModel.ValidField { Name = ColType.ID.ToString(), MaxLenth = 3, InputChar = EInputChar.Num });
|
Cells.Add(new ViewModel.ValidField { Name = ColType.Name.ToString() });
|
Cells.Add(new ViewModel.ValidField { Name = ColType.Count.ToString(), MaxLenth = 3, InputChar = EInputChar.Num });
|
}
|
|
protected override void Dispose(bool disposing)
|
{
|
if (!disposing)
|
{
|
base.Dispose(false);
|
}
|
}
|
|
/// <summary>
|
/// 関連伝票情報
|
/// </summary>
|
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
|
public List<UseRoom> DataList { get; set; } = new List<UseRoom>();
|
|
/// <summary>
|
/// 値変更あり
|
/// </summary>
|
/// <param name="inputText"></param>
|
/// <returns></returns>
|
public override bool IsValueChanged(int index, string inputText)
|
{
|
if (index == (int)ColType.ID)
|
{
|
if (DataList.Count == 0) { return true; }
|
return CConvert.ToInt(inputText) != DataList[0].RoomTypeID;
|
}
|
else if (index == (int)ColType.Count)
|
{
|
return CConvert.ToInt(inputText) != DataList.Count;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
|
/// <summary>
|
/// DOMの表示値
|
/// </summary>
|
/// <param name="index"></param>
|
/// <param name="JSRuntime"></param>
|
/// <returns></returns>
|
public async Task<string> GetInputValue(int index, IJSRuntime JSRuntime)
|
{
|
return await Cells[index].Ref.GetInputValue(JSRuntime);
|
}
|
|
/// <summary>
|
/// 表示の値の復元
|
/// </summary>
|
/// <param name="index"></param>
|
public void RestoreText(ColType index)
|
{
|
SetCellText((int)index, GetDataField((int)index));
|
}
|
|
/// <summary>
|
/// データの値
|
/// </summary>
|
/// <param name="index"></param>
|
/// <returns></returns>
|
public string GetDataField(int index)
|
{
|
if (index == (int)ColType.ID)
|
{
|
return DataList.Count == 0 ? string.Empty : DataList[0].RoomTypeID.ToString();
|
}
|
else if (index == (int)ColType.Count)
|
{
|
return DataList.Count.ToString();
|
}
|
else
|
{
|
return string.Empty;
|
}
|
}
|
|
public void SetDataField(int index, string inputText)
|
{
|
if (index == (int)ColType.ID)
|
{
|
foreach(UseRoom item in DataList)
|
{
|
item.RoomTypeID = CConvert.ToInt(inputText);
|
}
|
}
|
else if (index == (int)ColType.Count)
|
{
|
}
|
}
|
}
|
}
|