Ejemplo n.º 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            errorText.Text = "";

            var db = new computerEntities();

            if (clientSelect.SelectedValue == null)
            {
                errorText.Text = "Wybierz klienta.";
                return;
            }

            if (computerSelect.SelectedValue == null)
            {
                errorText.Text = "Wybierz komputer.";
                return;
            }

            var computers = db.Computers.ToList();
            var computer  = computers.First(c => c.ComputerID == int.Parse(computerSelect.SelectedValue.ToString()));

            var newSale = new Sales()
            {
                ClientID   = int.Parse(clientSelect.SelectedValue.ToString()),
                ComputerID = int.Parse(computerSelect.SelectedValue.ToString()),
                PriceToPay = decimal.Parse(summaryPriceInput.Text),
            };

            db.Sales.Add(newSale);
            computer.ComputerAmount--;

            db.SaveChanges();
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var db = new computerEntities();

            var reservationID = int.Parse(reservationSelect.SelectedValue.ToString());

            var reservation = db.Sales.First(r => r.ReservationID == reservationID);

            if (reservation != null)
            {
                reservation.Payed = true;
                db.SaveChanges();
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            errorText.Text = "";

            var db = new computerEntities();

            if (clientNameInput.Text == "")
            {
                errorText.Text = "Podaj imię i nazwisko.";
                return;
            }
            if (clientEmailInput.Text == "")
            {
                errorText.Text = "Podaj e-mail.";
                return;
            }
            if (clientPhoneInput.Text == "")
            {
                errorText.Text = "Podaj numer telefonu.";
                return;
            }
            if (clientGenderSelect.SelectedItem == null)
            {
                errorText.Text = "Wybierz płeć.";
                return;
            }

            var clientName   = clientNameInput.Text;
            var clientEmail  = clientEmailInput.Text;
            var clientPhone  = clientPhoneInput.Text;
            var clientGender = clientGenderSelect.SelectedItem.ToString();

            var newClient = new Clients()
            {
                ClientName   = clientName,
                ClientEmail  = clientEmail,
                ClientPhone  = clientPhone,
                ClientGender = clientGender
            };

            db.Clients.Add(newClient);

            db.SaveChanges();
        }
Ejemplo n.º 4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            errorText.Text = "";
            if (modelNameInput.Text == "")
            {
                errorText.Text = "Podaj nazwę modelu.";
                return;
            }

            var db = new computerEntities();

            var modelName = modelNameInput.Text;

            var newModel = new Models()
            {
                ModelName = modelName
            };

            db.Models.Add(newModel);

            db.SaveChanges();
        }
Ejemplo n.º 5
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            errorText.Text = "";
            var db = new computerEntities();

            if (computerNameInput.Text == "")
            {
                errorText.Text = "Wprowadź nazwę komputera.";
                return;
            }

            if (computerTypeSelect.SelectedValue == null)
            {
                errorText.Text = "Wybierz typ komputera.";
                return;
            }

            if (computerModelSelect.SelectedValue == null)
            {
                errorText.Text = "Wybierz model komputera.";
                return;
            }

            try
            {
                var computerReservationPriceTest = decimal.Parse(computerReservationPriceInput.Text);
            }
            catch
            {
                errorText.Text = "Wprowadź poprawną cenę rezerwacji komptera.";
                return;
            }

            try
            {
                var computerPriceTest = decimal.Parse(computerPriceInput.Text);
            } catch
            {
                errorText.Text = "Wprowadź poprawną cenę komptera.";
                return;
            }

            try
            {
                var computerAmountTest = int.Parse(computerAmountInput.Text);
            } catch
            {
                errorText.Text = "Wprowadź poprawną ilość komputerów.";
                return;
            }

            var computerModelId          = int.Parse(computerModelSelect.SelectedValue.ToString());
            var computerType             = computerTypeSelect.SelectedValue.ToString();
            var computerPrice            = decimal.Parse(computerPriceInput.Text);
            var computerReservationPrice = decimal.Parse(computerReservationPriceInput.Text);
            var computerName             = computerNameInput.Text;
            var computerAmount           = int.Parse(computerAmountInput.Text);

            var newComputer = new Computers()
            {
                ComputerModelId          = computerModelId,
                ComputerName             = computerName,
                ComputerReservationPrice = computerReservationPrice,
                ComputerPrice            = computerPrice,
                ComputerType             = computerType,
                ComputerAmount           = computerAmount
            };

            db.Computers.Add(newComputer);

            db.SaveChanges();
        }