116 lines
3.3 KiB
C#
116 lines
3.3 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace bsmd.database
|
|
{
|
|
public class ReportingParty : DatabaseEntity
|
|
{
|
|
|
|
#region enumerations
|
|
|
|
public enum ReportingPartyTypeEnum
|
|
{ MASTER, SHIPOWNER, CHARTERER, AGENT, PORT_AUTHORITY, CARRIER, OTHERS }
|
|
|
|
#endregion
|
|
|
|
public ReportingParty()
|
|
{
|
|
this.tablename = "[dbo].[ReportingParty]";
|
|
}
|
|
|
|
#region Properties
|
|
|
|
public string Name { get; set; }
|
|
|
|
public string StreetAndNumber { get; set; }
|
|
|
|
public string PostalCode { get; set; }
|
|
|
|
public string City { get; set; }
|
|
|
|
public string Country { get; set; }
|
|
|
|
public string LastName { get; set; }
|
|
|
|
public string FirstName { get; set; }
|
|
|
|
public string Phone { get; set; }
|
|
|
|
public string Fax { get; set; }
|
|
|
|
public string EMail { get; set; }
|
|
|
|
public ReportingPartyTypeEnum? ReportingPartyType { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region overrides
|
|
|
|
public override string ToString()
|
|
{
|
|
return this.Name;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IDatabaseEntity implementation
|
|
|
|
public override void PrepareSave(System.Data.IDbCommand cmd)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
|
{
|
|
|
|
string query = string.Format("SELECT Id, RPName, RPStreetAndNumber, RPPostalCode, RPCity, RPCountry, RPLastName, " +
|
|
"RPFirstName, RPPhone, RPFax, RPEMail FROM {0} ", this.Tablename);
|
|
|
|
switch (filter)
|
|
{
|
|
/// tbd
|
|
|
|
case Message.LoadFilter.ALL:
|
|
default:
|
|
break;
|
|
}
|
|
|
|
cmd.CommandText = query;
|
|
|
|
}
|
|
|
|
public override List<DatabaseEntity> LoadList(System.Data.IDataReader reader)
|
|
{
|
|
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
|
while (reader.Read())
|
|
{
|
|
ReportingParty rp = new ReportingParty();
|
|
|
|
rp.id = reader.GetGuid(0);
|
|
if (!reader.IsDBNull(1)) rp.Name = reader.GetString(1);
|
|
if (!reader.IsDBNull(2)) rp.StreetAndNumber = reader.GetString(2);
|
|
if (!reader.IsDBNull(3)) rp.PostalCode = reader.GetString(3);
|
|
if (!reader.IsDBNull(4)) rp.City = reader.GetString(4);
|
|
if (!reader.IsDBNull(5)) rp.Country = reader.GetString(5);
|
|
if (!reader.IsDBNull(6)) rp.LastName = reader.GetString(6);
|
|
if (!reader.IsDBNull(7)) rp.FirstName = reader.GetString(7);
|
|
if (!reader.IsDBNull(8)) rp.Phone = reader.GetString(8);
|
|
if (!reader.IsDBNull(9)) rp.Fax = reader.GetString(9);
|
|
if (!reader.IsDBNull(10)) rp.EMail = reader.GetString(10);
|
|
|
|
result.Add(rp);
|
|
}
|
|
reader.Close();
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|