Adding saving to port area entity
This commit is contained in:
parent
f311f5941a
commit
01e48f0d1b
@ -647,6 +647,8 @@ namespace bsmd.database
|
||||
int queryResult = this.PerformNonQuery(cmd);
|
||||
this.LogNonQueryResult(cmd.CommandText, queryResult);
|
||||
this.CreateEntityHistoryEntry(entity);
|
||||
if (entity is PortArea)
|
||||
DBManager.allPortAreas = null;
|
||||
|
||||
if (this._closeConnectionAfterUse) this.Disconnect();
|
||||
}
|
||||
@ -662,6 +664,8 @@ namespace bsmd.database
|
||||
this.LogNonQueryResult(cmd.CommandText, queryResult);
|
||||
}
|
||||
}
|
||||
if (entity is PortArea)
|
||||
DBManager.allPortAreas = null;
|
||||
if (this._closeConnectionAfterUse) this.Disconnect();
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using Newtonsoft.Json;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace bsmd.database
|
||||
{
|
||||
@ -38,6 +38,18 @@ namespace bsmd.database
|
||||
[ENI2Validation]
|
||||
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
|
||||
|
||||
#region abstract method implementation
|
||||
@ -53,6 +65,10 @@ namespace bsmd.database
|
||||
if (!reader.IsDBNull(3)) portArea.Port = reader.GetString(3);
|
||||
if (!reader.IsDBNull(4)) portArea.Code = reader.GetString(4);
|
||||
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);
|
||||
}
|
||||
reader.Close();
|
||||
@ -61,7 +77,7 @@ namespace bsmd.database
|
||||
|
||||
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)
|
||||
{
|
||||
@ -76,7 +92,31 @@ namespace bsmd.database
|
||||
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user