using HotelPms.Share.Util;
using System.Data;
using System.Reflection;
namespace HotelPms.Share.Data;
public abstract class RecordBase : IRecord
{
///
/// ef[^
///
public object Parent { get; set; } = null;
///
/// ÚWNXÉRs[·é
///
///
public abstract void CopyTo(object dest);
///
/// f[^ðNA·é
///
public abstract void Clear();
public abstract object? GetField(string name);
public virtual bool SetField(string name, object value)
{
return false;
}
///
/// DataRowÌîñÅ©gðXV·é(Äp¾©çA¿åÁÆx¢)
///
///
///
public abstract bool ConvertDataRow(DataRow row);
/// ieXgpj³f[^ÆärµÄÏíÁ½Æ±ëÍuV©³yIzvÆ·é
///
///
///
public string CompareOrgItem(RecordBase orgItem)
{
string outInfo = string.Empty;
try
{
if (orgItem == null) return this.ToString();
Dictionary dic = new Dictionary();
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}yIz" + Environment.NewLine, item.Name, dic[item.Name][1], dic[item.Name][0]);
}
}
}
catch (Exception ex)
{
outInfo = ex.Message;
}
return outInfo;
}
}