<Page x:Class="ComputerShopWpf.Views.OrdersPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="Заказы">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel Orientation="Horizontal">
            <TextBlock Text="Заказы" Style="{StaticResource PageTitleStyle}" Width="240"/>
            <Button x:Name="RefreshButton" Content="Обновить" Click="RefreshButton_Click"/>
            <Button x:Name="ShowItemsButton" Content="Состав заказа" Click="ShowItemsButton_Click"/>
        </StackPanel>

        <Border Grid.Row="1"
                Background="{StaticResource PanelBrush}"
                BorderBrush="{StaticResource BorderBrush}"
                BorderThickness="1"
                Padding="16"
                Margin="0,4,0,10">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="240"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <TextBlock x:Name="SelectedOrderTextBlock"
                           Text="Выберите заказ для изменения статуса"
                           VerticalAlignment="Center"
                           FontWeight="SemiBold"
                           TextWrapping="Wrap"
                           Margin="0,0,14,0"/>
                <ComboBox x:Name="StatusComboBox"
                          Grid.Column="1"
                          Margin="0,0,14,0">
                    <ComboBoxItem Content="новый"/>
                    <ComboBoxItem Content="в обработке"/>
                    <ComboBoxItem Content="отправлен"/>
                    <ComboBoxItem Content="выполнен"/>
                    <ComboBoxItem Content="отменён"/>
                </ComboBox>
                <Button x:Name="UpdateStatusButton"
                        Grid.Column="2"
                        Content="Изменить статус"
                        Click="UpdateStatusButton_Click"/>
            </Grid>
        </Border>

        <DataGrid x:Name="OrdersDataGrid"
                  Grid.Row="2"
                  SelectionChanged="OrdersDataGrid_SelectionChanged">
            <DataGrid.Columns>
                <DataGridTextColumn Header="ID" Binding="{Binding [order_id]}" Width="70"/>
                <DataGridTextColumn Header="Дата" Binding="{Binding [order_date], StringFormat={}{0:dd.MM.yyyy HH:mm}}" Width="150"/>
                <DataGridTextColumn Header="Статус" Binding="{Binding [status]}" Width="140"/>
                <DataGridTextColumn Header="Сумма" Binding="{Binding [total_cost], StringFormat={}{0:N2}}" Width="120"/>
                <DataGridTextColumn Header="Клиент" Binding="{Binding [client_name]}" Width="190"/>
                <DataGridTextColumn Header="Телефон клиента" Binding="{Binding [client_phone]}" Width="150"/>
                <DataGridTextColumn Header="Email клиента" Binding="{Binding [client_email]}" Width="190"/>
                <DataGridTextColumn Header="Сотрудник" Binding="{Binding [employee_name]}" Width="190"/>
                <DataGridTextColumn Header="Должность" Binding="{Binding [employee_position]}" Width="160"/>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Page>
