200 lines
8.9 KiB
C#
200 lines
8.9 KiB
C#
//
|
|
// Class: SEC
|
|
// Current CLR: 4.0.30319.34209
|
|
// System: Microsoft Visual Studio 10.0
|
|
// Author: dani
|
|
// Created: 4/3/2015 10:11:02 AM
|
|
//
|
|
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
|
|
|
|
using System;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Collections.Generic;
|
|
|
|
namespace bsmd.database
|
|
{
|
|
public class SEC : DatabaseEntity
|
|
{
|
|
|
|
private List<LastTenPortFacilitiesCalled> ltpfc = new List<LastTenPortFacilitiesCalled>();
|
|
|
|
private List<ShipToShipActivitiesDuringLastTenPortFacilitiesCalled> lsts = new List<ShipToShipActivitiesDuringLastTenPortFacilitiesCalled>();
|
|
|
|
public SEC()
|
|
{
|
|
this.tablename = "[dbo].[SEC]";
|
|
}
|
|
|
|
#region Properties
|
|
|
|
public bool? SECSimplification { get; set; }
|
|
|
|
public string PortOfCallWhereCompleteSECNotified { get; set; }
|
|
|
|
public string CSOLastName { get; set; }
|
|
|
|
public string CSOFirstName { get; set; }
|
|
|
|
public string CSOPhone { get; set; }
|
|
|
|
public string CSOFax { get; set; }
|
|
|
|
public string CSOEMail { get; set; }
|
|
|
|
public bool? ValidISSCOnBoard { get; set; }
|
|
|
|
public string ReasonsForNoValidISSC { get; set; }
|
|
|
|
public byte? ISSCType { get; set; }
|
|
|
|
public byte? ISSCIssuerType { get; set; }
|
|
|
|
public string ISSCIssuerName { get; set; }
|
|
|
|
public DateTime? ISSCDateOfExpiration { get; set; }
|
|
|
|
public bool? ApprovedSecurityPlanOnBoard { get; set; }
|
|
|
|
public byte? CurrentShipSecurityLevel { get; set; }
|
|
|
|
public string PortFacilityOfArrival { get; set; }
|
|
|
|
public byte? GeneralDescriptionOfCargo { get; set; }
|
|
|
|
public List<LastTenPortFacilitiesCalled> LastTenPortFacilitesCalled { get { return this.ltpfc; } }
|
|
|
|
public List<ShipToShipActivitiesDuringLastTenPortFacilitiesCalled> ShipToShipActivitiesDuringLastTenPortFacilitiesCalled { get { return this.lsts; } }
|
|
|
|
#endregion
|
|
|
|
#region DatabaseEntity implementation
|
|
|
|
public override void PrepareSave(System.Data.IDbCommand cmd)
|
|
{
|
|
|
|
SqlCommand scmd = cmd as SqlCommand;
|
|
|
|
scmd.Parameters.AddWithValue("@P1", this.MessageHeader.Id);
|
|
scmd.Parameters.AddWithNullableValue("@P2", this.SECSimplification);
|
|
scmd.Parameters.AddWithNullableValue("@P3", this.PortOfCallWhereCompleteSECNotified);
|
|
scmd.Parameters.AddWithNullableValue("@P4", this.CSOLastName);
|
|
scmd.Parameters.AddWithNullableValue("@P5", this.CSOFirstName);
|
|
scmd.Parameters.AddWithNullableValue("@P6", this.CSOPhone);
|
|
scmd.Parameters.AddWithNullableValue("@P7", this.CSOEMail);
|
|
scmd.Parameters.AddWithNullableValue("@P8", this.ValidISSCOnBoard);
|
|
scmd.Parameters.AddWithNullableValue("@P9", this.ReasonsForNoValidISSC);
|
|
scmd.Parameters.AddWithNullableValue("@P10", this.ISSCType);
|
|
scmd.Parameters.AddWithNullableValue("@P11", this.ISSCIssuerType);
|
|
scmd.Parameters.AddWithNullableValue("@P12", this.ISSCIssuerName);
|
|
scmd.Parameters.AddWithNullableValue("@P13", this.ISSCDateOfExpiration);
|
|
scmd.Parameters.AddWithNullableValue("@P14", this.ApprovedSecurityPlanOnBoard);
|
|
scmd.Parameters.AddWithNullableValue("@P15", this.CurrentShipSecurityLevel);
|
|
scmd.Parameters.AddWithNullableValue("@P16", this.PortFacilityOfArrival);
|
|
scmd.Parameters.AddWithNullableValue("@P17", this.GeneralDescriptionOfCargo);
|
|
scmd.Parameters.AddWithNullableValue("@P18", this.CSOFax);
|
|
|
|
if (this.IsNew)
|
|
{
|
|
this.CreateId();
|
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
|
scmd.CommandText = string.Format("INSERT INTO {0} (Id, MessageHeaderId, SECSimplification, PortOfCallWhereCompleteSECNotified, " +
|
|
"CSOLastName, CSOFirstName, CSOPhone, CSOEMail, ValidISSCOnBoard, ReasonsForNoValidISSC, " +
|
|
"ISSCType, ISSCIssuerType, ISSCIssuerName,ISSCDateOfExpiration, ApprovedSecurityPlanOnBoard, " +
|
|
"CurrentShipSecurityLevel, PortFacilityOfArrival, GeneralDescriptionOfCargo, CSOFax) " +
|
|
"VALUES ( @ID, @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, @P15, @P16, @P17, @P18 )", this.Tablename);
|
|
}
|
|
else
|
|
{
|
|
scmd.Parameters.AddWithValue(@"ID", this.Id);
|
|
scmd.CommandText = string.Format("UPDATE {0} SET SECSimplification = @P2, PortOfCallWhereCompleteSECNotified = @P3, " +
|
|
"CSOLastName = @P4, CSOFirstName = @P5, CSOPhone = @P6," +
|
|
"CSOEMail = @P7, ValidISSCOnBoard = @P8, ReasonsForNoValidISSC = @P9, " +
|
|
"ISSCType = @P10, ISSCIssuerType = @P11, ISSCIssuerName = @P12, ISSCDateOfExpiration = @P13, " +
|
|
"ApprovedSecurityPlanOnBoard = @P14, CurrentShipSecurityLevel = @P15, PortFacilityOfArrival = @P16, " +
|
|
"GeneralDescriptionOfCargo = @P17, CSOFax = @P18 WHERE Id = @ID", this.Tablename);
|
|
}
|
|
}
|
|
|
|
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
|
{
|
|
string query = string.Format("SELECT Id, SECSimplification, PortOfCallWhereCompleteSECNotified, CSOLastName, " +
|
|
"CSOFirstName, CSOPhone, CSOEMail, ValidISSCOnBoard, ReasonsForNoValidISSC, " +
|
|
"ISSCType, ISSCIssuerType, ISSCIssuerName, ISSCDateOfExpiration, ApprovedSecurityPlanOnBoard, " +
|
|
"CurrentShipSecurityLevel, PortFacilityOfArrival, GeneralDescriptionOfCargo, CSOFax FROM {0}", this.Tablename);
|
|
|
|
switch (filter)
|
|
{
|
|
case Message.LoadFilter.MESSAGEHEADER:
|
|
query += "WHERE MessageHeaderId = @MHID";
|
|
((SqlCommand)cmd).Parameters.AddWithValue("@MHID", criteria[0]);
|
|
break;
|
|
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())
|
|
{
|
|
SEC sec = new SEC();
|
|
|
|
sec.id = reader.GetGuid(0);
|
|
if (!reader.IsDBNull(1)) sec.SECSimplification = reader.GetBoolean(1);
|
|
if (!reader.IsDBNull(2)) sec.PortOfCallWhereCompleteSECNotified = reader.GetString(2);
|
|
if (!reader.IsDBNull(3)) sec.CSOLastName = reader.GetString(3);
|
|
if (!reader.IsDBNull(4)) sec.CSOFirstName = reader.GetString(4);
|
|
if (!reader.IsDBNull(5)) sec.CSOPhone = reader.GetString(5);
|
|
if (!reader.IsDBNull(6)) sec.CSOEMail = reader.GetString(6);
|
|
if (!reader.IsDBNull(7)) sec.ValidISSCOnBoard = reader.GetBoolean(7);
|
|
if (!reader.IsDBNull(8)) sec.ReasonsForNoValidISSC = reader.GetString(8);
|
|
if (!reader.IsDBNull(9)) sec.ISSCType = reader.GetByte(9);
|
|
if (!reader.IsDBNull(10)) sec.ISSCIssuerType = reader.GetByte(10);
|
|
if (!reader.IsDBNull(11)) sec.ISSCIssuerName = reader.GetString(11);
|
|
if (!reader.IsDBNull(12)) sec.ISSCDateOfExpiration = reader.GetDateTime(12);
|
|
if (!reader.IsDBNull(13)) sec.ApprovedSecurityPlanOnBoard = reader.GetBoolean(13);
|
|
if (!reader.IsDBNull(14)) sec.CurrentShipSecurityLevel = reader.GetByte(14);
|
|
if (!reader.IsDBNull(15)) sec.PortFacilityOfArrival = reader.GetString(15);
|
|
if (!reader.IsDBNull(16)) sec.GeneralDescriptionOfCargo = reader.GetByte(16);
|
|
if (!reader.IsDBNull(17)) sec.CSOFax = reader.GetString(17);
|
|
result.Add(sec);
|
|
}
|
|
reader.Close();
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region sublist lookup implementation
|
|
|
|
public LastTenPortFacilitiesCalled GetPortFacilityWithIdentifier(string identifier)
|
|
{
|
|
foreach(ISublistElement lp in this.ltpfc) {
|
|
if (lp.Identifier.Equals(identifier))
|
|
return lp as LastTenPortFacilitiesCalled;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public ShipToShipActivitiesDuringLastTenPortFacilitiesCalled GetShipToShipWithIdentifier(string identifier)
|
|
{
|
|
foreach (ISublistElement lp in this.lsts)
|
|
{
|
|
if (lp.Identifier.Equals(identifier))
|
|
return lp as ShipToShipActivitiesDuringLastTenPortFacilitiesCalled;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|