Exemple #1
0
        private bool CheckRommAmount(int room_id, int amount)
        {
            DataTable dt    = SqlDB.Select($"select * from Rooms where id={room_id}");
            int       value = Convert.ToInt32(dt.Rows[0]["amount"]);

            if (value < amount)
            {
                MessageBox.Show("Количество проживающих не соответствует вместимости номера");
                return(false);
            }
            else
            {
                return(true);
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DataTable find = SqlDB.Select($"select * from [Users] where login='******' and password='******'");

            if (find.Rows.Count > 0)
            {
                MessageBox.Show("Пользователь с таким именем уже существует");
            }
            else
            {
                if (RegexLogin(LoginBox.Text))
                {
                    if (RegexPassword(Password.Password))
                    {
                        if (RepeatPassword.Password.Equals(Password.Password))
                        {
                            try
                            {
                                SqlDB.Command($"insert into [Users] values('{LoginBox.Text}', '{Password.Password}')");
                                MessageBox.Show("Успешно создан");
                                MainWindow mw = new MainWindow();
                                mw.Show();
                                Close();
                            }
                            catch (Exception error)
                            {
                                MessageBox.Show(error.Message);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Пароли не совпадают");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Пароль обязан быть 8-20 символовв");
                    }
                }
                else
                {
                    MessageBox.Show("Логин обязан быть 4-15 символов");
                }
            }
        }
Exemple #3
0
        public void SetNumbers(string selection)
        {
            List <Numbers> rooms = new List <Numbers>();
            DataTable      dt    = SqlDB.Select(selection);

            if (dt.Rows.Count <= 0)
            {
                MessageBox.Show("Таких номеров нет");
                Table.ItemsSource = rooms;
                return;
            }
            foreach (DataRow dr in dt.Rows)
            {
                rooms.Add(new Numbers()
                {
                    Number = Convert.ToInt32(dr["number"].ToString()),
                    Price  = Convert.ToDouble(dr["price"].ToString())
                });
            }
            Table.ItemsSource = rooms;
        }
        public void SetPersons()
        {
            rooms = new List <Persons>();
            DataTable dt = SqlDB.Select("SELECT full_name, passport_number, telephone_number, number, price, food, [services], Rooms.amount FROM Rooms join RoomCard on Rooms.id = RoomCard.id_room join ClientCard on ClientCard.id = id_client_card; ");

            foreach (DataRow dr in dt.Rows)
            {
                rooms.Add(new Persons()
                {
                    Full_Name       = dr["full_name"].ToString(),
                    PassportNumber  = dr["passport_number"].ToString(),
                    TelephoneNumber = dr["telephone_number"].ToString(),
                    Food            = CheckFoodAndServices(dr["food"].ToString()),
                    Services        = CheckFoodAndServices(dr["services"].ToString()),
                    Amount          = Convert.ToInt32(dr["amount"]),
                    Number          = Convert.ToInt32(dr["number"].ToString()),
                    Price           = Convert.ToDouble(dr["price"].ToString())
                });
            }
            Table.ItemsSource = rooms;
        }