Adding saving to port area entity
This commit is contained in:
parent
f311f5941a
commit
01e48f0d1b
@ -629,8 +629,8 @@ namespace bsmd.database
|
|||||||
this.Delete(messageCore);
|
this.Delete(messageCore);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Save(DatabaseEntity entity)
|
public void Save(DatabaseEntity entity)
|
||||||
{
|
{
|
||||||
List<string> truncatedFields = new List<string>();
|
List<string> truncatedFields = new List<string>();
|
||||||
List<string> fieldNames = new List<string>();
|
List<string> fieldNames = new List<string>();
|
||||||
entity.TruncateFields(truncatedFields, fieldNames);
|
entity.TruncateFields(truncatedFields, fieldNames);
|
||||||
@ -646,24 +646,28 @@ namespace bsmd.database
|
|||||||
entity.PrepareSave(cmd);
|
entity.PrepareSave(cmd);
|
||||||
int queryResult = this.PerformNonQuery(cmd);
|
int queryResult = this.PerformNonQuery(cmd);
|
||||||
this.LogNonQueryResult(cmd.CommandText, queryResult);
|
this.LogNonQueryResult(cmd.CommandText, queryResult);
|
||||||
this.CreateEntityHistoryEntry(entity);
|
this.CreateEntityHistoryEntry(entity);
|
||||||
|
if (entity is PortArea)
|
||||||
|
DBManager.allPortAreas = null;
|
||||||
|
|
||||||
|
if (this._closeConnectionAfterUse) this.Disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
if (this._closeConnectionAfterUse) this.Disconnect();
|
public void Delete(DatabaseEntity entity)
|
||||||
}
|
{
|
||||||
|
|
||||||
public void Delete(DatabaseEntity entity)
|
|
||||||
{
|
|
||||||
if (!entity.IsNew)
|
if (!entity.IsNew)
|
||||||
{
|
{
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
using (SqlCommand cmd = new SqlCommand())
|
||||||
{
|
{
|
||||||
entity.PrepareDelete(cmd);
|
entity.PrepareDelete(cmd);
|
||||||
int queryResult = this.PerformNonQuery(cmd);
|
int queryResult = this.PerformNonQuery(cmd);
|
||||||
this.LogNonQueryResult(cmd.CommandText, queryResult);
|
this.LogNonQueryResult(cmd.CommandText, queryResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this._closeConnectionAfterUse) this.Disconnect();
|
if (entity is PortArea)
|
||||||
}
|
DBManager.allPortAreas = null;
|
||||||
|
if (this._closeConnectionAfterUse) this.Disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
public void DeleteMessageErrors(Message message)
|
public void DeleteMessageErrors(Message message)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
// Copyright (c) 2015-2017 schick Informatik
|
// Copyright (c) 2015-2017 schick Informatik
|
||||||
// Description:
|
// Description:
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using Newtonsoft.Json;
|
using System.Data.SqlClient;
|
||||||
|
|
||||||
namespace bsmd.database
|
namespace bsmd.database
|
||||||
{
|
{
|
||||||
@ -38,6 +38,18 @@ namespace bsmd.database
|
|||||||
[ENI2Validation]
|
[ENI2Validation]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(255)]
|
||||||
|
public string Agency { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(255)]
|
||||||
|
public string Berth { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(255)]
|
||||||
|
public string Ships { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(255)]
|
||||||
|
public string Remarks { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region abstract method implementation
|
#region abstract method implementation
|
||||||
@ -53,6 +65,10 @@ namespace bsmd.database
|
|||||||
if (!reader.IsDBNull(3)) portArea.Port = reader.GetString(3);
|
if (!reader.IsDBNull(3)) portArea.Port = reader.GetString(3);
|
||||||
if (!reader.IsDBNull(4)) portArea.Code = reader.GetString(4);
|
if (!reader.IsDBNull(4)) portArea.Code = reader.GetString(4);
|
||||||
if (!reader.IsDBNull(5)) portArea.Name = reader.GetString(5);
|
if (!reader.IsDBNull(5)) portArea.Name = reader.GetString(5);
|
||||||
|
if (!reader.IsDBNull(6)) portArea.Agency = reader.GetString(6);
|
||||||
|
if (!reader.IsDBNull(7)) portArea.Berth = reader.GetString(7);
|
||||||
|
if (!reader.IsDBNull(8)) portArea.Ships = reader.GetString(8);
|
||||||
|
if (!reader.IsDBNull(9)) portArea.Remarks = reader.GetString(9);
|
||||||
result.Add(portArea);
|
result.Add(portArea);
|
||||||
}
|
}
|
||||||
reader.Close();
|
reader.Close();
|
||||||
@ -61,7 +77,7 @@ namespace bsmd.database
|
|||||||
|
|
||||||
public override void PrepareLoadCommand(IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
public override void PrepareLoadCommand(IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
||||||
{
|
{
|
||||||
string query = string.Format("SELECT Id, Country, Locode, Port, Code, Name FROM {0} ", this.Tablename);
|
string query = string.Format("SELECT Id, Country, Locode, Port, Code, Name, Agency, Berth, Ships, Remarks FROM {0} ", this.Tablename);
|
||||||
|
|
||||||
switch (filter)
|
switch (filter)
|
||||||
{
|
{
|
||||||
@ -74,10 +90,34 @@ namespace bsmd.database
|
|||||||
cmd.CommandText = query;
|
cmd.CommandText = query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PrepareSave(IDbCommand cmd)
|
public override void PrepareSave(IDbCommand cmd)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
SqlCommand scmd = cmd as SqlCommand;
|
||||||
}
|
|
||||||
|
scmd.Parameters.AddWithNullableValue("@COUNTRY", this.Country);
|
||||||
|
scmd.Parameters.AddWithNullableValue("@LOCODE", this.Locode);
|
||||||
|
scmd.Parameters.AddWithNullableValue("@PORT", this.Port);
|
||||||
|
scmd.Parameters.AddWithNullableValue("@CODE", this.Code);
|
||||||
|
scmd.Parameters.AddWithNullableValue("@NAME", this.Name);
|
||||||
|
scmd.Parameters.AddWithNullableValue("@AGENCY", this.Agency);
|
||||||
|
scmd.Parameters.AddWithNullableValue("@BERTH", this.Berth);
|
||||||
|
scmd.Parameters.AddWithNullableValue("@SHIPS", this.Ships);
|
||||||
|
scmd.Parameters.AddWithNullableValue("@REMARKS", this.Remarks);
|
||||||
|
|
||||||
|
if (this.IsNew)
|
||||||
|
{
|
||||||
|
this.CreateId();
|
||||||
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
||||||
|
scmd.CommandText = string.Format("INSERT INTO {0} (Id, Country, Locode, Port, Code, Name, Agency, Berth, Ships, Remarks) " +
|
||||||
|
"VALUES (@ID, @COUNTRY, @LOCODE, @PORT, @CODE, @NAME, @AGENCY, @BERTH, @SHIPS, @REMARKS)", this.Tablename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
||||||
|
scmd.CommandText = string.Format("UPDATE {0} SET Country = @COUNTRY, Locode = @LOCODE, Port = @PORT, Code = @CODE, Name = @NAME, " +
|
||||||
|
"Agency = @AGENCY, Berth = @BERTH, Ships = @SHIPS, Remarks = @REMARKS WHERE Id = @ID", this.Tablename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user