<Page x:Class="Hotel_Course_Project.HostelsPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:materialDesign="https://materialdesigninxaml.net/winfx/xaml/themes"
      xmlns:local="clr-namespace:Hotel_Course_Project"
      mc:Ignorable="d" 
      d:DesignHeight="450" d:DesignWidth="800"
      Title="Окно Заказов" Loaded="Page_Loaded">

    <Grid>
        <TabControl>
            <TabItem Header="Заказы">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="40"></RowDefinition>
                        <RowDefinition></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="100"></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>

                    <Button x:Name="AddOrderBtn" Click="AddOrderBtn_Click">Добавить</Button>

                    <StackPanel Margin="20,0,0,0" Grid.Column="2" Orientation="Horizontal">
                        <TextBlock VerticalAlignment="Center">Поиск</TextBlock>
                        <TextBox  Name="OrderSeacrhTB" TextChanged="OrderSeacrhTB_TextChanged" VerticalAlignment="Center" Width="100"></TextBox>
                        <Button Name="OrderSrchBtn" Click="OrderSrchBtn_Click">Поиск</Button>
                    </StackPanel>
                    <DataGrid Grid.Row="1" Grid.ColumnSpan="2" x:Name="OrderList" AutoGenerateColumns="False" ColumnWidth="*" IsReadOnly="True">
                        <DataGrid.Columns>
                            <DataGridTemplateColumn Header="Период сдачи">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding DateStart ,StringFormat=\{0:dd.MM.yy\}}"></TextBlock>
                                            <TextBlock Text=" - "></TextBlock>
                                            <TextBlock Text="{Binding DateEnd , StringFormat=\{0:dd.MM.yy\}}"></TextBlock>
                                        </StackPanel>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTextColumn Header="Номер" Binding="{Binding Room.NumRoom}"></DataGridTextColumn>
                            <DataGridTemplateColumn Header="Клиент">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Client.LName}"></TextBlock>
                                            <TextBlock Text=" "></TextBlock>
                                            <TextBlock Text="{Binding Client.FName[0]}"></TextBlock>
                                            <TextBlock Text="."></TextBlock>
                                            <TextBlock Text="{Binding Client.MName[0]}"></TextBlock>
                                            <TextBlock Text="."></TextBlock>
                                        </StackPanel>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTextColumn Header="Дата оплаты" Binding="{Binding Pay.PayDate}"></DataGridTextColumn>
                            <DataGridTextColumn Header="Статус заказа" Binding="{Binding OrderStatus.Name}"></DataGridTextColumn>
                            <DataGridTextColumn Header="Стоимость" Binding="{Binding Pay.EndSum}"></DataGridTextColumn>
                            <DataGridTemplateColumn>
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button x:Name="SelectOrderBtn" Click="SelectOrderBtn_Click">Выбрать</Button>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </TabItem>
            <TabItem Header="Клиенты">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="40"></RowDefinition>
                        <RowDefinition></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="100"></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>

                    <Button x:Name="AddClientfBtn" Click="AddClientBtn_Click">Добавить</Button>

                    <StackPanel Grid.Column="2" Orientation="Horizontal">
                        <TextBlock VerticalAlignment="Center">Поиск</TextBlock>
                        <TextBox  Name="ClientSeacrhTB" TextChanged="ClientSeacrhTB_TextChanged" VerticalAlignment="Center" Width="100"></TextBox>
                        <Button Name="ClientSrchBtn" Click="ClientSrchBtn_Click">Поиск</Button>
                    </StackPanel>


                    <DataGrid x:Name="ClientList" Grid.Row="1" Grid.ColumnSpan="3" AutoGenerateColumns="False" ColumnWidth="*" IsReadOnly="True" >
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Фамилия" Binding="{Binding LName}"></DataGridTextColumn>
                            <DataGridTextColumn Header="Имя" Binding="{Binding FName}"></DataGridTextColumn>
                            <DataGridTextColumn Header="Отчество" Binding="{Binding MName}"></DataGridTextColumn>
                            <DataGridTemplateColumn>
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button x:Name="ClientSelectBtn" Click="ClientSelectBtn_Click">Выбрать</Button>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</Page>
