513 lines
18 KiB
C#
513 lines
18 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Diagnostics.Eventing.Reader;
|
|
using System.Drawing;
|
|
using System.Drawing.Printing;
|
|
using System.Linq;
|
|
using System.Runtime.ConstrainedExecution;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Web;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Forms.DataVisualization.Charting;
|
|
using System.Xml.Serialization;
|
|
using DatenDB;
|
|
using Deckungsbeitrag.Properties;
|
|
using ZXing;
|
|
using ZXing.QrCode.Internal;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
|
|
|
|
namespace Deckungsbeitrag
|
|
{
|
|
public partial class FormExpedit : Form
|
|
{
|
|
|
|
public Image etikett = null;
|
|
public Auftrag auftrag;
|
|
public AuftragArtikel auftragArtikel;
|
|
public Benutzer benutzer;
|
|
public Kunde kunde;
|
|
public FormExpedit(Benutzer benutzer)
|
|
{
|
|
InitializeComponent();
|
|
|
|
this.benutzer = benutzer;
|
|
//this.groupBoxEtikett.MouseDoubleClick += new MouseEventHandler(GroupBox_DoubleClick);
|
|
//this.groupBoxEtikett.MouseClick += new MouseEventHandler(GroupBox_Click);
|
|
this.Width = groupBoxEtikett.Width + 35;
|
|
this.Height = 470;
|
|
this.StartPosition = FormStartPosition.CenterScreen;
|
|
this.tabControlAuftragList.Visible = false;
|
|
this.buttonStatusSpeichern.Visible = false;
|
|
}
|
|
private void FormExpedit_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
//LADEN DER AUFTRAGSLISTEN FUNKTIONIERT DERZEIT NICHT NOTWENDIG.
|
|
|
|
//this.Cursor = Cursors.WaitCursor;
|
|
//Funktionen.HideControls(this.Controls);
|
|
|
|
//List<Auftrag> alllist = Auftrag.GetExpeditLists(null);
|
|
//List<Auftrag> sonderlist = Auftrag.GetExpeditLists((int)AuftragTyp.Sonder);
|
|
//List<Auftrag> standartlist = Auftrag.GetExpeditLists((int)AuftragTyp.Standart);
|
|
//if (standartlist.Count == 0) this.tabPageStandart.Visible = false;
|
|
//if (sonderlist.Count == 0) { this.tabPageSonder.Visible = false; }
|
|
|
|
|
|
//ListView_Load(alllist, this.listViewLieferungen);
|
|
//ListView_Load(sonderlist, this.listViewSonder);
|
|
//ListView_Load(standartlist, this.listViewStandart);
|
|
//Sonderauftrag_Load();
|
|
|
|
//Funktionen.ShowControls(this.Controls);
|
|
//this.Cursor = Cursors.Default;
|
|
|
|
this.buttonDrucken.Enabled = false;
|
|
this.buttonDrucken.BackColor = Color.Gray;
|
|
this.pictureBoxMinus.BackColor = Color.Gray;
|
|
this.pictureBoxPlus.BackColor = Color.Gray;
|
|
this.dTPLiefertag.Value = DateTime.Today;
|
|
this.dTPLiefertag.Enabled = false;
|
|
|
|
}
|
|
private void Container_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
PictureBox pb = (PictureBox)sender;
|
|
int cont = int.Parse(this.labelContainer.Text);
|
|
if (pb.Name.ToString().Contains("Plus")) cont++;
|
|
|
|
if (pb.Name.ToString().Contains("Minus"))
|
|
{
|
|
if (cont > 0)
|
|
{
|
|
cont--;
|
|
pb.BackColor = Color.Red;
|
|
pb.Enabled = true;
|
|
|
|
}
|
|
else { pb.BackColor = Color.Gray; pb.Enabled = false; }
|
|
}
|
|
|
|
this.labelContainer.Text = cont.ToString();
|
|
labelContainer_TextChanged(this, e);
|
|
|
|
}
|
|
private void Load_Etikett_GroupBox(Auftrag auftrag)
|
|
{
|
|
//if (auftrag != null) this.textBoxQRCode.Text = auftrag.AuftragID + " " + Kunde.GetKunde(null, auftrag.KundeID, null).Suchtext;
|
|
this.labelContainer.Text = auftrag.ContainerClean.ToString();
|
|
|
|
etikett = Funktionen.Etikett_Entwurf(auftrag);
|
|
|
|
this.pictureBoxEntwurf.Image = etikett;
|
|
this.buttonDrucken.Enabled = true;
|
|
this.buttonDrucken.BackColor = Color.FromArgb(0, 192, 0);
|
|
|
|
}
|
|
private void labelContainer_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (this.labelContainer.Text == "0") { this.pictureBoxMinus.Enabled = false; this.pictureBoxMinus.BackColor = Color.Gray; }
|
|
else { this.pictureBoxMinus.Enabled = true; this.pictureBoxMinus.BackColor = Color.Red; }
|
|
|
|
auftrag.ContainerClean = int.Parse(this.labelContainer.Text);
|
|
Load_Etikett_GroupBox(auftrag);
|
|
}
|
|
private void buttonAbbrechen_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
this.Close();
|
|
}
|
|
private void textBoxQRCode_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Menu)
|
|
{
|
|
textBoxQRCode_Leave(this, null);
|
|
}
|
|
|
|
//Console.WriteLine(textBoxQRCode.Text);
|
|
|
|
}
|
|
private void textBoxQRCode_Enter(object sender, EventArgs e)
|
|
{
|
|
//BEI VERWENDUNG DER TABS WIRD DER AUFTRAG GESUCHT
|
|
//foreach (ListViewItem item in this.listViewLieferungen.Items) item.Selected = false;
|
|
}
|
|
private void buttonDrucken_Click(object sender, EventArgs e)
|
|
{
|
|
Funktionen.Etikett_Drucken(auftrag);
|
|
}
|
|
private void buttonKundeNr_Click(object sender, EventArgs e)
|
|
{
|
|
Open_List();
|
|
|
|
if (kunde != null)
|
|
{
|
|
this.buttonKundeNr.Text = kunde.Suchtext;
|
|
auftrag = new Auftrag();
|
|
auftrag.KundeID = (int)kunde.KundeID;
|
|
auftrag.ZusatzInfo = kunde.Suchtext;
|
|
auftrag.Liefertag = dTPLiefertag.Value;
|
|
this.dTPLiefertag.Enabled = true;
|
|
this.pictureBoxPlus.Enabled = true;
|
|
this.pictureBoxPlus.BackColor = Color.FromArgb(0, 192, 0);
|
|
|
|
}
|
|
}
|
|
private void buttonSWS_Drucken_Click(object sender, EventArgs e)
|
|
{
|
|
Open_List();
|
|
if(kunde != null) Funktionen.SWS_Drucken(null, this.kunde);
|
|
}
|
|
private void Open_List()
|
|
{
|
|
FormListe liste = new FormListe(null, true);
|
|
if (liste.ShowDialog() == DialogResult.OK)
|
|
{
|
|
this.kunde = liste.kunde;
|
|
}
|
|
}
|
|
private void textBoxQRCode_Leave(object sender, EventArgs e)
|
|
{
|
|
//this.tabControlAuftragList.SelectedIndex = 0;
|
|
FormExpedit ex;
|
|
ListView listView = null;
|
|
|
|
if (string.IsNullOrWhiteSpace(textBoxQRCode.Text)) textBoxQRCode.Text = "Kundennummer eingeben";
|
|
else
|
|
{
|
|
if (tabControlAuftragList.Visible == true)
|
|
{
|
|
if (sender.GetType() == typeof(FormExpedit))
|
|
{
|
|
ex = (FormExpedit)sender;
|
|
listView = (ListView)ex.ActiveControl;
|
|
}
|
|
else
|
|
{
|
|
foreach (Control c in this.tabControlAuftragList.SelectedTab.Controls)
|
|
{
|
|
if (c.GetType() == typeof(ListView)) { listView = (ListView)c; }
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(textBoxQRCode.Text))
|
|
{
|
|
|
|
if (int.TryParse(textBoxQRCode.Text, out int value))
|
|
{
|
|
auftrag = Auftrag.GetAuftrag(value);
|
|
}
|
|
|
|
//Kunde kunde = Kunde.GetKunde(string.Empty, auftrag.KundeID, string.Empty);
|
|
foreach (ListViewItem item in listView.Items)
|
|
{
|
|
Auftrag auftrag = item.Tag as Auftrag;
|
|
if (auftrag.AuftragID.ToString() == textBoxQRCode.Text)
|
|
{
|
|
item.Selected = true;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (auftrag != null)
|
|
{
|
|
Load_Etikett_GroupBox(auftrag);
|
|
|
|
buttonDrucken.Enabled = true;
|
|
buttonDrucken.BackColor = Color.FromArgb(0, 192, 0);
|
|
this.labelContainer.Text = auftrag.ContainerClean.ToString();
|
|
}
|
|
|
|
}
|
|
this.buttonAbbrechen.Focus();
|
|
}
|
|
private void dTPLiefertag_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
if(auftrag != null) auftrag.Liefertag = dTPLiefertag.Value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// FUNKTIONEN MIT LISTVIEW
|
|
/// </summary>
|
|
|
|
//GLEICHE FUNKTIONEN ABER ONE CLICK ODER DOUBLE CLICK (LISTVIEW)
|
|
private void GroupBox_Click(object sender, MouseEventArgs e)
|
|
{
|
|
Control ctr = this.groupBoxEtikett.GetChildAtPoint(e.Location);
|
|
|
|
if(auftrag != null)
|
|
{
|
|
if (this.listViewLieferungen.SelectedItems.Count == 0 && this.textBoxQRCode.Text.Contains("scannen"))
|
|
{
|
|
MessageBox.Show("Containeranzahl ändern NICHT MÖGLICH. Du hast noch keinen Auftrag ausgewählt.", "ACHTUNG", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
|
}
|
|
else
|
|
{
|
|
if (ctr != null && ctr.Name.Contains("Minus"))
|
|
{
|
|
if (int.Parse(this.labelContainer.Text) == 0) { MessageBox.Show($"Containeranzahl kleiner als 0 ist nicht möglich.", "ACHTUNG", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; }
|
|
else
|
|
{
|
|
if (MessageBox.Show("Möchtest du die Containeranzahl händisch verändern?", "Frage", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
this.pictureBoxMinus.Enabled = this.pictureBoxPlus.Enabled = true;
|
|
this.pictureBoxMinus.BackColor = Color.Red;
|
|
this.pictureBoxPlus.BackColor = Color.FromArgb(0, 192, 0);
|
|
labelContainer_TextChanged(this, e);
|
|
}
|
|
else return;
|
|
}
|
|
|
|
}
|
|
|
|
if (ctr != null && ctr.Name.Contains("Plus"))
|
|
{
|
|
if (MessageBox.Show("Möchtest du die Containeranzahl händisch verändern?", "Frage", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
this.pictureBoxMinus.Enabled = this.pictureBoxPlus.Enabled = true;
|
|
this.pictureBoxMinus.BackColor = Color.Red;
|
|
this.pictureBoxPlus.BackColor = Color.FromArgb(0, 192, 0);
|
|
labelContainer_TextChanged(this, e);
|
|
}
|
|
else return;
|
|
}
|
|
}
|
|
|
|
}
|
|
else MessageBox.Show("Containeranzahl ändern NICHT MÖGLICH. Du hast noch keinen Kunden gewählt.", "ACHTUNG", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
|
|
|
}
|
|
private void GroupBox_DoubleClick(object sender, MouseEventArgs e)
|
|
{
|
|
Control ctr = this.groupBoxEtikett.GetChildAtPoint(e.Location);
|
|
if (this.listViewLieferungen.SelectedItems.Count == 0 && this.textBoxQRCode.Text.Contains("scannen"))
|
|
{
|
|
MessageBox.Show("Containeranzahl ändern NICHT MÖGLICH. Du hast noch keinen Auftrag ausgewählt.", "ACHTUNG", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
|
}
|
|
else
|
|
{
|
|
if (ctr.Name.Contains("Minus"))
|
|
{
|
|
if (int.Parse(this.labelContainer.Text) == 0) MessageBox.Show($"Containeranzahl kleiner als 0 ist nicht möglich.", "ACHTUNG", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
else
|
|
{
|
|
if (MessageBox.Show("Möchtest du die Containeranzahl händisch verändern?", "Frage", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
this.pictureBoxMinus.Enabled = this.pictureBoxPlus.Enabled = true;
|
|
this.pictureBoxMinus.BackColor = Color.Red;
|
|
this.pictureBoxPlus.BackColor = Color.FromArgb(0, 192, 0);
|
|
labelContainer_TextChanged(this, e);
|
|
}
|
|
}
|
|
}
|
|
if (ctr.Name.Contains("Plus"))
|
|
{
|
|
if (MessageBox.Show("Möchtest du die Containeranzahl händisch verändern?", "Frage", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
this.pictureBoxMinus.Enabled = this.pictureBoxPlus.Enabled = true;
|
|
this.pictureBoxMinus.BackColor = Color.Red;
|
|
this.pictureBoxPlus.BackColor = Color.FromArgb(0, 192, 0);
|
|
labelContainer_TextChanged(this, e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//LISTVIEW STANDERHÖHUNG WENN ITEM CHECKED WIRD BUTTON SPEICHERN VERFÜGBAR
|
|
private void listViewSonder_ItemChecked(object sender, ItemCheckedEventArgs e)
|
|
{
|
|
ListView lv = (ListView)sender;
|
|
if (lv.CheckedItems.Count > 0) { this.buttonStatusSpeichern.Enabled = this.buttonStatusSpeichern.Visible = true; this.buttonStatusSpeichern.BackColor = Color.Yellow; }
|
|
}
|
|
|
|
//BUTTON SPEICHERN
|
|
private void buttonStatusSpeichern_Click(object sender, EventArgs e)
|
|
{
|
|
foreach (ListViewItem item in this.listViewSTH.CheckedItems)
|
|
{
|
|
foreach (ListViewItem.ListViewSubItem subItem in item.SubItems)
|
|
{
|
|
if (subItem.Tag != null)
|
|
{
|
|
auftragArtikel = AuftragArtikel.GetArtikel(((Views)subItem.Tag).AuftragArtikelID);
|
|
if (auftragArtikel.Erledigt) auftragArtikel.Erledigt = false;
|
|
else auftragArtikel.Erledigt = true;
|
|
auftragArtikel.Save();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//WENN TAB GEWECHSELT ANZEIGE AKTUALISIEREN
|
|
private void tabControlAuftragList_Selected(object sender, TabControlEventArgs e)
|
|
{
|
|
TabControl tabControl = (TabControl)sender;
|
|
if(tabControl.SelectedIndex < 3) { this.groupBoxEtikett.Visible = true; this.buttonStatusSpeichern.Visible = this.buttonStatusSpeichern.Enabled = false; }
|
|
if(tabControl.SelectedIndex == 3) { this.groupBoxEtikett.Visible = false; this.buttonStatusSpeichern.Visible = true; }
|
|
}
|
|
|
|
//TAB CONTROL LISTVIEWS MOUSECLICK EVENTS
|
|
private void listView_MouseClick(object sender, MouseEventArgs e)
|
|
{
|
|
ListView listView = (ListView)sender;
|
|
ListViewItem item = listView.GetItemAt(e.X, e.Y);
|
|
if (listView.SelectedItems.Count == 1)
|
|
{
|
|
auftrag = item.Tag as Auftrag;
|
|
buttonDrucken.Enabled = true;
|
|
buttonDrucken.BackColor = Color.FromArgb(0, 192, 0);
|
|
this.textBoxQRCode.Text = auftrag.AuftragID.ToString();
|
|
this.labelContainer.Text = auftrag.ContainerClean.ToString();
|
|
textBoxQRCode_Leave(this, e);
|
|
this.textBoxQRCode.Enabled = false;
|
|
}
|
|
listView.Focus();
|
|
}
|
|
private void listView_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
{
|
|
ListView lv = (ListView)sender;
|
|
ListViewItem item1 = lv.GetItemAt(e.X, e.Y);
|
|
auftrag = item1.Tag as Auftrag;
|
|
FormAuftragDetail detail = new FormAuftragDetail(auftrag, benutzer);
|
|
if(detail.ShowDialog() == DialogResult.OK)
|
|
{
|
|
this.auftrag = detail.auftrag;
|
|
Load_Etikett_GroupBox(this.auftrag);
|
|
}
|
|
|
|
}
|
|
private void listViewLieferungen_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
ListView l = (ListView)sender;
|
|
if (l.SelectedItems.Count == 0) this.textBoxQRCode.Enabled = true;
|
|
}
|
|
private void ListView_Load(List<Auftrag> auftraglist, ListView lv)
|
|
{
|
|
|
|
lv.Items.Clear();
|
|
foreach (Auftrag auftrag in auftraglist)
|
|
{
|
|
Kunde kunde = Kunde.GetKunde(string.Empty, auftrag.KundeID, string.Empty);
|
|
ListViewItem item = new ListViewItem();
|
|
item.Tag = auftrag;
|
|
item.Text = "";
|
|
item.SubItems.Add(auftrag.Liefertag.ToString("dddd dd.MM"));
|
|
if (kunde.KundeNummer == "0") item.SubItems.Add(auftrag.ZusatzInfo);
|
|
else item.SubItems.Add(kunde.Suchtext);
|
|
item.SubItems.Add(kunde.Region);
|
|
item.SubItems.Add(auftrag.Container.ToString());
|
|
if ((int)auftrag.Status == 3) item.SubItems.Add(auftrag.Status.ToString() + " " + Aufgabe.GetAufgabe(string.Empty, auftrag.AuftragID).Bezeichnung);
|
|
else item.SubItems.Add(auftrag.Status.ToString());
|
|
|
|
if (auftrag.Liefertag <= DateTime.Today.AddDays(1))
|
|
{
|
|
if (auftrag.Liefertag < DateTime.Today) { item.BackColor = (Color)Settings.Default["AuftAbgel"]; }
|
|
else
|
|
{
|
|
item.BackColor = (Color)Settings.Default["AuftBald"];
|
|
item.ForeColor = Color.Black;
|
|
}
|
|
}
|
|
|
|
lv.Items.Add(item);
|
|
}
|
|
Funktionen.Columns_Resize(lv);
|
|
lv.Columns[0].Width = 0;
|
|
lv.Columns[1].Width = lv.Columns[1].Width + 50;
|
|
|
|
}
|
|
private void Sonderauftrag_Load()
|
|
{
|
|
//this.buttonSTH.Enabled = this.buttonSTH.Visible = false;
|
|
//this.listViewLieferungen.Visible = false;
|
|
//this.listViewSTH.Visible = true;
|
|
this.listViewSTH.Columns.Clear();
|
|
this.listViewSTH.Items.Clear();
|
|
|
|
List<Views> artikel = Views.GetArtikel_sthList();
|
|
|
|
var groups = artikel.GroupBy(a => new { a.ArtikelName, a.KundeName, a.Anzahl });
|
|
|
|
|
|
//Spalten in die ListView einfügen. Pro Kund mit STH wird eine Spalte erstellt.
|
|
this.listViewSTH.Columns.Add("ARTIKEL");
|
|
foreach (var col in groups.GroupBy(g => g.Key.KundeName))
|
|
{
|
|
this.listViewSTH.Columns.Add(col.Key.ToString());
|
|
}
|
|
this.listViewSTH.Columns.Add("GESAMT");
|
|
|
|
//Zeilen in die ListView einfügen. Pro Artikel mit STH wird eine Zeile erstellt.
|
|
//Subitems für jede Spalte erstellen
|
|
foreach (var row in groups.GroupBy(g => g.Key.ArtikelName))
|
|
{
|
|
ListViewItem item = new ListViewItem();
|
|
item.Tag = row;
|
|
item.Text = row.Key.ToString();
|
|
|
|
//Subitems getrennt formatierbar machen
|
|
item.UseItemStyleForSubItems = false;
|
|
|
|
//Subitems für jede Spalte erstellen
|
|
for (int i = 0; i <= this.listViewSTH.Columns.Count; i++)
|
|
{
|
|
item.SubItems.Add(string.Empty);
|
|
}
|
|
this.listViewSTH.Items.Add(item);
|
|
}
|
|
|
|
//Übereinstimmend mit Spalten(Kunde) und Zeile(Artikel) wird die Anzahl der Stück eingefügt
|
|
//Letzte Spalte Artikelsumme berechnen und eintragen
|
|
//SubItem "GESAMT" Schriftfarbe und Dicke ändern
|
|
foreach (Views view in artikel)
|
|
{
|
|
foreach (ListViewItem item in this.listViewSTH.Items)
|
|
{
|
|
if (item.Text == view.ArtikelName)
|
|
{
|
|
foreach (ColumnHeader ch in this.listViewSTH.Columns)
|
|
{
|
|
|
|
if (ch.Text == view.KundeName) { item.SubItems[ch.Index].Text = view.Anzahl.ToString(); item.SubItems[ch.Index].Tag = view; }
|
|
|
|
//Letzte Spalte Artikelsumme berechnen und eintragen.
|
|
if (ch.Text == "GESAMT")
|
|
{
|
|
int ges = 0;
|
|
for (int i = 0; i < this.listViewSTH.Columns.Count - 1; i++)
|
|
{
|
|
if (int.TryParse(item.SubItems[i].Text, out int value)) ges += value;
|
|
}
|
|
item.SubItems[ch.Index].Text = ges.ToString();
|
|
|
|
//SubItem "GESAMT" Schriftfarbe und Dicke ändern
|
|
item.SubItems[ch.Index].ForeColor = Color.Red;
|
|
item.SubItems[ch.Index].Font = new Font(item.Font, FontStyle.Bold);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//Spaltenbreite der ListView wird automatisch optimiert.
|
|
Funktionen.Columns_Resize(this.listViewSTH);
|
|
//Umreihen der Spalten in der Listview wird
|
|
Funktionen.Columns_Reorder(this.listViewSTH);
|
|
|
|
//GESAMT-Spalte wird als 2.Spalte angezeigt.
|
|
foreach (ColumnHeader ch in this.listViewSTH.Columns) if (ch.Text == "GESAMT") { ch.DisplayIndex = 1; }
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|