<Page x:Class="ComputerShopWpf.Views.ProductsPage"
      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>

        <TextBlock Text="Товары" Style="{StaticResource PageTitleStyle}"/>

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

                    <StackPanel Grid.Column="0" Margin="0,0,14,0">
                        <TextBlock Text="Название товара"/>
                        <TextBox x:Name="ProductNameTextBox"/>
                    </StackPanel>
                    <StackPanel Grid.Column="1" Margin="0,0,14,0">
                        <TextBlock Text="Категория"/>
                        <TextBox x:Name="CategoryTextBox"/>
                    </StackPanel>
                    <StackPanel Grid.Column="2" Margin="0,0,14,0">
                        <TextBlock Text="Цена"/>
                        <TextBox x:Name="PriceTextBox"/>
                    </StackPanel>
                    <StackPanel Grid.Column="3" Margin="0,0,14,0">
                        <TextBlock Text="Остаток"/>
                        <TextBox x:Name="StockTextBox"/>
                    </StackPanel>
                    <StackPanel Grid.Column="4">
                        <TextBlock Text="Поставщик"/>
                        <ComboBox x:Name="SuppliersComboBox"
                                  DisplayMemberPath="company_name"
                                  SelectedValuePath="supplier_id"/>
                    </StackPanel>
                </Grid>
                <StackPanel Orientation="Horizontal" Margin="0,6,0,0">
                    <Button x:Name="AddProductButton" Content="Добавить товар" Click="AddProductButton_Click"/>
                    <Button x:Name="RefreshButton" Content="Обновить" Click="RefreshButton_Click"/>
                </StackPanel>
            </StackPanel>
        </Border>

        <DataGrid x:Name="ProductsDataGrid" Grid.Row="2">
            <DataGrid.Columns>
                <DataGridTextColumn Header="ID" Binding="{Binding [product_id]}" Width="70"/>
                <DataGridTextColumn Header="Название" Binding="{Binding [product_name]}" Width="*"/>
                <DataGridTextColumn Header="Категория" Binding="{Binding [category]}" Width="150"/>
                <DataGridTextColumn Header="Цена" Binding="{Binding [price], StringFormat={}{0:N2}}" Width="120"/>
                <DataGridTextColumn Header="Остаток" Binding="{Binding [stock_quantity]}" Width="110"/>
                <DataGridTextColumn Header="Поставщик" Binding="{Binding [supplier_name]}" Width="190"/>
                <DataGridTextColumn Header="Контакт" Binding="{Binding [contact_person]}" Width="170"/>
                <DataGridTextColumn Header="Телефон поставщика" Binding="{Binding [supplier_phone]}" Width="160"/>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Page>
