using MudBlazor;
|
using static HotelPms.Client.Blazor.Util.SystemEnum;
|
using System.Xml.Linq;
|
using System.Text.Json.Serialization;
|
using HotelPms.Data.UseInfo;
|
using HotelPms.Share.Util;
|
using Microsoft.JSInterop;
|
using HotelPms.Client.Blazor.Util;
|
using Microsoft.VisualBasic;
|
using System.Globalization;
|
|
namespace HotelPms.Client.Blazor.Models
|
{
|
/// <summary>
|
/// 売上伝票入力情報
|
/// </summary>
|
public class SaleInputRow : EditRow
|
{
|
public enum ColType : int
|
{
|
/// <summary>
|
/// 部屋タイプ(ReadOnly 全部選択時表示・部屋選択時非表示)
|
/// </summary>
|
RoomType = 0,
|
/// <summary>
|
/// 部屋番号(ReadOnly 全部選択時表示・部屋選択時非表示)
|
/// </summary>
|
RoomID,
|
/// <summary>
|
/// 科目名称
|
/// </summary>
|
ItemName,
|
/// <summary>
|
/// 人数
|
/// </summary>
|
PersonCount,
|
/// <summary>
|
/// 内女
|
/// </summary>
|
Woman,
|
/// <summary>
|
/// 単価
|
/// </summary>
|
UnitPrice,
|
/// <summary>
|
/// 割引(Endキーより、理由や%設定)
|
/// </summary>
|
DiscountSummary,
|
/// <summary>
|
/// 合計金額
|
/// </summary>
|
TotalSummary,
|
/// <summary>
|
/// 集計日
|
/// </summary>
|
SumDate,
|
/// <summary>
|
/// 頁
|
/// </summary>
|
Page,
|
/// <summary>
|
/// 詳細(ボタン)
|
/// </summary>
|
Detail,
|
/// <summary>
|
/// ソートキー(非表示)
|
/// </summary>
|
SortKey,
|
}
|
public SaleInputRow()
|
{
|
Cells.Add(new ViewModel.ValidField { Name = ColType.RoomType.ToString() });
|
Cells.Add(new ViewModel.ValidField { Name = ColType.RoomID.ToString() });
|
Cells.Add(new ViewModel.ValidField { Name = ColType.ItemName.ToString(), MaxLenth = 50, ShowStyle = EShowStyle.ShowList });
|
Cells.Add(new ViewModel.ValidField { Name = ColType.PersonCount.ToString(), MaxLenth = 3, InputChar = EInputChar.Num });
|
Cells.Add(new ViewModel.ValidField { Name = ColType.Woman.ToString(), MaxLenth = 3, InputChar = EInputChar.Num });
|
Cells.Add(new ViewModel.ValidField { Name = ColType.UnitPrice.ToString(), MaxLenth = 19, InputChar = EInputChar.Num });
|
Cells.Add(new ViewModel.ValidField { Name = ColType.DiscountSummary.ToString(), MaxLenth = 19, InputChar = EInputChar.Num, ShowStyle = EShowStyle.ShowList });
|
Cells.Add(new ViewModel.ValidField { Name = ColType.TotalSummary.ToString(), MaxLenth = 19, InputChar = EInputChar.Num });
|
Cells.Add(new ViewModel.ValidField { Name = ColType.SumDate.ToString(), MaxLenth = 10, InputChar = EInputChar.Num | EInputChar.Slash, ShowStyle = EShowStyle.ShowList });
|
Cells.Add(new ViewModel.ValidField { Name = ColType.Page.ToString(), MaxLenth = 3, InputChar = EInputChar.Num });
|
Cells.Add(new ViewModel.ValidField { Name = ColType.Detail.ToString(), MaxLenth = 3, InputChar = EInputChar.Num });
|
Cells.Add(new ViewModel.ValidField { Name = ColType.SortKey.ToString(), Disabled = true });
|
}
|
|
protected override void Dispose(bool disposing)
|
{
|
if (!disposing)
|
{
|
base.Dispose(false);
|
}
|
}
|
|
/// <summary>
|
/// 関連伝票情報
|
/// </summary>
|
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
|
public List<Sale> DataList { get; set; } = new List<Sale>();
|
|
/// <summary>
|
/// 一番若い伝票情報返す
|
/// </summary>
|
/// <returns></returns>
|
public Sale GetSale()
|
{
|
if (DataList.Count == 0) { return null; }
|
return DataList[0];
|
}
|
|
/// <summary>
|
/// 値変更あり
|
/// </summary>
|
/// <param name="inputText"></param>
|
/// <returns></returns>
|
public override bool IsValueChanged(int index, string inputText)
|
{
|
if (index == (int)ColType.ItemName)
|
{
|
if (DataList.Count == 0) { return inputText.Length > 0; } //新規行の場合、入力したら、変更あり
|
return inputText.CompareTo(DataList[0].ItemName) != 0;
|
}
|
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(SaleInputRow.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.ItemName)
|
{
|
return DataList.Count == 0 ? string.Empty : DataList[0].ItemName;
|
}
|
else
|
{
|
return string.Empty;
|
}
|
}
|
|
public void SetItem(HotelPms.Data.Master.Item item)
|
{
|
foreach (Sale sale in DataList)
|
{
|
sale.ItemID = item.ID;
|
sale.ItemName = item.Name;
|
sale.ItemKind = item.Kind;
|
}
|
}
|
|
public void SetDataField(int index, string inputText)
|
{
|
if (index == (int)ColType.ItemName)
|
{
|
foreach (Sale item in DataList)
|
{
|
item.ItemName = inputText;
|
}
|
}
|
else
|
{
|
}
|
}
|
|
/// <summary>
|
/// 売上伝票より表示データの作成
|
/// </summary>
|
/// <param name=""></param>
|
public async Task<bool> Add(Data.UseInfo.Sale item)
|
{
|
try
|
{
|
DataList.Add(item);
|
SetCellText((int)ColType.RoomType, await MasterCore.GetRoomTypeName((item.Parent as Data.UseInfo.UseRoom).RoomTypeID));
|
SetCellText((int)ColType.RoomID, (item.Parent as Data.UseInfo.UseRoom).RoomID.ToString());
|
SetCellText((int)ColType.ItemName, item.ItemName);
|
SetCellText((int)ColType.PersonCount, item.PersonCount.ToString());
|
SetCellText((int)ColType.Woman, item.InFemale.ToString());
|
SetCellText((int)ColType.UnitPrice, item.Price.ToText("N0"));
|
SetCellText((int)ColType.DiscountSummary, item.DiscountSummary.ToText("N0"));
|
SetCellText((int)ColType.TotalSummary, item.TotalSummary.ToText("N0"));
|
SetCellText((int)ColType.SumDate, item.UseDate.ToText());
|
SetCellText((int)ColType.Page, item.ReceiptPage.ToString());
|
return true;
|
}
|
catch
|
{
|
return false;
|
}
|
}
|
}
|
}
|