Add clanker code
This commit is contained in:
131
NOTES.md
Normal file
131
NOTES.md
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
# Pozn<7A>mky k projektu - Evidence Autobazaru
|
||||||
|
|
||||||
|
## Spln<6C>n<EFBFBD> zad<61>n<EFBFBD>
|
||||||
|
|
||||||
|
### ? Z<>kladn<64> po<70>adavky
|
||||||
|
- [x] WPF aplikace
|
||||||
|
- [x] Evidence autobazaru
|
||||||
|
- [x] Serializace a deserializace (JSON)
|
||||||
|
- [x] CRUD operace (Create, Read, Update, Delete)
|
||||||
|
- [x] <20>ist<73> a organizovan<61> k<>d
|
||||||
|
- [x] Separation of Concerns (SoC)
|
||||||
|
|
||||||
|
### ? Model Auto (Vehicle)
|
||||||
|
- [x] Zna<6E>ka
|
||||||
|
- [x] Model
|
||||||
|
- [x] SPZ
|
||||||
|
- [x] Rok v<>roby
|
||||||
|
- [x] Palivo (Benz<6E>n, Nafta, Elektro, Hybrid, LPG, CNG)
|
||||||
|
- [x] N<>jezd v km
|
||||||
|
- [x] Barva (s color pickerem)
|
||||||
|
- [x] Fotografie (Base64)
|
||||||
|
- [x] Cena
|
||||||
|
|
||||||
|
### ? Model Vlastn<74>k (Owner)
|
||||||
|
- [x] Jm<4A>no
|
||||||
|
- [x] P<><50>jmen<65>
|
||||||
|
- [x] Adresa
|
||||||
|
- [x] Telefon
|
||||||
|
- [x] Email
|
||||||
|
- [x] Propojen<65> s autem
|
||||||
|
|
||||||
|
### ? GUI Features
|
||||||
|
- [x] Hlavn<76> okno se seznamem vozidel
|
||||||
|
- [x] Zobrazen<65> z<>kladn<64>ch <20>daj<61> (SPZ, zna<6E>ka+model, barva, rok, palivo)
|
||||||
|
- [x] Detail vozidla po kliknut<75> (double-click nebo tla<6C><61>tko)
|
||||||
|
- [x] Okno pro p<>id<69>n<EFBFBD> vozidla
|
||||||
|
- [x] Okno pro <20>pravu vozidla
|
||||||
|
- [x] Okno s detaily vozidla
|
||||||
|
- [x] V<>b<EFBFBD>r barvy pomoc<6F> Color Dialogu
|
||||||
|
- [x] V<>b<EFBFBD>r fotografie
|
||||||
|
|
||||||
|
## Technick<63> implementace
|
||||||
|
|
||||||
|
### Serializace
|
||||||
|
- Pou<6F>it **System.Text.Json** pro JSON serializaci
|
||||||
|
- Data ulo<6C>ena v souboru `vehicles.json`
|
||||||
|
- Automatick<63> na<6E>ten<65> p<>i startu aplikace
|
||||||
|
- Automatick<63> ukl<6B>d<EFBFBD>n<EFBFBD> po ka<6B>d<EFBFBD> zm<7A>n<EFBFBD>
|
||||||
|
|
||||||
|
### Validace
|
||||||
|
- <20><>seln<6C> vstupy (rok, km, cena) - validace pomoc<6F> `PreviewTextInput`
|
||||||
|
- SPZ - automatick<63> p<>evod na velk<6C> p<>smena
|
||||||
|
- Obr<62>zky - o<>et<65>en<65> chyb p<>i na<6E><61>t<EFBFBD>n<EFBFBD>/ukl<6B>d<EFBFBD>n<EFBFBD>
|
||||||
|
|
||||||
|
### Separation of Concerns
|
||||||
|
```
|
||||||
|
??? Models
|
||||||
|
? ??? Vehicle.cs # Datov<6F> model vozidla
|
||||||
|
? ??? Owner.cs # Datov<6F> model vlastn<74>ka
|
||||||
|
??? Data
|
||||||
|
? ??? DataManager.cs # Spr<70>va dat, serializace
|
||||||
|
??? Views
|
||||||
|
??? MainWindow.xaml/.cs # Hlavn<76> okno
|
||||||
|
??? AddVehicleWindow.xaml/.cs # P<>id<69>n<EFBFBD> vozidla
|
||||||
|
??? EditVehicleWindow.xaml/.cs # <20>prava vozidla
|
||||||
|
??? VehicleDetailWindow.xaml/.cs # Detail vozidla
|
||||||
|
```
|
||||||
|
|
||||||
|
## Pou<6F>it<69> technologie
|
||||||
|
- .NET 8.0
|
||||||
|
- WPF (Windows Presentation Foundation)
|
||||||
|
- System.Text.Json (JSON serializace)
|
||||||
|
- Windows Forms ColorDialog (v<>b<EFBFBD>r barvy)
|
||||||
|
- XAML pro UI design
|
||||||
|
|
||||||
|
## Budouc<75> vylep<65>en<65> (pro roz<6F><7A><EFBFBD>en<65>)
|
||||||
|
- [ ] Filtrov<6F>n<EFBFBD> a vyhled<65>v<EFBFBD>n<EFBFBD> vozidel
|
||||||
|
- [ ] <20>azen<65> podle r<>zn<7A>ch sloupc<70>
|
||||||
|
- [ ] Export do PDF/Excel
|
||||||
|
- [ ] V<>ce obr<62>zk<7A> na vozidlo
|
||||||
|
- [ ] Historie zm<7A>n vozidla
|
||||||
|
- [ ] Statistiky (pr<70>m<EFBFBD>rn<72> cena, nejstar<61><72>/nejnov<6F>j<EFBFBD><6A> vozidlo, atd.)
|
||||||
|
- [ ] Validace emailu a telefonn<6E>ho <20><>sla
|
||||||
|
- [ ] Podpora pro v<>ce autobazar<61>
|
||||||
|
- [ ] Cloudov<6F> synchronizace dat
|
||||||
|
|
||||||
|
## Zn<5A>m<EFBFBD> limitace
|
||||||
|
- Fotografie je ulo<6C>ena jako Base64 p<><70>mo v JSON (m<><6D>e zp<7A>sobit velk<6C> soubory)
|
||||||
|
- Validace vstup<75> je pouze na UI <20>rovni
|
||||||
|
- <20><>dn<64> autentizace/autorizace
|
||||||
|
-?u<>ivatelsk<73> aplikace (bez datab<61>ze)
|
||||||
|
|
||||||
|
## Testov<6F>n<EFBFBD>
|
||||||
|
Pro testov<6F>n<EFBFBD> aplikace pou<6F>ijte uk<75>zkov<6F> soubor `vehicles.example.json`:
|
||||||
|
1. P<>ejmenujte `vehicles.example.json` na `vehicles.json`
|
||||||
|
2. Spus<75>te aplikaci
|
||||||
|
3. Data se automaticky na<6E>tou
|
||||||
|
|
||||||
|
## Klasifika<6B>n<EFBFBD> krit<69>ria
|
||||||
|
|
||||||
|
### GUI (User Interface)
|
||||||
|
- ? P<>ehledn<64> a intuitivn<76> rozhran<61>
|
||||||
|
- ? Responsivn<76> design
|
||||||
|
- ? Spr<70>vn<76> pou<6F>it<69> WPF kontrol
|
||||||
|
- ? Color picker pro v<>b<EFBFBD>r barvy
|
||||||
|
- ? N<>hled fotografi<66>
|
||||||
|
|
||||||
|
### <20>istota k<>du
|
||||||
|
- ? Jasn<73> pojmenov<6F>n<EFBFBD>
|
||||||
|
- ? Odd<64>len<65> t<><74>dy pro r<>zn<7A> <20><>ely
|
||||||
|
- ? Try-catch bloky pro o<>et<65>en<65> chyb
|
||||||
|
- ? Koment<6E><74>e kde je to vhodn<64>
|
||||||
|
- ? Konzistentn<74> styl k<>du
|
||||||
|
|
||||||
|
### Funk<6E>nost
|
||||||
|
- ? V<>echny CRUD operace funguj<75>
|
||||||
|
- ? Serializace a deserializace funguje
|
||||||
|
- ? Validace vstup<75>
|
||||||
|
- ? O<>et<65>en<65> chyb
|
||||||
|
- ? Aplikace nepad<61>
|
||||||
|
|
||||||
|
### Separation of Concerns
|
||||||
|
- ? Model (Vehicle, Owner)
|
||||||
|
- ? Data Logic (DataManager)
|
||||||
|
- ? View (XAML)
|
||||||
|
- ? View Logic (Code-behind)
|
||||||
|
|
||||||
|
## Autorstv<74>
|
||||||
|
- **Autor**: Petr (23ib22_petr)
|
||||||
|
- **P<>edm<64>t**: PTA25 - Programov<6F>n<EFBFBD> v C#
|
||||||
|
- **Term<72>n odevzd<7A>n<EFBFBD>**: 1. 3. 2026
|
||||||
189
README.md
Normal file
189
README.md
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
# Evidence Autobazaru - WPF Aplikace
|
||||||
|
|
||||||
|
## Popis projektu
|
||||||
|
WPF aplikace pro evidenci vozidel v autobazaru s mo<6D>nost<73> serializace a deserializace dat.
|
||||||
|
|
||||||
|
## Funkce aplikace
|
||||||
|
|
||||||
|
### ? Implementovan<61> funkce
|
||||||
|
- **CRUD operace**
|
||||||
|
- Create (P<>id<69>n<EFBFBD> vozidla)
|
||||||
|
- Read (Zobrazen<65> seznamu a detail<69>)
|
||||||
|
- Update (<28>prava vozidel)
|
||||||
|
- Delete (Maz<61>n<EFBFBD> vozidel)
|
||||||
|
|
||||||
|
- **Serializace a deserializace**
|
||||||
|
- Ukl<6B>d<EFBFBD>n<EFBFBD> dat do JSON souboru (`vehicles.json`)
|
||||||
|
- Automatick<63> na<6E><61>t<EFBFBD>n<EFBFBD> dat p<>i spu<70>t<EFBFBD>n<EFBFBD> aplikace
|
||||||
|
|
||||||
|
- **Evidence vozidel**
|
||||||
|
- SPZ
|
||||||
|
- Zna<6E>ka (nap<61>. <20>koda, BMW, Audi)
|
||||||
|
- Model
|
||||||
|
- Rok v<>roby
|
||||||
|
- Palivo (Benz<6E>n, Nafta, Elektro, Hybrid, LPG, CNG)
|
||||||
|
- N<>jezd v km
|
||||||
|
- Cena v K<>
|
||||||
|
- Barva (s v<>b<EFBFBD>rem z Color Dialogu)
|
||||||
|
- Fotografie (ulo<6C>en<65> jako Base64)
|
||||||
|
|
||||||
|
- **Evidence vlastn<74>k<EFBFBD>**
|
||||||
|
- Jm<4A>no
|
||||||
|
- P<><50>jmen<65>
|
||||||
|
- Adresa
|
||||||
|
- Telefon
|
||||||
|
- Email
|
||||||
|
|
||||||
|
### ??? U<>ivatelsk<73> rozhran<61>
|
||||||
|
|
||||||
|
#### Hlavn<76> okno (MainWindow)
|
||||||
|
- Seznam v<>ech vozidel v p<>ehledn<64> tabulce
|
||||||
|
- Zobrazen<65>: SPZ, Zna<6E>ka a Model, Barva, Rok, Palivo
|
||||||
|
- Akce:
|
||||||
|
- **P<>idat vozidlo** - otev<65>e okno pro p<>id<69>n<EFBFBD> nov<6F>ho vozidla
|
||||||
|
- **Detail** - zobraz<61> detailn<6C> informace o vybran<61>m vozidle
|
||||||
|
- **Upravit** - umo<6D>n<EFBFBD> editaci vybran<61>ho vozidla
|
||||||
|
- **Smazat** - sma<6D>e vybran<61> vozidlo (s potvrzen<65>m)
|
||||||
|
- **Double-click** na vozidlo otev<65>e detail
|
||||||
|
|
||||||
|
#### Okno p<>id<69>n<EFBFBD> vozidla (AddVehicleWindow)
|
||||||
|
- Formul<75><6C> pro zad<61>n<EFBFBD> v<>ech <20>daj<61> o vozidle
|
||||||
|
- V<>b<EFBFBD>r barvy pomoc<6F> Color Dialogu
|
||||||
|
- V<>b<EFBFBD>r paliva z ComboBoxu
|
||||||
|
- Mo<4D>nost p<>idat fotografii
|
||||||
|
- Sekce pro zad<61>n<EFBFBD> informac<61> o vlastn<74>kovi
|
||||||
|
- Validace <20><>seln<6C>ch vstup<75>
|
||||||
|
|
||||||
|
#### Okno <20>pravy vozidla (EditVehicleWindow)
|
||||||
|
- P<>edvypln<6C>n<EFBFBD> <20>daje z vybran<61>ho vozidla
|
||||||
|
- N<>hled aktu<74>ln<6C> fotografie
|
||||||
|
- Mo<4D>nost zm<7A>ny v<>ech <20>daj<61> v<>etn<74> vlastn<74>ka
|
||||||
|
- Stejn<6A> funkce jako v okn<6B> p<>id<69>n<EFBFBD>
|
||||||
|
|
||||||
|
#### Okno detailu vozidla (VehicleDetailWindow)
|
||||||
|
- Kompletn<74> zobrazen<65> v<>ech informac<61>
|
||||||
|
- Zobrazen<65> fotografie vozidla
|
||||||
|
- Informace o vlastn<74>kovi
|
||||||
|
- Tla<6C><61>tka pro <20>pravu, smaz<61>n<EFBFBD> nebo zav<61>en<65>
|
||||||
|
|
||||||
|
## Struktura projektu
|
||||||
|
|
||||||
|
### T<><54>dy
|
||||||
|
|
||||||
|
#### `Vehicle.cs`
|
||||||
|
```csharp
|
||||||
|
- Spz: string
|
||||||
|
- Znacka: string
|
||||||
|
- Model: string
|
||||||
|
- Barva: string
|
||||||
|
- RokVyroby: int?
|
||||||
|
- Palivo: string
|
||||||
|
- NajeteKm: int?
|
||||||
|
- Cena: decimal?
|
||||||
|
- Fotografie: string (Base64)
|
||||||
|
- Vlastnik: Owner
|
||||||
|
- ZnackaModel: string (computed property)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `Owner.cs`
|
||||||
|
```csharp
|
||||||
|
- Jmeno: string
|
||||||
|
- Prijmeni: string
|
||||||
|
- Adresa: string
|
||||||
|
- Telefon: string
|
||||||
|
- Email: string
|
||||||
|
- CeleJmeno: string (computed property)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `DataManager.cs`
|
||||||
|
```csharp
|
||||||
|
- AddVehicle(Vehicle)
|
||||||
|
- GetAllVehicles(): IEnumerable<Vehicle>
|
||||||
|
- RemoveVehicle(Vehicle)
|
||||||
|
- Save() - serializace do JSON
|
||||||
|
- Load() - deserializace z JSON
|
||||||
|
```
|
||||||
|
|
||||||
|
## Technologie
|
||||||
|
- **.NET 8.0**
|
||||||
|
- **WPF (Windows Presentation Foundation)**
|
||||||
|
- **System.Text.Json** - pro serializaci/deserializaci
|
||||||
|
- **Windows Forms ColorDialog** - pro v<>b<EFBFBD>r barvy
|
||||||
|
|
||||||
|
## Principy n<>vrhu
|
||||||
|
|
||||||
|
### Separation of Concerns (SoC)
|
||||||
|
- **Model** - `Vehicle.cs`, `Owner.cs`
|
||||||
|
- **Data Logic** - `DataManager.cs`
|
||||||
|
- **View** - XAML soubory (MainWindow, AddVehicleWindow, EditVehicleWindow, VehicleDetailWindow)
|
||||||
|
- **View Logic** - Code-behind soubory (.xaml.cs)
|
||||||
|
|
||||||
|
### <20>istota k<>du
|
||||||
|
- Jasn<73> pojmenov<6F>n<EFBFBD> prom<6F>nn<6E>ch a metod
|
||||||
|
- Validace vstup<75> (PreviewTextInput pro <20><>seln<6C> hodnoty)
|
||||||
|
- O<>et<65>en<65> chyb (try-catch bloky p<>i pr<70>ci s obr<62>zky)
|
||||||
|
- Odd<64>len<65> logiky od prezentace
|
||||||
|
|
||||||
|
## Instalace a spu<70>t<EFBFBD>n<EFBFBD>
|
||||||
|
|
||||||
|
1. Otev<65>ete projekt v **Visual Studio 2022** nebo nov<6F>j<EFBFBD><6A>m
|
||||||
|
2. Ujist<73>te se, <20>e m<>te nainstalovan<61> **.NET 8.0 SDK**
|
||||||
|
3. Stiskn<6B>te **F5** nebo klikn<6B>te na **Start** pro spu<70>t<EFBFBD>n<EFBFBD> aplikace
|
||||||
|
4. Data se automaticky ukl<6B>daj<61> do souboru `vehicles.json` ve stejn<6A> slo<6C>ce jako aplikace
|
||||||
|
|
||||||
|
## Ovl<76>d<EFBFBD>n<EFBFBD> aplikace
|
||||||
|
|
||||||
|
### P<>id<69>n<EFBFBD> vozidla
|
||||||
|
1. Klikn<6B>te na tla<6C><61>tko **"P<>idat vozidlo"**
|
||||||
|
2. Vypl<70>te <20>daje o vozidle
|
||||||
|
3. Vyberte barvu pomoc<6F> tla<6C><61>tka **"Vybrat barvu"**
|
||||||
|
4. (Voliteln<6C>) Vyberte fotografii
|
||||||
|
5. (Voliteln<6C>) Vypl<70>te <20>daje o vlastn<74>kovi
|
||||||
|
6. Klikn<6B>te na **"Ulozit"**
|
||||||
|
|
||||||
|
### Zobrazen<65> detailu
|
||||||
|
- **Double-click** na vozidlo v seznamu, nebo
|
||||||
|
- Vyberte vozidlo a klikn<6B>te na **"Detail"**
|
||||||
|
|
||||||
|
### <20>prava vozidla
|
||||||
|
1. Vyberte vozidlo v seznamu
|
||||||
|
2. Klikn<6B>te na **"Upravit"**
|
||||||
|
3. Zm<5A><6D>te po<70>adovan<61> <20>daje
|
||||||
|
4. Klikn<6B>te na **"Ulozit"**
|
||||||
|
|
||||||
|
### Smaz<61>n<EFBFBD> vozidla
|
||||||
|
1. Vyberte vozidlo v seznamu
|
||||||
|
2. Klikn<6B>te na **"Smazat"**
|
||||||
|
3. Potvr<76>te smaz<61>n<EFBFBD>
|
||||||
|
|
||||||
|
## Ukl<6B>d<EFBFBD>n<EFBFBD> dat
|
||||||
|
|
||||||
|
Data jsou ulo<6C>ena v souboru **`vehicles.json`** ve form<72>tu:
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"Spz": "1A2 3456",
|
||||||
|
"Znacka": "Skoda",
|
||||||
|
"Model": "Octavia",
|
||||||
|
"Barva": "#FF0000",
|
||||||
|
"RokVyroby": 2020,
|
||||||
|
"Palivo": "Benz<6E>n",
|
||||||
|
"NajeteKm": 50000,
|
||||||
|
"Cena": 350000,
|
||||||
|
"Fotografie": "base64_string...",
|
||||||
|
"Vlastnik": {
|
||||||
|
"Jmeno": "Jan",
|
||||||
|
"Prijmeni": "Novak",
|
||||||
|
"Adresa": "Praha 1",
|
||||||
|
"Telefon": "+420123456789",
|
||||||
|
"Email": "jan.novak@email.cz"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Autor
|
||||||
|
Vytvo<EFBFBD>eno pro p<>edm<64>t PTA25 - Programov<6F>n<EFBFBD> v C#
|
||||||
|
|
||||||
|
## Term<72>n odevzd<7A>n<EFBFBD>
|
||||||
|
**1. 3. 2026**
|
||||||
@@ -9,7 +9,10 @@ namespace dealer
|
|||||||
public class DataManager
|
public class DataManager
|
||||||
{
|
{
|
||||||
private List<Vehicle> vehicles = new List<Vehicle>();
|
private List<Vehicle> vehicles = new List<Vehicle>();
|
||||||
|
private List<Owner> owners = new List<Owner>();
|
||||||
|
private List<Image> images = new List<Image>();
|
||||||
|
|
||||||
|
// Vehicle CRUD
|
||||||
public void AddVehicle(Vehicle vehicle)
|
public void AddVehicle(Vehicle vehicle)
|
||||||
{
|
{
|
||||||
vehicles.Add(vehicle);
|
vehicles.Add(vehicle);
|
||||||
@@ -25,23 +28,260 @@ namespace dealer
|
|||||||
vehicles.Remove(vehicle);
|
vehicles.Remove(vehicle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Owner CRUD
|
||||||
|
public void AddOwner(Owner owner)
|
||||||
|
{
|
||||||
|
owners.Add(owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Owner> GetAllOwners()
|
||||||
|
{
|
||||||
|
return owners;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Owner? GetOwnerById(Guid? id)
|
||||||
|
{
|
||||||
|
if (id == null) return null;
|
||||||
|
return owners.FirstOrDefault(o => o.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveOwner(Owner owner)
|
||||||
|
{
|
||||||
|
// Remove owner reference from all vehicles
|
||||||
|
foreach (var vehicle in vehicles.Where(v => v.VlastnikId == owner.Id))
|
||||||
|
{
|
||||||
|
vehicle.VlastnikId = null;
|
||||||
|
vehicle.Vlastnik = null;
|
||||||
|
}
|
||||||
|
owners.Remove(owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Owner> SearchOwners(string searchText)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(searchText))
|
||||||
|
return owners;
|
||||||
|
|
||||||
|
searchText = searchText.ToLower();
|
||||||
|
return owners.Where(o =>
|
||||||
|
(o.Jmeno?.ToLower().Contains(searchText) ?? false) ||
|
||||||
|
(o.Prijmeni?.ToLower().Contains(searchText) ?? false) ||
|
||||||
|
(o.Email?.ToLower().Contains(searchText) ?? false) ||
|
||||||
|
(o.Telefon?.Contains(searchText) ?? false) ||
|
||||||
|
(o.CeleJmeno?.ToLower().Contains(searchText) ?? false));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Image CRUD
|
||||||
|
public void AddImage(Image image)
|
||||||
|
{
|
||||||
|
images.Add(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Image> GetAllImages()
|
||||||
|
{
|
||||||
|
return images;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image? GetImageById(Guid? id)
|
||||||
|
{
|
||||||
|
if (id == null) return null;
|
||||||
|
return images.FirstOrDefault(i => i.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveImage(Image image)
|
||||||
|
{
|
||||||
|
// Remove image reference from all vehicles
|
||||||
|
foreach (var vehicle in vehicles.Where(v => v.FotografieId == image.Id))
|
||||||
|
{
|
||||||
|
vehicle.FotografieId = null;
|
||||||
|
vehicle.Fotografie = null;
|
||||||
|
}
|
||||||
|
images.Remove(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Link owners and images to vehicles after loading
|
||||||
|
private void LinkRelationsToVehicles()
|
||||||
|
{
|
||||||
|
foreach (var vehicle in vehicles)
|
||||||
|
{
|
||||||
|
if (vehicle.VlastnikId.HasValue)
|
||||||
|
{
|
||||||
|
vehicle.Vlastnik = GetOwnerById(vehicle.VlastnikId);
|
||||||
|
}
|
||||||
|
if (vehicle.FotografieId.HasValue)
|
||||||
|
{
|
||||||
|
vehicle.Fotografie = GetImageById(vehicle.FotografieId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
// Implementace ukládání dat do souboru - JSON
|
// Save vehicles
|
||||||
var json = System.Text.Json.JsonSerializer.Serialize(vehicles);
|
var vehiclesJson = System.Text.Json.JsonSerializer.Serialize(vehicles);
|
||||||
System.IO.File.WriteAllText("vehicles.json", json);
|
System.IO.File.WriteAllText("vehicles.json", vehiclesJson);
|
||||||
|
|
||||||
|
// Save owners
|
||||||
|
var ownersJson = System.Text.Json.JsonSerializer.Serialize(owners);
|
||||||
|
System.IO.File.WriteAllText("owners.json", ownersJson);
|
||||||
|
|
||||||
|
// Save images
|
||||||
|
var imagesJson = System.Text.Json.JsonSerializer.Serialize(images);
|
||||||
|
System.IO.File.WriteAllText("images.json", imagesJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Load()
|
public void Load()
|
||||||
{
|
{
|
||||||
string path = "vehicles.json";
|
// Load owners first
|
||||||
|
string ownersPath = "owners.json";
|
||||||
// Implementace načítání dat ze souboru - JSON
|
if (System.IO.File.Exists(ownersPath))
|
||||||
if (System.IO.File.Exists(path))
|
|
||||||
{
|
{
|
||||||
var json = System.IO.File.ReadAllText(path);
|
var json = System.IO.File.ReadAllText(ownersPath);
|
||||||
|
owners = System.Text.Json.JsonSerializer.Deserialize<List<Owner>>(json) ?? new List<Owner>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load images
|
||||||
|
string imagesPath = "images.json";
|
||||||
|
if (System.IO.File.Exists(imagesPath))
|
||||||
|
{
|
||||||
|
var json = System.IO.File.ReadAllText(imagesPath);
|
||||||
|
images = System.Text.Json.JsonSerializer.Deserialize<List<Image>>(json) ?? new List<Image>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load vehicles
|
||||||
|
string vehiclesPath = "vehicles.json";
|
||||||
|
if (System.IO.File.Exists(vehiclesPath))
|
||||||
|
{
|
||||||
|
var json = System.IO.File.ReadAllText(vehiclesPath);
|
||||||
vehicles = System.Text.Json.JsonSerializer.Deserialize<List<Vehicle>>(json) ?? new List<Vehicle>();
|
vehicles = System.Text.Json.JsonSerializer.Deserialize<List<Vehicle>>(json) ?? new List<Vehicle>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Link relations to vehicles
|
||||||
|
LinkRelationsToVehicles();
|
||||||
|
|
||||||
|
// If no data exists, seed with sample data
|
||||||
|
if (!vehicles.Any() && !owners.Any())
|
||||||
|
{
|
||||||
|
SeedData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SeedData()
|
||||||
|
{
|
||||||
|
// Seed owners
|
||||||
|
var owner1 = new Owner
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Jmeno = "Jan",
|
||||||
|
Prijmeni = "Novak",
|
||||||
|
Adresa = "Praha 1, Vaclavske namesti 1",
|
||||||
|
Telefon = "+420 123 456 789",
|
||||||
|
Email = "jan.novak@email.cz"
|
||||||
|
};
|
||||||
|
|
||||||
|
var owner2 = new Owner
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Jmeno = "Marie",
|
||||||
|
Prijmeni = "Svobodova",
|
||||||
|
Adresa = "Brno, Husova 23",
|
||||||
|
Telefon = "+420 987 654 321",
|
||||||
|
Email = "marie.svobodova@email.cz"
|
||||||
|
};
|
||||||
|
|
||||||
|
var owner3 = new Owner
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Jmeno = "Petr",
|
||||||
|
Prijmeni = "Dvorak",
|
||||||
|
Adresa = "Ostrava, Hlavni 45",
|
||||||
|
Telefon = "+420 777 888 999",
|
||||||
|
Email = "petr.dvorak@email.cz"
|
||||||
|
};
|
||||||
|
|
||||||
|
owners.Add(owner1);
|
||||||
|
owners.Add(owner2);
|
||||||
|
owners.Add(owner3);
|
||||||
|
|
||||||
|
// Seed images (1x1 pixel placeholder images in different colors)
|
||||||
|
var image1 = new Image
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPj/HwADBwIAMCbHYQAAAABJRU5ErkJggg==",
|
||||||
|
FileName = "skoda_octavia.png",
|
||||||
|
ContentType = "image/png"
|
||||||
|
};
|
||||||
|
|
||||||
|
var image2 = new Image
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M/wHwAEBgIApD5fRAAAAABJRU5ErkJggg==",
|
||||||
|
FileName = "bmw_x5.png",
|
||||||
|
ContentType = "image/png"
|
||||||
|
};
|
||||||
|
|
||||||
|
var image3 = new Image
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Data = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==",
|
||||||
|
FileName = "tesla_model3.png",
|
||||||
|
ContentType = "image/png"
|
||||||
|
};
|
||||||
|
|
||||||
|
images.Add(image1);
|
||||||
|
images.Add(image2);
|
||||||
|
images.Add(image3);
|
||||||
|
|
||||||
|
// Seed vehicles
|
||||||
|
vehicles.Add(new Vehicle
|
||||||
|
{
|
||||||
|
Spz = "1A2 3456",
|
||||||
|
Znacka = "Skoda",
|
||||||
|
Model = "Octavia",
|
||||||
|
Barva = "#0055AA",
|
||||||
|
RokVyroby = 2020,
|
||||||
|
Palivo = "Benzín",
|
||||||
|
NajeteKm = 45000,
|
||||||
|
Cena = 350000,
|
||||||
|
VlastnikId = owner1.Id,
|
||||||
|
Vlastnik = owner1,
|
||||||
|
FotografieId = image1.Id,
|
||||||
|
Fotografie = image1
|
||||||
|
});
|
||||||
|
|
||||||
|
vehicles.Add(new Vehicle
|
||||||
|
{
|
||||||
|
Spz = "7B8 9012",
|
||||||
|
Znacka = "BMW",
|
||||||
|
Model = "X5",
|
||||||
|
Barva = "#000000",
|
||||||
|
RokVyroby = 2019,
|
||||||
|
Palivo = "Nafta",
|
||||||
|
NajeteKm = 78000,
|
||||||
|
Cena = 850000,
|
||||||
|
VlastnikId = owner2.Id,
|
||||||
|
Vlastnik = owner2,
|
||||||
|
FotografieId = image2.Id,
|
||||||
|
Fotografie = image2
|
||||||
|
});
|
||||||
|
|
||||||
|
vehicles.Add(new Vehicle
|
||||||
|
{
|
||||||
|
Spz = "3C4 5678",
|
||||||
|
Znacka = "Tesla",
|
||||||
|
Model = "Model 3",
|
||||||
|
Barva = "#FFFFFF",
|
||||||
|
RokVyroby = 2022,
|
||||||
|
Palivo = "Elektro",
|
||||||
|
NajeteKm = 15000,
|
||||||
|
Cena = 1200000,
|
||||||
|
VlastnikId = owner3.Id,
|
||||||
|
Vlastnik = owner3,
|
||||||
|
FotografieId = image3.Id,
|
||||||
|
Fotografie = image3
|
||||||
|
});
|
||||||
|
|
||||||
|
// Save the seeded data
|
||||||
|
Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
dealer/Image.cs
Normal file
12
dealer/Image.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace dealer
|
||||||
|
{
|
||||||
|
public class Image
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; } = Guid.NewGuid();
|
||||||
|
public string? Data { get; set; } // Base64 encoded image data or file path
|
||||||
|
public string? FileName { get; set; }
|
||||||
|
public string? ContentType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
26
dealer/Owner.cs
Normal file
26
dealer/Owner.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace dealer
|
||||||
|
{
|
||||||
|
public class Owner
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; } = Guid.NewGuid();
|
||||||
|
public string? Jmeno { get; set; }
|
||||||
|
public string? Prijmeni { get; set; }
|
||||||
|
public string? Adresa { get; set; }
|
||||||
|
public string? Telefon { get; set; }
|
||||||
|
public string? Email { get; set; }
|
||||||
|
|
||||||
|
public string CeleJmeno => $"{Jmeno} {Prijmeni}".Trim();
|
||||||
|
|
||||||
|
public string DisplayText => string.IsNullOrEmpty(CeleJmeno)
|
||||||
|
? Email ?? Telefon ?? "Neznamy vlastnik"
|
||||||
|
: CeleJmeno;
|
||||||
|
|
||||||
|
public override string ToString() => DisplayText;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace dealer
|
namespace dealer
|
||||||
@@ -9,11 +10,26 @@ namespace dealer
|
|||||||
public class Vehicle
|
public class Vehicle
|
||||||
{
|
{
|
||||||
public string? Spz { get; set; }
|
public string? Spz { get; set; }
|
||||||
|
public string? Znacka { get; set; }
|
||||||
public string? Model { get; set; }
|
public string? Model { get; set; }
|
||||||
public string? Barva { get; set; }
|
public string? Barva { get; set; }
|
||||||
public int? RokVyroby { get; set; }
|
public int? RokVyroby { get; set; }
|
||||||
|
public string? Palivo { get; set; }
|
||||||
public int? NajeteKm { get; set; }
|
public int? NajeteKm { get; set; }
|
||||||
public decimal? Cena { get; set; }
|
public decimal? Cena { get; set; }
|
||||||
public string? Fotografie { get; set; }
|
|
||||||
|
public Guid? FotografieId { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public Image? Fotografie { get; set; }
|
||||||
|
|
||||||
|
public Guid? VlastnikId { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public Owner? Vlastnik { get; set; }
|
||||||
|
|
||||||
|
public string ZnackaModel => !string.IsNullOrEmpty(Znacka) && !string.IsNullOrEmpty(Model)
|
||||||
|
? $"{Znacka} {Model}"
|
||||||
|
: Model ?? Znacka ?? "Nezadano";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
84
dealer/windows/AddOwnerWindow.xaml
Normal file
84
dealer/windows/AddOwnerWindow.xaml
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<Window x:Class="dealer.AddOwnerWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:dealer"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Pridat vlastnika" Height="400" Width="400"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
ResizeMode="NoResize">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Auto">
|
||||||
|
<StackPanel Margin="20">
|
||||||
|
<TextBlock Text="Novy vlastnik"
|
||||||
|
FontSize="20"
|
||||||
|
FontWeight="Bold"
|
||||||
|
Margin="0,0,0,20"
|
||||||
|
HorizontalAlignment="Center" />
|
||||||
|
|
||||||
|
<TextBlock Text="Jmeno:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="JmenoTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Prijmeni:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="PrijmeniTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Telefon:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="TelefonTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Email:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="EmailTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Adresa:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="AdresaTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
AcceptsReturn="True"
|
||||||
|
Height="60"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
|
||||||
|
<Border Grid.Row="1"
|
||||||
|
BorderBrush="LightGray"
|
||||||
|
BorderThickness="0,1,0,0"
|
||||||
|
Background="WhiteSmoke">
|
||||||
|
<StackPanel Orientation="Horizontal"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Margin="0,15">
|
||||||
|
<Button Name="SaveButton"
|
||||||
|
Content="Ulozit"
|
||||||
|
Width="100"
|
||||||
|
Height="35"
|
||||||
|
Margin="5"
|
||||||
|
FontSize="14"
|
||||||
|
Click="SaveButton_Click" />
|
||||||
|
<Button Name="CancelButton"
|
||||||
|
Content="Zrusit"
|
||||||
|
Width="100"
|
||||||
|
Height="35"
|
||||||
|
Margin="5"
|
||||||
|
FontSize="14"
|
||||||
|
Click="CancelButton_Click" />
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
49
dealer/windows/AddOwnerWindow.xaml.cs
Normal file
49
dealer/windows/AddOwnerWindow.xaml.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace dealer
|
||||||
|
{
|
||||||
|
public partial class AddOwnerWindow : Window
|
||||||
|
{
|
||||||
|
private DataManager dataManager;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the owner that was created when the user saved, or null if cancelled.
|
||||||
|
/// </summary>
|
||||||
|
public Owner? CreatedOwner { get; private set; }
|
||||||
|
|
||||||
|
public AddOwnerWindow(DataManager dataManager)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.dataManager = dataManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(JmenoTextBox.Text) && string.IsNullOrWhiteSpace(PrijmeniTextBox.Text))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyplnte alespon jmeno nebo prijmeni.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var owner = new Owner
|
||||||
|
{
|
||||||
|
Jmeno = JmenoTextBox.Text.Trim(),
|
||||||
|
Prijmeni = PrijmeniTextBox.Text.Trim(),
|
||||||
|
Telefon = TelefonTextBox.Text.Trim(),
|
||||||
|
Email = EmailTextBox.Text.Trim(),
|
||||||
|
Adresa = AdresaTextBox.Text.Trim()
|
||||||
|
};
|
||||||
|
|
||||||
|
dataManager.AddOwner(owner);
|
||||||
|
dataManager.Save();
|
||||||
|
CreatedOwner = owner;
|
||||||
|
this.DialogResult = true;
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CancelButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:dealer"
|
xmlns:local="clr-namespace:dealer"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Pridat vozidlo" Height="550" Width="450"
|
Title="Pridat vozidlo" Height="700" Width="500"
|
||||||
WindowStartupLocation="CenterOwner"
|
WindowStartupLocation="CenterOwner"
|
||||||
ResizeMode="NoResize">
|
ResizeMode="NoResize">
|
||||||
<Grid>
|
<Grid>
|
||||||
@@ -30,6 +30,12 @@
|
|||||||
CharacterCasing="Upper"
|
CharacterCasing="Upper"
|
||||||
Margin="0,0,0,10" />
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Znacka:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="ZnackaTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
<TextBlock Text="Model:" FontSize="14" Margin="0,5" />
|
<TextBlock Text="Model:" FontSize="14" Margin="0,5" />
|
||||||
<TextBox Name="ModelTextBox"
|
<TextBox Name="ModelTextBox"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
@@ -66,6 +72,19 @@
|
|||||||
PreviewTextInput="NumericOnly_PreviewTextInput"
|
PreviewTextInput="NumericOnly_PreviewTextInput"
|
||||||
Margin="0,0,0,10" />
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Palivo:" FontSize="14" Margin="0,5" />
|
||||||
|
<ComboBox Name="PalivoComboBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
Margin="0,0,0,10">
|
||||||
|
<ComboBoxItem Content="Benzin" />
|
||||||
|
<ComboBoxItem Content="Nafta" />
|
||||||
|
<ComboBoxItem Content="Elektro" />
|
||||||
|
<ComboBoxItem Content="Hybrid" />
|
||||||
|
<ComboBoxItem Content="LPG" />
|
||||||
|
<ComboBoxItem Content="CNG" />
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
<TextBlock Text="Najete km:" FontSize="14" Margin="0,5" />
|
<TextBlock Text="Najete km:" FontSize="14" Margin="0,5" />
|
||||||
<TextBox Name="MileageTextBox"
|
<TextBox Name="MileageTextBox"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
@@ -94,6 +113,44 @@
|
|||||||
Foreground="Gray"
|
Foreground="Gray"
|
||||||
Margin="0,0,0,10"
|
Margin="0,0,0,10"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
|
|
||||||
|
<Separator Margin="0,15,0,15" />
|
||||||
|
|
||||||
|
<TextBlock Text="Vlastnik" FontSize="16" FontWeight="Bold" Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Vybrat vlastnika:" FontSize="14" Margin="0,5" />
|
||||||
|
<Grid Margin="0,0,0,10">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ComboBox Name="OwnerComboBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
IsEditable="True"
|
||||||
|
IsTextSearchEnabled="False"
|
||||||
|
StaysOpenOnEdit="True"
|
||||||
|
DisplayMemberPath="DisplayText"
|
||||||
|
TextBoxBase.TextChanged="OwnerComboBox_TextChanged"
|
||||||
|
SelectionChanged="OwnerComboBox_SelectionChanged" />
|
||||||
|
<Button Name="AddNewOwnerButton"
|
||||||
|
Grid.Column="1"
|
||||||
|
Content="+"
|
||||||
|
Width="35"
|
||||||
|
Height="35"
|
||||||
|
Margin="5,0,0,0"
|
||||||
|
FontSize="18"
|
||||||
|
FontWeight="Bold"
|
||||||
|
ToolTip="Pridat noveho vlastnika"
|
||||||
|
Click="AddNewOwnerButton_Click" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<TextBlock Name="SelectedOwnerInfo"
|
||||||
|
Text=""
|
||||||
|
FontStyle="Italic"
|
||||||
|
Foreground="Gray"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using WinForms = System.Windows.Forms;
|
using WinForms = System.Windows.Forms;
|
||||||
@@ -13,12 +15,76 @@ namespace dealer
|
|||||||
public System.Windows.Media.Color SelectedColor { get; private set; } = Colors.White;
|
public System.Windows.Media.Color SelectedColor { get; private set; } = Colors.White;
|
||||||
|
|
||||||
private DataManager dataManager;
|
private DataManager dataManager;
|
||||||
|
private Owner? selectedOwner;
|
||||||
|
private bool isUpdatingOwnerComboBox = false;
|
||||||
|
|
||||||
public AddVehicleWindow(DataManager dataManager)
|
public AddVehicleWindow(DataManager dataManager)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.dataManager = dataManager;
|
this.dataManager = dataManager;
|
||||||
|
LoadOwners();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadOwners()
|
||||||
|
{
|
||||||
|
OwnerComboBox.ItemsSource = dataManager.GetAllOwners().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OwnerComboBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (isUpdatingOwnerComboBox) return;
|
||||||
|
|
||||||
|
var comboBox = sender as System.Windows.Controls.ComboBox;
|
||||||
|
if (comboBox == null) return;
|
||||||
|
|
||||||
|
string searchText = comboBox.Text;
|
||||||
|
var filteredOwners = dataManager.SearchOwners(searchText).ToList();
|
||||||
|
|
||||||
|
isUpdatingOwnerComboBox = true;
|
||||||
|
comboBox.ItemsSource = filteredOwners;
|
||||||
|
comboBox.IsDropDownOpen = true;
|
||||||
|
isUpdatingOwnerComboBox = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OwnerComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
selectedOwner = OwnerComboBox.SelectedItem as Owner;
|
||||||
|
UpdateSelectedOwnerInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateSelectedOwnerInfo()
|
||||||
|
{
|
||||||
|
if (selectedOwner != null)
|
||||||
|
{
|
||||||
|
var info = selectedOwner.CeleJmeno;
|
||||||
|
if (!string.IsNullOrEmpty(selectedOwner.Telefon))
|
||||||
|
info += $"\nTel: {selectedOwner.Telefon}";
|
||||||
|
if (!string.IsNullOrEmpty(selectedOwner.Email))
|
||||||
|
info += $"\nEmail: {selectedOwner.Email}";
|
||||||
|
if (!string.IsNullOrEmpty(selectedOwner.Adresa))
|
||||||
|
info += $"\nAdresa: {selectedOwner.Adresa}";
|
||||||
|
SelectedOwnerInfo.Text = info;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SelectedOwnerInfo.Text = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddNewOwnerButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var addOwnerWindow = new AddOwnerWindow(dataManager);
|
||||||
|
addOwnerWindow.Owner = this;
|
||||||
|
if (addOwnerWindow.ShowDialog() == true && addOwnerWindow.CreatedOwner != null)
|
||||||
|
{
|
||||||
|
LoadOwners();
|
||||||
|
OwnerComboBox.SelectedItem = dataManager.GetAllOwners().FirstOrDefault(o => o.Id == addOwnerWindow.CreatedOwner.Id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LoadOwners();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectPhotoButton_Click(object sender, RoutedEventArgs e)
|
private void SelectPhotoButton_Click(object sender, RoutedEventArgs e)
|
||||||
@@ -74,22 +140,75 @@ namespace dealer
|
|||||||
|
|
||||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
string? base64Image = null;
|
if (string.IsNullOrWhiteSpace(SpzTextBox.Text))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyplnte SPZ.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(ZnackaTextBox.Text))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyplnte znacku.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(ModelTextBox.Text))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyplnte model.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(YearTextBox.Text))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyplnte rok vyroby.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PalivoComboBox.SelectedItem == null)
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyberte palivo.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(MileageTextBox.Text) && (!int.TryParse(MileageTextBox.Text, out int mileageVal) || mileageVal < 0))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Najete km musi byt nezaporne cele cislo.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(PriceTextBox.Text) && (!decimal.TryParse(PriceTextBox.Text, out decimal priceVal) || priceVal < 0))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Cena musi byt nezaporne cislo.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Image? image = null;
|
||||||
if (!string.IsNullOrEmpty(SelectedPhotoPath) && File.Exists(SelectedPhotoPath))
|
if (!string.IsNullOrEmpty(SelectedPhotoPath) && File.Exists(SelectedPhotoPath))
|
||||||
{
|
{
|
||||||
byte[] imageBytes = File.ReadAllBytes(SelectedPhotoPath);
|
byte[] imageBytes = File.ReadAllBytes(SelectedPhotoPath);
|
||||||
base64Image = Convert.ToBase64String(imageBytes);
|
image = new Image
|
||||||
|
{
|
||||||
|
Data = Convert.ToBase64String(imageBytes),
|
||||||
|
FileName = System.IO.Path.GetFileName(SelectedPhotoPath),
|
||||||
|
ContentType = GetContentType(SelectedPhotoPath)
|
||||||
|
};
|
||||||
|
this.dataManager.AddImage(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
var vehicle = new Vehicle
|
var vehicle = new Vehicle
|
||||||
{
|
{
|
||||||
Spz = SpzTextBox.Text,
|
Spz = SpzTextBox.Text,
|
||||||
|
Znacka = ZnackaTextBox.Text,
|
||||||
Model = ModelTextBox.Text,
|
Model = ModelTextBox.Text,
|
||||||
Barva = $"#{SelectedColor.R:X2}{SelectedColor.G:X2}{SelectedColor.B:X2}",
|
Barva = $"#{SelectedColor.R:X2}{SelectedColor.G:X2}{SelectedColor.B:X2}",
|
||||||
RokVyroby = int.TryParse(YearTextBox.Text, out int rok) ? rok : (int?)null,
|
RokVyroby = int.TryParse(YearTextBox.Text, out int rok) ? rok : (int?)null,
|
||||||
|
Palivo = (PalivoComboBox.SelectedItem as System.Windows.Controls.ComboBoxItem)?.Content?.ToString(),
|
||||||
NajeteKm = int.TryParse(MileageTextBox.Text, out int km) ? km : (int?)null,
|
NajeteKm = int.TryParse(MileageTextBox.Text, out int km) ? km : (int?)null,
|
||||||
Cena = decimal.TryParse(PriceTextBox.Text, out decimal cena) ? cena : (decimal?)null,
|
Cena = decimal.TryParse(PriceTextBox.Text, out decimal cena) ? cena : (decimal?)null,
|
||||||
Fotografie = base64Image
|
FotografieId = image?.Id,
|
||||||
|
Fotografie = image,
|
||||||
|
VlastnikId = selectedOwner?.Id,
|
||||||
|
Vlastnik = selectedOwner
|
||||||
};
|
};
|
||||||
|
|
||||||
this.dataManager.AddVehicle(vehicle);
|
this.dataManager.AddVehicle(vehicle);
|
||||||
@@ -102,5 +221,19 @@ namespace dealer
|
|||||||
{
|
{
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetContentType(string filePath)
|
||||||
|
{
|
||||||
|
var extension = System.IO.Path.GetExtension(filePath)?.ToLowerInvariant();
|
||||||
|
return extension switch
|
||||||
|
{
|
||||||
|
".jpg" or ".jpeg" => "image/jpeg",
|
||||||
|
".png" => "image/png",
|
||||||
|
".gif" => "image/gif",
|
||||||
|
".bmp" => "image/bmp",
|
||||||
|
".webp" => "image/webp",
|
||||||
|
_ => "application/octet-stream"
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
84
dealer/windows/EditOwnerWindow.xaml
Normal file
84
dealer/windows/EditOwnerWindow.xaml
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<Window x:Class="dealer.EditOwnerWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:dealer"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Upravit vlastnika" Height="400" Width="400"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
ResizeMode="NoResize">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Auto">
|
||||||
|
<StackPanel Margin="20">
|
||||||
|
<TextBlock Text="Upravit vlastnika"
|
||||||
|
FontSize="20"
|
||||||
|
FontWeight="Bold"
|
||||||
|
Margin="0,0,0,20"
|
||||||
|
HorizontalAlignment="Center" />
|
||||||
|
|
||||||
|
<TextBlock Text="Jmeno:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="JmenoTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Prijmeni:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="PrijmeniTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Telefon:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="TelefonTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Email:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="EmailTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Adresa:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="AdresaTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
AcceptsReturn="True"
|
||||||
|
Height="60"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
|
||||||
|
<Border Grid.Row="1"
|
||||||
|
BorderBrush="LightGray"
|
||||||
|
BorderThickness="0,1,0,0"
|
||||||
|
Background="WhiteSmoke">
|
||||||
|
<StackPanel Orientation="Horizontal"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Margin="0,15">
|
||||||
|
<Button Name="SaveButton"
|
||||||
|
Content="Ulozit"
|
||||||
|
Width="100"
|
||||||
|
Height="35"
|
||||||
|
Margin="5"
|
||||||
|
FontSize="14"
|
||||||
|
Click="SaveButton_Click" />
|
||||||
|
<Button Name="CancelButton"
|
||||||
|
Content="Zrusit"
|
||||||
|
Width="100"
|
||||||
|
Height="35"
|
||||||
|
Margin="5"
|
||||||
|
FontSize="14"
|
||||||
|
Click="CancelButton_Click" />
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
74
dealer/windows/EditOwnerWindow.xaml.cs
Normal file
74
dealer/windows/EditOwnerWindow.xaml.cs
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace dealer
|
||||||
|
{
|
||||||
|
public partial class EditOwnerWindow : Window
|
||||||
|
{
|
||||||
|
private Owner owner;
|
||||||
|
private DataManager dataManager;
|
||||||
|
|
||||||
|
public EditOwnerWindow(Owner owner, DataManager dataManager)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.owner = owner;
|
||||||
|
this.dataManager = dataManager;
|
||||||
|
LoadOwnerData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadOwnerData()
|
||||||
|
{
|
||||||
|
JmenoTextBox.Text = owner.Jmeno ?? "";
|
||||||
|
PrijmeniTextBox.Text = owner.Prijmeni ?? "";
|
||||||
|
TelefonTextBox.Text = owner.Telefon ?? "";
|
||||||
|
EmailTextBox.Text = owner.Email ?? "";
|
||||||
|
AdresaTextBox.Text = owner.Adresa ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(JmenoTextBox.Text))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyplnte jmeno.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(PrijmeniTextBox.Text))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyplnte prijmeni.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(TelefonTextBox.Text))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyplnte telefon.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(EmailTextBox.Text))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyplnte email.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(AdresaTextBox.Text))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyplnte adresu.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
owner.Jmeno = JmenoTextBox.Text.Trim();
|
||||||
|
owner.Prijmeni = PrijmeniTextBox.Text.Trim();
|
||||||
|
owner.Telefon = TelefonTextBox.Text.Trim();
|
||||||
|
owner.Email = EmailTextBox.Text.Trim();
|
||||||
|
owner.Adresa = AdresaTextBox.Text.Trim();
|
||||||
|
|
||||||
|
dataManager.Save();
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CancelButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:dealer"
|
xmlns:local="clr-namespace:dealer"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Upravit vozidlo" Height="600" Width="450"
|
Title="Upravit vozidlo" Height="700" Width="500"
|
||||||
WindowStartupLocation="CenterOwner"
|
WindowStartupLocation="CenterOwner"
|
||||||
ResizeMode="NoResize">
|
ResizeMode="NoResize">
|
||||||
<Grid>
|
<Grid>
|
||||||
@@ -30,6 +30,12 @@
|
|||||||
CharacterCasing="Upper"
|
CharacterCasing="Upper"
|
||||||
Margin="0,0,0,10" />
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Znacka:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="ZnackaTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
<TextBlock Text="Model:" FontSize="14" Margin="0,5" />
|
<TextBlock Text="Model:" FontSize="14" Margin="0,5" />
|
||||||
<TextBox Name="ModelTextBox"
|
<TextBox Name="ModelTextBox"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
@@ -66,6 +72,19 @@
|
|||||||
PreviewTextInput="NumericOnly_PreviewTextInput"
|
PreviewTextInput="NumericOnly_PreviewTextInput"
|
||||||
Margin="0,0,0,10" />
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Palivo:" FontSize="14" Margin="0,5" />
|
||||||
|
<ComboBox Name="PalivoComboBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
Margin="0,0,0,10">
|
||||||
|
<ComboBoxItem Content="Benzin" />
|
||||||
|
<ComboBoxItem Content="Nafta" />
|
||||||
|
<ComboBoxItem Content="Elektro" />
|
||||||
|
<ComboBoxItem Content="Hybrid" />
|
||||||
|
<ComboBoxItem Content="LPG" />
|
||||||
|
<ComboBoxItem Content="CNG" />
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
<TextBlock Text="Najete km:" FontSize="14" Margin="0,5" />
|
<TextBlock Text="Najete km:" FontSize="14" Margin="0,5" />
|
||||||
<TextBox Name="MileageTextBox"
|
<TextBox Name="MileageTextBox"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
@@ -100,6 +119,44 @@
|
|||||||
Foreground="Gray"
|
Foreground="Gray"
|
||||||
Margin="0,0,0,10"
|
Margin="0,0,0,10"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
|
|
||||||
|
<Separator Margin="0,15,0,15" />
|
||||||
|
|
||||||
|
<TextBlock Text="Vlastnik" FontSize="16" FontWeight="Bold" Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Vybrat vlastnika:" FontSize="14" Margin="0,5" />
|
||||||
|
<Grid Margin="0,0,0,10">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ComboBox Name="OwnerComboBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
IsEditable="True"
|
||||||
|
IsTextSearchEnabled="False"
|
||||||
|
StaysOpenOnEdit="True"
|
||||||
|
DisplayMemberPath="DisplayText"
|
||||||
|
TextBoxBase.TextChanged="OwnerComboBox_TextChanged"
|
||||||
|
SelectionChanged="OwnerComboBox_SelectionChanged" />
|
||||||
|
<Button Name="AddNewOwnerButton"
|
||||||
|
Grid.Column="1"
|
||||||
|
Content="+"
|
||||||
|
Width="35"
|
||||||
|
Height="35"
|
||||||
|
Margin="5,0,0,0"
|
||||||
|
FontSize="18"
|
||||||
|
FontWeight="Bold"
|
||||||
|
ToolTip="Pridat noveho vlastnika"
|
||||||
|
Click="AddNewOwnerButton_Click" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<TextBlock Name="SelectedOwnerInfo"
|
||||||
|
Text=""
|
||||||
|
FontStyle="Italic"
|
||||||
|
Foreground="Gray"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
@@ -18,6 +20,8 @@ namespace dealer
|
|||||||
private DataManager dataManager;
|
private DataManager dataManager;
|
||||||
private Vehicle vehicle;
|
private Vehicle vehicle;
|
||||||
private bool photoChanged = false;
|
private bool photoChanged = false;
|
||||||
|
private Owner? selectedOwner;
|
||||||
|
private bool isUpdatingOwnerComboBox = false;
|
||||||
|
|
||||||
public EditVehicleWindow(Vehicle vehicle, DataManager dataManager)
|
public EditVehicleWindow(Vehicle vehicle, DataManager dataManager)
|
||||||
{
|
{
|
||||||
@@ -26,14 +30,72 @@ namespace dealer
|
|||||||
this.dataManager = dataManager;
|
this.dataManager = dataManager;
|
||||||
this.vehicle = vehicle;
|
this.vehicle = vehicle;
|
||||||
|
|
||||||
|
LoadOwners();
|
||||||
LoadVehicleData();
|
LoadVehicleData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LoadOwners()
|
||||||
|
{
|
||||||
|
OwnerComboBox.ItemsSource = dataManager.GetAllOwners().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OwnerComboBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (isUpdatingOwnerComboBox) return;
|
||||||
|
|
||||||
|
var comboBox = sender as System.Windows.Controls.ComboBox;
|
||||||
|
if (comboBox == null) return;
|
||||||
|
|
||||||
|
string searchText = comboBox.Text;
|
||||||
|
var filteredOwners = dataManager.SearchOwners(searchText).ToList();
|
||||||
|
|
||||||
|
isUpdatingOwnerComboBox = true;
|
||||||
|
comboBox.ItemsSource = filteredOwners;
|
||||||
|
comboBox.IsDropDownOpen = true;
|
||||||
|
isUpdatingOwnerComboBox = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OwnerComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
selectedOwner = OwnerComboBox.SelectedItem as Owner;
|
||||||
|
UpdateSelectedOwnerInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateSelectedOwnerInfo()
|
||||||
|
{
|
||||||
|
if (selectedOwner != null)
|
||||||
|
{
|
||||||
|
var info = selectedOwner.CeleJmeno;
|
||||||
|
if (!string.IsNullOrEmpty(selectedOwner.Telefon))
|
||||||
|
info += $"\nTel: {selectedOwner.Telefon}";
|
||||||
|
if (!string.IsNullOrEmpty(selectedOwner.Email))
|
||||||
|
info += $"\nEmail: {selectedOwner.Email}";
|
||||||
|
if (!string.IsNullOrEmpty(selectedOwner.Adresa))
|
||||||
|
info += $"\nAdresa: {selectedOwner.Adresa}";
|
||||||
|
SelectedOwnerInfo.Text = info;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SelectedOwnerInfo.Text = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddNewOwnerButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var addOwnerWindow = new AddOwnerWindow(dataManager);
|
||||||
|
addOwnerWindow.Owner = this;
|
||||||
|
addOwnerWindow.ShowDialog();
|
||||||
|
LoadOwners();
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadVehicleData()
|
private void LoadVehicleData()
|
||||||
{
|
{
|
||||||
// SPZ
|
// SPZ
|
||||||
SpzTextBox.Text = vehicle.Spz ?? "";
|
SpzTextBox.Text = vehicle.Spz ?? "";
|
||||||
|
|
||||||
|
// Zna<6E>ka
|
||||||
|
ZnackaTextBox.Text = vehicle.Znacka ?? "";
|
||||||
|
|
||||||
// Model
|
// Model
|
||||||
ModelTextBox.Text = vehicle.Model ?? "";
|
ModelTextBox.Text = vehicle.Model ?? "";
|
||||||
|
|
||||||
@@ -57,18 +119,42 @@ namespace dealer
|
|||||||
// Rok vyroby
|
// Rok vyroby
|
||||||
YearTextBox.Text = vehicle.RokVyroby?.ToString() ?? "";
|
YearTextBox.Text = vehicle.RokVyroby?.ToString() ?? "";
|
||||||
|
|
||||||
|
// Palivo
|
||||||
|
if (!string.IsNullOrEmpty(vehicle.Palivo))
|
||||||
|
{
|
||||||
|
foreach (System.Windows.Controls.ComboBoxItem item in PalivoComboBox.Items)
|
||||||
|
{
|
||||||
|
if (item.Content?.ToString() == vehicle.Palivo)
|
||||||
|
{
|
||||||
|
PalivoComboBox.SelectedItem = item;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Najete km
|
// Najete km
|
||||||
MileageTextBox.Text = vehicle.NajeteKm?.ToString() ?? "";
|
MileageTextBox.Text = vehicle.NajeteKm?.ToString() ?? "";
|
||||||
|
|
||||||
// Cena
|
// Cena
|
||||||
PriceTextBox.Text = vehicle.Cena?.ToString() ?? "";
|
PriceTextBox.Text = vehicle.Cena?.ToString() ?? "";
|
||||||
|
|
||||||
|
// Vlastnik - select from combobox
|
||||||
|
if (vehicle.VlastnikId.HasValue)
|
||||||
|
{
|
||||||
|
selectedOwner = dataManager.GetOwnerById(vehicle.VlastnikId);
|
||||||
|
if (selectedOwner != null)
|
||||||
|
{
|
||||||
|
OwnerComboBox.SelectedItem = selectedOwner;
|
||||||
|
UpdateSelectedOwnerInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Fotografie (base64)
|
// Fotografie (base64)
|
||||||
if (!string.IsNullOrEmpty(vehicle.Fotografie))
|
if (vehicle.Fotografie != null && !string.IsNullOrEmpty(vehicle.Fotografie.Data))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
byte[] imageBytes = Convert.FromBase64String(vehicle.Fotografie);
|
byte[] imageBytes = Convert.FromBase64String(vehicle.Fotografie.Data);
|
||||||
using (var ms = new MemoryStream(imageBytes))
|
using (var ms = new MemoryStream(imageBytes))
|
||||||
{
|
{
|
||||||
var bitmap = new BitmapImage();
|
var bitmap = new BitmapImage();
|
||||||
@@ -155,19 +241,75 @@ namespace dealer
|
|||||||
|
|
||||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(SpzTextBox.Text))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyplnte SPZ.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(ZnackaTextBox.Text))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyplnte znacku.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(ModelTextBox.Text))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyplnte model.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(YearTextBox.Text))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyplnte rok vyroby.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PalivoComboBox.SelectedItem == null)
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyberte palivo.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(MileageTextBox.Text) && (!int.TryParse(MileageTextBox.Text, out int mileageVal) || mileageVal < 0))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Najete km musi byt nezaporne cele cislo.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(PriceTextBox.Text) && (!decimal.TryParse(PriceTextBox.Text, out decimal priceVal) || priceVal < 0))
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Cena musi byt nezaporne cislo.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Update vehicle properties
|
// Update vehicle properties
|
||||||
vehicle.Spz = SpzTextBox.Text;
|
vehicle.Spz = SpzTextBox.Text;
|
||||||
|
vehicle.Znacka = ZnackaTextBox.Text;
|
||||||
vehicle.Model = ModelTextBox.Text;
|
vehicle.Model = ModelTextBox.Text;
|
||||||
vehicle.Barva = $"#{SelectedColor.R:X2}{SelectedColor.G:X2}{SelectedColor.B:X2}";
|
vehicle.Barva = $"#{SelectedColor.R:X2}{SelectedColor.G:X2}{SelectedColor.B:X2}";
|
||||||
vehicle.RokVyroby = int.TryParse(YearTextBox.Text, out int rok) ? rok : (int?)null;
|
vehicle.RokVyroby = int.TryParse(YearTextBox.Text, out int rok) ? rok : (int?)null;
|
||||||
|
vehicle.Palivo = (PalivoComboBox.SelectedItem as System.Windows.Controls.ComboBoxItem)?.Content?.ToString();
|
||||||
vehicle.NajeteKm = int.TryParse(MileageTextBox.Text, out int km) ? km : (int?)null;
|
vehicle.NajeteKm = int.TryParse(MileageTextBox.Text, out int km) ? km : (int?)null;
|
||||||
vehicle.Cena = decimal.TryParse(PriceTextBox.Text, out decimal cena) ? cena : (decimal?)null;
|
vehicle.Cena = decimal.TryParse(PriceTextBox.Text, out decimal cena) ? cena : (decimal?)null;
|
||||||
|
|
||||||
|
// Update owner reference
|
||||||
|
vehicle.VlastnikId = selectedOwner?.Id;
|
||||||
|
vehicle.Vlastnik = selectedOwner;
|
||||||
|
|
||||||
// Update photo only if changed
|
// Update photo only if changed
|
||||||
if (photoChanged && !string.IsNullOrEmpty(SelectedPhotoPath) && File.Exists(SelectedPhotoPath))
|
if (photoChanged && !string.IsNullOrEmpty(SelectedPhotoPath) && File.Exists(SelectedPhotoPath))
|
||||||
{
|
{
|
||||||
byte[] imageBytes = File.ReadAllBytes(SelectedPhotoPath);
|
byte[] imageBytes = File.ReadAllBytes(SelectedPhotoPath);
|
||||||
vehicle.Fotografie = Convert.ToBase64String(imageBytes);
|
var image = new Image
|
||||||
|
{
|
||||||
|
Data = Convert.ToBase64String(imageBytes),
|
||||||
|
FileName = System.IO.Path.GetFileName(SelectedPhotoPath),
|
||||||
|
ContentType = GetContentType(SelectedPhotoPath)
|
||||||
|
};
|
||||||
|
this.dataManager.AddImage(image);
|
||||||
|
vehicle.FotografieId = image.Id;
|
||||||
|
vehicle.Fotografie = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dataManager.Save();
|
this.dataManager.Save();
|
||||||
@@ -180,5 +322,19 @@ namespace dealer
|
|||||||
{
|
{
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetContentType(string filePath)
|
||||||
|
{
|
||||||
|
var extension = System.IO.Path.GetExtension(filePath)?.ToLowerInvariant();
|
||||||
|
return extension switch
|
||||||
|
{
|
||||||
|
".jpg" or ".jpeg" => "image/jpeg",
|
||||||
|
".png" => "image/png",
|
||||||
|
".gif" => "image/gif",
|
||||||
|
".bmp" => "image/bmp",
|
||||||
|
".webp" => "image/webp",
|
||||||
|
_ => "application/octet-stream"
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,10 +28,10 @@
|
|||||||
MouseDoubleClick="VehiclesListView_MouseDoubleClick">
|
MouseDoubleClick="VehiclesListView_MouseDoubleClick">
|
||||||
<ListView.View>
|
<ListView.View>
|
||||||
<GridView>
|
<GridView>
|
||||||
<GridViewColumn Header="SPZ" Width="150" DisplayMemberBinding="{Binding Spz}" />
|
<GridViewColumn Header="SPZ" Width="120" DisplayMemberBinding="{Binding Spz}" />
|
||||||
<GridViewColumn Header="Model" Width="250"
|
<GridViewColumn Header="Značka a Model" Width="200"
|
||||||
DisplayMemberBinding="{Binding Model}" />
|
DisplayMemberBinding="{Binding ZnackaModel}" />
|
||||||
<GridViewColumn Header="Barva" Width="150">
|
<GridViewColumn Header="Barva" Width="130">
|
||||||
<GridViewColumn.CellTemplate>
|
<GridViewColumn.CellTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
@@ -45,16 +45,18 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</GridViewColumn.CellTemplate>
|
</GridViewColumn.CellTemplate>
|
||||||
</GridViewColumn>
|
</GridViewColumn>
|
||||||
|
<GridViewColumn Header="Rok" Width="70" DisplayMemberBinding="{Binding RokVyroby}" />
|
||||||
|
<GridViewColumn Header="Palivo" Width="100" DisplayMemberBinding="{Binding Palivo}" />
|
||||||
</GridView>
|
</GridView>
|
||||||
</ListView.View>
|
</ListView.View>
|
||||||
</ListView>
|
</ListView>
|
||||||
|
|
||||||
<!-- Tlačítka -->
|
<!-- Tlacitka -->
|
||||||
<StackPanel Grid.Row="2"
|
<StackPanel Grid.Row="2"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
HorizontalAlignment="Center">
|
HorizontalAlignment="Center">
|
||||||
<Button Name="AddButton"
|
<Button Name="AddButton"
|
||||||
Content="Přidat vozidlo"
|
Content="Pridat vozidlo"
|
||||||
Width="120"
|
Width="120"
|
||||||
Height="35"
|
Height="35"
|
||||||
Margin="5"
|
Margin="5"
|
||||||
@@ -62,25 +64,33 @@
|
|||||||
Click="AddButton_Click" />
|
Click="AddButton_Click" />
|
||||||
<Button Name="DetailButton"
|
<Button Name="DetailButton"
|
||||||
Content="Detail"
|
Content="Detail"
|
||||||
Width="120"
|
Width="100"
|
||||||
Height="35"
|
Height="35"
|
||||||
Margin="5"
|
Margin="5"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
Click="DetailButton_Click" />
|
Click="DetailButton_Click" />
|
||||||
<Button Name="EditButton"
|
<Button Name="EditButton"
|
||||||
Content="Upravit"
|
Content="Upravit"
|
||||||
Width="120"
|
Width="100"
|
||||||
Height="35"
|
Height="35"
|
||||||
Margin="5"
|
Margin="5"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
Click="EditButton_Click" />
|
Click="EditButton_Click" />
|
||||||
<Button Name="DeleteButton"
|
<Button Name="DeleteButton"
|
||||||
Content="Smazat"
|
Content="Smazat"
|
||||||
Width="120"
|
Width="100"
|
||||||
Height="35"
|
Height="35"
|
||||||
Margin="5"
|
Margin="5"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
Click="DeleteButton_Click" />
|
Click="DeleteButton_Click" />
|
||||||
|
<Button Name="OwnersButton"
|
||||||
|
Content="Vlastnici"
|
||||||
|
Width="100"
|
||||||
|
Height="35"
|
||||||
|
Margin="5"
|
||||||
|
FontSize="14"
|
||||||
|
Background="#FFE0E0FF"
|
||||||
|
Click="OwnersButton_Click" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
@@ -79,7 +79,7 @@ namespace dealer
|
|||||||
|
|
||||||
if (selectedVehicle == null)
|
if (selectedVehicle == null)
|
||||||
{
|
{
|
||||||
System.Windows.MessageBox.Show("Vyberte vozidlo, které chcete zobrazit.", "Upozornění", MessageBoxButton.OK, MessageBoxImage.Warning);
|
System.Windows.MessageBox.Show("Vyberte vozidlo, ktere chcete zobrazit.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,13 +99,13 @@ namespace dealer
|
|||||||
|
|
||||||
if (selectedVehicle == null)
|
if (selectedVehicle == null)
|
||||||
{
|
{
|
||||||
System.Windows.MessageBox.Show("Vyberte vozidlo, které chcete smazat.", "Upozornění", MessageBoxButton.OK, MessageBoxImage.Warning);
|
System.Windows.MessageBox.Show("Vyberte vozidlo, ktere chcete smazat.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = System.Windows.MessageBox.Show(
|
var result = System.Windows.MessageBox.Show(
|
||||||
$"Opravdu chcete smazat vozidlo {selectedVehicle.Model} (SPZ: {selectedVehicle.Spz})?",
|
$"Opravdu chcete smazat vozidlo {selectedVehicle.Model} (SPZ: {selectedVehicle.Spz})?",
|
||||||
"Potvrzení smazání",
|
"Potvrzeni smazani",
|
||||||
MessageBoxButton.YesNo,
|
MessageBoxButton.YesNo,
|
||||||
MessageBoxImage.Question);
|
MessageBoxImage.Question);
|
||||||
|
|
||||||
@@ -117,5 +117,16 @@ namespace dealer
|
|||||||
this.VehiclesListView.ItemsSource = this.dataManager.GetAllVehicles();
|
this.VehiclesListView.ItemsSource = this.dataManager.GetAllVehicles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OwnersButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var ownersWindow = new OwnersWindow(this.dataManager);
|
||||||
|
ownersWindow.Owner = this;
|
||||||
|
ownersWindow.ShowDialog();
|
||||||
|
|
||||||
|
// Refresh vehicles list to update owner references
|
||||||
|
this.VehiclesListView.ItemsSource = null;
|
||||||
|
this.VehiclesListView.ItemsSource = this.dataManager.GetAllVehicles();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
85
dealer/windows/OwnersWindow.xaml
Normal file
85
dealer/windows/OwnersWindow.xaml
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
<Window x:Class="dealer.OwnersWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:dealer"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Sprava vlastniku" Height="500" Width="700"
|
||||||
|
WindowStartupLocation="CenterOwner">
|
||||||
|
<Grid Margin="10">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<TextBlock Grid.Row="0"
|
||||||
|
Text="Evidence vlastniku"
|
||||||
|
FontSize="24"
|
||||||
|
FontWeight="Bold"
|
||||||
|
Margin="0,0,0,10"
|
||||||
|
HorizontalAlignment="Center" />
|
||||||
|
|
||||||
|
<Grid Grid.Row="1" Margin="0,0,0,10">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Text="Hledat:" VerticalAlignment="Center" Margin="0,0,10,0" />
|
||||||
|
<TextBox Name="SearchTextBox"
|
||||||
|
Grid.Column="1"
|
||||||
|
Padding="5"
|
||||||
|
TextChanged="SearchTextBox_TextChanged" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<ListView Grid.Row="2"
|
||||||
|
Name="OwnersListView"
|
||||||
|
Margin="0,0,0,10"
|
||||||
|
MouseDoubleClick="OwnersListView_MouseDoubleClick">
|
||||||
|
<ListView.View>
|
||||||
|
<GridView>
|
||||||
|
<GridViewColumn Header="Jmeno" Width="120" DisplayMemberBinding="{Binding Jmeno}" />
|
||||||
|
<GridViewColumn Header="Prijmeni" Width="120" DisplayMemberBinding="{Binding Prijmeni}" />
|
||||||
|
<GridViewColumn Header="Telefon" Width="120" DisplayMemberBinding="{Binding Telefon}" />
|
||||||
|
<GridViewColumn Header="Email" Width="180" DisplayMemberBinding="{Binding Email}" />
|
||||||
|
<GridViewColumn Header="Adresa" Width="150" DisplayMemberBinding="{Binding Adresa}" />
|
||||||
|
</GridView>
|
||||||
|
</ListView.View>
|
||||||
|
</ListView>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="3"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
HorizontalAlignment="Center">
|
||||||
|
<Button Name="AddButton"
|
||||||
|
Content="Pridat vlastnika"
|
||||||
|
Width="130"
|
||||||
|
Height="35"
|
||||||
|
Margin="5"
|
||||||
|
FontSize="14"
|
||||||
|
Click="AddButton_Click" />
|
||||||
|
<Button Name="EditButton"
|
||||||
|
Content="Upravit"
|
||||||
|
Width="100"
|
||||||
|
Height="35"
|
||||||
|
Margin="5"
|
||||||
|
FontSize="14"
|
||||||
|
Click="EditButton_Click" />
|
||||||
|
<Button Name="DeleteButton"
|
||||||
|
Content="Smazat"
|
||||||
|
Width="100"
|
||||||
|
Height="35"
|
||||||
|
Margin="5"
|
||||||
|
FontSize="14"
|
||||||
|
Click="DeleteButton_Click" />
|
||||||
|
<Button Name="CloseButton"
|
||||||
|
Content="Zavrit"
|
||||||
|
Width="100"
|
||||||
|
Height="35"
|
||||||
|
Margin="5"
|
||||||
|
FontSize="14"
|
||||||
|
Click="CloseButton_Click" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
91
dealer/windows/OwnersWindow.xaml.cs
Normal file
91
dealer/windows/OwnersWindow.xaml.cs
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace dealer
|
||||||
|
{
|
||||||
|
public partial class OwnersWindow : Window
|
||||||
|
{
|
||||||
|
private DataManager dataManager;
|
||||||
|
|
||||||
|
public OwnersWindow(DataManager dataManager)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.dataManager = dataManager;
|
||||||
|
RefreshOwnersList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshOwnersList()
|
||||||
|
{
|
||||||
|
string searchText = SearchTextBox?.Text ?? "";
|
||||||
|
OwnersListView.ItemsSource = null;
|
||||||
|
OwnersListView.ItemsSource = dataManager.SearchOwners(searchText);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SearchTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
RefreshOwnersList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var addWindow = new AddOwnerWindow(dataManager);
|
||||||
|
addWindow.Owner = this;
|
||||||
|
addWindow.ShowDialog();
|
||||||
|
RefreshOwnersList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EditButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var selectedOwner = OwnersListView.SelectedItem as Owner;
|
||||||
|
if (selectedOwner == null)
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyberte vlastnika, ktereho chcete upravit.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var editWindow = new EditOwnerWindow(selectedOwner, dataManager);
|
||||||
|
editWindow.Owner = this;
|
||||||
|
editWindow.ShowDialog();
|
||||||
|
RefreshOwnersList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var selectedOwner = OwnersListView.SelectedItem as Owner;
|
||||||
|
if (selectedOwner == null)
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("Vyberte vlastnika, ktereho chcete smazat.", "Upozorneni", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = System.Windows.MessageBox.Show(
|
||||||
|
$"Opravdu chcete smazat vlastnika {selectedOwner.CeleJmeno}?\n\nVozidla tohoto vlastnika zustanou, ale nebudou mit prirazeneho vlastnika.",
|
||||||
|
"Potvrzeni smazani",
|
||||||
|
MessageBoxButton.YesNo,
|
||||||
|
MessageBoxImage.Question);
|
||||||
|
|
||||||
|
if (result == MessageBoxResult.Yes)
|
||||||
|
{
|
||||||
|
dataManager.RemoveOwner(selectedOwner);
|
||||||
|
dataManager.Save();
|
||||||
|
RefreshOwnersList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OwnersListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
var selectedOwner = OwnersListView.SelectedItem as Owner;
|
||||||
|
if (selectedOwner == null) return;
|
||||||
|
|
||||||
|
var editWindow = new EditOwnerWindow(selectedOwner, dataManager);
|
||||||
|
editWindow.Owner = this;
|
||||||
|
editWindow.ShowDialog();
|
||||||
|
RefreshOwnersList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,6 +47,16 @@
|
|||||||
<TextBlock Name="SpzTextBlock" Grid.Column="1" FontSize="14" />
|
<TextBlock Name="SpzTextBlock" Grid.Column="1" FontSize="14" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Znacka -->
|
||||||
|
<Grid Margin="0,5">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="120" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Text="Znacka:" FontSize="14" FontWeight="SemiBold" />
|
||||||
|
<TextBlock Name="ZnackaTextBlock" Grid.Column="1" FontSize="14" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<!-- Model -->
|
<!-- Model -->
|
||||||
<Grid Margin="0,5">
|
<Grid Margin="0,5">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@@ -85,6 +95,16 @@
|
|||||||
<TextBlock Name="YearTextBlock" Grid.Column="1" FontSize="14" />
|
<TextBlock Name="YearTextBlock" Grid.Column="1" FontSize="14" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Palivo -->
|
||||||
|
<Grid Margin="0,5">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="120" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Text="Palivo:" FontSize="14" FontWeight="SemiBold" />
|
||||||
|
<TextBlock Name="PalivoTextBlock" Grid.Column="1" FontSize="14" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<!-- Najete km -->
|
<!-- Najete km -->
|
||||||
<Grid Margin="0,5">
|
<Grid Margin="0,5">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@@ -104,6 +124,50 @@
|
|||||||
<TextBlock Text="Cena:" FontSize="14" FontWeight="SemiBold" />
|
<TextBlock Text="Cena:" FontSize="14" FontWeight="SemiBold" />
|
||||||
<TextBlock Name="PriceTextBlock" Grid.Column="1" FontSize="14" />
|
<TextBlock Name="PriceTextBlock" Grid.Column="1" FontSize="14" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<Separator Margin="0,15,0,15" />
|
||||||
|
|
||||||
|
<TextBlock Text="Vlastnik" FontSize="16" FontWeight="Bold" Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<!-- Vlastnik Jmeno -->
|
||||||
|
<Grid Margin="0,5">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="120" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Text="Jmeno a Prijmeni:" FontSize="14" FontWeight="SemiBold" />
|
||||||
|
<TextBlock Name="OwnerNameTextBlock" Grid.Column="1" FontSize="14" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Adresa -->
|
||||||
|
<Grid Margin="0,5">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="120" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Text="Adresa:" FontSize="14" FontWeight="SemiBold" />
|
||||||
|
<TextBlock Name="AddressTextBlock" Grid.Column="1" FontSize="14" TextWrapping="Wrap" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Telefon -->
|
||||||
|
<Grid Margin="0,5">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="120" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Text="Telefon:" FontSize="14" FontWeight="SemiBold" />
|
||||||
|
<TextBlock Name="PhoneTextBlock" Grid.Column="1" FontSize="14" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Email -->
|
||||||
|
<Grid Margin="0,5">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="120" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Text="Email:" FontSize="14" FontWeight="SemiBold" />
|
||||||
|
<TextBlock Name="EmailTextBlock" Grid.Column="1" FontSize="14" />
|
||||||
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|
||||||
@@ -139,3 +203,5 @@
|
|||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ namespace dealer
|
|||||||
// SPZ
|
// SPZ
|
||||||
SpzTextBlock.Text = vehicle.Spz ?? "Nezadano";
|
SpzTextBlock.Text = vehicle.Spz ?? "Nezadano";
|
||||||
|
|
||||||
|
// Znacka
|
||||||
|
ZnackaTextBlock.Text = vehicle.Znacka ?? "Nezadano";
|
||||||
|
|
||||||
// Model
|
// Model
|
||||||
ModelTextBlock.Text = vehicle.Model ?? "Nezadano";
|
ModelTextBlock.Text = vehicle.Model ?? "Nezadano";
|
||||||
|
|
||||||
@@ -50,6 +53,9 @@ namespace dealer
|
|||||||
// Rok vyroby
|
// Rok vyroby
|
||||||
YearTextBlock.Text = vehicle.RokVyroby?.ToString() ?? "Nezadano";
|
YearTextBlock.Text = vehicle.RokVyroby?.ToString() ?? "Nezadano";
|
||||||
|
|
||||||
|
// Palivo
|
||||||
|
PalivoTextBlock.Text = vehicle.Palivo ?? "Nezadano";
|
||||||
|
|
||||||
// Najete km
|
// Najete km
|
||||||
if (vehicle.NajeteKm != null)
|
if (vehicle.NajeteKm != null)
|
||||||
MileageTextBlock.Text = vehicle.NajeteKm.Value.ToString("N0") + " km";
|
MileageTextBlock.Text = vehicle.NajeteKm.Value.ToString("N0") + " km";
|
||||||
@@ -62,12 +68,28 @@ namespace dealer
|
|||||||
else
|
else
|
||||||
PriceTextBlock.Text = "Nezadano";
|
PriceTextBlock.Text = "Nezadano";
|
||||||
|
|
||||||
|
// Vlastnik
|
||||||
|
if (vehicle.Vlastnik != null)
|
||||||
|
{
|
||||||
|
OwnerNameTextBlock.Text = vehicle.Vlastnik.CeleJmeno;
|
||||||
|
AddressTextBlock.Text = vehicle.Vlastnik.Adresa ?? "Nezadano";
|
||||||
|
PhoneTextBlock.Text = vehicle.Vlastnik.Telefon ?? "Nezadano";
|
||||||
|
EmailTextBlock.Text = vehicle.Vlastnik.Email ?? "Nezadano";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OwnerNameTextBlock.Text = "Nezadano";
|
||||||
|
AddressTextBlock.Text = "Nezadano";
|
||||||
|
PhoneTextBlock.Text = "Nezadano";
|
||||||
|
EmailTextBlock.Text = "Nezadano";
|
||||||
|
}
|
||||||
|
|
||||||
// Fotografie (base64)
|
// Fotografie (base64)
|
||||||
if (!string.IsNullOrEmpty(vehicle.Fotografie))
|
if (vehicle.Fotografie != null && !string.IsNullOrEmpty(vehicle.Fotografie.Data))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
byte[] imageBytes = Convert.FromBase64String(vehicle.Fotografie);
|
byte[] imageBytes = Convert.FromBase64String(vehicle.Fotografie.Data);
|
||||||
using (var ms = new MemoryStream(imageBytes))
|
using (var ms = new MemoryStream(imageBytes))
|
||||||
{
|
{
|
||||||
var bitmap = new BitmapImage();
|
var bitmap = new BitmapImage();
|
||||||
@@ -129,3 +151,4 @@ namespace dealer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
14
images.example.json
Normal file
14
images.example.json
Normal file
File diff suppressed because one or more lines are too long
26
owners.example.json
Normal file
26
owners.example.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"Id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
||||||
|
"Jmeno": "Jan",
|
||||||
|
"Prijmeni": "Novak",
|
||||||
|
"Adresa": "Praha 1, Vaclavske namesti 1",
|
||||||
|
"Telefon": "+420 123 456 789",
|
||||||
|
"Email": "jan.novak@email.cz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
|
||||||
|
"Jmeno": "Marie",
|
||||||
|
"Prijmeni": "Svobodova",
|
||||||
|
"Adresa": "Brno, Husova 23",
|
||||||
|
"Telefon": "+420 987 654 321",
|
||||||
|
"Email": "marie.svobodova@email.cz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Id": "c3d4e5f6-a7b8-9012-cdef-345678901234",
|
||||||
|
"Jmeno": "Petr",
|
||||||
|
"Prijmeni": "Dvorak",
|
||||||
|
"Adresa": "Ostrava, Hlavni 45",
|
||||||
|
"Telefon": "+420 777 888 999",
|
||||||
|
"Email": "petr.dvorak@email.cz"
|
||||||
|
}
|
||||||
|
]
|
||||||
181
temp_add.txt
Normal file
181
temp_add.txt
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
<Window x:Class="dealer.AddVehicleWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:dealer"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Pridat vozidlo" Height="700" Width="500"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
ResizeMode="NoResize">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Auto">
|
||||||
|
<StackPanel Margin="20">
|
||||||
|
<TextBlock Text="Nove vozidlo"
|
||||||
|
FontSize="20"
|
||||||
|
FontWeight="Bold"
|
||||||
|
Margin="0,0,0,20"
|
||||||
|
HorizontalAlignment="Center" />
|
||||||
|
|
||||||
|
<TextBlock Text="SPZ:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="SpzTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
MaxLength="10"
|
||||||
|
CharacterCasing="Upper"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Znacka:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="ZnackaTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Model:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="ModelTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Barva:" FontSize="14" Margin="0,5" />
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,0,0,10">
|
||||||
|
<Border Name="ColorPreviewBorder"
|
||||||
|
Width="40"
|
||||||
|
Height="32"
|
||||||
|
BorderBrush="Gray"
|
||||||
|
BorderThickness="1"
|
||||||
|
Background="White"
|
||||||
|
Margin="0,0,10,0" />
|
||||||
|
<Button Name="SelectColorButton"
|
||||||
|
Content="Vybrat barvu"
|
||||||
|
Width="120"
|
||||||
|
Height="32"
|
||||||
|
Click="SelectColorButton_Click" />
|
||||||
|
<TextBlock Name="ColorNameTextBlock"
|
||||||
|
Text="Nevybrano"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Margin="10,0,0,0"
|
||||||
|
FontStyle="Italic"
|
||||||
|
Foreground="Gray" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<TextBlock Text="Rok vyroby:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="YearTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
MaxLength="4"
|
||||||
|
PreviewTextInput="NumericOnly_PreviewTextInput"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Palivo:" FontSize="14" Margin="0,5" />
|
||||||
|
<ComboBox Name="PalivoComboBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
Margin="0,0,0,10">
|
||||||
|
<ComboBoxItem Content="Benz<6E>n" />
|
||||||
|
<ComboBoxItem Content="Nafta" />
|
||||||
|
<ComboBoxItem Content="Elektro" />
|
||||||
|
<ComboBoxItem Content="Hybrid" />
|
||||||
|
<ComboBoxItem Content="LPG" />
|
||||||
|
<ComboBoxItem Content="CNG" />
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
|
<TextBlock Text="Najete km:" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="MileageTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
PreviewTextInput="NumericOnly_PreviewTextInput"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Cena (Kc):" FontSize="14" Margin="0,5" />
|
||||||
|
<TextBox Name="PriceTextBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
PreviewTextInput="DecimalOnly_PreviewTextInput"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Fotografie:" FontSize="14" Margin="0,15,0,5" />
|
||||||
|
<Button Name="SelectPhotoButton"
|
||||||
|
Content="Vybrat fotografii"
|
||||||
|
Width="150"
|
||||||
|
Height="30"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="0,0,0,5"
|
||||||
|
Click="SelectPhotoButton_Click" />
|
||||||
|
<TextBlock Name="PhotoPathTextBlock"
|
||||||
|
Text="Zadna fotografie nevybrana"
|
||||||
|
FontStyle="Italic"
|
||||||
|
Foreground="Gray"
|
||||||
|
Margin="0,0,0,10"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
|
|
||||||
|
<Separator Margin="0,15,0,15" />
|
||||||
|
|
||||||
|
<TextBlock Text="Vlastnik" FontSize="16" FontWeight="Bold" Margin="0,0,0,10" />
|
||||||
|
|
||||||
|
<TextBlock Text="Vybrat vlastnika:" FontSize="14" Margin="0,5" />
|
||||||
|
<Grid Margin="0,0,0,10">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<ComboBox Name="OwnerComboBox"
|
||||||
|
FontSize="14"
|
||||||
|
Padding="5"
|
||||||
|
IsEditable="True"
|
||||||
|
IsTextSearchEnabled="False"
|
||||||
|
StaysOpenOnEdit="True"
|
||||||
|
DisplayMemberPath="DisplayText"
|
||||||
|
TextBoxBase.TextChanged="OwnerComboBox_TextChanged"
|
||||||
|
SelectionChanged="OwnerComboBox_SelectionChanged" />
|
||||||
|
<Button Name="AddNewOwnerButton"
|
||||||
|
Grid.Column="1"
|
||||||
|
Content="+"
|
||||||
|
Width="35"
|
||||||
|
Height="35"
|
||||||
|
Margin="5,0,0,0"
|
||||||
|
FontSize="18"
|
||||||
|
FontWeight="Bold"
|
||||||
|
ToolTip="Pridat noveho vlastnika"
|
||||||
|
Click="AddNewOwnerButton_Click" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<TextBlock Name="SelectedOwnerInfo"
|
||||||
|
Text=""
|
||||||
|
FontStyle="Italic"
|
||||||
|
Foreground="Gray"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Margin="0,0,0,10" />
|
||||||
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
|
||||||
|
<Border Grid.Row="1"
|
||||||
|
BorderBrush="LightGray"
|
||||||
|
BorderThickness="0,1,0,0"
|
||||||
|
Background="WhiteSmoke">
|
||||||
|
<StackPanel Orientation="Horizontal"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Margin="0,15">
|
||||||
|
<Button Name="SaveButton"
|
||||||
|
Content="Ulozit"
|
||||||
|
Width="100"
|
||||||
|
Height="35"
|
||||||
|
Margin="5"
|
||||||
|
FontSize="14"
|
||||||
|
Click="SaveButton_Click" />
|
||||||
|
<Button Name="CancelButton"
|
||||||
|
Content="Zrusit"
|
||||||
|
Width="100"
|
||||||
|
Height="35"
|
||||||
|
Margin="5"
|
||||||
|
FontSize="14"
|
||||||
|
Click="CancelButton_Click" />
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
38
vehicles.example.json
Normal file
38
vehicles.example.json
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"Spz": "1A2 3456",
|
||||||
|
"Znacka": "Skoda",
|
||||||
|
"Model": "Octavia",
|
||||||
|
"Barva": "#0055AA",
|
||||||
|
"RokVyroby": 2020,
|
||||||
|
"Palivo": "Benz<6E>n",
|
||||||
|
"NajeteKm": 45000,
|
||||||
|
"Cena": 350000,
|
||||||
|
"FotografieId": null,
|
||||||
|
"VlastnikId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Spz": "7B8 9012",
|
||||||
|
"Znacka": "BMW",
|
||||||
|
"Model": "X5",
|
||||||
|
"Barva": "#000000",
|
||||||
|
"RokVyroby": 2019,
|
||||||
|
"Palivo": "Nafta",
|
||||||
|
"NajeteKm": 78000,
|
||||||
|
"Cena": 850000,
|
||||||
|
"FotografieId": "11111111-2222-3333-4444-555555555555",
|
||||||
|
"VlastnikId": "b2c3d4e5-f6a7-8901-bcde-f23456789012"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Spz": "3C4 5678",
|
||||||
|
"Znacka": "Tesla",
|
||||||
|
"Model": "Model 3",
|
||||||
|
"Barva": "#FFFFFF",
|
||||||
|
"RokVyroby": 2022,
|
||||||
|
"Palivo": "Elektro",
|
||||||
|
"NajeteKm": 15000,
|
||||||
|
"Cena": 1200000,
|
||||||
|
"FotografieId": null,
|
||||||
|
"VlastnikId": "c3d4e5f6-a7b8-9012-cdef-345678901234"
|
||||||
|
}
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user