152 lines
3.8 KiB
C#
152 lines
3.8 KiB
C#
using BrightIdeasSoftware;
|
|
using DatenDB;
|
|
using Npgsql;
|
|
using System;
|
|
using System.CodeDom;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Drawing.Printing;
|
|
using System.Linq;
|
|
using System.Runtime.ConstrainedExecution;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Deckungsbeitrag
|
|
{
|
|
public partial class FormAufleger : Form
|
|
{
|
|
private Dictionary<DateTime, List<Auftrag>> auftragliste;
|
|
private System.Windows.Forms.Timer timer;
|
|
|
|
public FormAufleger()
|
|
{
|
|
InitializeComponent();
|
|
|
|
// Timer für Wartezeit bis TextChanged eintritt.
|
|
timer = new System.Windows.Forms.Timer();
|
|
timer.Interval = 700; // 0,7 Sekunden
|
|
//timer.Tick += Timer_Tick;
|
|
|
|
}
|
|
|
|
private async void FormAufleger_Load(object sender, EventArgs e)
|
|
{
|
|
this.Cursor = Cursors.WaitCursor;
|
|
this.SuspendLayout();
|
|
|
|
await GetAuftraege();
|
|
|
|
|
|
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
LoadPanel();
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
private void LoadPanel()
|
|
{
|
|
for (int i = 0; i < this.tLPAuftrag.RowCount; i++)
|
|
{
|
|
if(i == 0)
|
|
{
|
|
int index = 0;
|
|
foreach (var key in auftragliste.Keys.OrderBy(k => k))
|
|
{
|
|
Control ctr = this.tLPAuftrag.GetControlFromPosition(index, i);
|
|
ctr.Text = Funktionen.GetWochentagDeutsch(key.DayOfWeek);
|
|
ctr.Text += " (" + key.ToShortDateString() + ")"; // "13.02.2026"
|
|
|
|
index++;
|
|
}
|
|
}
|
|
if(i == 1)
|
|
{
|
|
foreach (List<Auftrag> liste in auftragliste.Values)
|
|
{
|
|
int col = 0;
|
|
foreach (Auftrag auftrag in liste)
|
|
{
|
|
Control ctr = this.tLPAuftrag.GetControlFromPosition(col, i);
|
|
FlowLayoutPanel flp = ctr as FlowLayoutPanel;
|
|
|
|
UCAuftrag uca = new UCAuftrag(auftrag);
|
|
uca.Tag = auftrag;
|
|
uca.Size = new Size(flp.Width - 30, uca.Height);
|
|
flp.Controls.Add(uca);
|
|
|
|
col++;
|
|
}
|
|
}
|
|
}
|
|
if(i == 2)
|
|
{
|
|
foreach (FlowLayoutPanel flowpanel in this.tLPAuftrag.Controls.OfType<FlowLayoutPanel>())
|
|
{
|
|
int column = this.tLPAuftrag.GetColumn(flowpanel);
|
|
int container = 0;
|
|
foreach (UCAuftrag uca in flowpanel.Controls) container += int.Parse(uca.ContainerAnzahl);
|
|
Control ctr = this.tLPAuftrag.GetControlFromPosition(column, i);
|
|
|
|
ctr.Text = container.ToString();
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private async Task GetAuftraege()
|
|
{
|
|
var conn = new NpgsqlConnection(ConfigurationManager.AppSettings["ConnectionString"]); // Pro Task!
|
|
try
|
|
{
|
|
await conn.OpenAsync();
|
|
auftragliste = await Auftrag.GetAuftraegeProLiefertagAsync(conn, AuftragTyp.Standart, AuftragStatus.Abgeholt);
|
|
}
|
|
finally
|
|
{
|
|
if (conn.State == ConnectionState.Open)
|
|
conn.Close();
|
|
conn.Dispose();
|
|
}
|
|
}
|
|
|
|
private void FormAufleger_Shown(object sender, EventArgs e)
|
|
{
|
|
|
|
this.ResumeLayout(false);
|
|
this.Cursor = Cursors.Default;
|
|
this.textBoxScan.Focus();
|
|
}
|
|
|
|
protected override bool ProcessDialogKey(Keys keyData)
|
|
{
|
|
//TODO: Umbau in Switch.
|
|
|
|
// Escape [ESC] schließt den Screen.
|
|
if (Form.ModifierKeys == Keys.None && keyData == Keys.Escape)
|
|
{
|
|
this.Close();
|
|
return true;
|
|
}
|
|
|
|
return base.ProcessDialogKey(keyData);
|
|
}
|
|
|
|
private void textBoxScan_TextChanged(object sender, EventArgs e)
|
|
{
|
|
// TextChanged tritt nur ein wenn x Sekunden keine Eingabe erfolgt. Logik befindet sich in Timer_Tick
|
|
timer.Stop(); // Alten Timer beenden
|
|
timer.Start(); // Neuen Timer starten
|
|
|
|
}
|
|
}
|
|
}
|