ホテル管理システム
ogi
yesterday 1a1c8e71fcd14858f595029f089b2d4a00202b32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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)
            {
            }
        }
    }
}