101 lines
3.3 KiB
C#
101 lines
3.3 KiB
C#
//
|
|
// Class: PortOfCallLast30DaysCrewJoinedShip
|
|
// Current CLR: 4.0.30319.34209
|
|
// System: Microsoft Visual Studio 10.0
|
|
// Author: dani
|
|
// Created: 3/22/2015 8:53:43 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 PortOfCallLast30DaysCrewJoinedShip : DatabaseEntity, ISublistElement
|
|
{
|
|
|
|
public PortOfCallLast30DaysCrewJoinedShip()
|
|
{
|
|
this.tablename = "[dbo].[PortOfCallLast30DaysCrewJoinedShip]";
|
|
}
|
|
|
|
#region Properties
|
|
|
|
public PortOfCallLast30Days PortOfCallLast30Days { get; set; }
|
|
[ShowReport]
|
|
public string PortOfCallLast30DaysCrewJoinedShipName { get; set; }
|
|
|
|
public string Identifier { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region abstract class implementation
|
|
|
|
public override void PrepareSave(IDbCommand cmd)
|
|
{
|
|
SqlCommand scmd = cmd as SqlCommand;
|
|
|
|
scmd.Parameters.AddWithValue("@P1", this.PortOfCallLast30Days.Id);
|
|
scmd.Parameters.AddWithNullableValue("@P2", this.PortOfCallLast30DaysCrewJoinedShipName);
|
|
scmd.Parameters.AddWithNullableValue("@P3", this.Identifier);
|
|
|
|
if (this.IsNew)
|
|
{
|
|
cmd.CommandText = string.Format("INSERT INTO {0} (PortOfCallLast30DaysId, PortOfCallLast30DaysCrewJoinedShipName, Identifier) " +
|
|
"VALUES (@P1, @P2, @P3)" , this.Tablename);
|
|
}
|
|
else
|
|
{
|
|
cmd.CommandText = string.Format("UPDATE {0} SET PortOfCallLast30DaysCrewJoinedShipName = @P2 WHERE Id = @ID", this.Tablename);
|
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
|
}
|
|
|
|
}
|
|
|
|
public override void PrepareLoadCommand(IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
|
{
|
|
|
|
string query = string.Format("SELECT Id, PortOfCallLast30DaysCrewJoinedShipName, Identifier FROM {0}",
|
|
this.Tablename);
|
|
|
|
switch (filter)
|
|
{
|
|
case Message.LoadFilter.POC30_ID:
|
|
query += "WHERE PortOfCallLast30DaysId = @POC30ID";
|
|
((SqlCommand)cmd).Parameters.AddWithValue("@POC30ID", criteria[0]);
|
|
break;
|
|
case Message.LoadFilter.ALL:
|
|
default:
|
|
|
|
break;
|
|
}
|
|
|
|
cmd.CommandText = query;
|
|
}
|
|
|
|
public override List<DatabaseEntity> LoadList(IDataReader reader)
|
|
{
|
|
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
|
|
|
while(reader.Read())
|
|
{
|
|
PortOfCallLast30DaysCrewJoinedShip poc30 = new PortOfCallLast30DaysCrewJoinedShip();
|
|
poc30.id = reader.GetGuid(0);
|
|
if (!reader.IsDBNull(1)) poc30.PortOfCallLast30DaysCrewJoinedShipName = reader.GetString(1);
|
|
if (!reader.IsDBNull(2)) poc30.Identifier = reader.GetString(2);
|
|
result.Add(poc30);
|
|
}
|
|
|
|
reader.Close();
|
|
return result;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|