максим карбышев 2 лет назад
Родитель
Сommit
7e1b0064f6

+ 3 - 0
Kinomaks/AddWindows/AddHallWindow.xaml.cs

@@ -46,6 +46,9 @@ namespace Kinomaks.AddWindows
             int countOfSeats = 0;
             foreach (UIElement item in Seats.Children)
             {
+                if (((Button)item).Background == Brushes.Red)
+                    continue;
+
                 countOfSeats++;
             }
 

+ 2 - 2
Kinomaks/AddWindows/AddTimetableWindow.xaml

@@ -14,9 +14,9 @@
         <Button x:Name="BackButton"  Content="Назад" HorizontalAlignment="Left" Margin="20,17,0,0" VerticalAlignment="Top" Height="39" Width="140" FontSize="25" Click="BackButtonClick"/>
         <Button x:Name="AddButton" Content="Добавить" HorizontalAlignment="Center" Margin="0,792,0,0" VerticalAlignment="Top" Height="60" Width="180" FontSize="36" Click="AddButtonClick" />
         <Label Content="Зал №:" HorizontalAlignment="Left" Margin="449,410,0,0" VerticalAlignment="Top" Height="60" Width="180" Foreground="White" FontSize="36"/>
-        <ComboBox x:Name="Hall" HorizontalAlignment="Left" VerticalAlignment="Top" Height="60" Width="316" Foreground="White" FontSize="36" Margin="629,410,0,0"/>
+        <ComboBox x:Name="Hall" HorizontalAlignment="Left" VerticalAlignment="Top" Height="60" Width="316" Foreground="Black" FontSize="36" Margin="629,410,0,0"/>
         <Label Content="Фильм:" HorizontalAlignment="Left" Margin="449,504,0,0" VerticalAlignment="Top" Height="60" Width="180" Foreground="White" FontSize="36"/>
-        <ComboBox x:Name="Film" HorizontalAlignment="Left" VerticalAlignment="Top" Height="60" Width="544" Foreground="White" FontSize="36" Margin="629,504,0,0"/>
+        <ComboBox x:Name="Film" HorizontalAlignment="Left" VerticalAlignment="Top" Height="60" Width="544" Foreground="Black" FontSize="36" Margin="629,504,0,0"/>
 
     </Grid>
 </Window>

+ 13 - 4
Kinomaks/AddWindows/AddTimetableWindow.xaml.cs

@@ -15,6 +15,7 @@ namespace Kinomaks.AddWindows
         public AddTimetableWindow()
         {
             InitializeComponent();
+            Hall.ItemsSource = Connection.db.Hall.Select(item => item.Number).ToList();
             Film.ItemsSource = Connection.db.Films.Select(items => items.Title).ToList();
         }
         private void AddButtonClick(object sender, RoutedEventArgs e)
@@ -49,8 +50,10 @@ namespace Kinomaks.AddWindows
                 return;
             }
 
-            if (Connection.db.Timetable.Select(item => item.Time + " " + item.Date + " " + item.Hall).Contains(timeResult + " " + dateResult + " " +
-                Connection.db.Hall.Where(item => item.Number == Convert.ToInt32(Hall.SelectedItem)).Select(item => item.ID).FirstOrDefault()))
+            Hall selectedHall = Connection.db.Hall.Where(item => item.Number == (int)Hall.SelectedItem).FirstOrDefault();
+
+            if (Connection.db.Timetable.Select(item => item.Time + " " + item.Date + " " + item.IDHall).Contains(timeResult + " " + dateResult + " " +
+                                            selectedHall.ID))
             {
                 ErrorWindow errorWindow = new ErrorWindow("зал уже занят");
                 errorWindow.Show();
@@ -61,20 +64,26 @@ namespace Kinomaks.AddWindows
             {
                 Time = timeResult,
                 Date = dateResult,
-                IDHall = Connection.db.Hall.Where(item => item.Number == Convert.ToInt32(Hall.SelectedItem)).Select(item => item.ID).FirstOrDefault()
+                IDHall = selectedHall.ID
             };
 
             Connection.db.Timetable.Add(timetable);
             Connection.db.SaveChanges();
 
+            Films selectedFilm = Connection.db.Films.Where(item => item.Title == Film.SelectedItem.ToString()).FirstOrDefault();
+
             FilmTimetable filmTimetable = new FilmTimetable()
             {
-                IDFilm = Connection.db.Films.Where(item => item.Title == Film.Text).Select(item => item.ID).FirstOrDefault(),
+                IDFilm = selectedFilm.ID,
                 IDTimeTable = Connection.db.Timetable.Max(item => item.ID)
             };
 
             Connection.db.FilmTimetable.Add(filmTimetable);
             Connection.db.SaveChanges();
+
+            MainWindow mainWindow = new MainWindow();
+            mainWindow.Show();
+            this.Close();
             #endregion
         }
 

+ 1 - 1
Kinomaks/App.xaml

@@ -2,7 +2,7 @@
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:local="clr-namespace:Kinomaks"
-             StartupUri="MainWindow.xaml">
+             StartupUri="AuthorizationWindow.xaml">
     <Application.Resources>
         <ResourceDictionary Source="Style.xaml"/>
     </Application.Resources>

+ 1 - 1
Kinomaks/ElementsWindows/FilmWindow.xaml

@@ -13,7 +13,7 @@
         <Label Content="Цена:" HorizontalAlignment="Left" Margin="140,176,0,0" VerticalAlignment="Top" Height="60" Width="180" Foreground="White" HorizontalContentAlignment="Right" FontSize="36"/>
         <Label Name="Price" HorizontalAlignment="Left" Margin="322,176,0,0" VerticalAlignment="Top" Height="60" Width="700" FontSize="36" Foreground="White"/>
         <Label Content="Описание:" HorizontalAlignment="Left" Margin="140,266,0,0" VerticalAlignment="Top" Height="60" Width="180" Foreground="White" FontSize="36"/>
-        <Label Name="Description" HorizontalAlignment="Left" Margin="140,337,0,0" VerticalAlignment="Top" Height="413" Width="884" FontSize="36" Foreground="White"/>
+        <TextBlock Name="Description" HorizontalAlignment="Left" Margin="140,337,0,0" VerticalAlignment="Top" Height="413" Width="884" FontSize="36" Foreground="White" TextWrapping="Wrap"/>
         <Image Name="Logo" HorizontalAlignment="Left" Margin="1129,133,0,0" Width="411" Height="649" VerticalAlignment="Top"/>
         <Button x:Name="GoToTimetable" Content="Перейти к расписанию с фильмом" HorizontalAlignment="Center" Margin="0,792,0,0" VerticalAlignment="Top" Height="60" Width="608" FontSize="36" Click="GoToTimetableClick" />
     </Grid>

+ 1 - 0
Kinomaks/ElementsWindows/FilmWindow.xaml.cs

@@ -16,6 +16,7 @@ namespace Kinomaks.ElementsWindows
             film = Connection.db.Films.Where(item => item.ID == id).FirstOrDefault();
             Title.Content = film.Title;
             Price.Content = string.Format("{0:f2}", film.Price);
+            Description.Text = film.Descripton;
             Logo.Source = ImagesManip.NewImage(film);
         }
 

+ 1 - 1
Kinomaks/ElementsWindows/ReturnWindow.xaml.cs

@@ -28,7 +28,7 @@ namespace Kinomaks.ElementsWindows
             DateTime date = Connection.db.UserTicket.Where(item => item.ID == cheque).Select(item => item.Timetable.Date).FirstOrDefault();
             TimeSpan time = Connection.db.UserTicket.Where(item => item.ID == cheque).Select(item => item.Timetable.Time).FirstOrDefault();
 
-            if (now.Date >= date || (now.Date == date && now.TimeOfDay > time))
+            if (now.Date > date || (now.Date == date && now.TimeOfDay >= time))
             {
                 ErrorWindow errorWindow = new ErrorWindow("вы уже не можете вернуть этот билет");
                 errorWindow.Show();

+ 1 - 1
Kinomaks/ElementsWindows/TimetableWindow.xaml.cs

@@ -25,7 +25,7 @@ namespace Kinomaks.ElementsWindows
 
         private void FilmsListSelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            int idTimetable = ((FilmTimetable)sender).IDTimeTable;
+            int idTimetable = ((FilmTimetable)FilmsList.SelectedItem).IDTimeTable;
             BuyingATicket buyingATicket = new BuyingATicket(idTimetable);
             buyingATicket.Show();
             this.Close();

+ 3 - 3
Kinomaks/MainWindow.xaml

@@ -10,9 +10,9 @@
         <TabControl BorderThickness="0">
             <TabItem Header="Главная" Height="20" Width="100" Background="#FF4F5856">
                 <Grid Margin="-3,-22,-3,-2">
-                    <Button Name="FilmsList" Content="Фильмы" HorizontalAlignment="Center" Margin="0,314,0,0" VerticalAlignment="Top" Height="70" Width="222" FontSize="36" Click="FilmsListClick"/>
-                    <Button Name="Tabletime" Content="Расписание" HorizontalAlignment="Center" VerticalAlignment="Center" Height="70" Width="222" FontSize="36" Click="TimetableListClick"/>
-                    <Button x:Name="Return" Content="Возврат" HorizontalAlignment="Center" Margin="0,498,0,0" VerticalAlignment="Top" Height="70" Width="222" FontSize="36" Click="ReturnClick"/>
+                    <Button Name="FilmsList" Content="Фильмы" HorizontalAlignment="Center" Margin="0,316,0,0" VerticalAlignment="Top" Height="70" Width="222" FontSize="36" Click="FilmsListClick"/>
+                    <Button Name="Tabletime" Content="Расписание" HorizontalAlignment="Center" VerticalAlignment="Top" Height="70" Width="222" FontSize="36" Click="TimetableListClick" Margin="0,408,0,0"/>
+                    <Button x:Name="Return" Content="Возврат" HorizontalAlignment="Center" Margin="0,500,0,0" VerticalAlignment="Top" Height="70" Width="222" FontSize="36" Click="ReturnClick"/>
                 </Grid>
             </TabItem>
             <TabItem Name="AddItem" Header="Добавить" Height="20" Width="100" Background="#FF4F5856">