588 lines
22 KiB
C#
588 lines
22 KiB
C#
using DatenDB;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Web.Caching;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Forms.VisualStyles;
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
|
|
namespace Deckungsbeitrag
|
|
{
|
|
public partial class FormNeuerAuftrag : Form
|
|
{
|
|
public Fehlermeldungen meldung = new Fehlermeldungen();
|
|
public Kunde kunde;
|
|
public Auftrag Auftrag;
|
|
public Auftrag extraAuftrag;
|
|
public Fach fach;
|
|
public AuftragArtikel AuftragArtikel;
|
|
private Benutzer benutzer;
|
|
private Maschine maschine;
|
|
bool extra;
|
|
List<Sortiment> sortimentListe;
|
|
public DateTime? letzterLiefertag;
|
|
private Kunde knd;
|
|
public DataGridViewCell aktivCell;
|
|
|
|
public FormNeuerAuftrag()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
public FormNeuerAuftrag(Benutzer benutzer, Maschine maschine, bool extra, Auftrag auftrag, Fach fach) : this()
|
|
{
|
|
this.benutzer = benutzer;
|
|
this.maschine = maschine;
|
|
this.extra = extra;
|
|
this.fach = fach;
|
|
if (auftrag == null) this.extraAuftrag = auftrag;
|
|
else this.Auftrag = auftrag;
|
|
|
|
}
|
|
public FormNeuerAuftrag(Benutzer benutzer) : this()
|
|
{
|
|
this.benutzer = benutzer;
|
|
this.Auftrag = new Auftrag();
|
|
|
|
}
|
|
public FormNeuerAuftrag(Benutzer benutzer, DateTime? letzterLiefertag) : this(benutzer)
|
|
{
|
|
this.letzterLiefertag = letzterLiefertag;
|
|
this.Auftrag = new Auftrag();
|
|
//this.knd = Open_List();
|
|
}
|
|
|
|
private void FormNeuerAuftrag_Load(object sender, EventArgs e)
|
|
{
|
|
this.kunde = Funktionen.KundenAuswahl();
|
|
//TODO: Umbauen damit kein Fehler wenn KundenAuswahl negativ endet.
|
|
|
|
this.label1.Text = this.textBoxZusatz.Text.Length.ToString() + "/" + this.textBoxZusatz.MaxLength.ToString();
|
|
sortimentListe = (List<Sortiment>)Funktionen.SortimentLesen("Liste");
|
|
|
|
//TODO: Funktion versuchen was diese bewirkt.
|
|
this.dGArtikel.ForeColor = Color.Black;
|
|
|
|
//Unterscheidung zwischen BenutzerRollen. Verschiedene Controls werden gesperrt, angezeigt oder verändert
|
|
if (this.benutzer.Rolle == BenutzerRolle.Verwaltung || this.benutzer.Rolle == BenutzerRolle.Admin || this.benutzer.Rolle == BenutzerRolle.Master)
|
|
{
|
|
this.comboBoxTyp.Enabled = true;
|
|
this.buttonExtraKunde.Enabled = false;
|
|
this.buttonExtraKunde.BackColor = Color.Gray;
|
|
this.comboBoxTyp.SelectedIndex = 2;
|
|
}
|
|
else
|
|
{
|
|
this.comboBoxTyp.Enabled = false;
|
|
foreach(Control c in this.groupBoxSonder.Controls) { if(c.GetType() != typeof(Label)) c.Enabled = false; }
|
|
this.dGArtikel.Enabled = this.dGArtikel.Visible = false;
|
|
//this.pictureBoxWalli.Visible = true;
|
|
this.comboBoxTyp.SelectedIndex = 1;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Div Controls werden geladen. Darunter RadioButtons, ComboBox und GridView.
|
|
/// </summary>
|
|
private void Load_Controls()
|
|
{
|
|
Get_RadioButtons();
|
|
comboBox_Load();
|
|
|
|
if (Auftrag == null)
|
|
{
|
|
this.dTPLiefertag.Value = DateTime.Today.AddDays(1);
|
|
this.comboBoxAufgabe.SelectedIndex = -1;
|
|
this.comboBoxBenutzer.SelectedIndex = -1;
|
|
}
|
|
else
|
|
{
|
|
if (kunde == null) kunde = Kunde.GetKunde(string.Empty, Auftrag.KundeID, string.Empty);
|
|
this.textBoxKndNr.Text = kunde.KundeNummer;
|
|
this.textBoxKundeName.Text = kunde.Suchtext;
|
|
this.textBoxKundeName.Enabled = false;
|
|
this.textBoxKndNr.Enabled = false;
|
|
if (letzterLiefertag.HasValue) this.dTPLiefertag.Value = letzterLiefertag.Value;
|
|
else this.dTPLiefertag.Value = DateTime.Today.AddDays(1);
|
|
this.textBoxCont.Text = Auftrag.Container.ToString();
|
|
this.textBoxZusatz.Text = Auftrag.ZusatzInfo;
|
|
|
|
dTPLiefertag_Leave(this.dTPLiefertag, EventArgs.Empty);
|
|
textBoxCont_TextChanged(this.textBoxCont, EventArgs.Empty);
|
|
|
|
if (Auftrag.ArbeiterID != null)
|
|
{
|
|
foreach (Benutzer b in comboBoxBenutzer.Items) if (b.BenutzerID == Auftrag.ArbeiterID) this.comboBoxBenutzer.SelectedItem = b;
|
|
}
|
|
if (Auftrag.Typ == AuftragTyp.Sonder)
|
|
{
|
|
foreach (Aufgabe auf in comboBoxAufgabe.Items)
|
|
{
|
|
if (auf.AufgabeID == Auftrag.AufgabeID)
|
|
{
|
|
this.comboBoxAufgabe.SelectedItem = auf;
|
|
if (auf.Bezeichnung == "STH" || auf.Bezeichnung == "STV" || auf.Bezeichnung == "STA") Load_Gridview(kunde.KundeNummer.ToString(), auf);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
private void Get_RadioButtons()
|
|
{
|
|
if (kunde != null)
|
|
{
|
|
foreach (RadioButton rb in this.Controls.OfType<RadioButton>())
|
|
{
|
|
if (rb.Name.Contains("MO")) rb.Tag = Liefertag.MO;
|
|
if (rb.Name.Contains("Di")) rb.Tag = Liefertag.DI;
|
|
if (rb.Name.Contains("MI")) rb.Tag = Liefertag.MI;
|
|
if (rb.Name.Contains("DO")) rb.Tag = Liefertag.DO;
|
|
if (rb.Name.Contains("FR")) rb.Tag = Liefertag.FR;
|
|
|
|
rb.Enabled = true;
|
|
}
|
|
}
|
|
else foreach (RadioButton rb in this.Controls.OfType<RadioButton>()) rb.Enabled = false;
|
|
|
|
}
|
|
private void comboBox_Load()
|
|
{
|
|
List<Aufgabe> aufgabenlist = Aufgabe.GetList(2);
|
|
foreach (Aufgabe aufgabe in aufgabenlist) this.comboBoxAufgabe.AutoCompleteCustomSource.Add(aufgabe.Bezeichnung);
|
|
this.comboBoxAufgabe.DataSource = aufgabenlist;
|
|
this.comboBoxAufgabe.DisplayMember = "Bezeichnung";
|
|
this.comboBoxAufgabe.SelectedIndex = -1;
|
|
|
|
List<Benutzer> benutzerlist = Benutzer.GetArbeiterList();
|
|
foreach (Benutzer benutzer in benutzerlist) this.comboBoxBenutzer.AutoCompleteCustomSource.Add(benutzer.Vorname);
|
|
this.comboBoxBenutzer.DataSource = benutzerlist;
|
|
this.comboBoxBenutzer.DisplayMember = "Vorname";
|
|
this.comboBoxBenutzer.SelectedIndex = -1;
|
|
|
|
this.comboBoxTyp.DataSource = Enum.GetValues(typeof(AuftragTyp));
|
|
}
|
|
private void Load_Gridview(string kundeid, Aufgabe auf)
|
|
{
|
|
List<KundeArtikel> artikelListe = KundeArtikel.GetList(kundeid);
|
|
|
|
//List<Sortiment> resultList = null;
|
|
//resultList = sortimentListe.FindAll(Sortiment => Sortiment.KundeNummer == kundeNr);
|
|
|
|
if (artikelListe.Count != 0)
|
|
{
|
|
this.dGArtikel.AutoGenerateColumns = false;
|
|
foreach (DataGridViewColumn col in this.dGArtikel.Columns)
|
|
{
|
|
col.DataPropertyName = col.Name;
|
|
|
|
if (col.Name.Contains("Bearbeitet")) col.Visible = false;
|
|
if (col.Name == "Fehlmenge")
|
|
{
|
|
if (auf.Bezeichnung == "STA") col.Visible = true;
|
|
else col.Visible = false;
|
|
}
|
|
if (col.Name == "Korrektur")
|
|
{
|
|
if(auf.Bezeichnung != "STA") col.Visible = true;
|
|
else col.Visible = false;
|
|
}
|
|
}
|
|
|
|
|
|
// DataGridView mit ArtikelStand Liste verbinden und Columns automatisch generieren.
|
|
this.dGArtikel.DataSource = artikelListe;
|
|
|
|
this.dGArtikel.ClearSelection();
|
|
//this.dGArtikel.CurrentCell = this.dGArtikel.Rows[0].Cells[3];
|
|
|
|
// Alle Spaltenbreiten an den Zellinhalt anpassen
|
|
this.dGArtikel.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
|
|
// Alle Zeilenhöhen an Zellinhalt anpassen
|
|
this.dGArtikel.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Button Click Events.
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void buttonAbbrechen_Click(object sender, EventArgs e)
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
this.Close();
|
|
}
|
|
private void buttonSpeichern_Click(object sender, EventArgs e)
|
|
{
|
|
int[] save;
|
|
if(kunde == null)
|
|
{
|
|
MessageBox.Show("Auftrag kann nicht gespeichert werden. Kein Kunde vorhanden.", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
|
this.textBoxKndNr.Focus();
|
|
return;
|
|
}
|
|
|
|
//AUFTRAG DATEN ÜBERGEBEN
|
|
Auftrag.KundeID = (int)kunde.KundeID;
|
|
Auftrag.Liefertag = this.dTPLiefertag.Value;
|
|
Auftrag.Container = int.Parse(this.textBoxCont.Text);
|
|
Auftrag.ErstelltVon = (int)this.benutzer.BenutzerID;
|
|
Auftrag.Erstellt = DateTime.Now;
|
|
Auftrag.Container = int.Parse(this.textBoxCont.Text);
|
|
Auftrag.Typ = (AuftragTyp)comboBoxTyp.SelectedItem;
|
|
if (maschine != null) Auftrag.MaschineID = (int)maschine.MaschineID;
|
|
else Auftrag.MaschineID = null;
|
|
|
|
if(Auftrag.FindeAuftrag(Auftrag) == true)
|
|
{
|
|
if (meldung.AuftragVorhanden(Auftrag) == DialogResult.Yes)
|
|
{
|
|
//BEI BENUTZER WASCHSTRASSE DEAKTIVIERT
|
|
if (benutzer.Rolle != BenutzerRolle.Waschstrasse)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(this.comboBoxAufgabe.Text)) Auftrag.AufgabeID = Aufgabe.GetAufgabeID(this.comboBoxAufgabe.Text);
|
|
else Auftrag.AufgabeID = null;
|
|
if (!string.IsNullOrWhiteSpace(textBoxZusatz.Text)) Auftrag.ZusatzInfo = this.textBoxZusatz.Text;
|
|
if (!string.IsNullOrWhiteSpace(this.comboBoxBenutzer.Text)) Auftrag.ArbeiterID = this.comboBoxBenutzer.SelectedItem != null ? (int?)((Benutzer)this.comboBoxBenutzer.SelectedItem).BenutzerID : null;
|
|
}
|
|
|
|
if (benutzer.Rolle == BenutzerRolle.Verwaltung || benutzer.Rolle == BenutzerRolle.Admin) Auftrag.Status = AuftragStatus.Herrichten;
|
|
else Auftrag.Status = AuftragStatus.Aufgelegt;
|
|
|
|
//Wenn SONDERAUFTRAG(STH,STV,STA) dann ARTIKEL speichern.
|
|
if (Auftrag.Typ == AuftragTyp.Sonder)
|
|
{
|
|
int tosave = 0;
|
|
int saved = 0;
|
|
foreach (DataGridViewRow artikel in this.dGArtikel.Rows)
|
|
{
|
|
tosave++;
|
|
KundeArtikel stand;
|
|
if (artikel.Cells[0].Value != null)
|
|
{
|
|
stand = KundeArtikel.GetItem(int.Parse(artikel.Cells[0].Value.ToString()));
|
|
if (artikel.Cells[5].Visible == true)
|
|
{
|
|
stand.Fehlmenge = int.Parse(artikel.Cells[5].Value.ToString());
|
|
stand.FehlmengeBearbeitet = this.benutzer.BenutzerName + " am " + DateTime.Now.ToString();
|
|
}
|
|
if (artikel.Cells[6].Visible == true)
|
|
{
|
|
stand.Korrektur = int.Parse(artikel.Cells[6].Value.ToString());
|
|
stand.KorrekturBearbeitet = this.benutzer.BenutzerName + " am " + DateTime.Now.ToString();
|
|
}
|
|
if (stand.Save() == 1) saved++;
|
|
}
|
|
}
|
|
//Kontrolle ob alle Artikel gespeichert wurden.
|
|
if (saved != tosave) meldung.Speicherfehler();
|
|
else
|
|
{
|
|
//Speichern von AUFTRAG
|
|
save = Auftrag.Save();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!extra)
|
|
{
|
|
//this.fach.KundeID = Auftrag.KundeID;
|
|
//this.fach.Lieferdatum = Auftrag.Liefertag;
|
|
//this.fach.Liefertag = (Liefertag)Auftrag.Liefertag.DayOfWeek;
|
|
//if (extraAuftrag == null) { this.fach.ExtraAuftragID = null; this.fach.ExtraKundeID = null; }
|
|
//else { this.fach.ExtraAuftragID = extraAuftrag.AuftragID; this.fach.ExtraKundeID = extraAuftrag.KundeID; }
|
|
//this.fach.Gewaschen = (DateTime)Auftrag.Erstellt;
|
|
|
|
//FormFachBearbeiten fachbearb = new FormFachBearbeiten(this.Auftrag ,this.fach);
|
|
//if (fachbearb.ShowDialog() == DialogResult.OK)
|
|
//{
|
|
// this.fach = fachbearb.fach;
|
|
// //Speichern von AUFTRAG
|
|
// save = Auftrag.Save();
|
|
//}
|
|
//this.fach.AuftragID = Auftrag.AuftragID;
|
|
if (Auftrag.Save()[1] == 1) this.Close();
|
|
|
|
}
|
|
else save = Auftrag.Save();
|
|
}
|
|
}
|
|
else { Auftrag = new Auftrag(); FormNeuerAuftrag_Load(this, e); }
|
|
}
|
|
else
|
|
{
|
|
//BEI BENUTZER WASCHSTRASSE DEAKTIVIERT
|
|
if (benutzer.Rolle != BenutzerRolle.Waschstrasse)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(this.comboBoxAufgabe.Text)) Auftrag.AufgabeID = Aufgabe.GetAufgabeID(this.comboBoxAufgabe.Text);
|
|
else Auftrag.AufgabeID = null;
|
|
if (!string.IsNullOrWhiteSpace(textBoxZusatz.Text)) Auftrag.ZusatzInfo = this.textBoxZusatz.Text;
|
|
if (!string.IsNullOrWhiteSpace(this.comboBoxBenutzer.Text)) Auftrag.ArbeiterID = this.comboBoxBenutzer.SelectedItem != null ? (int?)((Benutzer)this.comboBoxBenutzer.SelectedItem).BenutzerID : null;
|
|
}
|
|
|
|
if (benutzer.Rolle == BenutzerRolle.Verwaltung || benutzer.Rolle == BenutzerRolle.Admin) Auftrag.Status = AuftragStatus.Herrichten;
|
|
else Auftrag.Status = AuftragStatus.Aufgelegt;
|
|
|
|
//Wenn SONDERAUFTRAG(STH,STV,STA) dann ARTIKEL speichern.
|
|
if (Auftrag.Typ == AuftragTyp.Sonder)
|
|
{
|
|
int tosave = 0;
|
|
int saved = 0;
|
|
bool negieren = false;
|
|
foreach (DataGridViewRow artikel in this.dGArtikel.Rows)
|
|
{
|
|
tosave++;
|
|
KundeArtikel stand;
|
|
if (artikel.Cells[0].Value != null)
|
|
{
|
|
stand = KundeArtikel.GetItem(int.Parse(artikel.Cells[0].Value.ToString()));
|
|
if (artikel.Cells[5].Visible == true)
|
|
{
|
|
stand.Fehlmenge = int.Parse(artikel.Cells[5].Value.ToString());
|
|
stand.FehlmengeBearbeitet = this.benutzer.BenutzerName + " am " + DateTime.Now.ToString();
|
|
}
|
|
if (artikel.Cells[6].Visible == true)
|
|
{
|
|
if (int.TryParse(artikel.Cells[6].Value.ToString(), out int result))
|
|
{
|
|
if (Aufgabe.GetAufgabe(null, (int?)Auftrag.AufgabeID).Bezeichnung == "STV") negieren = true;
|
|
stand.Korrektur = (negieren && stand.Korrektur > 0) ? -result : result;
|
|
stand.KorrekturBearbeitet = this.benutzer.BenutzerName + " am " + DateTime.Now.ToString();
|
|
}
|
|
else { meldung.Eingabefehler(); return; }
|
|
}
|
|
if (stand.Save() == 1) saved++;
|
|
}
|
|
}
|
|
//Kontrolle ob alle Artikel gespeichert wurden.
|
|
if (saved != tosave) meldung.Speicherfehler();
|
|
else
|
|
{
|
|
//Speichern von AUFTRAG
|
|
save = Auftrag.Save();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!extra)
|
|
{
|
|
//this.fach.KundeID = Auftrag.KundeID;
|
|
//this.fach.Lieferdatum = Auftrag.Liefertag;
|
|
//this.fach.Liefertag = (Liefertag)Auftrag.Liefertag.DayOfWeek;
|
|
//if (extraAuftrag == null) { this.fach.ExtraAuftragID = null; this.fach.ExtraKundeID = null; }
|
|
//else { this.fach.ExtraAuftragID = extraAuftrag.AuftragID; this.fach.ExtraKundeID = extraAuftrag.KundeID; }
|
|
//this.fach.Gewaschen = (DateTime)Auftrag.Erstellt;
|
|
|
|
//FormFachBearbeiten fachbearb = new FormFachBearbeiten(this.Auftrag ,this.fach);
|
|
//if (fachbearb.ShowDialog() == DialogResult.OK)
|
|
//{
|
|
// this.fach = fachbearb.fach;
|
|
// //Speichern von AUFTRAG
|
|
// save = Auftrag.Save();
|
|
//}
|
|
//this.fach.AuftragID = Auftrag.AuftragID;
|
|
if (Auftrag.Save()[1] == 1) this.Close();
|
|
|
|
}
|
|
else save = Auftrag.Save();
|
|
}
|
|
}
|
|
|
|
if(benutzer.Rolle != BenutzerRolle.Waschstrasse)
|
|
{
|
|
this.DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
Auftrag = new Auftrag();
|
|
FormNeuerAuftrag_Load(this, e);
|
|
}
|
|
}
|
|
private void Container_Click(object sender, EventArgs e)
|
|
{
|
|
PictureBox pb = (PictureBox)sender;
|
|
int cont = int.Parse(this.textBoxCont.Text);
|
|
if (pb.Name.ToString().Contains("Plus")) cont++;
|
|
if (pb.Name.ToString().Contains("Minus")) cont--;
|
|
this.textBoxCont.Text = cont.ToString();
|
|
}
|
|
|
|
/// <summary>
|
|
/// TextBox Events
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void textBoxZusatz_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.label1.Text = this.textBoxZusatz.Text.Length.ToString() + "/" + this.textBoxZusatz.MaxLength.ToString();
|
|
}
|
|
private void textBoxCont_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (this.textBoxCont.Text == "0") { this.pictureBoxMinus.Enabled = false; this.pictureBoxMinus.BackColor = Color.Gray; }
|
|
else { this.pictureBoxMinus.Enabled = true; this.pictureBoxMinus.BackColor = Color.Red; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Liefertag mit automatischer Berechnung des nächsten Datums bzw. des Wochentages des Datums.
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void dTPLiefertag_Leave(object sender, EventArgs e)
|
|
{
|
|
foreach (RadioButton liefertag in this.Controls.OfType<RadioButton>())
|
|
{
|
|
if (liefertag.Name.Contains(((Liefertag)dTPLiefertag.Value.DayOfWeek).ToString())) liefertag.Checked = true;
|
|
}
|
|
}
|
|
private void Liefertag_rB_Checked(object sender, EventArgs e)
|
|
{
|
|
foreach (RadioButton radioButton in this.Controls.OfType<RadioButton>())
|
|
{
|
|
if (radioButton.Checked) radioButton.BackColor = Color.Yellow;
|
|
else { radioButton.BackColor = Color.Gray; }
|
|
}
|
|
}
|
|
private void Liefertag_rB_Click(object sender, EventArgs e)
|
|
{
|
|
RadioButton radioButton = (RadioButton)sender;
|
|
foreach(Liefertag tag in Enum.GetValues(typeof(Liefertag)))
|
|
{
|
|
if (radioButton.Name.Contains(tag.ToString())) this.dTPLiefertag.Value = Berechnungen.GetNextWeekday((int)tag);
|
|
}
|
|
this.dTPLiefertag.Enabled = false;
|
|
}
|
|
private void dTPLiefertag_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
dTPLiefertag_Leave(sender, e);
|
|
}
|
|
|
|
private void textBoxKndNr_Click(object sender, EventArgs e)
|
|
{
|
|
this.textBoxKndNr.Clear();
|
|
//Process.Start("C:\\Windows\\WinSxS\\amd64_microsoft-windows-osk_31bf3856ad364e35_10.0.22621.3672_none_8a93c823d58f9d77\\osk.exe");
|
|
}
|
|
|
|
//Wenn die Textbox verlassen wird, wir die Eingabe überprüft und weiter Schritte eingeleitet
|
|
private void textBoxKndNr_Leave(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(textBoxKndNr.Text))
|
|
{
|
|
//kunde = Kunde.GetKunde(textBoxKndNr.Text, null, null);
|
|
if (Kunde.GetKunde(textBoxKndNr.Text, null, null) == null)
|
|
{
|
|
|
|
if (MessageBox.Show($"Kunde konnte nicht gefunden werden. Möchtest du in der Liste suchen?", "Frage", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
FormListe liste = new FormListe(null, 0);
|
|
if (liste.ShowDialog() == DialogResult.OK)
|
|
{
|
|
kunde = liste.kunde;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
this.textBoxKndNr.Clear();
|
|
this.textBoxKndNr.Focus();
|
|
return;
|
|
}
|
|
}
|
|
else this.kunde = Kunde.GetKunde(textBoxKndNr.Text, null, null);
|
|
|
|
textBoxKndNr.Text = kunde.KundeNummer;
|
|
textBoxKundeName.Text = kunde.Suchtext;
|
|
textBoxKundeName.Enabled = false;
|
|
string sortNr = kunde.KundeNummer;
|
|
|
|
Load_Gridview(sortNr, null);
|
|
}
|
|
else
|
|
{
|
|
if (textBoxKndNr.Focused)
|
|
{
|
|
if (MessageBox.Show($"Möchtest du den Kunden händisch eingeben?", "Frage", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
this.textBoxKundeName.Focus();
|
|
kunde = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//Wird verwendet wenn ein zusätzlicher Auftrag(Kunde) in ein Fach gelegt wird
|
|
private void buttonExtraKunde_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
FormNeuerAuftrag nauftrag = new FormNeuerAuftrag(benutzer, maschine, true, this.extraAuftrag, null);
|
|
if (nauftrag.ShowDialog() == DialogResult.OK)
|
|
{
|
|
this.extraAuftrag = nauftrag.Auftrag;
|
|
}
|
|
|
|
}
|
|
|
|
//Wenn der Kunde nicht gefunden wird und händisch eingegeben wird, wird beim verlassen der Textbox der Kunde als DIV ZIELKUNDE erstellt.
|
|
//Der individuelle Kundename wird als KUNDE.SUCHTEXT eingetragen aber nicht gespeichert.
|
|
private void textBoxKundeName_Leave(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(textBoxKundeName.Text))
|
|
{
|
|
kunde = Kunde.GetKunde("2300000", null, null);
|
|
kunde.Suchtext = this.textBoxKundeName.Text;
|
|
}
|
|
}
|
|
|
|
//Wenn mit TAB aus Textbox gesprungen wird, wird Focus auf TEXTBOX KUNDENAME gelegt. (Dadurch wird Fehlermeldung aktiviert)
|
|
private void textBoxKndNr_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
|
{
|
|
if (e.KeyValue == 9) textBoxKundeName.Focus();
|
|
}
|
|
|
|
private void comboBoxAufgabe_SelectedValueChanged(object sender, EventArgs e)
|
|
{
|
|
if (comboBoxAufgabe.SelectedIndex == 3 || comboBoxAufgabe.SelectedIndex == 1)
|
|
{
|
|
if (this.kunde != null) Load_Gridview(this.kunde.KundeID.ToString(), Aufgabe.GetAufgabe(this.comboBoxAufgabe.Text.ToString(), null));
|
|
}
|
|
if (comboBoxAufgabe.SelectedIndex == 2)
|
|
{
|
|
if (this.kunde != null) Load_Gridview(this.kunde.KundeID.ToString(), Aufgabe.GetAufgabe(this.comboBoxAufgabe.Text.ToString(), null));
|
|
}
|
|
}
|
|
private void DataGridView_CellEnter(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Überprüfen ob die Eingabe eine Zahl ist. Es wird sonst eine Meldung angezeigt und das weiterspringen wird verhindert.
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void dGArtikel_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
|
|
{
|
|
if (e.ColumnIndex >= 5)
|
|
{
|
|
DataGridView dgv = (DataGridView)sender;
|
|
DataGridViewCell dgc = dgv.CurrentCell;
|
|
if (!int.TryParse(dgc.EditedFormattedValue.ToString(), out int i))
|
|
{
|
|
meldung.Eingabefehler();
|
|
e.Cancel = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|