Maincontrols scrollbar gemacht, einige kleine Änderungen im Excelhighlighting und der Validierung
115 lines
3.7 KiB
C#
115 lines
3.7 KiB
C#
//
|
|
// Class: InfectedArea
|
|
// Current CLR: 4.0.30319.34209
|
|
// System: Microsoft Visual Studio 14.0
|
|
// Author: dani
|
|
// Created: 2/26/2016 8:35:02 AM
|
|
//
|
|
// Copyright (c) 2016 Informatikbüro Daniel Schick. All rights reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace bsmd.database
|
|
{
|
|
public class InfectedArea : DatabaseEntity, ISublistElement
|
|
{
|
|
|
|
public InfectedArea()
|
|
{
|
|
this.tablename = "[dbo].[InfectedArea]";
|
|
}
|
|
|
|
#region Properties
|
|
|
|
public MDH MDH { get; set; }
|
|
|
|
[ShowReport]
|
|
[MaxLength(99)]
|
|
[ENI2Validation]
|
|
public string InfectedAreaPort { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public DateTime? InfectedAreaDate { get; set; }
|
|
|
|
public string Identifier { get; set; }
|
|
|
|
public string SublistCollectionKey { get { return "infectedarea"; } }
|
|
|
|
#endregion
|
|
|
|
#region abstract class implementation
|
|
|
|
public override List<DatabaseEntity> LoadList(IDataReader reader)
|
|
{
|
|
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
|
|
|
while (reader.Read())
|
|
{
|
|
InfectedArea ia = new InfectedArea();
|
|
ia.id = reader.GetGuid(0);
|
|
if (!reader.IsDBNull(1)) ia.InfectedAreaPort = reader.GetString(1);
|
|
if (!reader.IsDBNull(2)) ia.InfectedAreaDate = reader.GetDateTime(2);
|
|
if (!reader.IsDBNull(3)) ia.Identifier = reader.GetString(3);
|
|
result.Add(ia);
|
|
}
|
|
|
|
reader.Close();
|
|
return result;
|
|
}
|
|
|
|
public override void PrepareLoadCommand(IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
|
{
|
|
string query = string.Format("SELECT Id, InfectedAreaPort, InfectedAreaDate, " +
|
|
"Identifier FROM {0} ", this.Tablename);
|
|
|
|
switch (filter)
|
|
{
|
|
case Message.LoadFilter.MDH_ID:
|
|
query += "WHERE MDH_Id = @MDHID";
|
|
if (!cmd.Parameters.Contains("@MDHID"))
|
|
((SqlCommand)cmd).Parameters.AddWithValue("@MDHID", criteria[0]);
|
|
break;
|
|
case Message.LoadFilter.ALL:
|
|
default:
|
|
|
|
break;
|
|
}
|
|
|
|
query += " ORDER BY CAST(Identifier AS INT)";
|
|
|
|
cmd.CommandText = query;
|
|
}
|
|
|
|
public override void PrepareSave(IDbCommand cmd)
|
|
{
|
|
SqlCommand scmd = cmd as SqlCommand;
|
|
|
|
scmd.Parameters.AddWithNullableValue("@P1", this.MDH.Id);
|
|
scmd.Parameters.AddWithNullableValue("@P2", this.InfectedAreaPort);
|
|
scmd.Parameters.AddWithNullableValue("@P3", this.InfectedAreaDate);
|
|
scmd.Parameters.AddWithNullableValue("@P4", this.Identifier);
|
|
|
|
if (this.IsNew)
|
|
{
|
|
this.CreateId();
|
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
|
scmd.CommandText = string.Format("INSERT INTO {0} (Id, MDH_Id, InfectedAreaPort, InfectedAreaDate, " +
|
|
"Identifier) VALUES (@ID, @P1, @P2, @P3, @P4)", this.Tablename);
|
|
}
|
|
else
|
|
{
|
|
scmd.CommandText = string.Format("UPDATE {0} SET InfectedAreaPort = @P2, InfectedAreaDate = @P3, Identifier = @P4 " +
|
|
"WHERE Id = @ID", this.Tablename);
|
|
scmd.Parameters.AddWithNullableValue("@ID", this.Id);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|