ホテル管理システム
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
using HotelPms.Share.Util;
using System.Data;
using System.Reflection;
 
namespace HotelPms.Share.Data;
 
public abstract class RecordBase : IRecord
{
    /// <summary>
    /// eƒf[ƒ^
    /// </summary>
    public object Parent { get; set; } = null;
 
    /// <summary>
    /// –Ú•WƒNƒ‰ƒX‚ɃRƒs[‚·‚é
    /// </summary>
    /// <param name="dest"></param>
    public abstract void CopyTo(object dest);
 
    /// <summary>
    /// ƒf[ƒ^‚ðƒNƒŠƒA‚·‚é
    /// </summary>
    public abstract void Clear();
 
    public abstract object? GetField(string name);
 
    public virtual bool SetField(string name, object value)
    {
        return false;
    }
 
    /// <summary>
    /// DataRow‚̏î•ñ‚ÅŽ©g‚ðXV‚·‚é(”Ä—p‚¾‚©‚çA‚¿‚å‚Á‚Æ’x‚¢)
    /// </summary>
    /// <param name="row"></param>
    /// <returns></returns>
    public abstract bool ConvertDataRow(DataRow row);
 
    /// <summary> iƒeƒXƒg—pjŒ³ƒf[ƒ^‚Æ”äŠr‚µ‚ĕςí‚Á‚½‚Æ‚±‚ë‚́uV©Œ³yIzv‚Æ‚·‚é
    /// </summary>
    /// <param name="orgItem"></param>
    /// <returns></returns>
    public string CompareOrgItem(RecordBase orgItem)
    {
        string outInfo = string.Empty;
        try
        {
            if (orgItem == null) return this.ToString();
 
            Dictionary<string, object[]> dic = new Dictionary<string, object[]>();
            PropertyInfo[] myInfo = orgItem.GetType().GetProperties();
            foreach (PropertyInfo item in myInfo)
            {
                dic.Add(item.Name, new object[] { string.Format("{0}", CConvert.GetPropertyValue(orgItem, item.Name)), null });
            }
 
            myInfo = this.GetType().GetProperties();
            foreach (PropertyInfo item in myInfo)
            {
                dic[item.Name][1] = string.Format("{0}", CConvert.GetPropertyValue(this, item.Name));
 
                if (dic[item.Name][1].Equals(dic[item.Name][0]))
                {
                    outInfo += string.Format("{0} = {1}" + Environment.NewLine, item.Name, dic[item.Name][1]);
                }
                else
                {
                    outInfo += string.Format("{0} = {1} © {2}yIz" + Environment.NewLine, item.Name, dic[item.Name][1], dic[item.Name][0]);
                }
            }
        }
        catch (Exception ex)
        {
            outInfo = ex.Message;
        }
 
        return outInfo;
    }
}