ホテル管理システム
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
using HotelPms.Share.Util;
using System.Data.Common;
 
namespace HotelPms.Share.Data.Script;
 
public class Field
{
    /// <summary>
    /// 項目名(列名)
    /// </summary>
    public string Name { get; set; } = string.Empty;   
 
    /// <summary>
    /// 説明
    /// </summary>
    public string Description { get; set; } = string.Empty;
 
    /// <summary>
    /// 型
    /// 例:NVARCHAR(50)
    /// </summary>
    public string DataType { get; set; } = string.Empty;
 
    /// <summary>
    /// プライマリーキーかどうか
    /// </summary>
    public bool IsPrimaryKey { get; set; } = false;
 
    /// <summary>
    /// 自動増加型かどうか
    /// </summary>
    public bool IsIdentity { get; set; } = false;
 
    /// <summary>
    /// 変更チェック
    /// ※プライマリーキー変更は手動でしましょう
    /// </summary>
    /// <param name="item"></param>
    /// <returns>0.なし 1.Description 2.DataType 12.両方変更あり</returns>
    public int CompareTo(Field item)
    {
 
        bool type1 = (item.Description.CompareTo(Description) != 0);
        bool type2 = (item.DataType.Replace("[", string.Empty).Replace("]", string.Empty).ToUpper().CompareTo(DataType.Replace("[", string.Empty).Replace("]", string.Empty).ToUpper()) != 0);
 
        if (type1 && !type2) { return 1; }
        else if (!type1 && type2) { return 2; }
        else if (type1 && type2) { return 12; }
        else { return 0; }
    }
 
    public Field() { }
 
    public Field(DbDataReader reader)
    {
        Name = CConvert.ToString(reader["Name"]);
        Description = CConvert.ToString(reader["Description"]);
        DataType = CConvert.ToString(reader["DataType"]);
        IsPrimaryKey = CConvert.ToInt(reader["IsPrimaryKey"]) == 1;
    }
}