ホテル管理システム
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
using HotelPms.Share.Util;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
 
namespace HotelPms.Data.Master;
 
public partial class ItemTable
{
    /// <summary>
    /// 自動データテーブル生成
    /// </summary>
    /// <returns></returns>
    public DataTable ToDataTable()
    {
        DataTable dataTable = new DataTable();
        dataTable.TableName = Name;
        PropertyInfo[] myInfo = typeof(Item).GetProperties(BindingFlags.Public | BindingFlags.Instance);
        foreach (PropertyInfo item in myInfo)
        {
            System.Diagnostics.Debug.WriteLine(item.Name);
 
            Attribute attribute = item.GetCustomAttribute(typeof(DebuggerNonUserCodeAttribute));
            if (attribute == null) { continue; }                
            dataTable.Columns.Add(item.Name, item.PropertyType);
        }
 
        //データ
        foreach (Item row in Rows)
        {
            DataRow dtRow = dataTable.NewRow();
            row.ToDataRow(dtRow);
            dataTable.Rows.Add(dtRow);
        }
        return dataTable;
    }
}