308 lines
9.3 KiB
C#
308 lines
9.3 KiB
C#
using DatenDB;
|
|
using System;
|
|
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.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Web;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Deckungsbeitrag
|
|
{
|
|
public partial class FormAuftragDetail : Form
|
|
{
|
|
public Auftrag auftrag;
|
|
public Benutzer benutzer;
|
|
public List<AuftragArtikel> artikelList;
|
|
public Fehlermeldungen meldung = new Fehlermeldungen();
|
|
|
|
//WENN AUFTRAG SPEICHERN
|
|
private bool _tosave = false;
|
|
public bool tosave
|
|
{
|
|
get { return _tosave; }
|
|
set
|
|
{
|
|
_tosave = value;
|
|
if (_tosave)
|
|
{
|
|
buttonSpeichern.Enabled = true;
|
|
buttonSpeichern.BackColor = Color.Yellow;
|
|
}
|
|
}
|
|
}
|
|
|
|
//WENN AUFTRAG ABZUSCHLIESSEN
|
|
private bool _toclose = false;
|
|
public bool toclose
|
|
{
|
|
get { return _toclose; }
|
|
set
|
|
{
|
|
_toclose = value;
|
|
if (_toclose)
|
|
{
|
|
buttonFertig.Enabled = true;
|
|
buttonFertig.BackColor = Color.FromArgb(0, 192, 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public FormAuftragDetail()
|
|
{
|
|
InitializeComponent();
|
|
this.BackColor = Properties.Settings.Default.Wirlblau;
|
|
labelContainer_TextChanged(this.labelContainer, EventArgs.Empty);
|
|
|
|
//SPEICHERN UND ABSCHLIESSEN BUTTONS WERDEN FUNKTIONSLOS UND GRAU
|
|
buttonSpeichern.Enabled = buttonFertig.Enabled = false;
|
|
buttonSpeichern.BackColor = buttonFertig.BackColor = Color.Gray;
|
|
|
|
}
|
|
public FormAuftragDetail(Auftrag auftrag, Benutzer benutzer) : this()
|
|
{
|
|
this.auftrag = auftrag;
|
|
this.benutzer = benutzer;
|
|
}
|
|
|
|
private void FormAuftragDetail_Load(object sender, EventArgs e)
|
|
{
|
|
this.dTPLiefertag.Value = auftrag.Liefertag;
|
|
this.labelKundeName.Text = Kunde.GetKunde(string.Empty, auftrag.KundeID, string.Empty).Suchtext;
|
|
this.labelRegion.Text = Kunde.GetKunde(string.Empty, auftrag.KundeID, string.Empty).Region;
|
|
this.labelContainer.Text = auftrag.ContainerClean.ToString();
|
|
this.labelContDirt.Text = auftrag.Container.ToString();
|
|
this.textBoxZusatz.Text = auftrag.ZusatzInfo;
|
|
|
|
//WENN STATUS 3(HERRICHTEN) oder HÖHER(FERTIG, AUSGELIEFERT) DANN KEINE VORHER NACHHER LISTEN
|
|
if (auftrag.Status <= AuftragStatus.Finisching)
|
|
{
|
|
List<Auftrag> davor = Auftrag.GetAuftragList("davor", auftrag);
|
|
List<Auftrag> danach = Auftrag.GetAuftragList("danach", auftrag);
|
|
|
|
foreach (Auftrag auftrag in davor)
|
|
{
|
|
ListViewItem item = new ListViewItem();
|
|
item.Tag = auftrag;
|
|
item.Text = Kunde.GetKunde(string.Empty, auftrag.KundeID, string.Empty).Suchtext;
|
|
item.SubItems.Add(Kunde.GetKunde(string.Empty, auftrag.KundeID, string.Empty).Region);
|
|
item.SubItems.Add(auftrag.Container.ToString());
|
|
item.SubItems.Add(auftrag.Status.ToString());
|
|
|
|
this.listViewDavor.Items.Add(item);
|
|
}
|
|
foreach (Auftrag auftrag in danach)
|
|
{
|
|
ListViewItem item = new ListViewItem();
|
|
item.Tag = auftrag;
|
|
item.Text = Kunde.GetKunde(string.Empty, auftrag.KundeID, string.Empty).Suchtext;
|
|
item.SubItems.Add(Kunde.GetKunde(string.Empty, auftrag.KundeID, string.Empty).Region);
|
|
item.SubItems.Add(auftrag.Container.ToString());
|
|
item.SubItems.Add(auftrag.Status.ToString());
|
|
|
|
this.listViewDanach.Items.Add(item);
|
|
|
|
}
|
|
int width = this.listViewDavor.Width;
|
|
this.listViewDavor = Funktionen.Columns_Resize(this.listViewDavor);
|
|
this.listViewDanach = Funktionen.Columns_Resize(this.listViewDanach);
|
|
this.listViewDanach.Width = this.listViewDavor.Width = width;
|
|
}
|
|
else listViewDanach.Visible = listViewDavor.Visible = label3.Visible = label4.Visible = false;
|
|
|
|
//WENN STATUS HERRICHTEN DANN LISTVIEW-ARTIKEL LADEN UND ANZEIGEN
|
|
if(auftrag.Status == AuftragStatus.Herrichten)
|
|
{
|
|
this.listViewArtikel.Visible = true;
|
|
this.artikelList = AuftragArtikel.GetList(auftrag.AuftragID.ToString());
|
|
this.listViewArtikel.Columns.Clear();
|
|
this.listViewArtikel.Columns.Add("ARTIKEL");
|
|
this.listViewArtikel.Columns.Add("ANZAHL");
|
|
|
|
foreach(AuftragArtikel art in artikelList)
|
|
{
|
|
ListViewItem item = new ListViewItem();
|
|
item.Tag = art;
|
|
item.Text = art.ArtikelName;
|
|
item.SubItems.Add(art.Anzahl.ToString());
|
|
if (art.Erledigt) { item.Checked = true; }
|
|
else item.Checked = false;
|
|
|
|
this.listViewArtikel.Items.Add(item);
|
|
|
|
}
|
|
|
|
Funktionen.Columns_Resize(this.listViewArtikel);
|
|
}
|
|
|
|
}
|
|
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; }
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// TOSAVE
|
|
/// </summary>
|
|
|
|
//BEI CLICK AUF CONTAINER +/- SPEICHERN WIRD AKITV
|
|
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")) cont--;
|
|
this.labelContainer.Text = cont.ToString();
|
|
|
|
tosave = true;
|
|
}
|
|
|
|
//BEI CLICK AUF DATUM SPEICHERN WIRD AKTIV
|
|
private void FormAuftragDetail_MouseClick(object sender, MouseEventArgs e)
|
|
{
|
|
Control ctr = this.GetChildAtPoint(e.Location);
|
|
if (ctr != null)
|
|
{
|
|
if (ctr.Name.Contains("dTP"))
|
|
{
|
|
ctr.Enabled = true;
|
|
tosave = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
//WENN LISTVIEW NICHT FOCUSED (FORM.LOAD) TOSAVE BLEIBT FALSE
|
|
private void listViewArtikel_ItemCheck(object sender, ItemCheckEventArgs e)
|
|
{
|
|
ListView listView = (ListView)sender;
|
|
|
|
if (listView.Focused)
|
|
{
|
|
if (e.NewValue != e.CurrentValue) { tosave = true; }
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// TOCLOSE
|
|
/// </summary>
|
|
private void listViewArtikel_ItemChecked(object sender, ItemCheckedEventArgs e)
|
|
{
|
|
ListView listView = (ListView)sender;
|
|
if(listView.Items.Count == listView.CheckedItems.Count) toclose = true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// BUTTONS
|
|
/// </summary>
|
|
|
|
//ÄNDERUNGEN SPEICHERN
|
|
private void buttonSpeichern_Click(object sender, EventArgs e)
|
|
{
|
|
if (tosave)
|
|
{
|
|
auftrag.Liefertag = dTPLiefertag.Value;
|
|
auftrag.ContainerClean = int.Parse(this.labelContainer.Text);
|
|
auftrag.Save();
|
|
|
|
//WENN STATUS HERRICHTEN DANN ITEMS UPDATEN
|
|
//LISTVIEWITEMS UPDATEN
|
|
if (auftrag.Typ == AuftragTyp.Sonder)
|
|
{
|
|
//LISTVIEWITEMS UPDATEN
|
|
foreach (ListViewItem item in this.listViewArtikel.Items)
|
|
{
|
|
AuftragArtikel art = (AuftragArtikel)item.Tag;
|
|
if (item.Checked) art.Erledigt = true;
|
|
else art.Erledigt = false;
|
|
|
|
art.Save();
|
|
}
|
|
}
|
|
}
|
|
this.DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
|
|
}
|
|
|
|
//AUFTRAG ABBRECHEN
|
|
private void buttonAbbrechen_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
this.Close();
|
|
}
|
|
|
|
//AUFTRAG ABSCHLIESSEN
|
|
private void buttonFertig_Click(object sender, EventArgs e)
|
|
{
|
|
if (toclose)
|
|
{
|
|
if(int.Parse(this.labelContainer.Text) == 0) if (meldung.NoCleanContainer() == DialogResult.OK) return;
|
|
|
|
auftrag.Erledigt = DateTime.Now;
|
|
auftrag.ErledigtVon = benutzer.BenutzerID;
|
|
|
|
auftrag.Save();
|
|
}
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
|
|
}
|
|
|
|
//SCHMUTZWÄSCHESCHEIN DRUCKEN
|
|
private void buttonSWS_Click(object sender, EventArgs e)
|
|
{
|
|
Funktionen.SWS_Drucken(auftrag);
|
|
//PrintDialog dialog = new PrintDialog();
|
|
//foreach (string printer in PrinterSettings.InstalledPrinters) if (printer.Contains(ConfigurationManager.AppSettings["PrinterName"])) dialog.PrinterSettings.PrinterName = printer;
|
|
|
|
////dialog.PrinterSettings.Copies = 10;
|
|
|
|
//if (dialog.ShowDialog() == DialogResult.OK)
|
|
//{
|
|
// PrintDocument printDocument = new PrintDocument();
|
|
// printDocument.PrintPage += new PrintPageEventHandler(PrintDocument_PrintPage);
|
|
// printDocument.PrinterSettings = dialog.PrinterSettings;
|
|
// printDocument.Print();
|
|
//}
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// UNUSED THINGS
|
|
/// </summary>
|
|
|
|
//RAHMEN UM FORM ZEICHNEN
|
|
private void FormAuftragDetail_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
Graphics surface = CreateGraphics();
|
|
Pen pen1 = new Pen(Color.White, 5);
|
|
|
|
surface.DrawLine(pen1, 10, 215, this.buttonAbbrechen.Right + 15, 215);
|
|
surface.DrawRectangle(pen1, 10, 10, this.buttonAbbrechen.Right + 5, this.buttonAbbrechen.Bottom + 5);
|
|
|
|
}
|
|
//PRINT PAGE FÜR DRUCK
|
|
private void PrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
|
|
{
|
|
e.Graphics.DrawImage(Funktionen.SWS_Entwurf(auftrag), e.PageBounds);
|
|
//e.Graphics.DrawImage(bitmap, 0, 0, 790, 900);
|
|
}
|
|
|
|
}
|
|
}
|