using BrightIdeasSoftware; using DatenDB; using Deckungsbeitrag.AA_Forms; using Deckungsbeitrag.AA_Klassen; using Deckungsbeitrag.Properties; using Deckungsbeitrag.UserControls; using Npgsql; using System; using System.Collections.Generic; using System.ComponentModel; using System.Configuration; using System.Data; using System.Diagnostics; using System.Diagnostics.Eventing.Reader; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Management.Instrumentation; using System.Reflection; using System.Runtime; using System.Runtime.ConstrainedExecution; using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using System.Windows.Input; using System.Xml.Serialization; using ZXing.Common; using Timer = System.Windows.Forms.Timer; namespace Deckungsbeitrag { public partial class FormMain : Form { #region Properties private readonly Benutzer benutzer = null; private readonly Meldungen meldung = new Meldungen(); private bool open = false; private bool isDragging = false; private Size _fixedSize; private bool _handlingResize; private readonly UserSettingsManager _settings = new UserSettingsManager(); private bool formloading = false; private Dictionary> auftragliste; private Control draggedBox; private Point dragOffset; private readonly PictureBox ghostImage; private readonly bool isButtonDragging = false; private List ArtikellisteProAuftrag; private OnboardingSchritt onBoardingArt = OnboardingSchritt.Main; private UCStatistik uCStatistik; private UCAuftragSuchen uCAuftrag; private UCInventur uCInventur; private readonly Screen screen = Screen.PrimaryScreen; private Kunde kunde; #endregion public FormMain() { InitializeComponent(); this.panelMain.AllowDrop = true; this.toolStripMenu.Size = new Size(toolStripButton1.Size.Width + 20, this.Height); _fixedSize = screen.WorkingArea.Size; } public FormMain(Benutzer benutzer) : this() { this.benutzer = benutzer; ghostImage = new PictureBox { Size = new Size(200, 100), // GroupBox-Größe Visible = false, BackColor = Color.Transparent, SizeMode = PictureBoxSizeMode.StretchImage }; panelMain.Controls.Add(ghostImage); // Zum Panel! } #region FormMain-Events private async void FormMain_Load(object sender, EventArgs e) { this.SuspendLayout(); this.Cursor = Cursors.WaitCursor; formloading = true; _settings.Load(); this.buttonKundeArtikelUpdate.BringToFront(); this.WindowState = FormWindowState.Maximized; this.MaximizedBounds = Screen.PrimaryScreen.WorkingArea; this.panelMain.Width = this.Width - this.toolStripMenu.Right - 20; this.panelMain.Location = new Point(this.toolStripMenu.Right, 0); this.Text += Assembly.GetExecutingAssembly().GetName().Version.ToString(); this.labelKundenDatum.Text = @"N:\TECHNIK\Software\Wirl-Verwaltung\Listen\Kundenstammblatt.csv"; this.labelSoftwareDatum.Text = @"N:\TECHNIK\Software\Wirl-Verwaltung\Setup\SetupVerwaltung*.msi"; this.labelArtikelDatum.Text = @"N:\TECHNIK\Software\Wirl-Verwaltung\Listen\Artikelkurzliste.csv"; GetInventuren(); GetSaison(); if (this.groupBoxContAnz.Visible) { await GetAuftraege(); GetContainerProTag(); } // UserCotnrols werden eingefügt GetUserControls(); // Controls werde Enabled Enable_Controls(); // Location für UCInventur festlegen. Get_UCInventur_Location(); this.Activate(); _fixedSize = this.Size; formloading = false; } private void FormMain_Shown(object sender, EventArgs e) { // Meldung wenn Updates oder Imports erledigt wurden. if (Program.Artikelliste_Importiert | Program.Kundenliste_Importiert | Program.Software_Updated) { string[] updates = new string[3]; updates[0] = Program.Artikelliste_Importiert ? "Artikelliste: ✅" : "Artikelliste: ❌"; updates[1] = Program.Kundenliste_Importiert ? "Kundenliste: ✅" : "Kundenliste: ❌"; updates[2] = Program.Software_Updated ? "Software: ✅" : "Sofware: ❌"; MessageBox.Show($"Folgende Updates wurden heute durchgeführt:\n\n{updates[0]}\n{updates[1]}\n{updates[2]}", "UPDATES DURCHGEFÜHRT", MessageBoxButtons.OK, MessageBoxIcon.Information); } // OnBoarding nur bei den Fahrern anzeigen. Bis die anderen Fertig sind. if (this.benutzer.Rolle == BenutzerRolle.Fahrer) ZeigeOnboarding(); this.ResumeLayout(); this.Cursor = Cursors.Default; } private void FormMain_ResizeBegin(object sender, EventArgs e) { _handlingResize = true; this.Size = _fixedSize; _handlingResize = false; } private void FormMain_Resize(object sender, EventArgs e) { if (_handlingResize) return; if (this.Size != _fixedSize) { _handlingResize = true; this.Size = _fixedSize; _handlingResize = false; } //this.panelMain.Size = new Size(this.ClientSize.Width - this.toolStripMenu.Right, this.Height); //this.panelProgress.Location = new Point(this.panelMain.Right - this.panelProgress.Width - 100, this.panelMain.Bottom - this.panelProgress.Height - 20); } /// /// Settings speichern bei Form_Closing. /// /// /// private void FormMain_FormClosing(object sender, FormClosingEventArgs e) { try { _settings.LocationButtonNeueAufgabe = this.buttonNeueAufgabe.Location; _settings.LocationButtonNeueInventur = this.buttonNeueInventur.Location; _settings.LocationButtonNeuerAuftrag = this.buttonNeuerAuftrag.Location; _settings.LocationButtonNeuerStand = this.buttonNeuerStand.Location; _settings.LocationButtonNeuerUser = this.buttonNeuerUser.Location; _settings.LocationGroupBoxContainer = this.groupBoxContAnz.Location; _settings.LocationGroupBoxSaison = this.groupBoxSaison.Location; if (uCStatistik != null) _settings.LocationGroupBoxStatistik = this.uCStatistik.Location; if (uCAuftrag != null) _settings.LocationGroupBoxAuftragSuchen = this.uCAuftrag.Location; _settings.OLV_State = this.objectListViewAuftrag.SaveState(); _settings.Save(); } catch (Exception ex) { MessageBox.Show("Fehler beim Speichern" + ex.Message); } } #endregion #region ToolStripButton-Events private void Get_Border_Paint(object sender, PaintEventArgs e) { ToolStripItem item = (ToolStripItem)sender; ControlPaint.DrawBorder(e.Graphics, new Rectangle(0, 0, item.Width, item.Height), Color.White, ButtonBorderStyle.Solid); } private void ToolStrip_MouseEnter(object sender, EventArgs e) { if (sender.GetType() == typeof(ToolStripButton)) { ToolStripButton tsb = (ToolStripButton)sender; tsb.ForeColor = Program.Wirlblau; tsb.BackColor = Color.White; } } private void ToolStrip_MouseLeave(object sender, EventArgs e) { if (sender.GetType() == typeof(ToolStripButton)) { ToolStripButton tsb = (ToolStripButton)sender; tsb.ForeColor = Color.White; tsb.BackColor = Program.Wirlblau; } } private void TSBBenutzerVW_Click(object sender, EventArgs e) { FormBenutzerVW benutzerVW = new FormBenutzerVW(); benutzerVW.ShowDialog(); } private void ToolStripBeenden_Click(object sender, EventArgs e) { Application.Exit(); } private void TSBAufgabeVW_Click(object sender, EventArgs e) { FormAufgabeVW aufgabeVW = new FormAufgabeVW(); aufgabeVW.ShowDialog(); } private void ToolStripZaehlscheine_Click(object sender, EventArgs e) { FormKundeVW kundedaten = new FormKundeVW(this.benutzer); if (kundedaten.ShowDialog() == DialogResult.OK) { } } private void ToolStripDB_Click(object sender, EventArgs e) { FormNeuDeckungsbeitrag deckungsbeitrag = new FormNeuDeckungsbeitrag(this.benutzer, false); if (deckungsbeitrag.ShowDialog() == DialogResult.OK) { } } private void TSBWaschstrasse_Click(object sender, EventArgs e) { FormAufleger aufleger = new FormAufleger(); aufleger.ShowDialog(); } private void ToolStripButtonImport_Click(object sender, EventArgs e) { FormImport import = new FormImport(); import.ShowDialog(); } private void TSBKosten_Click(object sender, EventArgs e) { FormNeuDeckungsbeitrag deckungsbeitrag = new FormNeuDeckungsbeitrag(this.benutzer, true); if (deckungsbeitrag.ShowDialog() == DialogResult.OK) { } } private void TSBEinstellung_Click(object sender, EventArgs e) { FormEinstellung einstellung = new FormEinstellung(); einstellung.ShowDialog(); } private void TSBExpedit_Click(object sender, EventArgs e) { FormExpedit exp = new FormExpedit(benutzer); exp.ShowDialog(); } private void TSBAuftragVW_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; if (!this.groupBoxAuftrag.Visible) { if (benutzer.Rolle == BenutzerRolle.Fahrer) this.rBFertig.Checked = true; else this.rBAlle.Checked = true; // Groupbox einblenden wenn OLV noch nicht sichtbar ist. foreach (GroupBox gb in this.panelMain.Controls.OfType()) gb.Visible = gb.Name.Contains("Auftrag"); // PanelMain Buttons ausblenden. foreach (Button btn in this.panelMain.Controls.OfType