// // Class: ShipToShipActivitiesDuringLastTenPortFacilitiesCalled // Current CLR: 4.0.30319.34209 // System: Microsoft Visual Studio 10.0 // Author: dani // Created: 4/3/2015 12:01:28 PM // // 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 ShipToShipActivitiesDuringLastTenPortFacilitiesCalled : DatabaseEntity { public ShipToShipActivitiesDuringLastTenPortFacilitiesCalled() { this.tablename = "[dbo].[ShipToShipActivitiesDuringLastTenPortFacilitiesCalled]"; } #region Properties public SEC SEC { get; set; } public string ShipToShipActivityLocationName { get; set; } public string ShipToShipActivityLocationLoCode { get; set; } public int? ShipToShipActivityLocationCoordinatesLatitude { get; set; } public int? ShipToShipActivityLocationCoordinatesLongitude { get; set; } public DateTime? ShipToShipActivityDateFrom { get; set; } public DateTime? ShipToShipActivityDateTo { get; set; } public string ShipToShipActivityType { get; set; } public string ShipToShipActivitySecurityMattersToReport { get; set; } #endregion #region DatabaseEntity implementation public override void PrepareSave(System.Data.IDbCommand cmd) { SqlCommand scmd = cmd as SqlCommand; scmd.Parameters.AddWithValue("@P1", this.SEC.Id); scmd.Parameters.AddWithNullableValue("@P2", this.ShipToShipActivityLocationName); scmd.Parameters.AddWithNullableValue("@P3", this.ShipToShipActivityLocationLoCode); scmd.Parameters.AddWithNullableValue("@P4", this.ShipToShipActivityLocationCoordinatesLatitude); scmd.Parameters.AddWithNullableValue("@P5", this.ShipToShipActivityLocationCoordinatesLongitude); scmd.Parameters.AddWithNullableValue("@P6", this.ShipToShipActivityDateFrom); scmd.Parameters.AddWithNullableValue("@P7", this.ShipToShipActivityDateTo); scmd.Parameters.AddWithNullableValue("@P8", this.ShipToShipActivityType); scmd.Parameters.AddWithNullableValue("@P9", this.ShipToShipActivitySecurityMattersToReport); if (this.IsNew) { scmd.CommandText = string.Format("INSERT INTO {0} (SEC_Id, ShipToShipActivityLocationName, ShipToShipActivityLocationLoCode, " + "ShipToShipActivityLocationCoordinatesLatitude, ShipToShipActivityLocationCoordinatesLongitude, ShipToShipActivityDateFrom, ShipToShipActivityDateTo, " + "ShipToShipActivityType, ShipToShipActivitySecurityMattersToReport) VALUES ( @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9)", this.Tablename); } else { scmd.Parameters.AddWithValue(@"ID", this.Id); scmd.CommandText = string.Format("UPDATE {0} SET ShipToShipActivityLocationName = @P2, ShipToShipActivityLocationLoCode = @P3, " + "ShipToShipActivityLocationCoordinatesLatitude = @P4, ShipToShipActivityLocationCoordinatesLongitude = @P5, ShipToShipActivityDateFrom = @P6," + "ShipToShipActivityDateTo = @P7, ShipToShipActivityType = @8, ShipToShipActivitySecurityMattersToReport = @P9 " + " 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, ShipToShipActivityLocationName, ShipToShipActivityLocationLoCode, ShipToShipActivityLocationCoordinatesLatitude, " + "ShipToShipActivityLocationCoordinatesLongitude, ShipToShipActivityDateFrom, ShipToShipActivityDateTo, ShipToShipActivityType, " + "ShipToShipActivitySecurityMattersToReport FROM {0}", this.Tablename); switch (filter) { case Message.LoadFilter.SEC_ID: query += "WHERE SEC_Id = @SECID"; ((SqlCommand)cmd).Parameters.AddWithValue("@SECID", criteria[0]); break; case Message.LoadFilter.ALL: default: break; } cmd.CommandText = query; } public override List LoadList(System.Data.IDataReader reader) { List result = new List(); while (reader.Read()) { ShipToShipActivitiesDuringLastTenPortFacilitiesCalled sts = new ShipToShipActivitiesDuringLastTenPortFacilitiesCalled(); sts.id = reader.GetGuid(0); if (!reader.IsDBNull(1)) sts.ShipToShipActivityLocationName = reader.GetString(1); if (!reader.IsDBNull(2)) sts.ShipToShipActivityLocationLoCode = reader.GetString(2); if (!reader.IsDBNull(3)) sts.ShipToShipActivityLocationCoordinatesLatitude = reader.GetInt32(3); if (!reader.IsDBNull(4)) sts.ShipToShipActivityLocationCoordinatesLongitude = reader.GetInt32(4); if (!reader.IsDBNull(5)) sts.ShipToShipActivityDateFrom = reader.GetDateTime(5); if (!reader.IsDBNull(6)) sts.ShipToShipActivityDateTo = reader.GetDateTime(6); if (!reader.IsDBNull(7)) sts.ShipToShipActivityType = reader.GetString(7); if (!reader.IsDBNull(8)) sts.ShipToShipActivitySecurityMattersToReport = reader.GetString(8); result.Add(sts); } reader.Close(); return result; } #endregion } }