97 lines
2.6 KiB
C#
97 lines
2.6 KiB
C#
using DatenDB;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Deckungsbeitrag.UserControls
|
|
{
|
|
public partial class UCKunde : UserControl
|
|
{
|
|
//private Label lblKunde;
|
|
//private Label lblRegion;
|
|
//private FlowLayoutPanel flp; // ← Field deklarieren!
|
|
private Kunde kunde;
|
|
public int[] ContAnzahl = new int[3];
|
|
public string KundenName
|
|
{
|
|
get => lblKunde.Text;
|
|
set => lblKunde.Text = value;
|
|
}
|
|
public string KundenRegion
|
|
{
|
|
get => lblRegion.Text;
|
|
set => lblRegion.Text = value;
|
|
}
|
|
public string ContainerAnzahl
|
|
{
|
|
get => lblCont.Text;
|
|
set => lblCont.Text = value;
|
|
}
|
|
|
|
public UCKunde()
|
|
{
|
|
InitializeComponent();
|
|
SetupControl();
|
|
}
|
|
|
|
public UCKunde(Kunde kunde) : this()
|
|
{
|
|
KundenName = kunde.Suchtext == string.Empty ? kunde.KundeName : kunde.Suchtext;
|
|
KundenRegion = kunde.Region;
|
|
|
|
ContAnzahl = Auftrag.GetContainerAnzahlen(kunde.KundeID);
|
|
|
|
// Sobald die Containeranzahlen angezeigt werden können.
|
|
ContainerAnzahl = $"{ContAnzahl[0]}/{ContAnzahl[1]}/{ContAnzahl[2]}";
|
|
}
|
|
private void SetupControl()
|
|
{
|
|
|
|
// ★★★ MOUSE-EVENTS DURCHREICHEN zu EINEM Handler ★★★
|
|
this.MouseDown += KundenControl_MouseDown;
|
|
lblKunde.MouseDown += KundenControl_MouseDown;
|
|
lblRegion.MouseDown += KundenControl_MouseDown;
|
|
}
|
|
private void KundenControl_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
Control ctr = sender as Control;
|
|
UCKunde kundectr;
|
|
if (ctr.GetType() == typeof(UCKunde)) kundectr = (UCKunde)ctr;
|
|
else kundectr = (UCKunde)ctr.Parent;
|
|
|
|
this.kunde = (Kunde)kundectr.Tag;
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
{
|
|
if (kundectr.Parent.Tag == null) this.DoDragDrop(new DataObject("KundeData", this), DragDropEffects.Copy);
|
|
else
|
|
{
|
|
this.DoDragDrop(sender, DragDropEffects.Move);
|
|
}
|
|
}
|
|
}
|
|
public object Clone()
|
|
{
|
|
return new UCKunde(this.kunde);
|
|
}
|
|
|
|
private void KundenControl_MouseClick(object sender, MouseEventArgs e)
|
|
{
|
|
var cont = (UserControl)sender;
|
|
var parent = (FlowLayoutPanel)cont.Parent;
|
|
|
|
if (e.Button == MouseButtons.Right && !parent.Name.Contains("Kunden"))
|
|
{
|
|
UserControl kndctrl = (UserControl)sender;
|
|
kndctrl.Parent.Controls.Remove(kndctrl);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//TODO: Design des Controls anpassen. Eventuell im Designer erstellen. |