private async void Atrakcja_btn_Click(object sender, RoutedEventArgs e) { var nr = await MSB.PobierzNRezerwacjiAsync(); if (nr <= 0) { return; } var res = await MSB.InputChoise("Wybierz typ atrakcji", "Basen", "Spa"); var rodzaj = ""; if (res == ContentDialogResult.Primary) { rodzaj = "Basen"; } else if (res == ContentDialogResult.Secondary) { rodzaj = "Spa"; } else { return; } new Atrakcja().ZarezerwujAtrakcje(nr, rodzaj); }
public async Task <bool> ZaplacAsync(int nRezerwacji) { var res = await MSB.InputChoise("Wybierz metodę płatności", "Karta", "Gotówka"); switch (res) { case Windows.UI.Xaml.Controls.ContentDialogResult.None: { return(false); } case Windows.UI.Xaml.Controls.ContentDialogResult.Primary: { await Card(); return(true); } case Windows.UI.Xaml.Controls.ContentDialogResult.Secondary: { await Cash(); return(true); } } return(true); //zakladam że zapłacił }
public async void ZarezerwujAtrakcje(int nRezerwacji, string Rodzaj) { this.nRezerwacji = nRezerwacji; this.rodzaj = Rodzaj; data = await MSB.InputDate(); // podaj date var time = await MSB.InputTime(); // podaj godzine try { data = CombineDateAndTime(data, time); } catch { await MSB.Print("Podaj poprawne dane"); return; } if (Sprawdz(rodzaj)) { var res = await MSB.InputChoise(rodzaj + " jest zajęte\nWybierz typ rezerwacji lub inny czas", "Basen", "Spa"); if (res == ContentDialogResult.Primary) { rodzaj = "Basen"; } else if (res == ContentDialogResult.Secondary) { rodzaj = "Spa"; } else { await MSB.Print("Dokonaj wyboru"); } ZarezerwujAtrakcje(nRezerwacji, rodzaj); } else { if (rodzaj == "Basen") { new Basen(this).ZajmijMiejsce(nRezerwacji); } else { new Spa(this).ZajmijMiejsce(nRezerwacji); } } }
public async void DodajRezerwacje(string imie, string nazwisko, int pesel, string adres, int nRezerwacji, int nrPokoju) { this.imie = imie; this.nazwisko = nazwisko; this.pesel = pesel; this.adres = adres; Przyjazd = await MSB.InputDate(); double dlugosc; if (!double.TryParse(await MSB.Input("Podaj ilość dni"), out dlugosc)) { await MSB.Print("Podaj poprawne dane"); } Dlugosc = dlugosc; this.nRezerwacji = nRezerwacji; this.nrPokoju = nrPokoju; //baza musi zawierac nr pokojow using (var ctx = new DbModel()) { var wolnepokoje = new List <int>(); int i = nrPokoju; // sprawdza pokoj ktory podano var rezerwacjewpokoju = ctx.TRezerwacja.Where(a => a.nrPokoju == i); int lwarunkow = 0; foreach (var item in rezerwacjewpokoju) { try { DateTime wyjazdzpokoju = item.Przyjazd.AddDays(item.Dlugosc); // opuszczenie pokoju hotelowego DateTime wyjazdgoscia = this.Przyjazd.AddDays(this.Dlugosc); // opuszczenie pokoju przez goscia if (wyjazdzpokoju < this.Przyjazd) { // po terminie zajetego pokoju lwarunkow++; } else if (wyjazdgoscia < item.Przyjazd) { // przed terminem zajetego pokoju lwarunkow++; } } catch { } } if (lwarunkow == rezerwacjewpokoju.Count()) { wolnepokoje.Add(i); // kazder rezerwacji nie przeszkadza termin } if (wolnepokoje.Count == 0) { var res = await MSB.InputChoise("Brak wolnych pokoi\nWprowadź inny termin\n", "Szukaj dalej", "Rezygnuj"); if (res == Windows.UI.Xaml.Controls.ContentDialogResult.Primary) { //szukaj dalej DodajRezerwacje(imie, nazwisko, pesel, adres, nRezerwacji, nrPokoju); return; } else { //anulowano albo zrezygnowano await MSB.Print("Zrezygnowano"); // zrezygnowano return; } } string str = "wolnego pokoju spośród: "; foreach (var item in wolnepokoje) { str += item; str += ", "; } while (true) { var res = await MSB.PobierzNrAsync(str); // zapytaj ktory pokój foreach (var item in wolnepokoje) { if (item == res) {//podano poprawny wolny nr pokoju ctx.Add(this); ctx.SaveChanges(); await MSB.Print(String.Format("Dodałem rezerwację on numerze {0} dla {1} {2} na {3}", nRezerwacji, imie, nazwisko, Przyjazd)); return; } else { await MSB.Print("Wybierz poprawny numer"); } } } } }
private async void Spr_Rezerwazje_btn_Click(object sender, RoutedEventArgs e) { var odp = await MSB.InputChoise("Rezerwacja: ", "Dodaj nową rezerwację", "Sprawdź już istniejącą"); switch (odp) { case ContentDialogResult.Primary: { var nr = await MSB.PobierzNRezerwacjiAsync(); if (nr <= 0) { return; // anulowano lub podano zly nr } var rezerwacja = new Rezerwacja(); var imie = await MSB.Input("Podaj imię"); if (String.Compare(imie, "-1") == 0) { return; // anulowano } var nazwisko = await MSB.Input("Podaj nazwisko"); if (String.Compare(nazwisko, "-1") == 0) { return; // anulowano } var pesel = await MSB.PobierzNrAsync("pesel"); if (pesel < 0) { return; // anulowano } var nrPokoju = await MSB.PobierzNrAsync("pokoju"); if (nrPokoju < 0) { return; // anulowano } var adres = await MSB.Input("Podaj adres"); if (String.Compare(adres, "-1") == 0) { return; // anulowano } rezerwacja.DodajRezerwacje(imie, nazwisko, pesel, adres, nr, nrPokoju); } break; case ContentDialogResult.Secondary: { var nr = await MSB.PobierzNRezerwacjiAsync(); if (nr <= 0) { return; // anulowano lub podano zly nr } var rezerwacja = new Rezerwacja(); if (rezerwacja.SprawdzRezerwacje(nr)) { //wyswietl anuluj var res = await MSB.InputChoise("Rezerwacja nr: " + nr + " znajduje się w systemie", "Wyświetl szczegóły", "Anuluj rezerwacje"); switch (res) { case ContentDialogResult.None: { //anulowano break; } case ContentDialogResult.Primary: { // wyswietl using (var ctx = new DbModel()) { try { var tmp = ctx.TRezerwacja.Where(a => a.nRezerwacji == nr).FirstOrDefault(); var str = string.Format("Dla numeru rezerwacji {0} zarejestrono osobe {1} {2}, pesel: {3}, adres: {4}", tmp.nRezerwacji, tmp.imie, tmp.nazwisko, tmp.pesel, tmp.adres); await MSB.Print(str); } catch { } } break; } case ContentDialogResult.Secondary: { // anuluj rezerwacje rezerwacja.AnulujRezerwacje(nr); break; } } } else { await MSB.Print("Rezerwacja o numerze: " + nr + "\nnie istnieje w systemie."); } } break; } }