<hc:Window x:Class="智慧物流软件系统.OutInventoryAddDucumentView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        xmlns:hc="https://handyorg.github.io/handycontrol"
        Height="500" Width="850" WindowStyle="None"  Background="{x:Null}" BorderThickness="0" AllowsTransparency="True" WindowStartupLocation="CenterScreen" Opacity="1" Loaded="Window_Loaded">
    <hc:Window.Resources>
        <ResourceDictionary>
            <Style TargetType="Button" BasedOn="{StaticResource ButtonDefault}">
                <Setter Property="Padding" Value="25,0"></Setter>
            </Style>
        </ResourceDictionary>
    </hc:Window.Resources>

    <Border Background="AliceBlue" CornerRadius="10" BorderThickness="1.5" BorderBrush="Black" >
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="1.5*"></RowDefinition>
                <RowDefinition Height="10*"></RowDefinition>
                <RowDefinition Height="0.8*"></RowDefinition>
                <RowDefinition Height="1.5*"></RowDefinition>
            </Grid.RowDefinitions>

            <Button Margin="-5,-1" Visibility="{Binding IsClose,Converter={StaticResource Boolean2VisibilityConverter}}" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource CloseGeometry}" HorizontalAlignment="Right" VerticalAlignment="Top" Click="closeClick"/>
            <StackPanel Orientation="Vertical">
                <TextBlock FontSize="25" Name="Title" Text="新增出库单据" TextWrapping="Wrap" VerticalAlignment="Top" HorizontalAlignment="Center"/>
                <hc:Divider Margin="0"></hc:Divider>
            </StackPanel>

            <Border Grid.Row="1" Margin="2 2 2 0" Background="AliceBlue"  Padding="0">
                <Border   Background="AliceBlue" Padding="0">
                    <Grid >
                        <StackPanel Margin="3" Orientation="Horizontal">
                            <StackPanel Margin="3"  Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
                                <TextBlock  VerticalAlignment="Center" 
                            Text="货架类型：" FontSize="22" >
                                </TextBlock>
                                <ComboBox 
                                    IsEnabled="{Binding ShelfTypeIsEnabled}"
                                    VerticalAlignment="Center"
                                    DisplayMemberPath="ShelfTypeName"
                                    ItemsSource="{Binding ShelfTypeItems}"
                                    SelectedItem="{Binding SelectedShelfTypeItem}"
                                    FontSize="22" 
                                    IsEditable="False"/>
                            </StackPanel>
                            <Button MinHeight="40" FontSize="18" 
                                Content="&#xe604;增加物料" FontFamily="{StaticResource IconFont}"
                                Foreground="WhiteSmoke"
                                Background="HotPink"
                                Command="{Binding BtnAddCommand}">
                            </Button>
                        </StackPanel>
                    </Grid>
                </Border>
            </Border>

            <Grid Margin="5,0" Grid.Row="2" >
                <DataGrid Grid.Row="1" SelectedCellsChanged="DataGrid_SelectedCellsChanged"
                          RowHeight="39" 
                          ItemsSource="{Binding DataGridItemSource}"
                          SelectedItem="{Binding SelectedItemSource, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                          AutoGenerateColumns="False" Name="dg1"  FontSize="15">
                    <DataGrid.Columns>
                        <DataGridTextColumn IsReadOnly="True" Header="物料编码" Binding="{Binding MatCode}"></DataGridTextColumn>
                        <DataGridTextColumn IsReadOnly="True" Header="物料名称" MaxWidth="150" Binding="{Binding MatName}"></DataGridTextColumn>
                        <DataGridTextColumn IsReadOnly="True" Header="物料规格" MaxWidth="150" Binding="{Binding MatSpec}"></DataGridTextColumn>
                        <DataGridTextColumn IsReadOnly="True" Header="物料批次" Binding="{Binding MatBatch}"></DataGridTextColumn>
                        <DataGridTextColumn IsReadOnly="True" Header="库存数量" Binding="{Binding TotalQty}"></DataGridTextColumn>
                        <DataGridTemplateColumn CanUserResize="False" Header="需求数量">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBox Width="80" Height="25" Text="{Binding NeedQty, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn CanUserResize="False" Header="">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button Style="{StaticResource ButtonDanger}" Margin="0,0,0,0" IsEnabled="True" Content="删除" Width="60" Command="{Binding DataContext.DelCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" CommandParameter="{Binding }"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                    </DataGrid.Columns>
                </DataGrid>
            </Grid>

            <StackPanel Grid.Row="3" HorizontalAlignment="Right" Orientation="Horizontal">
                <TextBlock FontSize="22" Text="已选物料："></TextBlock>
                <TextBlock FontSize="22" Text="{Binding SelectedTypeCount}"></TextBlock>
                <TextBlock FontSize="22" Text="种"></TextBlock>
            </StackPanel>

            <StackPanel Margin="3" x:Name="spacingPanel" Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
                <Button Margin="0" Content="生成出库单" Background="ForestGreen" Foreground="White" MinHeight="40" FontSize="20" 
                        Command="{Binding GenerateOutOrderCommand}"/>
                <TextBlock Margin="16" Text=""></TextBlock>
                <Button Margin="0" Content="取消"  Background="IndianRed" Foreground="White"  MinHeight="40" FontSize="20" Click="closeClick"/>
            </StackPanel>

        </Grid>
    </Border>
</hc:Window>
