Prześlij pliki do ''
This commit is contained in:
parent
38679ba1f4
commit
a668c060f7
21
Magazyn.cs
Normal file
21
Magazyn.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WpfApp1.Obsluga
|
||||
{
|
||||
class Magazyn
|
||||
{
|
||||
public Magazyn()
|
||||
{
|
||||
}
|
||||
|
||||
public Pracownik Edmund = new Pracownik("Edmund", 1, 2000, DateTime.Parse("2014-09-14 08:00:00"), DateTime.Parse("2014-09-14 14:00:00"));
|
||||
public Pracownik Maja = new Pracownik("Maja", 2, 4000, DateTime.Parse("2014-09-14 14:01:00"), DateTime.Parse("2014-09-14 20:00:00"));
|
||||
|
||||
//public List<Pracownik> pracowniks = new List<Pracownik> { new Pracownik("Edmund", 1, 15.15), new Pracownik("Maja", 2, 25.05) };
|
||||
|
||||
}
|
||||
}
|
131
MainWindow.xaml.cs
Normal file
131
MainWindow.xaml.cs
Normal file
@ -0,0 +1,131 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using WpfApp1.Obsluga;
|
||||
|
||||
namespace WpfApp1
|
||||
{
|
||||
/// <summary>
|
||||
/// Logika interakcji dla klasy MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
Zapas zapas = new Zapas();
|
||||
Magazyn magazyn = new Magazyn();
|
||||
int id_Pracownik = 0;
|
||||
DateTime dateTime = DateTime.Now;
|
||||
|
||||
|
||||
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
wybor.Text = "1";
|
||||
ZaladujListe(zapas.produkts);
|
||||
|
||||
}
|
||||
|
||||
private void ZaladujListe(List<Produkt> produkts)
|
||||
{
|
||||
lista.Items.Clear();
|
||||
foreach (Produkt produkt in produkts)
|
||||
{
|
||||
lista.Items.Add(produkt.Nazwa + " " + produkt.Id + " " + produkt.Cena + " " + "Ilość produktu w automacie: " + produkt.Ilosc + " (ta wartość jest podana roboczo)");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Ok_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ZmiejszZapas(Convert.ToInt32(wybor.Text));
|
||||
}
|
||||
|
||||
private void Panel_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ZmiejszZapas(int id)
|
||||
{
|
||||
foreach (Produkt aprodukt in zapas.produkts)
|
||||
{
|
||||
if (aprodukt.Id == id)
|
||||
{
|
||||
if (aprodukt.Ilosc >= 1)
|
||||
{
|
||||
aprodukt.Ilosc = aprodukt.Ilosc-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dateTime = DateTime.Now;
|
||||
Dostawa(dateTime, aprodukt.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
ZaladujListe(zapas.produkts);
|
||||
}
|
||||
|
||||
void Dostawa(DateTime dateTime, int id_towar)
|
||||
{
|
||||
//int id_Pracownik = 0;
|
||||
|
||||
if(dateTime.TimeOfDay.CompareTo(magazyn.Edmund.Koniec_pracy.TimeOfDay) <0)
|
||||
{
|
||||
id_Pracownik = magazyn.Edmund.Id;
|
||||
}
|
||||
else if(dateTime.TimeOfDay.CompareTo(magazyn.Maja.Koniec_pracy.TimeOfDay) < 0)
|
||||
{
|
||||
id_Pracownik = magazyn.Maja.Id;
|
||||
}
|
||||
|
||||
if(id_Pracownik == 1)
|
||||
{
|
||||
Thread.Sleep(magazyn.Edmund.Czas);
|
||||
foreach (Produkt aprodukt in zapas.produkts)
|
||||
{
|
||||
if (aprodukt.Id == id_towar)
|
||||
{
|
||||
{
|
||||
aprodukt.Ilosc = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
ZaladujListe(zapas.produkts);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Thread.Sleep(magazyn.Maja.Czas);
|
||||
foreach (Produkt aprodukt in zapas.produkts)
|
||||
{
|
||||
if (aprodukt.Id == id_towar)
|
||||
{
|
||||
{
|
||||
aprodukt.Ilosc = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
ZaladujListe(zapas.produkts);
|
||||
}
|
||||
}
|
||||
|
||||
private void Wybor_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
28
Pracownik.cs
Normal file
28
Pracownik.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace WpfApp1.Obsluga
|
||||
{
|
||||
class Pracownik
|
||||
{
|
||||
public Pracownik(string imie, int id, int czas, DateTime start, DateTime koniec)
|
||||
{
|
||||
this.imie = imie;
|
||||
this.id = id;
|
||||
this.czas = czas;
|
||||
start_pracy = start;
|
||||
koniec_pracy = koniec;
|
||||
}
|
||||
|
||||
private string imie;
|
||||
private int id;
|
||||
private int czas;
|
||||
private DateTime start_pracy;
|
||||
private DateTime koniec_pracy;
|
||||
|
||||
public string Imie { get => imie; set => imie = value; }
|
||||
public int Id { get => id; set => id = value; }
|
||||
public int Czas { get => czas; set => czas = value; }
|
||||
public DateTime Datatime { get => start_pracy; set => start_pracy = value; }
|
||||
public DateTime Koniec_pracy { get => koniec_pracy; set => koniec_pracy = value; }
|
||||
}
|
||||
}
|
31
Produkt.cs
Normal file
31
Produkt.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WpfApp1.Obsluga
|
||||
{
|
||||
public class Produkt
|
||||
{
|
||||
public Produkt(int id , string nazwa, int ilosc, double cena)
|
||||
{
|
||||
this.Id = id;
|
||||
this.Nazwa = nazwa;
|
||||
this.Ilosc = ilosc;
|
||||
this.cena = cena;
|
||||
}
|
||||
|
||||
private String nazwa;
|
||||
private int ilosc;
|
||||
private int id;
|
||||
private double cena;
|
||||
|
||||
|
||||
|
||||
public string Nazwa { get => nazwa; set => nazwa = value; }
|
||||
public int Ilosc { get => ilosc; set => ilosc = value; }
|
||||
public int Id { get => id; set => id = value; }
|
||||
public double Cena { get => cena; set => cena = value; }
|
||||
}
|
||||
}
|
32
Zapas.cs
Normal file
32
Zapas.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WpfApp1.Obsluga
|
||||
{
|
||||
class Zapas
|
||||
{
|
||||
public Zapas()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Produkt> produkts = new List<Produkt>() { new Produkt(1, "baton", 3, 2.50), new Produkt(2, "kola", 5, 3.00), new Produkt(3, "chusteczki", 4, 1.50) };
|
||||
|
||||
|
||||
/*void ustawPrdukt(Produkt produkt, string nazwa, int id, int ilosc, float cena)
|
||||
{
|
||||
produkt.Nazwa = nazwa;
|
||||
produkt.Id = id;
|
||||
produkt.Ilosc = ilosc;
|
||||
produkt.Cena = cena;
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user