<UserControl x:Class="SlnMesnac.WPF.Page.ExecutePage"
             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:local="clr-namespace:SlnMesnac.WPF.Page"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="FontSize" Value="15"/>
        </Style>

        <Style TargetType="DataGrid">
            <!--网格线颜色-->
            <Setter Property="CanUserResizeColumns" Value="false"/>
            <Setter Property="Background" Value="#1152AC" />
            <Setter Property="BorderBrush" Value="#4285DE" />
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="HorizontalGridLinesBrush">
                <Setter.Value>
                    <SolidColorBrush Color="#4285DE"/>
                </Setter.Value>
            </Setter>
            <Setter Property="VerticalGridLinesBrush">
                <Setter.Value>
                    <SolidColorBrush Color="#1152AC"/>
                </Setter.Value>
            </Setter>
        </Style>
        <!--列头标题栏样式-->
        <Style TargetType="DataGridColumnHeader">
            <!--<Setter Property="HorizontalContentAlignment" Value="Center"/>
   <Setter Property="VerticalContentAlignment" Value="Center"/>-->
            <!--<Setter Property="Background" Value="#dddddd"/>
   <Setter Property="Foreground" Value="Black"/>-->
            <!--<Setter Property="BorderThickness" Value="1" />-->
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="BorderBrush" Value="#4285DE" />
            <Setter Property="Height" Value="40"/>
            <Setter Property="FontSize" Value="15"/>
            <Setter Property="Background" Value="#4285DE"/>
            <Setter Property="Foreground" Value="White"/>
        </Style>

        <!--单元格样式-->
        <Style TargetType="DataGridCell">
            <Setter Property="FocusVisualStyle" Value="{x:Null}" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="BorderBrush" Value="#4285DE" />
            <Setter Property="Height" Value="40"/>
            <Setter Property="FontSize" Value="15"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type DataGridCell}">
                        <Grid Background="{TemplateBinding Background}" >
                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Background" Value="#4285DE"/>
                    <!--<Setter Property="Foreground" Value="#dddddd"/>-->
                </Trigger>
            </Style.Triggers>

        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="6*"/>
            <ColumnDefinition Width="4*"/>
        </Grid.ColumnDefinitions>
        <Border Grid.Column="0" >
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="1.5*"/>
                    <RowDefinition Height="7.5*"/>
                </Grid.RowDefinitions>
                <Border Grid.Row="0">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="1*"/>
                            <ColumnDefinition Width="9*"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" Text="班组成员：" FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Right"/>
                        <TextBlock Grid.Column="1" Text="{Binding TeamMember}"  FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBlock>
                    </Grid>
                </Border>
                <Border Grid.Row="1" Margin="5">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="2*"/>
                            <ColumnDefinition Width="3*"/>
                            <ColumnDefinition Width="2*"/>
                            <ColumnDefinition Width="3*"/>
                            <ColumnDefinition Width="2*"/>
                            <ColumnDefinition Width="3*"/>
                        </Grid.ColumnDefinitions>
                        <Border Grid.Row="0" Grid.Column="0">
                            <TextBlock Text="ERP订单编号" FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Border>
                        <Border Grid.Row="0" Grid.Column="1">
                            <TextBox Text="{Binding OrderCodeTextBox}" Height="30" Width="170" FontSize="15" Foreground="White" HorizontalAlignment="Left"/>
                        </Border>
                        <Border Grid.Row="0" Grid.Column="2">
                            <TextBlock Text="工单编号" FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Border>
                        <Border Grid.Row="0" Grid.Column="3">
                            <TextBox  Text="{Binding PlanCodeTextBox}" Height="30" Width="170" FontSize="15" Foreground="White" HorizontalAlignment="Left"/>
                        </Border>
                        <Border Grid.Row="0" Grid.Column="4">
                            <TextBlock Text="物料名称" FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Border>
                        <Border Grid.Row="0" Grid.Column="5">
                            <TextBox Text="{Binding MaterialNameTextBox}" Height="30" Width="170" FontSize="15" Foreground="White" HorizontalAlignment="Left"/>
                        </Border>
                        <Border Grid.Row="1" Grid.Column="0">
                            <TextBlock Text="工位：" FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Border>
                        <Border Grid.Row="1" Grid.Column="1">
                            <TextBlock Text="{Binding StationTextBox}" FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Left"/>
                            <!--<ComboBox x:Name="StationComboBox" ItemsSource="{Binding StationList}" SelectedItem="{Binding Station}" Width="180" Height="30" FontSize="15" HorizontalAlignment="Left"/>-->
                        </Border>
                        <Border Grid.Row="1" Grid.Column="5">
                            <Button Content="检索工单" x:Name="Select"  Command="{Binding SearchCommand}" CommandParameter="{Binding Name,ElementName=Select}" Style="{StaticResource  BUTTON_AGREE}" FontSize="15" FontWeight="Bold" Background="#009999" BorderBrush="#FF36B5C1"  Margin="20,5,20,5"/>
                        </Border>
                    </Grid>
                </Border>
                <Border Grid.Row="2" Margin="5"  BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5" >
                    <Border.Effect>
                        <DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
                    </Border.Effect>
                    <DataGrid x:Name="DataGridPlanInfo" ItemsSource="{Binding ProdPLanInfoDataGrid}" Background="Transparent" 
                        FontSize="15" ColumnHeaderHeight="40" LoadingRow="dgvMH_LoadingRow"
                        RowHeight="40" AutoGenerateColumns="False" RowHeaderWidth="0" 
                        GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden" 
                        ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False"
                        Foreground="#FFFFFF" SelectedItem="{Binding SelectedRow}">
                        <!--resourceStyle 399行修改选中字体颜色-->
                        <DataGrid.Columns>
                            <DataGridTemplateColumn  Width="55" Header="序号"  >
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type DataGridRow}}, Path=Header}" FontSize="18" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"></TextBlock>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <!--<DataGridTextColumn Binding="{Binding IndexCode}" Header="序号" Width="2*"  IsReadOnly="True"  ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}"/>-->
                            <DataGridTextColumn Binding="{Binding OrderCode}" Header="ERP订单编号" Width="2*"  IsReadOnly="True" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}"/>
                            <!--<DataGridTextColumn Binding="{Binding PlanCode}" Header="工单编号" Width="3.5*"  IsReadOnly="True" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}"/>-->
                            <!--<DataGridTextColumn Binding="{Binding date,StringFormat=\{0:yyyy-MM-dd\}}" Header="工单编号" Width="2*" IsReadOnly="True" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}"/>-->
                            <DataGridTextColumn Binding="{Binding MaterialName}" Header="物料名称" Width="4*" IsReadOnly="True" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}"/>
                            <DataGridTextColumn Binding="{Binding PlanAmount}" Header="计划数量" Width="1.5*" IsReadOnly="True" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}"/>
                            <DataGridTextColumn Binding="{Binding CompleteAmount}" Header="完成数量" Width="1.5*"  IsReadOnly="True" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}"/>
                            <DataGridTemplateColumn Header="操作" Width="1*" >
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <WrapPanel>
                                            <Button Content="执行" 
                                                    FontSize="15" 
                                                    Width="60" 
                                                    Height="30" 
                                                    Command="{Binding DataContext.ExecuteCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}}" 
                                                    CommandParameter="{Binding}">
                                                <Button.Style>
                                                    <Style TargetType="Button">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                        <Style.Triggers>
                                                            <DataTrigger Binding="{Binding PlanStatus}" Value="4">
                                                                <Setter Property="IsEnabled" Value="True"/>
                                                            </DataTrigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </Button.Style>
                                            </Button>
                                        </WrapPanel>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                        <DataGrid.RowStyle>
                            <Style TargetType="DataGridRow">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding PlanStatus}" Value="0">
                                        <Setter Property="Background" Value="Transparent"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding PlanStatus}" Value="1">
                                        <Setter Property="Background" Value="Transparent"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding PlanStatus}" Value="0">
                                        <Setter Property="Background" Value="Transparent"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding PlanStatus}" Value="0">
                                        <Setter Property="Background" Value="Transparent"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding PlanStatus}" Value="4">
                                        <Setter Property="Background" Value="Green"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </DataGrid.RowStyle>
                    </DataGrid>
                </Border>
            </Grid>
        </Border>
        <Border Grid.Column="1" Margin="3">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="2*"/>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="5*"/>
                    <RowDefinition Height="1*"/>
                </Grid.RowDefinitions>
                <Border Grid.Row="0">
                    <TextBlock Text="工单信息" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                </Border>
                <Border Grid.Row="1">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Border Grid.Row="0">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="2*"/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="2*"/>
                                </Grid.ColumnDefinitions>
                                <Border Grid.Row="0" Grid.Column="0">
                                    <TextBlock Text="ERP订单编号" FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                </Border>
                                <Border Grid.Row="0" Grid.Column="1" Height="50" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5">
                                    <Border.Effect>
                                        <DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
                                    </Border.Effect>
                                    <TextBlock Text="{Binding OrderCodeText}" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                </Border>
                                <Border Grid.Row="0" Grid.Column="2">
                                    <TextBlock Text="工单编号" FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                </Border>
                                <Border Grid.Row="0" Grid.Column="3" Height="50" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5">
                                    <Border.Effect>
                                        <DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
                                    </Border.Effect>
                                    <TextBlock Text="{Binding PlanCodeText}" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                </Border>
                            </Grid>
                        </Border>
                        <Border Grid.Row="1">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="5*"/>
                                </Grid.ColumnDefinitions>
                                <Border Grid.Column="0">
                                    <TextBlock Text="物料名称" FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                </Border>
                                <Border Grid.Column="1" Height="50" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5">
                                    <Border.Effect>
                                        <DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
                                    </Border.Effect>
                                    <TextBlock Text="{Binding MaterialNameText}" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                </Border>
                            </Grid>
                        </Border>
                    </Grid>
                    <!--<Grid>
                        
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="2*"/>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="2*"/>
                        </Grid.ColumnDefinitions>
                        <Border Grid.Row="0" Grid.Column="0">
                            <TextBlock Text="ERP订单编号" FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Border>
                        <Border Grid.Row="0" Grid.Column="1" Height="50" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5">
                            <Border.Effect>
                                <DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
                            </Border.Effect>
                            <TextBlock Text="{Binding OrderCodeText}" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Border>
                        <Border Grid.Row="0" Grid.Column="2">
                            <TextBlock Text="工单编号" FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Border>
                        <Border Grid.Row="0" Grid.Column="3" Height="50" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5">
                            <Border.Effect>
                                <DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
                            </Border.Effect>
                            <TextBlock Text="{Binding PlanCodeText}" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Border>
                        <Border Grid.Row="1" Grid.Column="0">
                            <TextBlock Text="物料名称" FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Border>
                        <Border Grid.Row="1" Grid.Column="1" Height="50" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5">
                            <Border.Effect>
                                <DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
                            </Border.Effect>
                            <TextBlock Text="{Binding MaterialNameText}" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Border>
                        <Border Grid.Row="1" Grid.Column="2">
                            <TextBlock Text="计划工位" FontSize="15" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Border>
                        <Border Grid.Row="1" Grid.Column="3" Height="50" BorderBrush="#1254AB" BorderThickness="2" CornerRadius="5">
                            <Border.Effect>
                                <DropShadowEffect Color="#1254AB" Direction="270" BlurRadius="10" ShadowDepth="5" Opacity="0.5"/>
                            </Border.Effect>
                            <TextBlock Text="{Binding StationCodeText}" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Border>
                    </Grid>-->
                </Border>
                <Border Grid.Row="2">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="1*"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <Border Grid.Column="1">
                            <TextBlock Text="工单明细" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Border>
                        <Border Grid.Column="2">
                            <Button Content="工艺信息" x:Name="TechnologicalInformation" Command="{Binding TechnologicalInformationCommand}" Style="{StaticResource  BUTTON_AGREE}" FontSize="15" FontWeight="Bold" Background="#009999" BorderBrush="#FF36B5C1"  Margin="40,16,40,16" Click="ChangeShifts_Click"/>
                        </Border>
                    </Grid>
                </Border>
                <Border Grid.Row="3">
                    <DataGrid Name="dataGridPlanDetail" ItemsSource="{Binding ProdPLanDetailDataGrid,Mode=TwoWay}" Background="Transparent" 
                         FontSize="15" ColumnHeaderHeight="30" LoadingRow="dgvMH_LoadingRow"
                         RowHeight="40" AutoGenerateColumns="False" RowHeaderWidth="0" 
                         GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden" 
                         ScrollViewer.VerticalScrollBarVisibility="Auto" BorderThickness="0" CanUserAddRows="False"
                         Foreground="#FFFFFF" SelectedItem="{Binding SelectedDetailRow}">
                        <DataGrid.Columns>
                            <DataGridTemplateColumn Width="55" Header="序号" >
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type DataGridRow}}, Path=Header}" FontSize="18" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"/>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>

                            <DataGridTextColumn Binding="{Binding PlanAmount}" Header="计划数量" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
                            <DataGridTextColumn Binding="{Binding CompleteAmount}" Header="新增数量" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
                            <DataGridTextColumn Binding="{Binding CreatedBy}" Header="当前班长" Width="1*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>
                            <DataGridTextColumn Binding="{Binding BeginTime, StringFormat=\{0:yyy-MM-dd HH:mm:ss\}}" Header="实际开始时间" Width="2*" IsReadOnly="True" ElementStyle="{StaticResource DataGridTextColumnCenterSytle}"/>

                            <DataGridTemplateColumn Header="操作" Width="1*" >
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <WrapPanel>
                                            <Button Content="撤回" 
                                                FontSize="15" 
                                                Width="40" 
                                                Height="25" 
                                                Command="{Binding DataContext.WithdrawCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}}" 
                                                CommandParameter="{Binding}">
                                            </Button>
                                        </WrapPanel>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </Border>
                <Border Grid.Row="4">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <Border Grid.Column="0">
                            <Button Content="生产报工" x:Name="ProductionReport" Command="{Binding ProductionReportCommand}" Style="{StaticResource  BUTTON_AGREE}" FontSize="15" FontWeight="Bold" Background="#009999" BorderBrush="#FF36B5C1"  Margin="40,14,40,14"/>
                        </Border>
                        <Border Grid.Column="1">
                            <!--<Button Content="换班交接" x:Name="Handover" Command="{Binding HandoverCommand}" Style="{StaticResource  BUTTON_AGREE}" FontSize="15" FontWeight="Bold" Background="#009999" BorderBrush="#FF36B5C1"  Margin="40,14,40,14" Click="ChangeShifts_Click"/>-->
                        </Border>
                    </Grid>
                </Border>
            </Grid>
        </Border>
    </Grid>
</UserControl>
