private void Exit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                BindingExpression b = Phone.GetBindingExpression(TextBoxWatermarked.TextProperty);
                BindingExpression f = Full_Name.GetBindingExpression(TextBoxWatermarked.TextProperty);
                BindingExpression p = Email.GetBindingExpression(TextBoxWatermarked.TextProperty);
                if (b.HasValidationError || p.HasValidationError || f.HasValidationError)
                {
                    throw new Exception("Исправьте неправильно введенные данные!");
                }
                Random       rand        = new Random();
                int          code_client = Randomizer(rand, 1000, 100000);
                Model.Client cl          = Manipulation.db.Clients.Find(code_client);
                if (cl != null)
                {
                    code_client = Randomizer(rand, 1000, 100000);
                }

                Model.Client client = new Model.Client
                {
                    Client_code     = code_client,
                    Full_name       = Full_Name.Text,
                    Phone           = Phone.Text,
                    Email           = Email.Text,
                    Passport_number = autorization.Userr,
                    Birthdate       = DateTime.Parse(DateBornC.Text)
                };
                Manipulation.Insert <Model.Client>(client);

                Pages.NewClient Client = new Pages.NewClient(client);
                Client.Show();

                Close();
            }
            catch (ArgumentNullException ex) { MessageBox.Show("Зaполните все данные!"); }
            catch (NullReferenceException ex) { MessageBox.Show("Зaполните все данные!"); }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex) { MessageBox.Show("Зaполните все данные!"); }
            catch (Exception exp) { MessageBox.Show(exp.Message); }
        }
Esempio n. 2
0
        public void Add_Click(object sender, EventArgs e)
        {
            try
            {
                BindingExpression b = Full_Name.GetBindingExpression(TextBoxWatermarked.TextProperty);
                BindingExpression f = Phone.GetBindingExpression(TextBoxWatermarked.TextProperty);
                BindingExpression p = Email.GetBindingExpression(TextBoxWatermarked.TextProperty);
                BindingExpression s = PassNumber.GetBindingExpression(TextBoxWatermarked.TextProperty);
                if (b.HasValidationError || p.HasValidationError || s.HasValidationError || f.HasValidationError)
                {
                    throw new Exception("Исправьте неправильно введенные данные!");
                }
                Random       rand        = new Random();
                int          code_client = Randomizer(rand, 1000, 100000);
                Model.Client cl          = Manipulation.db.Clients.Find(code_client);
                if (cl != null)
                {
                    code_client = Randomizer(rand, 1000, 100000);
                }

                Model.Client client = new Model.Client
                {
                    Client_code     = code_client,
                    Full_name       = Full_Name.Text,
                    Phone           = Phone.Text,
                    Email           = Email.Text,
                    Passport_number = PassNumber.Text,
                    Birthdate       = DateTime.Parse(DateBornC.Text)
                };
                Manipulation.Insert <Model.Client>(client);
                MessageBox.Show("Вы зарегестрировали клиента!");
                ClearForm();
            }
            catch (FormatException ex) { MessageBox.Show("Введите правильные даные!", "Упс"); }
            catch (NullReferenceException ex) { MessageBox.Show("Зполните все данные!"); }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex) { MessageBox.Show("Зполните все данные!"); }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Esempio n. 3
0
        public void Add_Click(object sender, EventArgs e)
        {
            try
            {
                Model.Client     client       = new Model.Client();
                Model.Pay        pay          = new Model.Pay();
                Model.Room       room         = new Model.Room();
                Model.TypeOfFood type         = new Model.TypeOfFood();
                Model.Booking    booking      = new Model.Booking();
                string           numberOfRoom = (string)Room_Code.SelectedItem;
                string[]         split        = numberOfRoom.Split(' ');
                Random           rand         = new Random();

                room = Manipulation.db.Rooms.Find(split[0]);
                type = Manipulation.db.TypeOfFoods.Find((string)Type_food.SelectedItem);

                if (ClientExist.IsChecked == true)
                {
                    BindingExpression b = card_number.GetBindingExpression(TextBoxWatermarked.TextProperty);
                    if (b.HasValidationError)
                    {
                        throw new Exception("Исправьте неправильно введенные данные!");
                    }
                    IEnumerable <Model.Client> cli = Manipulation.db.Clients.Where(w => w.Full_name == (string)ListOfClients.SelectedItem);
                    client = cli.First();
                }
                else
                {
                    BindingExpression b = card_number.GetBindingExpression(TextBoxWatermarked.TextProperty);
                    BindingExpression f = Full_Name.GetBindingExpression(TextBoxWatermarked.TextProperty);
                    BindingExpression p = Email.GetBindingExpression(TextBoxWatermarked.TextProperty);
                    BindingExpression s = Phone.GetBindingExpression(TextBoxWatermarked.TextProperty);
                    BindingExpression a = PassNumber.GetBindingExpression(TextBoxWatermarked.TextProperty);
                    if (b.HasValidationError || p.HasValidationError || s.HasValidationError || f.HasValidationError || a.HasValidationError)
                    {
                        throw new Exception("Исправьте неправильно введенные данные!");
                    }

                    int code_client = Randomizer(rand, 1000, 100000);

                    client.Client_code     = code_client;
                    client.Full_name       = Full_Name.Text;
                    client.Phone           = Phone.Text;
                    client.Email           = Email.Text;
                    client.Passport_number = PassNumber.Text;
                    client.Birthdate       = DateTime.Parse(DateBornC.Text);

                    Manipulation.db.Clients.Add(client);
                }
                pay.Payment_number = Randomizer(rand, 10, 500);
                pay.Card_number    = card_number.Text;
                pay.Summ           = type.Summa + room.CategoryOfRoom.Cost * Nights;
                pay.Payer          = client.Client_code;
                pay.DateOfPay      = DateTime.Parse(dateOfPay.Text);
                client.Pays.Add(pay);

                Manipulation.db.Pays.Add(pay);
                room.Booking = "Да";

                booking.Booking_number = Randomizer(rand, 1000, 100000);
                booking.Client_code    = client.Client_code;
                booking.Client         = client;
                booking.Arrivall       = DateTime.Parse(Arrival.Text);
                booking.DateOfBooking  = DateTime.Today;
                booking.Departuree     = DateTime.Parse(Departure.Text);
                booking.Pay            = pay;
                booking.Payment_number = pay.Payment_number;
                booking.Room           = room;
                booking.Room_code      = room.Room_code;
                booking.TypeOfFood     = type.Type_name;
                booking.TypeOfFood1    = type;


                Manipulation.db.Bookings.Add(booking);

                MessageBox.Show("Вы зарегестрировали бронь!");
                Manipulation.db.SaveChanges();
                Close();
            }
            catch (NullReferenceException ex) { MessageBox.Show("Зaполните все данные!"); }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex) { MessageBox.Show("Зaполните все данные!"); }
            catch (Exception exp) { MessageBox.Show(exp.Message); }
        }