using System;
|
using System.Collections.Concurrent;
|
using System.Collections.Generic;
|
using System.Data.SqlClient;
|
using System.Text;
|
using HotelPms.Share.Data;
|
using HotelPms.Share.Util;
|
using Google.Protobuf.WellKnownTypes;
|
using customTypes;
|
using System.Data.Common;
|
|
namespace HotelPms.Data.Master
|
{
|
/// ****************************** Description *******************************
|
/// ◇システム名称
|
/// ホテルPMS
|
/// ◇概要
|
///
|
/// ◇履歴
|
/// 2021/05/14 コード作成ツール 自動作成
|
/// ****************************** Declarations ******************************
|
[Serializable()]
|
public partial class Demo : RecordBase
|
{
|
#region ★★★★★ Property ★★★★★
|
|
public static ConcurrentDictionary<string, int> PrimaryKey { get; } = new ConcurrentDictionary<string, int>();
|
|
#endregion
|
|
partial void OnConstruction()
|
{
|
if (PrimaryKey.Count == 0)
|
{
|
PrimaryKey.TryAdd("ID", 0);
|
|
}
|
}
|
|
#region ★★★★★ Function ★★★★★
|
|
public bool CompareTo(Demo item)
|
{
|
if (ID.CompareTo(item.ID) != 0
|
|| Name.CompareTo(item.Name) != 0
|
|| FInt.CompareTo(item.FInt) != 0
|
|| FTinyInt.CompareTo(item.FTinyInt) != 0
|
|| FSmallInt.CompareTo(item.FSmallInt) != 0
|
|| FFloat.CompareTo(item.FFloat) != 0
|
|| FBit.CompareTo(item.FBit) != 0
|
|| FDecimal.CompareTo(item.FDecimal) != 0
|
|| FDate.CompareTo(item.FDate) != 0
|
|| UpdateDate.CompareTo(item.UpdateDate) != 0
|
|| UpdateID.CompareTo(item.UpdateID) != 0
|
)
|
{
|
return false;
|
}
|
return true;
|
}
|
|
|
public override void CopyTo(object dest)
|
{
|
Demo item = dest as Demo;
|
item.ID = ID;
|
item.Name = Name;
|
item.FInt = FInt;
|
item.FTinyInt = FTinyInt;
|
item.FSmallInt = FSmallInt;
|
item.FFloat = FFloat;
|
item.FBit = FBit;
|
item.FDecimal = FDecimal;
|
item.FDate = FDate;
|
item.UpdateDate = UpdateDate;
|
item.UpdateID = UpdateID;
|
}
|
|
public override void Clear()
|
{
|
ID = 0;
|
Name = string.Empty;
|
FInt = 0;
|
FTinyInt = 0;
|
FSmallInt = 0;
|
FFloat = 0;
|
FBit = false;
|
FDecimal = 0;
|
FDate = Date.Default;
|
UpdateDate = CConvert.ToTimestamp(DateTime.MinValue);
|
UpdateID = 0;
|
}
|
|
public Demo DeepClone()
|
{
|
Demo item = new Demo();
|
item.ID = ID;
|
item.Name = Name;
|
item.FInt = FInt;
|
item.FTinyInt = FTinyInt;
|
item.FSmallInt = FSmallInt;
|
item.FFloat = FFloat;
|
item.FBit = FBit;
|
item.FDecimal = FDecimal;
|
item.FDate = FDate;
|
item.UpdateDate = UpdateDate;
|
item.UpdateID = UpdateID;
|
return item;
|
}
|
|
public override bool ConvertDataRow(System.Data.DataRow row)
|
{
|
ID = CConvert.ToInt(row["ID"],ID);
|
Name = row["Name"].ToString();
|
FInt = CConvert.ToInt(row["FInt"],FInt);
|
FTinyInt = CConvert.ToInt(row["FTinyInt"],FTinyInt);
|
FSmallInt = CConvert.ToInt(row["FSmallInt"],FSmallInt);
|
FFloat = CConvert.ToFloat(row["FFloat"],FFloat);
|
FBit = CConvert.ToBool(row["FBit"]);
|
FDecimal = CConvert.ToDecimal(row["FDecimal"]);
|
FDate = new Date(row.IsNull("FDate") ? 0 : CConvert.ToDateInt((System.DateTime)row["FDate"]));
|
UpdateDate = CConvert.ToTimestamp(row.IsNull("UpdateDate") ? DateTime.MinValue : (System.DateTime)row["UpdateDate"]);
|
UpdateID = CConvert.ToInt(row["UpdateID"], UpdateID);
|
return true;
|
}
|
|
public void ToDataRow(System.Data.DataRow row)
|
{
|
row["ID"] = ID;
|
row["Name"] = Name;
|
row["FInt"] = FInt;
|
row["FTinyInt"] = FTinyInt;
|
row["FSmallInt"] = FSmallInt;
|
row["FFloat"] = FFloat;
|
row["FBit"] = FBit;
|
row["FDecimal"] = FDecimal.ToDecimal();
|
row["FDate"] = FDate.ToDateTime();
|
row["UpdateDate"] = UpdateDate.ToDateTime();
|
row["UpdateID"] = UpdateID;
|
}
|
|
/// <summary>
|
/// 必ず順番にしないといけない
|
/// </summary>
|
/// <param name="row"></param>
|
public void ConvertReader(DbDataReader row)
|
{
|
int i = 0;
|
ID = (int)(row.IsDBNull(i) ? 0 : row.GetInt32(i)); i++;
|
Name = (row.IsDBNull(i) ? string.Empty : row.GetString(i)); i++;
|
FInt = (int)(row.IsDBNull(i) ? 0 : row.GetInt32(i)); i++;
|
FTinyInt = (byte)(row.IsDBNull(i) ? 0x00 : row.GetByte(i)); i++;
|
FSmallInt = (int)(row.IsDBNull(i) ? 0 : row.GetInt16(i)); i++;
|
FFloat = (float)(row.IsDBNull(i) ? 0D : row.GetDouble(i)); i++;
|
FBit = (bool)(row.IsDBNull(i) ? false : row.GetBoolean(i)); i++;
|
FDecimal = (decimal)(row.IsDBNull(i) ? 0M : row.GetDecimal(i)); i++;
|
FDate = new Date(row.IsDBNull(i) ? 0 : CConvert.ToDateInt(row.GetDateTime(i))); i++;
|
UpdateDate = CConvert.ToTimestamp(row.IsDBNull(i) ? DateTime.MinValue : row.GetDateTime(i)); i++;
|
UpdateID = (int)(row.IsDBNull(i) ? 0 : row.GetInt32(i)); i++;
|
}
|
|
public string AddSql()
|
{
|
return $@"INSERT INTO M_Demo(ID,Name,FInt,FTinyInt,FSmallInt,FFloat,FBit,FDecimal,FDate,UpdateDate,UpdateID) VALUES({ID},N'{Name}',{FInt},{FTinyInt},{FSmallInt},{FFloat},{(FBit ? 1 : 0)},{FDecimal.ToSqlValue()},{FDate.ToSqlValue()},GETDATE(),{UpdateID});";
|
}
|
|
public string UpdateSql()
|
{
|
return $@"UPDATE M_Demo SET Name = N'{Name}',FInt = {FInt},FTinyInt = {FTinyInt},FSmallInt = {FSmallInt},FFloat = {FFloat},FBit = {(FBit ? 1 : 0)},FDecimal = {FDecimal.ToSqlValue()},FDate = {FDate.ToSqlValue()},UpdateDate = GETDATE(),UpdateID={UpdateID} WHERE ID = {ID};";
|
}
|
|
public string ToText()
|
{
|
StringBuilder text = new StringBuilder();
|
text.AppendFormat("ID={0};", ID);
|
text.AppendFormat("Name={0};", Name);
|
text.AppendFormat("FInt={0};", FInt);
|
text.AppendFormat("FTinyInt={0};", FTinyInt);
|
text.AppendFormat("FSmallInt={0};", FSmallInt);
|
text.AppendFormat("FFloat={0};", FFloat);
|
text.AppendFormat("FBit={0};", FBit);
|
text.AppendFormat("FDecimal={0};", FDecimal.ToText());
|
text.AppendFormat("FDate={0};", FDate.ToText());
|
text.AppendFormat("UpdateDate={0};", UpdateDate);
|
text.AppendFormat("UpdateID={0};", UpdateID);
|
return text.ToString();
|
}
|
|
public override object GetField(string name)
|
{
|
|
if (name == "ID") { return ID; }
|
else if (name == "Name") { return Name; }
|
else if (name == "FInt") { return FInt; }
|
else if (name == "FTinyInt") { return FTinyInt; }
|
else if (name == "FSmallInt") { return FSmallInt; }
|
else if (name == "FFloat") { return FFloat; }
|
else if (name == "FBit") { return FBit; }
|
else if (name == "FDecimal") { return FDecimal; }
|
else if (name == "FDate") { return FDate; }
|
else if (name == "UpdateDate") { return UpdateDate; }
|
else if (name == "UpdateID") { return UpdateID; }
|
else { return null; }
|
}
|
|
public override bool SetField(string name, object value)
|
{
|
|
if (name == "ID") { ID = CConvert.ToInt(value); return true; }
|
else if (name == "Name") { Name = value.ToString(); return true; }
|
else if (name == "FInt") { FInt = CConvert.ToInt(value); return true; }
|
else if (name == "FTinyInt") { FTinyInt = CConvert.ToInt(value); return true; }
|
else if (name == "FSmallInt") { FSmallInt = CConvert.ToInt(value); return true; }
|
else if (name == "FFloat") { FFloat = CConvert.ToFloat(value); return true; }
|
else if (name == "FBit") { FBit = CConvert.ToBool(value); return true; }
|
else if (name == "FDecimal") { FDecimal = CConvert.ToDecimal(value); return true; }
|
else if (name == "FDate") { FDate = new Date(CConvert.ToDateInt(value)); return true; }
|
else if (name == "UpdateDate") { UpdateDate = CConvert.ToTimestamp(CConvert.ToDateTime(value)); return true; }
|
else if (name == "UpdateID") { UpdateID = CConvert.ToInt(value); return true; }
|
else { return false; }
|
}
|
|
#endregion
|
}
|
}
|