945 lines
38 KiB
C#
945 lines
38 KiB
C#
using BrightIdeasSoftware;
|
|
using Deckungsbeitrag;
|
|
using Deckungsbeitrag.AA_Klassen;
|
|
using Deckungsbeitrag.UserControls;
|
|
using HarfBuzzSharp;
|
|
using Npgsql;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
|
namespace DatenDB
|
|
{
|
|
#region Enums
|
|
public enum AuftragPriority
|
|
{
|
|
None = 0,
|
|
First = 1,
|
|
Second = 2,
|
|
Third = 3,
|
|
Fourth = 4,
|
|
Fifth = 5
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Enum AuftragStatus
|
|
/// </summary>
|
|
public enum AuftragStatus
|
|
{
|
|
Abgeholt = 0,
|
|
Aufgelegt = 1,
|
|
Gewaschen = 2,
|
|
Herrichten = 3,
|
|
Vorbereitet = 4,
|
|
Fertig = 6,
|
|
Geladen = 7,
|
|
Ausgeliefert = 8,
|
|
Erledigt = 10
|
|
}
|
|
|
|
/// <summary>
|
|
/// Enum AuftragTyp Wenn Geschäft dann Container = Pakete.
|
|
/// </summary>
|
|
public enum AuftragTyp
|
|
{
|
|
Geschäft = 0,
|
|
Standart = 1,
|
|
Inventur = 2,
|
|
Standerhöhung = 3,
|
|
Standverminderung = 4,
|
|
Regelmäßig = 5,
|
|
AufAbruf = 6
|
|
}
|
|
|
|
[Flags]
|
|
public enum AbteilungsStatus
|
|
{
|
|
Keine = 0,
|
|
|
|
// Bit 0-1: Frottee (Status)
|
|
FrotteeBegonnen = 1 << 0, // 1 = begonnen
|
|
FrotteeBeendet = 1 << 1, // 2 = beendet (Zwischenstatus)
|
|
|
|
// Bit 2-3: Kleinteile (Status)
|
|
KleinteileBegonnen = 1 << 2, // 4 = begonnen
|
|
KleinteileBeendet = 1 << 3, // 8 = beendet
|
|
|
|
// Bit 4-5: Großteile (Status)
|
|
GrossteileBegonnen = 1 << 4, // 16 = begonnen
|
|
GrossteileBeendet = 1 << 5, // 32 = beendet
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
public class Auftrag
|
|
{
|
|
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
|
public const string COLUMNS = "auftrag_id, benutzer_id, aufgabe_id, kunde_id, zusatz, liefertag, gedruckt, gedruckt_von, erledigt, erledigt_von, erstellt, erstellt_von, status, tour_id, container_dirt, maschine_id, container_clean, typ, aufgabe_erledigt, abteilungen_status, rhythmus, priority";
|
|
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
|
public const string ACOLUMNS = "a.auftrag_id, a.benutzer_id, a.aufgabe_id, a.kunde_id, a.zusatz, a.liefertag, a.gedruckt, a.gedruckt_von, a.erledigt, a.erledigt_von, a.erstellt, a.erstellt_von, a.status, a.tour_id, a.container_dirt, a.maschine_id, a.container_clean, a.typ, a.aufgabe_erledigt, a.abteilungen_status, a.rhythmus, a.priority";
|
|
private const string TABLE = "kundenverwaltung.auftrag";
|
|
public const string ASPECTS = "FahrerID,AufgabeID,KundeID,ZusatzInfo,Wann,Gedruckt,Erledigt,Erstellt von,Erstellt Am";
|
|
static bool isExpedit = false;
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
public Auftrag()
|
|
{
|
|
}
|
|
|
|
#region async Tasks
|
|
public static async Task<List<Auftrag>> GetAuftragListTodayAsync(AuftragStatus? status, NpgsqlConnection conn, AuftragTyp? typ, int? abtstatus)
|
|
{
|
|
List<Auftrag> resultList = new List<Auftrag>();
|
|
bool isExpedit = true;
|
|
using (var command = new NpgsqlCommand())
|
|
{
|
|
command.Connection = conn;
|
|
// Listen für FROTTEE EXPEDIT
|
|
if (abtstatus != null) command.CommandText = $"SELECT {ACOLUMNS}, k.name1 as kunde_name, k.suchtext as suchtext, u.benutzer_name as fahrer FROM {TABLE} a left join kundenverwaltung.kunde k on a.kunde_id = k.kunde_id left join kundenverwaltung.benutzer u on a.benutzer_id = u.benutzer_id WHERE status < {(int)status} AND status > {(int)AuftragStatus.Aufgelegt} AND (a.abteilungen_status & 2) = 0 ORDER BY liefertag ASC";
|
|
else
|
|
{
|
|
// Listen für EXPEDIT
|
|
// Aufträge mit: alle Typen, mit Status "Gewaschen" und "Herrichten" fällig HEUTE + 2 Tage
|
|
if (typ == null) command.CommandText = $"SELECT {ACOLUMNS}, k.name1 as kunde_name, k.suchtext as suchtext, u.benutzer_name as fahrer FROM {TABLE} a left join kundenverwaltung.kunde k on a.kunde_id = k.kunde_id left join kundenverwaltung.benutzer u on a.benutzer_id = u.benutzer_id WHERE status < {(int)status} AND status > {(int)AuftragStatus.Aufgelegt} AND liefertag < '{DateTime.Today.Date.AddDays(2)}' ORDER BY liefertag ASC";
|
|
else
|
|
{
|
|
if (status == null) command.CommandText = $"SELECT {ACOLUMNS}, k.name1 as kunde_name, k.suchtext as suchtext, u.benutzer_name as fahrer FROM {TABLE} a left join kundenverwaltung.kunde k on a.kunde_id = k.kunde_id left join kundenverwaltung.benutzer u on a.benutzer_id = u.benutzer_id WHERE typ = {(int)typ} and status < {(int)AuftragStatus.Vorbereitet} ORDER BY liefertag ASC";
|
|
else command.CommandText = $"SELECT {ACOLUMNS}, k.name1 as kunde_name, k.suchtext as suchtext, u.benutzer_name as fahrer FROM {TABLE} a left join kundenverwaltung.kunde k on a.kunde_id = k.kunde_id left join kundenverwaltung.benutzer u on a.benutzer_id = u.benutzer_id WHERE typ <= {(int)typ} AND status = {(int)status} ORDER BY liefertag ASC";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
using (var reader = await command.ExecuteReaderAsync())
|
|
{
|
|
while (await reader.ReadAsync())
|
|
resultList.Add(new Auftrag(reader, isExpedit));
|
|
}
|
|
}
|
|
|
|
//isExpedit1 = false;
|
|
return resultList;
|
|
}
|
|
public static async Task<List<Auftrag>> GetSonderListsAsync(int? typ, NpgsqlConnection conn, int? abtstatus)
|
|
{
|
|
List<Auftrag> resultList = new List<Auftrag>();
|
|
isExpedit = true;
|
|
using (var command = new NpgsqlCommand())
|
|
{
|
|
command.Connection = conn;
|
|
if (abtstatus != null) command.CommandText = $"SELECT {ACOLUMNS}, k.name1 as kunde_name, k.suchtext as suchtext, u.benutzer_name as fahrer FROM {TABLE} a left join Kundenverwaltung.kunde k on a.kunde_id = k.kunde_id left join kundenverwaltung.benutzer u on a.benutzer_id = u.benutzer_id WHERE typ >= @typ AND status < {(int)AuftragStatus.Fertig} AND a.abteilungen_status <= {abtstatus} ORDER BY status DESC, liefertag ASC";
|
|
else command.CommandText = $"SELECT {ACOLUMNS}, k.name1 as kunde_name, k.suchtext as suchtext, u.benutzer_name as fahrer FROM {TABLE} a left join Kundenverwaltung.kunde k on a.kunde_id = k.kunde_id left join kundenverwaltung.benutzer u on a.benutzer_id = u.benutzer_id WHERE typ >= @typ AND status < {(int)AuftragStatus.Fertig} ORDER BY status DESC, liefertag ASC";
|
|
command.Parameters.AddWithValue("@typ", typ ?? 0); // Parameterized + Null-Handling
|
|
|
|
using (var reader = await command.ExecuteReaderAsync())
|
|
{
|
|
while (await reader.ReadAsync())
|
|
resultList.Add(new Auftrag(reader, isExpedit));
|
|
}
|
|
}
|
|
//isExpedit = false;
|
|
return resultList;
|
|
}
|
|
public static async Task<List<Auftrag>> GetStatusListAsync(int? status, NpgsqlConnection conn)
|
|
{
|
|
List<Auftrag> resultList = new List<Auftrag>();
|
|
isExpedit = true;
|
|
using (var command = new NpgsqlCommand())
|
|
{
|
|
command.Connection = conn;
|
|
if (status == null) command.CommandText = $"SELECT {ACOLUMNS}, k.name1 as kunde_name, k.suchtext as suchtext, u.benutzer_name as fahrer FROM {TABLE} a left join kundenverwaltung.kunde k on a.kunde_id = k.kunde_id left join kundenverwaltung.benutzer u on a.benutzer_id = u.benutzer_id WHERE status <= {(int)AuftragStatus.Fertig} ORDER BY status DESC, liefertag ASC";
|
|
else command.CommandText = $"SELECT {ACOLUMNS}, k.name1 as kunde_name, k.suchtext as suchtext, u.benutzer_name as fahrer FROM {TABLE} a left join kundenverwaltung.kunde k on a.kunde_id = k.kunde_id left join kundenverwaltung.benutzer u on a.benutzer_id = u.benutzer_id WHERE status = {status} ORDER BY status DESC, liefertag ASC";
|
|
|
|
using (var reader = await command.ExecuteReaderAsync())
|
|
{
|
|
while (await reader.ReadAsync())
|
|
resultList.Add(new Auftrag(reader, isExpedit));
|
|
}
|
|
}
|
|
|
|
//isExpedit = false;
|
|
return resultList;
|
|
}
|
|
public static async Task<List<Auftrag>> GetFahrerListAsync(int? fahrerID, NpgsqlConnection conn)
|
|
{
|
|
List<Auftrag> resultList = new List<Auftrag>();
|
|
isExpedit = true;
|
|
using (var command = new NpgsqlCommand())
|
|
{
|
|
command.Connection = conn;
|
|
|
|
command.CommandText = $"SELECT {ACOLUMNS}, k.name1 as kunde_name, k.suchtext as suchtext, u.benutzer_name as fahrer FROM {TABLE} a left join kundenverwaltung.kunde k on a.kunde_id = k.kunde_id left join kundenverwaltung.benutzer u on a.benutzer_id = u.benutzer_id WHERE a.benutzer_id = {fahrerID} and liefertag = CURRENT_DATE and status < {(int)AuftragStatus.Ausgeliefert} ORDER BY status DESC";
|
|
|
|
using (var reader = await command.ExecuteReaderAsync())
|
|
{
|
|
while (await reader.ReadAsync())
|
|
resultList.Add(new Auftrag(reader, isExpedit));
|
|
}
|
|
}
|
|
|
|
//isExpedit = false;
|
|
return resultList;
|
|
}
|
|
|
|
public static async Task<Dictionary<DateTime, List<Auftrag>>> GetAuftraegeProLiefertagAsync(NpgsqlConnection conn, AuftragTyp standart, AuftragStatus aufgelegt)
|
|
{
|
|
|
|
// ✅ 5 FIXED Keys mit Sonntags-Check
|
|
var result = new Dictionary<DateTime, List<Auftrag>>
|
|
{
|
|
[DateTime.Today.Date] = new List<Auftrag>(),
|
|
};
|
|
|
|
using (var command = new NpgsqlCommand())
|
|
{
|
|
command.Connection = conn;
|
|
command.CommandText = $"SELECT {COLUMNS} from {TABLE} where status <= {(int)aufgelegt} and liefertag >= CURRENT_DATE order by liefertag ASC and priority ASC";
|
|
|
|
using (var reader = await command.ExecuteReaderAsync())
|
|
{
|
|
while (await reader.ReadAsync())
|
|
{
|
|
Auftrag auftrag = new Auftrag(reader);
|
|
var tag = auftrag.Liefertag.Date; // Nur Datum
|
|
if (result.Count == 5)
|
|
tag = result.Keys.Last();
|
|
if (!result.ContainsKey(tag)) result[tag] = new List<Auftrag>();
|
|
|
|
result[tag].Add(auftrag);
|
|
}
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
public static List<Auftrag> GetFinishingList(ArtikelKategorie kategorie)
|
|
{
|
|
DatenbankConnection.GetConnection().Open();
|
|
List<Auftrag> resultList = new List<Auftrag>();
|
|
NpgsqlCommand cmd = new NpgsqlCommand();
|
|
cmd.Connection = DatenbankConnection.GetConnection();
|
|
//cmd.CommandText = $"select {COLUMNS} from {TABLE} where status = 2 order by liefertag asc";
|
|
if (kategorie == ArtikelKategorie.Frottee) cmd.CommandText = $"select {ACOLUMNS} from {TABLE} a JOIN kundenverwaltung.kunde_artikel k ON a.kunde_id = k.kunde_id JOIN kundenverwaltung.artikel b ON k.artikel_id = b.artikel_id WHERE a.status = 2 and b.kategorie = {(int)kategorie} or a.status = 2 and b.kategorie = 4 GROUP BY a.auftrag_id, a.kunde_id HAVING COUNT(*) >= 1";
|
|
else cmd.CommandText = $"select {ACOLUMNS} from {TABLE} a JOIN kundenverwaltung.kunde_artikel k ON a.kunde_id = k.kunde_id JOIN kundenverwaltung.artikel b ON k.artikel_id = b.artikel_id WHERE a.status = 2 and b.kategorie = {(int)kategorie} GROUP BY a.auftrag_id, a.kunde_id HAVING COUNT(*) >= 1";
|
|
|
|
NpgsqlDataReader reader = cmd.ExecuteReader();
|
|
while (reader.Read()) resultList.Add(new Auftrag(reader));
|
|
reader.Close();
|
|
DatenbankConnection.GetConnection().Close();
|
|
return resultList;
|
|
}
|
|
public static List<Auftrag> GetRampeAuftragList()
|
|
{
|
|
DatenbankConnection.GetConnection().Open();
|
|
List<Auftrag> resultList = new List<Auftrag>();
|
|
NpgsqlCommand cmd = new NpgsqlCommand();
|
|
cmd.Connection = DatenbankConnection.GetConnection();
|
|
|
|
cmd.CommandText = $"select {COLUMNS} from {TABLE} where status = 0 order by liefertag asc";
|
|
|
|
NpgsqlDataReader reader = cmd.ExecuteReader();
|
|
while (reader.Read()) resultList.Add(new Auftrag(reader));
|
|
reader.Close();
|
|
DatenbankConnection.GetConnection().Close();
|
|
return resultList;
|
|
}
|
|
public static List<Auftrag> GetAuftragList(string s, Auftrag auftrag)
|
|
{
|
|
int? aID = null;
|
|
int? mID = null;
|
|
//Get MaschineID und AuftragID für Aufträge vor und nach Auftrag
|
|
if (auftrag != null)
|
|
{
|
|
mID = auftrag.MaschineID;
|
|
aID = auftrag.AuftragID;
|
|
}
|
|
//Get AufgabeID für Anzeige von Standerhöhungen
|
|
if (s == "STH") aID = (int)Aufgabe.GetAufgabe(s, null).AufgabeID;
|
|
|
|
DatenbankConnection.GetConnection().Open();
|
|
List<Auftrag> resultList = new List<Auftrag>();
|
|
NpgsqlCommand command = new NpgsqlCommand();
|
|
command.Connection = DatenbankConnection.GetConnection();
|
|
|
|
if (s == "Expedit") command.CommandText = $"select {COLUMNS} from {TABLE} where status = 3 order by liefertag asc";
|
|
if (s == string.Empty) command.CommandText = $"select {COLUMNS} from {TABLE} where gedruckt is null and erledigt is null";
|
|
if (s == "davor") command.CommandText = $"select {COLUMNS} from {TABLE} where maschine_id = {mID} and auftrag_id < {aID} order by liefertag asc limit 3";
|
|
if (s == "danach") command.CommandText = $"select {COLUMNS} from {TABLE} where maschine_id = {mID} and auftrag_id > {aID} order by liefertag asc limit 3";
|
|
if (s == "STH") command.CommandText = $"select {COLUMNS} from {TABLE} where status = 3 and aufgabe_id = {aID} order by liefertag";
|
|
|
|
NpgsqlDataReader reader = command.ExecuteReader();
|
|
while (reader.Read()) resultList.Add(new Auftrag(reader));
|
|
reader.Close();
|
|
DatenbankConnection.GetConnection().Close();
|
|
return resultList;
|
|
}
|
|
public static List<Auftrag> GetAuftragStatsListToday(DateTime produktion)
|
|
{
|
|
DatenbankConnection.GetConnection().Open();
|
|
List<Auftrag> resultList = new List<Auftrag>();
|
|
NpgsqlCommand command = new NpgsqlCommand();
|
|
command.Connection = DatenbankConnection.GetConnection();
|
|
|
|
command.CommandText = $"select {COLUMNS} from {TABLE} where typ = 1 and erstellt::date = '{produktion.Date}' order by liefertag asc";
|
|
|
|
NpgsqlDataReader reader = command.ExecuteReader();
|
|
while (reader.Read()) resultList.Add(new Auftrag(reader));
|
|
reader.Close();
|
|
DatenbankConnection.GetConnection().Close();
|
|
return resultList;
|
|
}
|
|
public static List<Auftrag> GetTourenListe(Benutzer fahrer)
|
|
{
|
|
DateTime dateTime = NaechsterLiefertag();
|
|
DatenbankConnection.GetConnection().Open();
|
|
List<Auftrag> resultList = new List<Auftrag>();
|
|
NpgsqlCommand command = new NpgsqlCommand();
|
|
command.Connection = DatenbankConnection.GetConnection();
|
|
|
|
command.CommandText = $"select {ACOLUMNS} from {TABLE} a join kundenverwaltung.kunde k on a.kunde_id = k.kunde_id where typ >= {(int)AuftragTyp.Standart} and a.liefertag = '{dateTime}' and a.benutzer_id = {fahrer.BenutzerID} and a.status <= {(int)AuftragStatus.Fertig} order by k.region, k.bezeichnung";
|
|
|
|
NpgsqlDataReader reader = command.ExecuteReader();
|
|
while (reader.Read()) resultList.Add(new Auftrag(reader));
|
|
reader.Close();
|
|
DatenbankConnection.GetConnection().Close();
|
|
return resultList;
|
|
}
|
|
|
|
public static Auftrag GetAuftrag(int? auftragID)
|
|
{
|
|
Auftrag result = new Auftrag();
|
|
|
|
try
|
|
{
|
|
DatenbankConnection.GetConnection().Open();
|
|
NpgsqlCommand command = new NpgsqlCommand();
|
|
command.Connection = DatenbankConnection.GetConnection();
|
|
command.CommandText = $"select {COLUMNS} from {TABLE} where auftrag_id = {auftragID}";
|
|
NpgsqlDataReader reader = command.ExecuteReader();
|
|
while (reader.Read()) result = new Auftrag(reader);
|
|
reader.Close();
|
|
DatenbankConnection.GetConnection().Close();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "FEHLER", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
Program.AddFehler(null, ex.Message, ex.StackTrace, null);
|
|
throw;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
public static Auftrag GetLastAuftrag(int? benutzerID)
|
|
{
|
|
DatenbankConnection.GetConnection().Open();
|
|
Auftrag result = new Auftrag();
|
|
NpgsqlCommand command = new NpgsqlCommand();
|
|
command.Connection = DatenbankConnection.GetConnection();
|
|
command.CommandText = $"select {COLUMNS} from {TABLE} where erstellt_von = {benutzerID} order by erstellt desc limit 1";
|
|
NpgsqlDataReader reader = command.ExecuteReader();
|
|
while (reader.Read()) result = new Auftrag(reader);
|
|
reader.Close();
|
|
DatenbankConnection.GetConnection().Close();
|
|
return result;
|
|
|
|
}
|
|
public static List<Auftrag> FindeAuftragVonKunde(Kunde kunde, string zusatz, string datum, DateTime? date)
|
|
{
|
|
List<Auftrag> result = new List<Auftrag>();
|
|
DatenbankConnection.GetConnection().Open();
|
|
NpgsqlCommand command = new NpgsqlCommand();
|
|
|
|
command.Connection = DatenbankConnection.GetConnection();
|
|
if (string.IsNullOrWhiteSpace(zusatz))
|
|
{
|
|
if (date == null) command.CommandText = $"select {COLUMNS} from {TABLE} where kunde_id = {kunde.KundeID} and status = {(int)AuftragStatus.Abgeholt}";
|
|
else command.CommandText = $"select {COLUMNS} from {TABLE} where kunde_id = {kunde.KundeID} and {datum} = '{date}'";
|
|
}
|
|
else command.CommandText = $"select {COLUMNS} from {TABLE} where kunde_id = {kunde.KundeID} and status = {(int)AuftragStatus.Abgeholt} and zusatz ~* '{zusatz}'";
|
|
NpgsqlDataReader reader = command.ExecuteReader();
|
|
while (reader.Read()) result.Add(new Auftrag(reader));
|
|
reader.Close();
|
|
DatenbankConnection.GetConnection().Close();
|
|
|
|
return result;
|
|
}
|
|
private bool FindAuftragStatus(int? auftragid, AuftragStatus status)
|
|
{
|
|
if (!auftragid.HasValue) return false;
|
|
|
|
NpgsqlConnection conn = null;
|
|
NpgsqlCommand cmd = null;
|
|
|
|
try
|
|
{
|
|
conn = new NpgsqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
|
|
conn.Open();
|
|
|
|
cmd = new NpgsqlCommand(@"
|
|
SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END
|
|
FROM kundenverwaltung.auftrag_status
|
|
WHERE auftrag_id = @AuftragId AND auftrag_status = @Status", conn);
|
|
|
|
cmd.Parameters.AddWithValue("AuftragId", auftragid.Value);
|
|
cmd.Parameters.AddWithValue("Status", (int)status);
|
|
|
|
int result = (int)cmd.ExecuteScalar();
|
|
return result > 0;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
finally
|
|
{
|
|
if (cmd != null) cmd.Dispose();
|
|
if (conn != null && conn.State == ConnectionState.Open)
|
|
{
|
|
conn.Close();
|
|
conn.Dispose();
|
|
}
|
|
}
|
|
}
|
|
internal int? FindeFahrerIDZuAuftrag(Kunde kunde, DateTime liefertag)
|
|
{
|
|
int? result = null;
|
|
|
|
try
|
|
{
|
|
DatenbankConnection.GetConnection().Open();
|
|
NpgsqlCommand command = new NpgsqlCommand();
|
|
|
|
command.Connection = DatenbankConnection.GetConnection();
|
|
command.CommandText = $"select a.benutzer_id from {TABLE} a inner join kundenverwaltung.kunde k on a.kunde_id = k.kunde_id where k.region = '{kunde.Region}' and a.liefertag = '{liefertag.Date}' order by a.benutzer_id limit 1";
|
|
NpgsqlDataReader reader = command.ExecuteReader();
|
|
while (reader.Read()) result = reader.GetInt32(0);
|
|
reader.Close();
|
|
DatenbankConnection.GetConnection().Close();
|
|
|
|
return result;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return result;
|
|
}
|
|
}
|
|
|
|
public (bool Gefunden, int auftragID) FindeAuftrag(bool exakt)
|
|
{
|
|
int result = 0;
|
|
|
|
try
|
|
{
|
|
DatenbankConnection.GetConnection().Open();
|
|
NpgsqlCommand command = new NpgsqlCommand();
|
|
|
|
command.Connection = DatenbankConnection.GetConnection();
|
|
if (this.Typ != AuftragTyp.Regelmäßig)
|
|
{
|
|
if (exakt) command.CommandText = $"select auftrag_id from {TABLE} where kunde_id = {this.KundeID} and erstellt::date = '{this.Erstellt.Value.Date}' and liefertag = '{this.Liefertag}'";
|
|
else command.CommandText = $"select auftrag_id from {TABLE} where kunde_id = {this.KundeID} and liefertag = '{this.Liefertag}' and status = {(int)this.Status}";
|
|
}
|
|
else command.CommandText = $"select auftrag_id from {TABLE} where kunde_id = {this.KundeID} and typ = {(int)this.Typ}";
|
|
NpgsqlDataReader reader = command.ExecuteReader();
|
|
while (reader.Read()) result = reader.GetInt16(0);
|
|
reader.Close();
|
|
DatenbankConnection.GetConnection().Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "FEHLER", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
Program.AddFehler(null, ex.Message, ex.StackTrace, null);
|
|
throw;
|
|
}
|
|
|
|
|
|
if(result > 0) return (true, result);
|
|
else return (false, result);
|
|
}
|
|
public static int[] GetContainerAnzahlen(int? kundeId)
|
|
{
|
|
const string sql = @"
|
|
SELECT
|
|
COALESCE(MAX(container_clean), 0) as max_clean,
|
|
COALESCE(ROUND(AVG(container_clean)), 0) as avg_clean,
|
|
COALESCE(MIN(container_clean), 0) as min_clean
|
|
FROM {0}
|
|
WHERE (@kundeId IS NULL OR kunde_id = @kundeId)";
|
|
|
|
NpgsqlConnection connection = null;
|
|
NpgsqlCommand command = null;
|
|
NpgsqlDataReader reader = null;
|
|
|
|
try
|
|
{
|
|
connection = DatenbankConnection.GetConnection();
|
|
connection.Open();
|
|
|
|
command = new NpgsqlCommand(string.Format(sql, TABLE), connection);
|
|
command.Parameters.AddWithValue("kundeId", kundeId ?? (object)DBNull.Value);
|
|
|
|
reader = command.ExecuteReader();
|
|
if (reader.Read())
|
|
{
|
|
return new[]
|
|
{
|
|
reader.GetInt32(0),
|
|
reader.GetInt32(1),
|
|
reader.GetInt32(2)
|
|
};
|
|
}
|
|
return new[] { 0, 0, 0 };
|
|
}
|
|
finally
|
|
{
|
|
reader?.Close();
|
|
command?.Dispose();
|
|
connection?.Close();
|
|
}
|
|
}
|
|
|
|
public static int[] GetContaineranzahl(int? kundeId)
|
|
{
|
|
int[] result = { 0, 0, 0 };
|
|
int i = 0;
|
|
DatenbankConnection.GetConnection().Open();
|
|
NpgsqlCommand command = new NpgsqlCommand();
|
|
|
|
command.Connection = DatenbankConnection.GetConnection();
|
|
command.CommandText = $"select max(container_clean), avg(container_clean), min(container_clean) from {TABLE} where kunde_id = {kundeId}";
|
|
|
|
NpgsqlDataReader reader = command.ExecuteReader();
|
|
while (reader.Read())
|
|
{
|
|
result[i] = reader.IsDBNull(i) ? 0 : reader.GetInt16(i);
|
|
i++;
|
|
}
|
|
reader.Close();
|
|
DatenbankConnection.GetConnection().Close();
|
|
|
|
|
|
return result;
|
|
}
|
|
public Auftrag(NpgsqlDataReader reader, bool isExpedit = true)
|
|
{
|
|
this.AuftragID = reader.GetInt32(0);
|
|
this.ArbeiterID = reader.IsDBNull(1) ? null : (int?)reader.GetInt32(1);
|
|
this.AufgabeID = reader.IsDBNull(2) ? null : (int?)reader.GetInt32(2);
|
|
this.KundeID = reader.GetInt32(3);
|
|
this.ZusatzInfo = reader.IsDBNull(4) ? string.Empty : reader.GetString(4);
|
|
this.Liefertag = reader.GetDateTime(5);
|
|
this.Gedruckt = reader.IsDBNull(6) ? null : (DateTime?)reader.GetDateTime(6);
|
|
this.GedrucktVon = reader.IsDBNull(7) ? null : (int?)reader.GetInt32(7);
|
|
this.Erledigt = reader.IsDBNull(8) ? null : (DateTime?)reader.GetDateTime(8);
|
|
this.ErledigtVon = reader.IsDBNull(9) ? null : (int?)reader.GetInt32(9);
|
|
this.Erstellt = reader.IsDBNull(10) ? null : (DateTime?)reader.GetDateTime(10);
|
|
this.ErstelltVon = reader.GetInt32(11);
|
|
this.Status = (AuftragStatus)reader.GetInt32(12);
|
|
this.TourID = reader.IsDBNull(13) ? null : (int?)reader.GetInt32(13);
|
|
this.Container = reader.IsDBNull(14) ? 0 : reader.GetInt32(14);
|
|
this.MaschineID = reader.IsDBNull(15) ? null : (int?)reader.GetInt32(15);
|
|
this.ContainerClean = reader.IsDBNull(16) ? 0 : reader.GetInt32(16);
|
|
this.Typ = reader.IsDBNull(17) ? AuftragTyp.Standart : (AuftragTyp)reader.GetInt32(17);
|
|
this.AufgabeErledigt = reader.IsDBNull(18) ? false : reader.GetBoolean(18);
|
|
this.Abteilungen = reader.IsDBNull(19) ? AbteilungsStatus.Keine : (AbteilungsStatus)reader.GetInt16(19);
|
|
this.Rhythmus = reader.IsDBNull(20) ? RegRhythmen.Unbekannt : (RegRhythmen)reader.GetInt32(20);
|
|
this.Priority = (AuftragPriority)reader.GetInt32(21);
|
|
|
|
if (isExpedit)
|
|
{
|
|
this.Kundename = reader.GetString(22);
|
|
this.Kundename = reader.IsDBNull(23) ? this.Kundename : reader.GetString(23);
|
|
if (this.Kundename == "BAR DIVERSE") this.Kundename = this.ZusatzInfo;
|
|
this.Fahrer = reader.IsDBNull(24) ? string.Empty : reader.GetString(24);
|
|
}
|
|
|
|
}
|
|
|
|
public Auftrag(NpgsqlDataReader reader)
|
|
{
|
|
this.AuftragID = reader.GetInt32(0);
|
|
this.ArbeiterID = reader.IsDBNull(1) ? null : (int?)reader.GetInt32(1);
|
|
this.AufgabeID = reader.IsDBNull(2) ? null : (int?)reader.GetInt32(2);
|
|
this.KundeID = reader.GetInt32(3);
|
|
this.ZusatzInfo = reader.IsDBNull(4) ? string.Empty : reader.GetString(4);
|
|
this.Liefertag = reader.GetDateTime(5);
|
|
this.Gedruckt = reader.IsDBNull(6) ? null : (DateTime?)reader.GetDateTime(6);
|
|
this.GedrucktVon = reader.IsDBNull(7) ? null : (int?)reader.GetInt32(7);
|
|
this.Erledigt = reader.IsDBNull(8) ? null : (DateTime?)reader.GetDateTime(8);
|
|
this.ErledigtVon = reader.IsDBNull(9) ? null : (int?)reader.GetInt32(9);
|
|
this.Erstellt = reader.IsDBNull(10) ? null : (DateTime?)reader.GetDateTime(10);
|
|
this.ErstelltVon = reader.GetInt32(11);
|
|
this.Status = (AuftragStatus)reader.GetInt32(12);
|
|
this.TourID = reader.IsDBNull(13) ? null : (int?)reader.GetInt32(13);
|
|
this.Container = reader.IsDBNull(14) ? 0 : reader.GetInt32(14);
|
|
this.MaschineID = reader.IsDBNull(15) ? null : (int?)reader.GetInt32(15);
|
|
this.ContainerClean = reader.IsDBNull(16) ? 0 : reader.GetInt32(16);
|
|
this.Typ = reader.IsDBNull(17) ? AuftragTyp.Standart : (AuftragTyp)reader.GetInt32(17);
|
|
this.AufgabeErledigt = reader.IsDBNull(18) ? false : reader.GetBoolean(18);
|
|
this.Abteilungen = reader.IsDBNull(19) ? AbteilungsStatus.Keine : (AbteilungsStatus)reader.GetInt16(19);
|
|
this.Rhythmus = reader.IsDBNull(20) ? RegRhythmen.Unbekannt : (RegRhythmen)reader.GetInt32(20);
|
|
this.Priority = (AuftragPriority)reader.GetInt32(21);
|
|
|
|
}
|
|
|
|
#region Properties
|
|
/// <summary>
|
|
/// SPALTE 1 - Der Kundename wird angezeigt
|
|
/// </summary>
|
|
[OLVColumn("Kunde", DisplayIndex = 0)]
|
|
public string Kundename { get; set; }
|
|
|
|
/// <summary>
|
|
/// SPALTE 3 - Liefertag mit ausgeschriebenen Tag als zweite Spalte.
|
|
/// </summary>
|
|
[OLVColumn("Liefertag", DisplayIndex = 2)]
|
|
public DateTime Liefertag { get; set; }
|
|
|
|
/// <summary>
|
|
/// SPALTE 4 - Containeranzahl schmutzig
|
|
/// </summary>
|
|
[OLVColumn("schmutzig", DisplayIndex = 3, TextAlign = System.Windows.Forms.HorizontalAlignment.Center)]
|
|
public int Container { get; set; }
|
|
|
|
/// <summary>
|
|
/// SPALTE 5 - Containeranzahl sauber
|
|
/// </summary>
|
|
[OLVColumn("sauber", DisplayIndex = 4, TextAlign = System.Windows.Forms.HorizontalAlignment.Center)]
|
|
public int ContainerClean { get; set; }
|
|
|
|
/// <summary>
|
|
/// SPALTE 6 - Der Status wird angezeigt.
|
|
/// </summary>
|
|
private AuftragStatus _status;
|
|
[OLVColumn("Status", DisplayIndex = 5)]
|
|
public AuftragStatus Status
|
|
{
|
|
get => _status;
|
|
set
|
|
{
|
|
if (_status == value) return;
|
|
|
|
_status = value;
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Status)));
|
|
if (this.AuftragID != null)
|
|
{
|
|
if (!FindAuftragStatus(this.AuftragID, Status))
|
|
SpeichereStatus(); // Automatisches Speichern
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// SPALTE 7 - Der Auftragtyp wird angezeigt.
|
|
/// </summary>
|
|
[OLVColumn("Typ", IsVisible = true, DisplayIndex = 6)]
|
|
public AuftragTyp Typ { get; set; }
|
|
|
|
/// <summary>
|
|
/// SPALTE 8 - Die "Erstellt von" Spalte mit Datum wird erstellt
|
|
/// </summary>
|
|
private string _auftragerstellt;
|
|
[OLVColumn("Erstellt")]
|
|
public string AuftragErstellt
|
|
{
|
|
get
|
|
{
|
|
if (this.Erstellt != null) return _auftragerstellt = Benutzer.GetBenutzer(null, this.ErstelltVon).BenutzerName + " von " + this.Erstellt.ToString();
|
|
else return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// SPALTE 9 - Die "Gedruckt von" Spalte mit Datum wird erstellt
|
|
/// </summary>
|
|
private string _auftraggedruckt;
|
|
[OLVColumn("Gedruckt")]
|
|
public string AuftragGedruckt
|
|
{
|
|
get
|
|
{
|
|
if(this.Gedruckt != null) return _auftraggedruckt = Benutzer.GetBenutzer(null, this.GedrucktVon).BenutzerName + " von " + this.Gedruckt.ToString();
|
|
else return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// SPALTE 10 - Die "Erledigt von" Spalte mit Datum wird erstellt
|
|
/// </summary>
|
|
private string _auftragerledigt;
|
|
[OLVColumn("Erledigt")]
|
|
public string AuftragErledigt
|
|
{
|
|
get
|
|
{
|
|
if (this.Erledigt != null) return _auftragerledigt = Benutzer.GetBenutzer(null, this.ErledigtVon).BenutzerName + " von " + this.Erledigt.ToString();
|
|
else return null;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// SPALTE 11 - Die Aufgabe (STV, STH, INV) wird angezeigt wenn vorhanden.
|
|
/// </summary>
|
|
private string _auftragaufgabe;
|
|
[OLVColumn("Aufgabe", DisplayIndex = 10, TextAlign = System.Windows.Forms.HorizontalAlignment.Center)]
|
|
public string AuftragAufgabe
|
|
{
|
|
get
|
|
{
|
|
if (this.AufgabeID != null) return _auftragaufgabe = Aufgabe.GetAufgabe(null, this.AufgabeID).Bezeichnung;
|
|
else return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// SPALTE 12 - Button Etikett Drucken wird angezeigt.
|
|
/// </summary>
|
|
private string _etikett;
|
|
[OLVColumn("Etikett", DisplayIndex = 11, TextAlign = System.Windows.Forms.HorizontalAlignment.Center)]
|
|
public string Etikett
|
|
{
|
|
get
|
|
{
|
|
if (Typ >= AuftragTyp.Inventur & Typ <= AuftragTyp.Standverminderung)
|
|
{
|
|
if (Status >= AuftragStatus.Vorbereitet) return _fertig = string.Empty;
|
|
else return _fertig = "🖨";
|
|
}
|
|
else
|
|
{
|
|
if (Status <= AuftragStatus.Herrichten) return _fertig = "🖨";
|
|
else
|
|
{
|
|
if (Status == AuftragStatus.Vorbereitet) return _fertig = "🖨";
|
|
else return _fertig = string.Empty;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// SPALTE 13 - Button Abschließenvon Aufträgen wird angezeigt.
|
|
/// </summary>
|
|
private string _fertig;
|
|
[OLVColumn("Abschließen", DisplayIndex = 12, TextAlign = System.Windows.Forms.HorizontalAlignment.Center)]
|
|
public string Fertig
|
|
{
|
|
get
|
|
{
|
|
if(Typ >= AuftragTyp.Inventur & Typ <= AuftragTyp.Standverminderung)
|
|
{
|
|
if (Status >= AuftragStatus.Fertig) return _fertig = string.Empty;
|
|
else return _fertig = "✅";
|
|
}
|
|
else
|
|
{
|
|
if (Status == AuftragStatus.Vorbereitet || Status == AuftragStatus.Herrichten || Status == AuftragStatus.Gewaschen) return _fertig = "✅";
|
|
else
|
|
{
|
|
return _fertig = string.Empty;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
[OLVColumn("Fahrer", DisplayIndex = 13)]
|
|
public string Fahrer { get; set; }
|
|
|
|
/// <summary>
|
|
/// Zusatz und Typ Properties werden ausgeblendet.
|
|
/// </summary>
|
|
[OLVColumn("Zusatz", IsVisible = false)]
|
|
public string ZusatzInfo { get; set; }
|
|
|
|
/// <summary>
|
|
/// Properties von ObjectListView ignoriert.
|
|
/// </summary>
|
|
[OLVIgnore]
|
|
public bool IsChecked { get; set; }
|
|
[OLVIgnore]
|
|
public int? AuftragID { get; set; }
|
|
[OLVIgnore]
|
|
public int? GedrucktVon { get; set; }
|
|
[OLVIgnore]
|
|
public DateTime? Gedruckt { get; set; }
|
|
[OLVIgnore]
|
|
public DateTime? Erledigt { get; set; }
|
|
[OLVIgnore]
|
|
public int? ErledigtVon { get; set; }
|
|
[OLVIgnore]
|
|
public DateTime? Erstellt { get; set; }
|
|
[OLVIgnore]
|
|
public int ErstelltVon { get; set; }
|
|
[OLVIgnore]
|
|
public int? MaschineID { get; set; }
|
|
[OLVIgnore]
|
|
public int KundeID { get; set; }
|
|
[OLVIgnore]
|
|
public int? TourID { get; set; }
|
|
/// <summary>
|
|
/// BenutzerID des ausführenden Users
|
|
/// </summary>
|
|
[OLVIgnore]
|
|
public int? ArbeiterID { get; set; }
|
|
[OLVIgnore]
|
|
public int? AufgabeID { get; set; }
|
|
[OLVIgnore]
|
|
public bool AufgabeErledigt { get; set; } = false;
|
|
[OLVIgnore]
|
|
public AbteilungsStatus Abteilungen { get; set; }
|
|
[OLVIgnore]
|
|
public RegRhythmen Rhythmus { get; set; }
|
|
[OLVIgnore]
|
|
public AuftragPriority Priority { get; set; } = 0;
|
|
|
|
#endregion
|
|
private void SpeichereStatus()
|
|
{
|
|
var conn = new NpgsqlConnection(ConfigurationManager.AppSettings["ConnectionString"]); // Pro Task!
|
|
try
|
|
{
|
|
conn.Open();
|
|
|
|
int auftragStatusID = 0;
|
|
NpgsqlCommand command = new NpgsqlCommand();
|
|
command.Connection = conn;
|
|
|
|
command.CommandText = "select nextval('kundenverwaltung.auftrag_status_seq')";
|
|
auftragStatusID = (int)(long)command.ExecuteScalar();
|
|
|
|
command.CommandText = $"INSERT INTO kundenverwaltung.auftrag_status(auftrag_status_id, auftrag_id, benutzer_id, auftrag_status, status_changed) VALUES (:p0, :p1, :p2, :p3, :p4)";
|
|
|
|
command.Parameters.AddWithValue("p0", auftragStatusID);
|
|
command.Parameters.AddWithValue("p1", this.AuftragID);
|
|
command.Parameters.AddWithValue("p2", Program.benutzer == null ? (object)DBNull.Value : Program.benutzer.BenutzerID);
|
|
command.Parameters.AddWithValue("p3", (int)_status);
|
|
command.Parameters.AddWithValue("p4", DateTime.Now);
|
|
|
|
command.ExecuteNonQuery();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
finally
|
|
{
|
|
if (conn.State == ConnectionState.Open)
|
|
conn.Close();
|
|
conn.Dispose();
|
|
}
|
|
}
|
|
|
|
public int[] Save()
|
|
{
|
|
DatenbankConnection.GetConnection().Open();
|
|
int[] result = new int[2];
|
|
NpgsqlCommand command = new NpgsqlCommand();
|
|
command.Connection = DatenbankConnection.GetConnection();
|
|
|
|
if (this.AuftragID.HasValue & this.AuftragID != 0)
|
|
{
|
|
command.CommandText = $"update {TABLE} set benutzer_id = :p1, aufgabe_id = :p2, kunde_id = :p3, zusatz = :p4, liefertag = :p5, gedruckt = :p6, gedruckt_von = :p7, erledigt = :p8, erledigt_von = :p9, erstellt = :p10, erstellt_von = :p11, status = :p12, tour_id = :p13, container_dirt = :p14, maschine_id = :p15, container_clean = :p16, typ = :p17, aufgabe_erledigt = :p18, abteilungen_status = :p19, rhythmus = :p20, priority = :p21 WHERE auftrag_id = :p0";
|
|
}
|
|
else
|
|
{
|
|
command.CommandText = "select nextval('kundenverwaltung.auftrag_seq')";
|
|
this.AuftragID = result[1] = (int)(long)command.ExecuteScalar();
|
|
command.CommandText = $"insert into {TABLE} ({COLUMNS}) values (:p0, :p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8, :p9, :p10, :p11, :p12, :p13, :p14, :p15, :p16, :p17, :p18, :p19, :p20, :p21)";
|
|
}
|
|
|
|
command.Parameters.AddWithValue("p0", this.AuftragID);
|
|
command.Parameters.AddWithValue("p1", this.ArbeiterID.HasValue ? this.ArbeiterID.Value : (object)DBNull.Value);
|
|
command.Parameters.AddWithValue("p2", this.AufgabeID.HasValue ? this.AufgabeID.Value : (object)DBNull.Value);
|
|
command.Parameters.AddWithValue("p3", this.KundeID);
|
|
command.Parameters.AddWithValue("p4", string.IsNullOrEmpty(this.ZusatzInfo) ? (object)DBNull.Value : this.ZusatzInfo);
|
|
command.Parameters.AddWithValue("p5", this.Liefertag);
|
|
command.Parameters.AddWithValue("p6", this.Gedruckt.HasValue ? this.Gedruckt.Value : (object)DBNull.Value);
|
|
command.Parameters.AddWithValue("p7", this.GedrucktVon.HasValue ? this.GedrucktVon.Value : (object)DBNull.Value);
|
|
command.Parameters.AddWithValue("p8", this.Erledigt.HasValue ? this.Erledigt.Value : (object)DBNull.Value);
|
|
command.Parameters.AddWithValue("p9", this.ErledigtVon.HasValue ? this.ErledigtVon.Value : (object)DBNull.Value);
|
|
command.Parameters.AddWithValue("p10", this.Erstellt);
|
|
command.Parameters.AddWithValue("p11", this.ErstelltVon);
|
|
command.Parameters.AddWithValue("p12", (int)this.Status);
|
|
command.Parameters.AddWithValue("p13", this.TourID.HasValue ? this.TourID.Value : (object)DBNull.Value);
|
|
command.Parameters.AddWithValue("p14", this.Container);
|
|
command.Parameters.AddWithValue("p15", this.MaschineID.HasValue ? this.MaschineID.Value : 0);
|
|
command.Parameters.AddWithValue("p16", this.ContainerClean);
|
|
command.Parameters.AddWithValue("p17", (int)this.Typ);
|
|
command.Parameters.AddWithValue("p18", this.AufgabeErledigt);
|
|
command.Parameters.AddWithValue("p19", (int)this.Abteilungen);
|
|
command.Parameters.AddWithValue("p20", (int)this.Rhythmus);
|
|
command.Parameters.AddWithValue("p21", (int)this.Priority);
|
|
|
|
result[0] = command.ExecuteNonQuery();
|
|
DatenbankConnection.GetConnection().Close();
|
|
return result;
|
|
}
|
|
public static DateTime NaechsterLiefertag()
|
|
{
|
|
DateTime heute = DateTime.Today;
|
|
DateTime kandidat = heute.AddDays(1);
|
|
|
|
// Wochenende überspringen
|
|
while (kandidat.DayOfWeek == DayOfWeek.Saturday || kandidat.DayOfWeek == DayOfWeek.Sunday)
|
|
kandidat = kandidat.AddDays(1);
|
|
|
|
return kandidat;
|
|
}
|
|
|
|
internal static List<Auftrag> SucheAuftrag(string datum, DateTime date, AuftragStatus? status, AuftragTyp? typ)
|
|
{
|
|
int parts = 0;
|
|
string commandline = $"select {COLUMNS} from {TABLE} where ";
|
|
string and = " and ";
|
|
List<Auftrag> result = new List<Auftrag>();
|
|
DatenbankConnection.GetConnection().Open();
|
|
NpgsqlCommand command = new NpgsqlCommand();
|
|
|
|
command.Connection = DatenbankConnection.GetConnection();
|
|
if (!string.IsNullOrWhiteSpace(datum)) { commandline += $"{datum} = '{date}'"; parts++; }
|
|
if (status != null)
|
|
{
|
|
if (parts > 0) commandline += and + $"status = {(int)status}";
|
|
else commandline += $"status = {(int)status}";
|
|
}
|
|
if (typ != null)
|
|
{
|
|
if (parts > 0) commandline += and + $"typ = {(int)typ}";
|
|
else commandline += $"typ = {(int)typ}";
|
|
}
|
|
|
|
command.CommandText = commandline;
|
|
NpgsqlDataReader reader = command.ExecuteReader();
|
|
while (reader.Read()) result.Add(new Auftrag(reader));
|
|
reader.Close();
|
|
DatenbankConnection.GetConnection().Close();
|
|
|
|
return result;
|
|
|
|
}
|
|
}
|
|
}
|
|
//INSTALL-REMINDER: DB anpassen. (Priority in Auftrag etc.)
|
|
//CAHNGES: Priority wird bei Auftrag hinterlegt. Derzeit nach Fahrer Vorname bis andere Lösung gefunden.
|
|
//TODO: Non-Hard-Coded-Lösung für Priority finden. |