예제 #1
0
        public tourPurchase(int routeId, routeChoice routesWindow, int clientId)
        {
            InitializeComponent();

            //datepicker.SelectedDate = DateTime.Now;

            this.routesWindow = routesWindow;
            this.routeId = routeId;
            this.clientId = clientId;

            SQLite connection = new SQLite();
            var reader = connection.ReadData(string.Format("SELECT Surname, Name, Secname FROM Clients WHERE ID ='{0}'", clientId));
            while (reader.Read())
            {
                personName.Content = string.Format("Продажа тура клиенту: {0} {1} {2}", reader.GetString(0), reader.GetString(1), reader.GetString(2));
            }

            reader = connection.ReadData(string.Format("SELECT Climat, Country, Hotel, Duration, Cost FROM Scopes WHERE ID = '{0}'", routeId));
            while (reader.Read())
            {
                Route route = new Route(
                    routeId,
                    reader.GetString(0),
                    reader.GetString(1),
                    reader.GetString(2),
                    reader.GetInt32(3),
                    reader.GetFloat(4));
                routesList.Items.Add(route);

            }
            connection.Close();
        }
예제 #2
0
        /* обновление ListBox климат */
        private void updateClimateList()
        {
            var climateList = new List<Obj>();
            SQLite connection = new SQLite();

            var reader = connection.ReadData("SELECT Climat FROM Scopes GROUP BY Climat ORDER BY Climat");
            while (reader.Read())
                climateList.Add(new Obj(false, reader.GetString(0)));

            ClimateListBox.ItemsSource = climateList;
        }
예제 #3
0
 private void sellTourBtn_Click(object sender, RoutedEventArgs e)
 {
     SQLite connection = new SQLite();
     if (checkFull())
     {
         if (Check.checkFloatNumber(priceBox.Text))
         {
             connection.WriteData(string.Format("INSERT INTO Tours (SID, CID, Date, Count, Discount, Price) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')", routeId, clientId, dateBox.Text, int.Parse(countBox.Text), discountBox.Text, float.Parse(priceBox.Text)));
             MessageBox.Show("Путевка успешно добавлена!", "Предупреждение", MessageBoxButton.OK);
             Close();
         }
         else
         {
             MessageBox.Show("В поле \"Стоимость\" должно быть введено число!", "Предупреждение", MessageBoxButton.OK);
         }
     }
     else
     {
         MessageBox.Show("Заполните все поля!", "Предупреждение", MessageBoxButton.OK);
     }
 }
예제 #4
0
        /* обновление ListBox страны */
        private void updateCountryList()
        {
            var countryList = new List<Obj>();
            SQLite connection = new SQLite();

            var climateArr = getItemsArr(ClimateListBox);
            var query = string.Format("SELECT Country FROM Scopes WHERE Climat IN {0} GROUP BY Country ORDER BY Country", climateArr);

            var reader = connection.ReadData(query);
            while (reader.Read())
                countryList.Add(new Obj(false, reader.GetString(0)));

            CountryListBox.ItemsSource = countryList;
        }
예제 #5
0
        /* обновление списка маршрутов */
        private void updateRoutesList()
        {
            routesList.Items.Clear();

            // считываем идентификаторы отмеченных элементов листбоксов
            var climateArr = " AND Climat IN " + getItemsArr(ClimateListBox);
            var countriesArr = " AND Country IN " + getItemsArr(CountryListBox);
            var hotelsArr = " AND Hotel IN " + getItemsArr(HotelListBox);

            // считываем диапазон длительности
            var duration = "";
            if (Check.checkNumber(minDurationBox.Text)) { duration += string.Format(" AND duration >= '{0}'", minDurationBox.Text); }
            if (Check.checkNumber(maxDurationBox.Text)) { duration += string.Format(" AND duration <= '{0}'", maxDurationBox.Text); }

            // считываем диапазон цен
            var cost = "";
            if (Check.checkNumber(minCostBox.Text)) { cost += string.Format(" AND cost >= '{0}'", minCostBox.Text); }
            if (Check.checkNumber(maxCostBox.Text)) { cost += string.Format(" AND cost <= '{0}'", maxCostBox.Text); }

            var query = string.Format("SELECT ID, Country, Climat, Hotel, Duration, Cost FROM Scopes WHERE 1 {0} {1} {2} {3} {4}",
                climateArr, countriesArr, hotelsArr, duration, cost);

            SQLite connection = new SQLite();
            var reader = connection.ReadData(query);
            while (reader.Read())
                routesList.Items.Add(new Route(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetInt32(4), reader.GetFloat(5)));
        }
예제 #6
0
        /* обновление ListBox отели */
        private void updateHotelList()
        {
            var hotelList = new List<Obj>();
            SQLite connection = new SQLite();

            var climateArr = getItemsArr(ClimateListBox);
            var countriesArr = getItemsArr(CountryListBox);
            var query = string.Format("SELECT Hotel FROM Scopes WHERE Climat IN {0} AND Country IN {1} GROUP BY Hotel ORDER BY Hotel", climateArr, countriesArr);

            var reader = connection.ReadData(query);
            while (reader.Read())
                hotelList.Add(new Obj(false, reader.GetString(0)));

            HotelListBox.ItemsSource = hotelList;
        }