예제 #1
0
        public PageTrips(List <string> list)
        {
            InitializeComponent();
            sqlManager = new SqlManager();
            int flag = 0;

            if (sqlManager.UpdateActualCountTripsInDB() != -2)
            {
                listParams = list;
                if (listParams.ElementAt(1) != "")
                {
                    Item.cityNum = sqlManager.ReturnNumber("SELECT Num_city FROM Cities WHERE Name_city = '" + listParams.ElementAt(1) + "'");
                    if (Item.cityNum == -2)
                    {
                        flag = -2;
                        PagesManager.ShowConnectionError();
                    }
                }
                if (flag != -2)
                {
                    UpdateListView();
                }
            }
            else
            {
                PagesManager.ShowConnectionError();
            }
        }
예제 #2
0
 private void CityBox_DropDownOpened(object sender, EventArgs e)
 {
     CityBox.SelectedIndex = -1;
     if (CountryBox.Text != "")
     {
         SqlManager sqlManager = new SqlManager();
         int        num        = sqlManager.ReturnNumber("SELECT Num_country FROM Countries WHERE Name_country = '" + CountryBox.Text + "'");
         if (num != -2)
         {
             CityBox.ItemsSource = null;
             CityBox             = DataManager.PushComboBox(CityBox, "Name_city", "SELECT Name_city FROM Cities WHERE Num_country = " + num);
             if (CityBox == null)
             {
                 PagesManager.ShowConnectionError();
             }
         }
         else if (num == -2)
         {
             PagesManager.ShowConnectionError();
         }
     }
     else
     {
         CityBox = DataManager.PushComboBox(CityBox, "Name_city", "SELECT Name_city FROM Cities");
         if (CityBox == null)
         {
             PagesManager.ShowConnectionError();
         }
     }
     System.GC.Collect();
 }
예제 #3
0
 private void Selected_Click(object sender, RoutedEventArgs e)
 {
     if (PagesManager.currentState != 1)
     {
         if (Item.items != null)
         {
             if (Item.items.Count != 0)
             {
                 PagesManager.CleanFrame();
                 PagesManager.ShowSelectedTrips();
                 Back.Visibility = Visibility.Visible;
                 ChangeWindow(true);
                 System.GC.Collect();
             }
             else
             {
                 MessageBox.Show("Вы не выбрали ни одной путевки.", "", MessageBoxButton.OK, MessageBoxImage.Warning);
             }
         }
         else
         {
             MessageBox.Show("Вы не выбрали ни одной путевки.", "", MessageBoxButton.OK, MessageBoxImage.Warning);
         }
     }
 }
예제 #4
0
        public PageHistory()
        {
            //получение истории пользователя
            InitializeComponent();
            SqlManager sqlManager = new SqlManager();
            DataTable  dt         = sqlManager.ReturnTable("SELECT Tours.Name_tour, Price, DateOfBuy " +
                                                           "FROM Trips JOIN Tours ON Tours.Num_tour = Trips.Num_tour " +
                                                           "WHERE Num_tourist = " + DataPerson.id);

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    HistoryGrid.Items.Add(new Item
                    {
                        NameTour = dr.ItemArray[0].ToString(),
                        Price    = Convert.ToInt32(dr.ItemArray[1]),
                        DateBuy  = dr.ItemArray[2].ToString().Remove(dr.ItemArray[2].ToString().Length - 8, 8)
                    });
                    System.GC.Collect();
                }
            }
            else
            {
                PagesManager.ShowConnectionError();
            }
        }
예제 #5
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult res = MessageBox.Show("Вы уверены, что хотите удалить свой аккаунт?", "", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (res == MessageBoxResult.Yes)
            {
                int flag = sqlManager.Delete("DELETE FROM Tourists WHERE Num_tourist = " + DataPerson.id);
                if (flag != -2)
                {
                    foreach (Window window in Application.Current.Windows)
                    {
                        if (window is TourismWindow)
                        {
                            MainWindow mw = new MainWindow();
                            mw.Show();
                            window.Close();
                        }
                    }
                }
                else if (flag == -2)
                {
                    PagesManager.ShowConnectionError();
                }
            }
        }
예제 #6
0
 public PageFilterTrips()
 {
     InitializeComponent();
     CountryBox = DataManager.PushComboBox(CountryBox, "Name_country", "SELECT Name_country FROM Countries");
     if (CountryBox == null)
     {
         PagesManager.ShowConnectionError();
     }
 }
예제 #7
0
        private void Continue_Click(object sender, RoutedEventArgs e)
        {
            DateBegin.Text = (DateBegin.Text == "") ? DateTime.Today.ToShortDateString() : DateBegin.Text;
            List <string> list = new List <string> {
                CountryBox.Text, CityBox.Text, SelectedPrice.Value.ToString(), DateBegin.Text, DateEnd.Text
            };                                                                                                                                    //передаваемые параметры

            PagesManager.ShowTrips(list);
            System.GC.Collect();
        }
예제 #8
0
 private void Cabinet_Click(object sender, RoutedEventArgs e)
 {
     if (PagesManager.currentState != 2)
     {
         PagesManager.CleanFrame();
         PagesManager.ShowCabinet();
         Back.Visibility = Visibility.Visible;
         ChangeWindow(true);
         System.GC.Collect();
     }
 }
예제 #9
0
 private void Trips_Click(object sender, RoutedEventArgs e)
 {
     if (PagesManager.currentState != 0)
     {
         //clear back state
         PagesManager.CleanFrame();
         PagesManager.ShowFilterTrips();
         Back.Visibility = Visibility.Visible;
         ChangeWindow(true);
         System.GC.Collect();
     }
 }
예제 #10
0
 private void History_Click(object sender, RoutedEventArgs e)
 {
     //вывод в дата грид все путевки полученные клиентом
     if (PagesManager.currentState != 3)
     {
         PagesManager.CleanFrame();
         PagesManager.ShowHistory();
         Back.Visibility = Visibility.Visible;
         ChangeWindow(true);
         System.GC.Collect();
     }
 }
예제 #11
0
 private void UpdateDataPerson(List <string> list)
 {
     flag = sqlManager.UpdatePerson(list);
     if (flag != -2)
     {
         ResetEdit();
         DataPerson.NewDataPerson();
         WriteDataPerson();
     }
     else if (flag == -2)
     {
         PagesManager.ShowConnectionError();
     }
 }
예제 #12
0
        private void Exit_Click(object sender, RoutedEventArgs e)
        {
            DataPerson.id = -1;
            MainWindow mw = new MainWindow();

            mw.Show();
            PagesManager.CleanStates();
            DataPerson.Clear();
            if (Item.items != null)
            {
                Item.items.Clear();
            }
            Close();
            System.GC.Collect();
        }
예제 #13
0
 public void WriteDataPerson()
 {
     if (DataPerson.NamePerson == null)
     {
         if (DataPerson.NewDataPerson() == -1)
         {
             PagesManager.ShowConnectionError();
         }
     }
     name.Content       = DataPerson.NamePerson;
     Lastname.Content   = DataPerson.LastName;
     MiddleName.Content = DataPerson.MiddleName;
     SeriaPass.Content  = DataPerson.SeriaPass;
     NumberPass.Content = DataPerson.NumberPass;
     Phone.Content      = DataPerson.PhoneNumber;
 }
예제 #14
0
 public void UpdateListView()
 {
     //заполнение путевок по заданному фильтру
     LVTours.Items.Clear();
     LVTours = sqlManager.PushListView(LVTours, listParams, Item.cityNum, Sort.SelectedIndex, Search.Text);
     if (LVTours != null)
     {
         if (LVTours.Items.Count == 0)
         {
             MessageBox.Show("Отсутствуют путевки по заданным фильтрам.", "", MessageBoxButton.OK, MessageBoxImage.Warning);
             Sort.SelectedIndex = -1;
             Search.Text        = "";
         }
     }
     else
     {
         PagesManager.ShowConnectionError();
     }
 }
예제 #15
0
        private void Buy_Click(object sender, RoutedEventArgs e)
        {
            SqlManager sqlManager;

            if (DataPerson.right == 3) //создание билета для обычного пользователя
            {
                MakeTicket(null);
            }
            else if (DataPerson.right == 2) //для сотрудника выбор пользователя из списка
            {
                SelectedTrips.Visibility  = Visibility.Hidden;
                choiseDataGrid.Visibility = Visibility.Visible;
                label.Visibility          = Visibility.Visible;
                sqlManager = new SqlManager();
                DataTable dt = sqlManager.ReturnTable("SELECT * FROM Tourists");
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        choiseDataGrid.Items.Add(new ManyPersons
                        {
                            NamePerson  = dr.ItemArray[2].ToString(),
                            LastName    = dr.ItemArray[1].ToString(),
                            MiddleName  = (dr.ItemArray[3].ToString() == "") ? "Отсутствует" : dr.ItemArray[3].ToString(),
                            SeriaPass   = Convert.ToInt32(dr.ItemArray[5]),
                            NumberPass  = Convert.ToInt32(dr.ItemArray[6]),
                            PhoneNumber = dr.ItemArray[7].ToString()
                        });
                    }
                }
                else
                {
                    PagesManager.ShowConnectionError();
                }
            }
        }
예제 #16
0
        private void MakeTicket(string[] param)
        {
            //создание билета
            SqlManager       sqlManager;
            MessageBoxResult res = MessageBox.Show("Вы хотите купить именно этот билет?", "", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (res == MessageBoxResult.Yes)
            {
                Word.Document doc = null;
                try
                {
                    Item item;
                    sqlManager = new SqlManager();
                    if (sqlManager.UpdateActualCountTripsInDB() != -2)
                    {
                        DataTable dt = sqlManager.ReturnTable("SELECT ActualCount " +
                                                              "FROM Tours " +
                                                              "WHERE Name_tour = '" + (SelectedTrips.SelectedItem as Item).NameTour + "'");
                        if (dt != null)
                        {
                            if (Convert.ToInt32(dt.Rows[0].ItemArray[0]) != 0)
                            {
                                //создаем новый документ
                                Word.Application app = new Word.Application();
                                var location         = System.Reflection.Assembly.GetExecutingAssembly().Location;
                                doc = app.Documents.Open(Path.GetDirectoryName(location) + @"\Шаблон.docx");
                                doc.Activate();
                                //открываем шаблон и получаем список закладок
                                Word.Bookmarks       wBookmarks = doc.Bookmarks;
                                Word.Range           wRange; //положение закладки в документе
                                List <Word.Bookmark> bookmarks = new List <Word.Bookmark>();
                                foreach (Word.Bookmark mark in wBookmarks)
                                {
                                    bookmarks.Add(mark);
                                }
                                string[] mass = (DataPerson.right == 3) ? sqlManager.ReturnDataPerson() : param;
                                if (mass != null)
                                {
                                    string[] data = new string[13];
                                    for (int i = 0; i < 6; i++)
                                    {
                                        data[i] = mass[i];
                                    }
                                    item     = Item.items.Find(x => x.NameTour == (SelectedTrips.SelectedItem as Item).NameTour);
                                    data[6]  = item.NameTour;
                                    data[7]  = item.NameCountry;
                                    data[8]  = item.NameCity;
                                    data[9]  = item.DateBegin;
                                    data[10] = item.DateEnd;
                                    data[11] = item.Price.ToString();
                                    data[12] = DateTime.Today.ToShortDateString();
                                    for (int i = 0; i < 13; i++) //заполнение данных на месте закладок
                                    {
                                        wRange      = bookmarks.ElementAt(i).Range;
                                        wRange.Text = data[i];
                                    }
                                    Item.items.Remove(item);
                                    SelectedTrips.Items.Remove(SelectedTrips.SelectedItem);
                                    int flag = sqlManager.ReturnNumber("SELECT Num_Tour FROM Tours WHERE Name_tour = '" + data[6] + "'");
                                    if (flag != -2)
                                    {
                                        int buf = flag;
                                        if (sqlManager.Insert("INSERT INTO Trips(Num_tour, Num_tourist, DateOfBuy) VALUES(" + buf +
                                                              "," + DataPerson.id + ", '" + DateTime.Today.Date + "')") != -2)
                                        {
                                            if ((flag = DataPerson.CountTickets()) != -2)
                                            {
                                                doc.SaveAs(FileName: @"..\Desktop\Ticket" + DataPerson.id + "_" + flag + ".docx");
                                                doc.Close();
                                                doc = null;
                                                MessageBox.Show("Ваш билет готов и находится на рабочем столе", "", MessageBoxButton.OK, MessageBoxImage.Information);
                                                choiseDataGrid.ItemsSource = null;
                                                choiseDataGrid.Visibility  = Visibility.Hidden;
                                                label.Visibility           = Visibility.Hidden;
                                                SelectedTrips.Visibility   = Visibility.Visible;
                                            }
                                            else
                                            {
                                                PagesManager.ShowConnectionError();
                                            }
                                        }
                                        else
                                        {
                                            PagesManager.ShowConnectionError();
                                        }
                                    }
                                    else
                                    {
                                        PagesManager.ShowConnectionError();
                                    }
                                }
                                else
                                {
                                    PagesManager.ShowConnectionError();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Билеты закончились!", "", MessageBoxButton.OK, MessageBoxImage.Warning);
                                item = Item.items.Find(x => x.NameTour == (SelectedTrips.SelectedItem as Item).NameTour);
                                Item.items.Remove(item);
                                SelectedTrips.Items.Remove(SelectedTrips.SelectedItem);
                                choiseDataGrid.ItemsSource = null;
                                choiseDataGrid.Visibility  = Visibility.Hidden;
                                label.Visibility           = Visibility.Hidden;
                                SelectedTrips.Visibility   = Visibility.Visible;
                            }
                            System.GC.Collect();
                        }
                        else
                        {
                            PagesManager.ShowConnectionError();
                        }
                    }
                    else
                    {
                        PagesManager.ShowConnectionError();
                    }
                }
                catch (Exception ex)
                {
                    doc.Close();
                    doc = null;
                    Console.WriteLine("Во время выполнения произошла ошибка! " + ex.Message);
                }
            }
        }