using BrightIdeasSoftware; using DatenDB; using Deckungsbeitrag.AA_Forms; using Deckungsbeitrag.AA_Klassen; using Deckungsbeitrag.Properties; using Npgsql; using System; using System.Collections.Generic; using System.ComponentModel; using System.Configuration; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Runtime; using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using System.Xml.Serialization; using Timer = System.Windows.Forms.Timer; namespace Deckungsbeitrag { public partial class FormMain : Form { private Benutzer benutzer = null; Meldungen meldung = new Meldungen(); bool open = false; private bool isDragging = false; private Point dragStartPoint; private Point newLocation; private Size _fixedSize; private bool _handlingResize; private readonly UserSettingsManager _settings = new UserSettingsManager(); private bool formloading = false; public FormMain() { InitializeComponent(); this.toolStripMenu.Size = new Size(toolStripButton1.Size.Width + 20, this.Height); //this.panelMain.Location = new Point(toolStripMenu.Right + 10, 12); if (Properties.Settings.Default.Location_ButtonNeuerAuftrag_Main != Point.Empty) this.buttonNeuerAuftrag.Location = Properties.Settings.Default.Location_ButtonNeuerAuftrag_Main; if (Properties.Settings.Default.Location_ButtonNeuerUser_Main != Point.Empty) this.buttonNeuerUser.Location = Properties.Settings.Default.Location_ButtonNeuerUser_Main; if (Properties.Settings.Default.Location_GroupBoxStatistik_Main != Point.Empty) this.groupBoxStatistik.Location = Properties.Settings.Default.Location_GroupBoxStatistik_Main; } public FormMain(Benutzer benutzer) : this() { this.benutzer = benutzer; this.groupBoxUpdate.Enabled = false; // AKTIVE ELEMENTE JE BENUTZER ROLLE switch (benutzer.Rolle) { case BenutzerRolle.Verwaltung: this.toolStripDB.Enabled = this.toolStripButtonImport.Enabled = this.tSBExpedit.Enabled = false; this.groupBoxUpdate.Visible = this.toolStripDB.Visible = this.toolStripButtonImport.Visible = this.tSBExpedit.Enabled = false; break; case BenutzerRolle.Fahrer: // ToolStripButtons werden deaktiviert. foreach(ToolStripButton tsb in this.toolStripMenu.Items) { // Ausgewählter ToolStripButton bleibt aktiv. if(!tsb.Name.Contains("Auftrag")) tsb.Enabled = false; } // Controls im PanelMain werden deaktiviert. foreach(Control ctr in this.panelMain.Controls) { // Ausgewählte Buttons bleiben aktiv. if (ctr.Name.Contains("Auftrag")) ctr.Enabled = true; else ctr.Enabled = false; } break; case BenutzerRolle.Admin: this.groupBoxUpdate.Visible = false; break; case BenutzerRolle.Waschstrasse: this.toolStripDB.Enabled = this.toolStripButtonImport.Enabled = this.tSBBenutzerVW.Enabled = this.tSBAufgabeVW.Enabled = this.tSBExpedit.Enabled = false; this.groupBoxUpdate.Visible = this.toolStripDB.Visible = this.toolStripButtonImport.Visible = this.tSBBenutzerVW.Enabled = this.tSBAufgabeVW.Enabled = this.tSBExpedit.Enabled = false; break; case BenutzerRolle.Master: break; default: break; } } private void FormMain_Load(object sender, EventArgs e) { formloading = true; _settings.Load(); 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); GetStatistik(); GetSaison(); // GroupBoxen im PanelMain werden ausgeblendet foreach (GroupBox gb in this.panelMain.Controls.OfType()) { if (!gb.Name.Contains("Update") & !gb.Name.Contains("Statistik") & !gb.Name.Contains("Neuer") & !gb.Name.Contains("Saison")) { gb.Visible = false; gb.Location = new Point(0, 0); gb.Size = new Size(this.panelMain.Width, this.panelMain.Height); } } this.Activate(); _fixedSize = this.Size; formloading = false; } private void GetSaison() { var listenQuelle = Saison.LadeSaisons(); // Liste comboBoxSaison.DataSource = listenQuelle; comboBoxSaison.DisplayMember = nameof(Saison.Bezeichnung); comboBoxSaison.ValueMember = nameof(Saison.SaisonId); // aktiven Eintrag suchen (falls genau einer aktiv ist) var aktiveSaison = listenQuelle .FirstOrDefault(s => s.Aktiv); // LINQ FirstOrDefault [web:13][web:16][web:19] if (aktiveSaison != null) { comboBoxSaison.SelectedValue = aktiveSaison.SaisonId; // per ValueMember setzen [web:11][web:20] } } private void Paint_Boarder(Size size, Point location, PaintEventArgs e) { Pen pen = new Pen(Color.FromArgb(1, 53, 101), 4); Rectangle rect = new Rectangle(1, 2, size.Width - 4, size.Height - 4); e.Graphics.DrawRectangle(pen, rect); } private void panelMain_Paint(object sender, PaintEventArgs e) { Paint_Boarder(this.panelMain.Size, this.panelMain.Location, e); } #region ToolStripButton_Click-Events 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 tSBWaschstrasse1_Click(object sender, EventArgs e) { //FormWaschstrasse waschstrasse = new FormWaschstrasse(this.tSBWaschverlauf.Text); //waschstrasse.ShowDialog(); //LISTVIEW MIT GEWASCHTEN FÄCHERN ERSTELLEN (KOMMT WENN BENUTZER = ADMIN) } 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 toolStripStatusLabel2_DoubleClick(object sender, EventArgs e) { FormEinstellung einstellung = new FormEinstellung("Sortiment"); 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") ? true : false; // PanelMain Buttons ausblenden. foreach (Button btn in this.panelMain.Controls.OfType