From 1a1c8e71fcd14858f595029f089b2d4a00202b32 Mon Sep 17 00:00:00 2001
From: ogi <Administrator@S-OGI-PC>
Date: Fri, 05 Dec 2025 09:24:16 +0900
Subject: [PATCH] プロジェクトファイルを追加。

---
 HotelPms.Client.Blazor/ViewModel/UseInput.cs |  755 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 755 insertions(+), 0 deletions(-)

diff --git a/HotelPms.Client.Blazor/ViewModel/UseInput.cs b/HotelPms.Client.Blazor/ViewModel/UseInput.cs
new file mode 100644
index 0000000..b192020
--- /dev/null
+++ b/HotelPms.Client.Blazor/ViewModel/UseInput.cs
@@ -0,0 +1,755 @@
+using customTypes;
+using HotelPms.Client.Blazor.Models;
+using HotelPms.Client.Blazor.Pages.UseDetail;
+using HotelPms.Client.Blazor.Shared;
+using HotelPms.Client.Blazor.Util;
+using HotelPms.Data.Common;
+using HotelPms.Data.UseInfo;
+using HotelPms.DataAccessGrpc.Client;
+using HotelPms.Share.IO;
+using HotelPms.Share.Util;
+using Microsoft.JSInterop;
+using System.ComponentModel;
+using System.Text;
+using System.Text.Json;
+using static HotelPms.Client.Blazor.Util.SystemEnum;
+
+namespace HotelPms.Client.Blazor.ViewModel;
+
+/// <summary>
+/// 利用情報詳細入力画面用
+/// </summary>
+public class UseInput : ValidModelEx
+{
+    public enum GroupKey : int
+    {
+        [Description("予約情報")]
+        Resv = 0,
+        [Description("個人情報")]
+        Person,
+        [Description("会社情報")]
+        Company,
+        [Description("その他")]
+        Other,
+        [Description("予約追加情報")]
+        ResvAdd,
+        [Description("個人追加情報")]
+        PersonAdd,
+        [Description("会社追加情報")]
+        CompanyAdd,
+        [Description("顧客追加情報")]
+        CustomerAdd,
+    }
+
+    /// <summary>
+    /// 利用情報
+    /// </summary>
+    public Data.UseInfo.Use Use { get; set; }
+
+    /// <summary>
+    /// 現在選択されている利用明細
+    /// </summary>
+    public Data.UseInfo.UseDetail UseDetail { get; set; }
+
+    /// <summary>
+    /// 現在の伝票表示区分
+    /// </summary>
+    public ESaleDispType SaleDispType { get; set; } = ESaleDispType.Normal;
+
+    /// <summary>
+    /// 現在選択されている利用日
+    /// yyyy/MM/dd
+    /// </summary>
+    public string UseDate { get; set; } = string.Empty;
+
+    /// <summary>
+    /// 現在選択されている利用日の泊数
+    /// </summary>
+    public int CurrentStay { get; set; } = 1;
+
+    /// <summary>
+    /// 部屋タイプ情報入力
+    /// </summary>
+    public IEnumerable<RoomTypeInputRow> RoomTypeList { get; set; } = new List<RoomTypeInputRow>();
+
+    private UseRoomRow m_SelUseRoomRow = null;
+
+    /// <summary>
+    /// 選択されている利用部屋
+    /// </summary>
+    public UseRoomRow SelUseRoomRow
+    {
+        get { return m_SelUseRoomRow; }
+        set
+        {
+            m_SelUseRoomRow = value;
+            EnvironmentSetting.Debug($"Change:{m_SelUseRoomRow.RoomID}");
+        }
+    }
+
+    /// <summary>
+    /// 利用部屋一覧
+    /// </summary>
+    public IEnumerable<UseRoomRow> UseRoomList { get; set; } = new List<UseRoomRow>();
+
+    /// <summary>
+    /// 伝票一覧
+    /// </summary>
+    public IEnumerable<SaleInputRow> SaleList { get; set; } = new List<SaleInputRow>();
+
+    /// <summary>
+    /// 入金一覧
+    /// </summary>
+    public IEnumerable<string> PayList { get; set; } = new List<string>();
+
+    /// <summary>
+    /// グループ毎返す
+    /// </summary>
+    /// <param name="key"></param>
+    /// <returns></returns>
+    public List<ValidField> GetGroup(GroupKey key)
+    {
+        List<ValidField> list = new List<ValidField>();
+        if (key == GroupKey.Resv) { for (int i = 0; i <= 11; i++) { list.Add(Fields[i]); } }
+        else if (key == GroupKey.Person) { for (int i = 12; i <= 19; i++) { list.Add(Fields[i]); } }
+        else if (key == GroupKey.Company) { for (int i = 20; i <= 25; i++) { list.Add(Fields[i]); } }
+        else if (key == GroupKey.Other) { for (int i = 26; i <= 32; i++) { list.Add(Fields[i]); } }
+        return list;
+    }
+
+    /// <summary>
+    /// 初期化
+    /// </summary>
+    public UseInput(IJSRuntime js) : base(js)
+    {
+        // 0 ~ 10
+        Add(new ValidField() { Name = "ResvNo", Caption = "予約番号", MaxLenth = 50, WidthUnit = 12 });
+        Add(new ValidField() { Name = "ResvType", Caption = "予約区分", Required = true, MaxLenth = 2, InputChar = EInputChar.Num, DispNameEnabled = true, ShowStyle = EShowStyle.ShowList, DispWidthUnit = 6 });
+        Add(new ValidField() { Name = "GroupType", Caption = "団体区分", Required = true, MaxLenth = 2, InputChar = EInputChar.Num, ShowStyle = EShowStyle.ShowList, DispNameEnabled = true, DispWidthUnit = 6 });
+        Add(new ValidField() { Name = "RoomID", Caption = "部屋No", MaxLenth = 7, InputChar = EInputChar.Num, WidthUnit = 5 });
+        Add(new ValidField() { Name = "SalesLoginID", Caption = "営業", MaxLenth = 7, InputChar = EInputChar.Num, ShowStyle = EShowStyle.ShowList, WidthUnit = 7, DispNameEnabled = true, DispWidthUnit = 8 });
+        Add(new ValidField() { Name = "CinDate", Caption = "チェックイン日", MaxLenth = 10, InputChar = EInputChar.Num | EInputChar.Slash, InputStyle = EInputStyle.Date });
+        Add(new ValidField() { Name = "CinTime", Caption = "到着時間", MaxLenth = 5, InputChar = EInputChar.Num | EInputChar.Colon, InputStyle = EInputStyle.Time });
+        Add(new ValidField() { Name = "Stay", Caption = "泊数", MaxLenth = 3, InputChar = EInputChar.Num, WidthUnit = 6, NewLine = true });
+        Add(new ValidField() { Name = "CoutDate", Caption = "チェックアウト日", MaxLenth = 10, InputChar = EInputChar.Num | EInputChar.Slash, InputStyle = EInputStyle.Date });
+        Add(new ValidField() { Name = "CoutTime", Caption = "出発時間", MaxLenth = 5, InputChar = EInputChar.Num | EInputChar.Colon, InputStyle = EInputStyle.Time });
+        Add(new ValidField() { Name = "GroupName", Caption = "団体名称", MaxLenth = 50 });
+        Add(new ValidField() { Name = "GroupKana", Caption = "団体カナ", MaxLenth = 50 });
+
+        // 11 ~ 18
+        Add(new ValidField() { Name = "MemberNo", Caption = "会員番号", MaxLenth = 50, WidthUnit = 12 });
+        Add(new ValidField() { Name = "Tel", Caption = "電話番号", MaxLenth = 50, InputChar = EInputChar.Num | EInputChar.Subtract, WidthUnit = 8 });
+        Add(new ValidField() { Name = "TelKind", Caption = "区分", Required = true, MaxLenth = 50, ShowStyle = EShowStyle.ShowList, ReadOnly = true, WidthUnit = 4 });
+        Add(new ValidField() { Name = "Name", Required = true, Caption = "氏名", MaxLenth = 50, WidthUnit = 12 });
+        Add(new ValidField() { Name = "Kana", Required = true, Caption = "カナ", MaxLenth = 50, WidthUnit = 12 });
+        Add(new ValidField() { Name = "ResvName", Caption = "予約者名", MaxLenth = 50, WidthUnit = 12 });
+        Add(new ValidField() { Name = "ResvKana", Caption = "カナ", MaxLenth = 50, WidthUnit = 12 });
+        Add(new ValidField() { Name = "ResvTel", Caption = "電話番号", InputChar = EInputChar.Num | EInputChar.Subtract, MaxLenth = 50, WidthUnit = 12 });
+
+        // 19 ~ 24
+        Add(new ValidField() { Name = "CorpID", Caption = "法人顧客", MaxLenth = 7, InputChar = EInputChar.Num, ShowStyle = EShowStyle.ShowList, WidthUnit = 12 });
+        Add(new ValidField() { Name = "CorpName", Caption = "会社名", MaxLenth = 50, WidthUnit = 12 });
+        Add(new ValidField() { Name = "CorpKana", Caption = "カナ", MaxLenth = 50, WidthUnit = 12 });
+        Add(new ValidField() { Name = "CorpTel", Caption = "会社電話", MaxLenth = 50, WidthUnit = 12 });
+        Add(new ValidField() { Name = "CorpFax", Caption = "会社FAX", MaxLenth = 50, WidthUnit = 12 });
+        Add(new ValidField() { Name = "ReceiptName", Caption = "宛名", MaxLenth = 50, InputChar = EInputChar.None, WidthUnit = 12 });
+
+        // 25 ~ 31
+        Add(new ValidField() { Name = "AreaID", Caption = "地域", MaxLenth = 7, InputChar = EInputChar.Num, ShowStyle = EShowStyle.ShowList, DispWidthUnit = 8, DispNameEnabled = true, WidthUnit = 12 });
+        Add(new ValidField() { Name = "CharacterType", Caption = "人物フラグ", MaxLenth = 7, InputChar = EInputChar.Num, ShowStyle = EShowStyle.ShowList, DispWidthUnit = 8, DispNameEnabled = true, WidthUnit = 12 });
+        Add(new ValidField() { Name = "CustomerRig", Caption = "顧客登録", MaxLenth = 1, InputChar = EInputChar.Num, ShowStyle = EShowStyle.ShowList, DispWidthUnit = 8, DispNameEnabled = true, WidthUnit = 12 });
+        Add(new ValidField() { Name = "AgentID", Caption = "エージェント", MaxLenth = 7, InputChar = EInputChar.Num, ShowStyle = EShowStyle.ShowList, DispWidthUnit = 8, DispNameEnabled = true, WidthUnit = 12 });
+        Add(new ValidField() { Name = "AgentBranchID", Caption = "支店", MaxLenth = 7, InputChar = EInputChar.Num, ShowStyle = EShowStyle.ShowList, DispWidthUnit = 8, DispNameEnabled = true, WidthUnit = 12 });
+        Add(new ValidField() { Name = "PlanID", Caption = "プラン", MaxLenth = 7, InputChar = EInputChar.Num, ShowStyle = EShowStyle.ShowList, DispWidthUnit = 8, DispNameEnabled = true, WidthUnit = 12 });
+        Add(new ValidField() { Name = "RoomAssign", Caption = "部屋指定", MaxLenth = 1, InputChar = EInputChar.Num, ShowStyle = EShowStyle.ShowList, DispWidthUnit = 8, DispNameEnabled = true, WidthUnit = 12 });
+
+        // 予約追加情報(自由集計)
+
+        // 個人追加情報
+        Add(new ValidField() { Name = "ZipCode", Caption = "郵便番号", MaxLenth = 50, InputChar = EInputChar.None });
+        Add(new ValidField() { Name = "Prefecture", Caption = "都道府県", MaxLenth = 20, InputChar = EInputChar.None });
+        Add(new ValidField() { Name = "Address2", Caption = "市区町村", MaxLenth = 50, InputChar = EInputChar.None });
+        Add(new ValidField() { Name = "Address3", Caption = "町域", MaxLenth = 50, InputChar = EInputChar.None });
+        Add(new ValidField() { Name = "Address4", Caption = "番地", MaxLenth = 100, InputChar = EInputChar.None });
+        Add(new ValidField() { Name = "Mail", Caption = "メール", MaxLenth = 100, InputChar = EInputChar.None });
+        Add(new ValidField() { Name = "PassportNo", Caption = "パスポート", MaxLenth = 50, InputChar = EInputChar.None });
+        Add(new ValidField() { Name = "Sex", Caption = "性別", MaxLenth = 2, InputChar = EInputChar.Num });
+        Add(new ValidField() { Name = "BirthDay", Caption = "誕生日", MaxLenth = 10, InputChar = EInputChar.Num | EInputChar.Slash, InputStyle = EInputStyle.Date });
+        Add(new ValidField() { Name = "Anniversary", Caption = "記念日", MaxLenth = 10, InputChar = EInputChar.Num | EInputChar.Slash, InputStyle = EInputStyle.Date });
+
+        // 会社追加情報
+        //Add(new ValidField() { Name = "ResvTel", Caption = "所属", MaxLenth = 50 });
+        //Add(new ValidField() { Name = "ResvTel", Caption = "役職", MaxLenth = 50 });
+        Add(new ValidField() { Name = "CorpZipCode", Caption = "法人郵便番号", MaxLenth = 50, InputChar = EInputChar.None });
+        Add(new ValidField() { Name = "CorpPrefecture", Caption = "都道府県", MaxLenth = 20, InputChar = EInputChar.None });
+        Add(new ValidField() { Name = "CorpAddress2", Caption = "市区町村", MaxLenth = 50, InputChar = EInputChar.None });
+        Add(new ValidField() { Name = "CorpAddress3", Caption = "町域", MaxLenth = 50, InputChar = EInputChar.None });
+        Add(new ValidField() { Name = "CorpAddress4", Caption = "番地", MaxLenth = 100, InputChar = EInputChar.None });
+        Add(new ValidField() { Name = "CorpMemo", Caption = "法人備考", MaxLenth = 500, InputChar = EInputChar.None });
+
+        // 顧客追加情報 (顧客自由集計 GroupID使用)
+
+
+        //追加電話番号はGridリストへ
+
+        // 複数想定(リスト)
+        Add(new ValidField() { Name = "Memo", Caption = "メモ", MaxLenth = 1000 });
+        Add(new ValidField() { Name = "Remark", Caption = "備考", MaxLenth = 1000 });
+    }
+
+    /// <summary>
+    /// 画面初期化
+    /// </summary>
+    public void InitGrid()
+    {
+        InitRoomTypeInput();
+    }
+
+    public async void InitRoomTypeInput()
+    {
+        List<RoomTypeInputRow> list = RoomTypeList as List<RoomTypeInputRow>;
+        List<UseRoomRow> roomList = UseRoomList as  List<UseRoomRow>;
+        
+        SortedDictionary<int, RoomTypeInputRow> typeDt = new SortedDictionary<int, RoomTypeInputRow>();  //まとめる
+        //UseRoomより取得する
+        List<Data.UseInfo.UseRoom> useRoomList = Use.GetUseRoomList(UseDate);
+        foreach (var item in useRoomList)
+        {
+            RoomTypeInputRow row;
+            if (!typeDt.TryGetValue(item.RoomTypeID, out row))
+            {
+                row = new();
+                row.SetCellText((int)RoomTypeInputRow.ColType.ID, item.RoomTypeID.ToString());
+                row.SetCellText((int)RoomTypeInputRow.ColType.Name, await MasterCore.GetRoomTypeName(item.RoomTypeID));
+                row.SetCellText((int)RoomTypeInputRow.ColType.Count, "0");
+                typeDt.Add(item.RoomTypeID, row);
+            }
+            row.SetCellText((int)RoomTypeInputRow.ColType.Count, CConvert.ToString(CConvert.ToInt(row.GetCellText((int)RoomTypeInputRow.ColType.Count)) + 1));
+            row.DataList.Add(item);
+
+            //部屋一覧
+            UseRoomRow roomRow = new UseRoomRow
+            {
+                RoomID = item.RoomID.ToString(),
+                Name = item.UseAlloList.Count == 0 ? string.Empty : item.UseAlloList[0].Person?.Name,
+                Representative = true,
+                UseStatus = (item.Parent as Data.UseInfo.UseDetail).UseStatus.ToString(),
+            };
+            roomRow.UseRoom = item;
+            roomList.Add(roomRow);
+        }
+
+        //常に空行追加
+        list.Add(new());
+
+        //部屋一覧初期選択データ
+        if (roomList.Count > 0) 
+        {
+            if (roomList.Count > 1)
+            {
+                UseRoomRow roomRow = new UseRoomRow
+                {
+                    RoomID = "",
+                    Name = "(一括)",
+                    Representative = false,
+                    UseStatus = "",
+                };
+                roomRow.UseRoom = roomList[0].UseRoom;
+                roomList.Insert(0, roomRow);
+            }
+
+            SelUseRoomRow = roomList[0]; 
+        }
+    }
+
+    /// <summary>
+    /// 入力項目→Data
+    /// </summary>
+    /// <param name="field"></param>
+    public void SetDataField(ValidField field)
+    {
+        #region 利用情報
+
+        if (field.Name == "ResvType")
+        {
+            Use.ResvType = CConvert.ToInt(field.Text);
+        }
+        else if (field.Name == "GroupType")
+        {
+            Use.GroupType = CConvert.ToInt(field.Text);
+        }
+        else if (field.Name == "GroupName")
+        {
+            Use.GroupName = field.Text;
+        }
+        else if (field.Name == "GroupKana")
+        {
+            Use.GroupKana = field.Text;
+        }
+
+        #endregion
+
+        #region 利用明細情報
+
+        if (UseDetail != null)
+        {
+            if (field.Name == "ResvNo")
+            {
+                UseDetail.ResvNo = field.Text;
+            }
+            else if (field.Name == "SalesLoginID")
+            {
+                UseDetail.SalesLoginID = CConvert.ToInt(field.Text);
+            }
+            else if (field.Name == "CinDate")
+            {
+                UseDetail.CinDate = new customTypes.Date(field.Text);
+            }
+            else if (field.Name == "CinTime")
+            {
+                UseDetail.CinTime = CConvert.ToInt(field.Text.Replace(":", string.Empty));
+            }
+            else if (field.Name == "Stay")
+            {
+                UseDetail.Stay = CConvert.ToInt(field.Text);
+            }
+            else if (field.Name == "CoutDate")
+            {
+                UseDetail.CoutDate = new customTypes.Date(field.Text);
+            }
+            else if (field.Name == "CoutTime")
+            {
+                UseDetail.CoutTime = CConvert.ToInt(field.Text.Replace(":", string.Empty));
+            }
+        }
+
+        #endregion
+
+        if (field.Name == "MemberNo")
+        {
+            //Use.MemberNo = field.Text;
+        }
+        else if (field.Name == "Tel")
+        {
+            //Use.Tel = field.Text;
+        }
+        else if (field.Name == "TelKind")
+        {
+            //Use.TelKind = field.Text;
+        }
+        else if (field.Name == "Name")
+        {
+            //Use.Name = field.Text;
+        }
+        else if (field.Name == "Kana")
+        {
+            //Use.Kana = field.Text;
+        }
+        else if (field.Name == "ResvName")
+        {
+            //Use.ResvName = field.Text;
+        }
+        else if (field.Name == "ResvKana")
+        {
+            //Use.ResvKana = field.Text;
+        }
+        else if (field.Name == "ResvTel")
+        {
+            //Use.ResvTel = field.Text;
+        }
+        else if (field.Name == "CorpID")
+        {
+            //Use.CorpID = CConvert.ToInt(field.Text);
+        }
+        else if (field.Name == "CorpName")
+        {
+            //Use.CorpName = field.Text;
+        }
+        else if (field.Name == "CorpKana")
+        {
+            //Use.CorpKana = field.Text;
+        }
+        else if (field.Name == "CorpTel")
+        {
+            //Use.CorpTel = field.Text;
+        }
+        else if (field.Name == "CorpFax")
+        {
+            //Use.CorpFax = field.Text;
+        }
+        else if (field.Name == "ReceiptName")
+        {
+            //Use.ReceiptName = field.Text;
+        }
+        else if (field.Name == "AreaID")
+        {
+            //Use.AreaID = CConvert.ToInt(field.Text);
+        }
+        else if (field.Name == "CharacterType")
+        {
+            //Use.CharacterType = CConvert.ToInt(field.Text);
+        }
+        else if (field.Name == "CustomerRig")
+        {
+            //Use.CustomerRig = CConvert.ToInt(field.Text);
+        }
+        else if (field.Name == "AgentID")
+        {
+            //Use.AgentID = CConvert.ToInt(field.Text);
+        }
+        else if (field.Name == "AgentBranchID")
+        {
+            //Use.AgentBranchID = CConvert.ToInt(field.Text);
+        }
+        else if (field.Name == "PlanID")
+        {
+            //Use.PlanID = CConvert.ToInt(field.Text);
+        }
+        else if (field.Name == "RoomAssign")
+        {
+            //Use.RoomAssign = CConvert.ToInt(field.Text);
+        }
+        else if (field.Name == "ZipCode")
+        {
+            //Use.ZipCode = field.Text;
+        }
+        else if (field.Name == "Prefecture")
+        {
+            //Use.Prefecture = field.Text;
+        }
+        else if (field.Name == "Address2")
+        {
+            //Use.Address2 = field.Text;
+        }
+        else if (field.Name == "Address3")
+        {
+            //Use.Address3 = field.Text;
+        }
+        else if (field.Name == "Address4")
+        {
+            //Use.Address4 = field.Text;
+        }
+        else if (field.Name == "Mail")
+        {
+            //Use.Mail = field.Text;
+        }
+        else if (field.Name == "PassportNo")
+        {
+            //Use.PassportNo = field.Text;
+        }
+        else if (field.Name == "Sex")
+        {
+            //Use.Sex = CConvert.ToInt(field.Text);
+        }
+        else if (field.Name == "BirthDay")
+        {
+            //Use.BirthDay = field.Text;
+        }
+        else if (field.Name == "Anniversary")
+        {
+            //Use.Anniversary = field.Text;
+        }
+        else if (field.Name == "CorpZipCode")
+        {
+            //Use.CorpZipCode = field.Text;
+        }
+        else if (field.Name == "CorpPrefecture")
+        {
+            //Use.CorpPrefecture = field.Text;
+        }
+        else if (field.Name == "CorpAddress2")
+        {
+            //Use.CorpAddress2 = field.Text;
+        }
+        else if (field.Name == "CorpAddress3")
+        {
+            //Use.CorpAddress3 = field.Text;
+        }
+        else if (field.Name == "CorpAddress4")
+        {
+            //Use.CorpAddress4 = field.Text;
+        }
+        else if (field.Name == "CorpMemo")
+        {
+            //Use.CorpMemo = field.Text;
+        }
+        else if (field.Name == "Memo")
+        {
+            //Use.Memo = field.Text;
+        }
+        else if (field.Name == "Remark")
+        {
+            //Use.Remark = field.Text;
+        }
+    }
+
+    /// <summary>
+    /// 現在表示されている利用明細を画面へ表示する
+    /// </summary>
+    public void SetUseDetailToForm()
+    {
+        //利用情報
+        SetField("ResvType", Use.ResvType.ToString(), CConvert.GetEnumDescription<EResvType>(Use.ResvType));
+        SetField("GroupType", Use.GroupType.ToString(), CConvert.GetEnumDescription<EGroupType>(Use.GroupType));
+        SetField("GroupName", Use.GroupName);
+        SetField("GroupKana", Use.GroupKana);
+
+        //利用明細
+        SetField("ResvNo", UseDetail.ResvNo.ToString());        
+        SetField("SalesLoginID", UseDetail.SalesLoginID.ToString(), string.Empty);
+        SetField("CinDate", UseDetail.CinDate.ToText());
+        SetField("CinTime", CConvert.ToTime(UseDetail.CinTime));
+        SetField("Stay", UseDetail.Stay.ToString());
+        SetField("CoutDate", UseDetail.CoutDate.ToText());
+        SetField("CoutTime", CConvert.ToTime(UseDetail.CoutTime));
+
+        if (UseDetail.UseRoomList.Count > 0) 
+        {
+            HotelPms.Data.UseInfo.UseRoom useRoom = UseDetail.UseRoomList[0];
+            SetField("RoomID", useRoom.RoomID.ToString());
+
+            //利用者特定
+            if (useRoom.UseAlloList.Count > 0 && useRoom.UseAlloList[0].Person != null)
+            {
+                HotelPms.Data.UseInfo.UsePerson usePerson = useRoom.UseAlloList[0].Person;
+                SetField("MemberNo", usePerson.MemberNo);
+                SetField("Name", usePerson.Name);
+                SetField("Kana", usePerson.Kana);
+                SetField("ReceiptName", usePerson.ReceiptName);
+                SetField("CorpID", usePerson.CorpID.ToString());
+                SetField("CorpName", usePerson.CorpName);
+                SetField("CorpKana", usePerson.CorpKana);
+
+                string tel = string.Empty;
+                int telKind = 0;                
+                string corpTel = string.Empty;
+                string corpFax = string.Empty;
+                if (usePerson.TelList.Count > 0)
+                {
+                    foreach (HotelPms.Data.UseInfo.UsePersonTel personTel in usePerson.TelList)
+                    {
+                        if ((personTel.Kind == (int)ETelKind.Tel || personTel.Kind == (int)ETelKind.Mobile) && tel.Length == 0)
+                        {
+                            tel = personTel.Tel;
+                            telKind = personTel.Kind;   
+                        }
+                        else if (personTel.Kind == (int)ETelKind.CorpTel && corpTel.Length == 0)
+                        {
+                            corpTel = personTel.Tel;
+                        }
+                        else if (personTel.Kind == (int)ETelKind.CorpFax && corpFax.Length == 0)
+                        {
+                            corpFax = personTel.Tel;
+                        }
+                    }
+                }
+
+                SetField("Tel", tel);
+                if (tel.Length == 0)
+                {
+                    SetField("TelKind", string.Empty, string.Empty);
+                }
+                else
+                {
+                    SetField("TelKind", telKind.ToString(), ((ETelKind)telKind).ToDescription());
+                }
+                SetField("CorpTel", corpTel);
+                SetField("CorpFax", corpFax);
+            }
+        }
+
+        //予約者情報
+        if (UseDetail.ResvPerson != null)
+        {
+            SetField("ResvName", UseDetail.ResvPerson.Name.ToString());
+            SetField("ResvKana", UseDetail.ResvPerson.Kana.ToString());
+            if (UseDetail.ResvPerson.TelList.Count > 0)
+            {
+                SetField("ResvTel", UseDetail.ResvPerson.TelList[0].Tel.ToString());
+            }
+            else
+            {
+                SetField("ResvTel", string.Empty);
+            }
+        }
+    }
+
+    /// <summary>
+    /// 自動ソースコード生成
+    /// </summary>
+    /// <returns></returns>
+    public string GetAutoCode()
+    {
+        StringBuilder text = new StringBuilder();
+        foreach (ViewModel.ValidField item in Fields)
+        {
+            if (item.Index > 0) { text.Append("else "); }
+            text.AppendLine($"if (sender.Name == \"{item.Name}\")");
+            text.AppendLine("{");
+            if (item.InputChar == EInputChar.Num)
+            {
+                text.AppendLine($"   //Use.{item.Name} = CConvert.ToInt(sender.Text);");
+            }
+            else
+            {
+                text.AppendLine($"   //Use.{item.Name} = sender.Text;");
+            }
+            text.AppendLine("}");
+        }
+        return text.ToString();
+    }
+
+    /// <summary>
+    /// 利用情報新規作成
+    /// </summary>
+    /// <returns></returns>
+    public async Task<bool> CreateDefault(Date cinDate, int stay)
+    {
+        try
+        {
+            Use = new()
+            {
+                ID = await EnvironmentSetting.GetSeq(ESeqType.Use),
+                ResvType = (int)EResvType.Reserve,
+                GroupType = (int)EGroupType.Person,
+                ReceiptPrtWay = 0,
+                PayWay = 1,
+                //CreateDate = CConvert.ToTimestamp(DateTime.Now.Date),
+                //CreateLoginID = 1,
+                //CreatePcName = Environment.MachineName,
+                //CreateClass = 1,
+                //UpdateDate = CConvert.ToTimestamp(DateTime.Now),
+                //UpdateLoginID = 789,
+                //UpdatePcName = Environment.MachineName,
+                //UpdateClass = 2
+            };
+
+            #region 代表利用明細
+
+            Data.UseInfo.UseDetail useDetail = new()
+            {
+                ID = Use.ID,
+                DetailID = await EnvironmentSetting.GetSeq(ESeqType.UseDetail),
+                UseStatus = (int)EUseStatus.Resv,
+                SubStatus = 0,
+                ExtenStatus = 0,
+                CinDate = cinDate,
+                CinTime = 1500,
+                Stay = stay,
+                CoutDate = cinDate.Add(stay),
+                CoutTime = 1000,
+                ResvType = Use.ResvType,
+                //CreateDate = Use.CreateDate,
+                //CreateLoginID = Use.CreateLoginID,
+                //CreatePcName = Use.CreatePcName,
+                //CreateClass = Use.CreateClass,
+                //UpdateDate = Use.UpdateDate,
+                //UpdateLoginID = Use.UpdateLoginID,
+                //UpdatePcName = Use.UpdatePcName,
+                //UpdateClass = Use.UpdateClass
+            };
+            Use.DetailList.Add(useDetail);
+            UseDetail = useDetail;   //現在選択されている利用明細
+
+            #endregion
+
+            return true;
+        }
+        catch (Exception ex)
+        {
+            OperationLog.Instance.WriteLog($"CreateDefault:{ex.Message}");
+            return false;
+        }
+    }
+
+    public void RemoveUseRoom(List<Data.UseInfo.UseRoom> list, int count)
+    {
+        try
+        {
+            //Parentが必要!!
+            int i = 0;
+            List<Data.UseInfo.UseRoom> delList = new List<Data.UseInfo.UseRoom>();
+            foreach(var item in list)
+            {                
+                delList.Add(item);
+                i++;
+                if (i == count) { break; }
+            }
+
+            foreach(var item in delList) 
+            {
+                (item.Parent as Data.UseInfo.UseDetail).UseRoomList.Remove(item);
+                list.Remove(item);
+            }
+        }
+        catch (Exception ex)
+        {
+            OperationLog.Instance.WriteLog($"RemoveUseRoom:{ex.Message}");
+        }
+    }
+
+    /// <summary>
+    /// 部屋を作成する
+    /// </summary>
+    /// <param name="typeID"></param>
+    /// <param name="kind"></param>
+    /// <returns></returns>
+    public async Task<Data.UseInfo.UseRoom> CreateUseRoom(int typeID, int kind)
+    {
+        try
+        {
+            Data.UseInfo.UseDetail detail = Use.GetDetailWithoutUseRoom(UseDate);
+            if (detail == null) 
+            {
+                detail = new()
+                {
+                    ID = Use.ID,
+                    DetailID = await EnvironmentSetting.GetSeq(ESeqType.UseDetail),
+                    UseStatus = (int)EUseStatus.Resv,
+                    SubStatus = 0,
+                    ExtenStatus = 0,
+                    CinDate = new(UseDate),
+                    CinTime = 1500,
+                    Stay = 1,
+                    CoutDate = new customTypes.Date(UseDate).Add(1),
+                    CoutTime = 1000,
+                    ResvType = Use.ResvType,
+                };
+                Use.DetailList.Add(detail);
+            }
+            else
+            {                
+                detail.SetUseRange(UseDate);  // 利用期間以外だったら、伸びる
+            }
+
+            //UseRoom作成
+            Data.UseInfo.UseRoom useRoom = new()
+            {
+                ID = Use.ID,
+                DetailID = detail.DetailID,
+                UseDate = new(UseDate),
+                RoomTypeID = typeID,
+                RoomKind = kind,
+            };
+            detail.UseRoomList.Add(useRoom);
+            useRoom.Parent = detail;
+
+            //基本伝票(部屋料金)作成
+            HotelPms.Data.Master.Item item = await MasterCore.GetBaseItem(useRoom.RoomTypeID, 0, UseDate);
+            int saleID = await EnvironmentSetting.GetSeq(ESeqType.Sale);
+            int taxRate = await EnvironmentSetting.GetTaxRate(useRoom.UseDate.ToText(), item.TaxType);
+            var saleItem = useRoom.AddSaleByItem(saleID, taxRate, item);
+
+            //料金の画面表示
+            SaleInputRow saleRow = new();
+            await saleRow.Add(saleItem);
+            (SaleList as List<SaleInputRow>).Add(saleRow);
+            return useRoom;
+        }
+        catch (Exception ex)
+        {
+            OperationLog.Instance.WriteLog($"CreateUseRoom:{ex.Message}");
+            return null;
+        }
+    }
+}

--
Gitblit v1.10.0