<fw:NChildWindow x:Class="Com.FirmLib.UI.Seller.WinSellerProjectContract"
             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:fw="http://schemas.FWind/xaml"
             xmlns:uc="clr-namespace:Com.FirmLib.UI.Common"
             xmlns:ui="clr-namespace:Com.FirmLib.UI"
             mc:Ignorable="d" Title="新建项目添加合同"
             d:DesignHeight="300" d:DesignWidth="500" Name="this" Height="{Binding Height,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UIElement}}"
                 Width="{Binding ActualWidth,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ScrollContentPresenter}}">
    <fw:NChildWindow.Resources>
        <fw:BindingProxy x:Key="DATA" Data="{Binding}"></fw:BindingProxy>
    </fw:NChildWindow.Resources>
    <fw:NChildWindow.AttachElement>
        <StackPanel HorizontalAlignment="Stretch" Orientation="Horizontal" VerticalAlignment="Center">
            <Button Command="{Binding Data.Commands.SaveCommand,Source={StaticResource ResourceKey=DATA}}" Click="btnOK_Click" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.ButtonKey}}"  BorderThickness="0"  FontFamily="{DynamicResource ResourceKey={x:Static fw:FontsUtil.AwesomeKey}}">
                <Button.Content>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{fw:FontIcon Icon=Save}"  Width="30" FontSize="20"></TextBlock>
                        <TextBlock Text="保存" VerticalAlignment="Center" Margin="-5,0,0,0"></TextBlock>
                    </StackPanel>
                </Button.Content>
            </Button>
        </StackPanel>

    </fw:NChildWindow.AttachElement>
    <Grid Validation.ErrorTemplate="{StaticResource ResourceKey={x:Static fw:ResourceKeys.EmptyErrorTemplateKey}}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.BindingGroup  >
            <BindingGroup x:Name="bg" />
        </Grid.BindingGroup>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Vertical" HorizontalAlignment="Left" Width="300" Margin="5,0,5,0">
                <Label   Content="供应商合同编号:"></Label>
                <TextBox Text="{Binding ContractNo,UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.TextBoxKey}}" Margin="5">
                </TextBox>

                <Label  Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.StarLableKey}}" Content="所属项目:"></Label>
                <TextBox IsEnabled="{Binding ProjectFixed,Converter={x:Static fw:ConverterFactory.BoolOpposition}}"  Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.TextBoxKey}}" HorizontalAlignment="Stretch" Margin="5">

                    <Binding Path="ProjectNo" Mode="TwoWay" UpdateSourceTrigger="LostFocus" >
                        <Binding.ValidationRules>
                            <fw:RequireValidationRule ></fw:RequireValidationRule>
                        </Binding.ValidationRules>
                    </Binding>
                </TextBox>
                <Label Content="项目本地名称:"></Label>

                <TextBlock Text="{Binding LocalProjectName}" Margin="5">
                </TextBlock>
            </StackPanel>

            <StackPanel Grid.Column="1">
                <Label   Content="" Margin="1"></Label>
                <Button Margin="5" Command="{Binding Commands.SelectContractNo}"  Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.LinkButtonKey}}"  VerticalAlignment="Center"   Content="从项目已有供应合同选择" HorizontalAlignment="Left" Padding="5,0,5,0"/>
            </StackPanel>
        </Grid>



        <GroupBox Grid.Row="1" Grid.Column="0"  Margin="0,10,0,10" Header="供应商联系信息" IsEnabled="{Binding ProjectFixed,Converter={x:Static fw:ConverterFactory.BoolOpposition}}"  Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.GroupBoxKey}}"  >
            <ui:ContactInformationInput x:Name="link"  DataContext="{Binding ContactItem,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" Width="300" ></ui:ContactInformationInput >
        </GroupBox>

        <GroupBox IsEnabled="True" Grid.Row="2" Grid.Column="0"  Margin="0,10,0,10" Header="合同中涉及的资产清单"  Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.GroupBoxKey}}"  >

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition ></RowDefinition>
                </Grid.RowDefinitions>
                <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
                    <Button Command="{Binding Commands.CreateAssetCommand}" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.ButtonKey}}"  Height="23" Margin="5" Content="添加未在项目内找到的资产" />
                    <Button Command="{Binding Commands.SelectAssetCommand}" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.ButtonKey}}"  Height="23" Margin="5" Content="选择项目内已存在的资产" />
                </StackPanel>
                <DataGrid fw:DataGridDragCopyOptions.CanDragCopy="True" Grid.Row="1" Grid.Column="0"   AutoGenerateColumns="False"   FrozenColumnCount="1" ItemsSource="{Binding RefAssetItems}"
                CanUserAddRows="False"
                CanUserDeleteRows="False"
                VerticalScrollBarVisibility="Auto"
                HorizontalScrollBarVisibility="Auto"
                SelectionUnit="Cell"
                HeadersVisibility="Column" 
                CanUserSortColumns="True"   
                CellStyle="{StaticResource ResourceKey={x:Static uc:CommonStyles.DataGridCellKey}}"
                  AlternationCount="2"
                >
                    <DataGrid.RowStyle>
                        <Style TargetType="DataGridRow">
                            <Setter Property="ContextMenu">
                                <Setter.Value>
                                    <ContextMenu>
                                        <MenuItem Header="从项目清单中删除该资产" Command="{Binding Data.Commands.DeleteCommand,Source={StaticResource ResourceKey=DATA}}" CommandParameter="{Binding }"></MenuItem>
                                    </ContextMenu>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Height" Value="30"></Setter>
                            <Style.Triggers>
                                <Trigger Property="ItemsControl.AlternationIndex"
                                 Value="0">
                                    <Setter Property="Background" Value="White" />
                                </Trigger>
                                <Trigger Property="ItemsControl.AlternationIndex"
                                 Value="1">
                                    <Setter Property="Background" Value="#FFE6E3DD" />
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </DataGrid.RowStyle>
                    <DataGrid.Columns>
                        <DataGridTemplateColumn Header="操作"  Width="100" IsReadOnly="True" >
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button Command="{Binding DataContext.Commands.ScanAssetInfo,ElementName=this}" CommandParameter="{Binding }" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.LinkButtonKey}}"  VerticalAlignment="Center"   Content="查看资产详情" HorizontalAlignment="Left" Padding="5,0,5,0"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>

                        </DataGridTemplateColumn>
                        <fw:TDataGridTextColumn Header="本地名称" Width="100" IsReadOnly="True"  Binding="{Binding Path=LocalName}"></fw:TDataGridTextColumn>
                        <fw:TDataGridTextColumn Header="本地编码"  Width="100" IsReadOnly="True"  Binding="{Binding Path=LocalCode}"></fw:TDataGridTextColumn>
                        <fw:TDataGridTextColumn Header="资产编号"  Width="100" IsReadOnly="True"  Binding="{Binding Path=AssetNo}"></fw:TDataGridTextColumn>
                        <fw:TDataGridTextColumn Header="品牌"  Width="100" IsReadOnly="True"  Binding="{Binding Path=Brand}"></fw:TDataGridTextColumn>
                        <fw:TDataGridTextColumn Header="产品名"  Width="100" IsReadOnly="True"  Binding="{Binding Path=Product}"></fw:TDataGridTextColumn>
                        <fw:TDataGridTextColumn Header="型号"  Width="100" IsReadOnly="True"  Binding="{Binding Path=Type}"></fw:TDataGridTextColumn>

                        <DataGridTemplateColumn Header="采购价格" Width="80" SortMemberPath="ProcurementPrice" fw:DataGridDragCopyOptions.CanColumnDragCopy="True">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Border fw:ElementCopyOptions.UseCopy="True" fw:ElementCopyOptions.CopyValue="{Binding Path=ProcurementPrice,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}">
   <TextBlock Text="{Binding Path=ProcurementPrice}" VerticalAlignment="Center" ></TextBlock>
                                    </Border>
                                 
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <Border fw:ElementCopyOptions.UseCopy="True" fw:ElementCopyOptions.CopyValue="{Binding Path=ProcurementPrice,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}">
                                        <fw:DescriptionDecorator  Description="元"  Background="Black">
                                            <fw:TTextBox Text="{Binding ProcurementPrice, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0">
                                                <fw:TTextBox.TextControl>
                                                    <fw:AccessPlusDecimal></fw:AccessPlusDecimal>
                                                </fw:TTextBox.TextControl>
                                            </fw:TTextBox>
                                        </fw:DescriptionDecorator>
                                    </Border>

                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn Header="保修期" Width="80" SortMemberPath="Warranty" fw:DataGridDragCopyOptions.CanColumnDragCopy="True">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Border fw:ElementCopyOptions.UseCopy="True" fw:ElementCopyOptions.CopyValue="{Binding Path=Warranty,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}">
   <TextBlock Text="{Binding Path=Warranty}" VerticalAlignment="Center" ></TextBlock>
                                    </Border>
                                 
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <Border fw:ElementCopyOptions.UseCopy="True" fw:ElementCopyOptions.CopyValue="{Binding Path=Warranty,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}">
                                        <fw:DescriptionDecorator  Description="天"  Background="Black">
                                            <fw:TTextBox Text="{Binding Warranty, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0">
                                                <fw:TTextBox.TextControl>
                                                    <fw:AccessPlusDecimal></fw:AccessPlusDecimal>
                                                </fw:TTextBox.TextControl>
                                            </fw:TTextBox>
                                        </fw:DescriptionDecorator>
                                    </Border>

                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn Header="生产日期" Width="120" SortMemberPath="ProductionDate" fw:DataGridDragCopyOptions.CanColumnDragCopy="True">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Border fw:ElementCopyOptions.UseCopy="True" fw:ElementCopyOptions.CopyValue="{Binding Path=ProductionDate,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}">
<TextBlock Text="{Binding Path=ProductionDate,Converter={x:Static fw:DateTimeConverter.Date},StringFormat=yyyy年MM月dd日}"  VerticalAlignment="Center"></TextBlock>
                                    </Border>
                                    
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <DatePicker fw:ElementCopyOptions.UseCopy="True" fw:ElementCopyOptions.CopyValue="{Binding Path=ProductionDate,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" SelectedDate="{Binding Path=ProductionDate,Converter={x:Static fw:DateTimeConverter.Date}}" VerticalAlignment="Center"></DatePicker>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellEditingTemplate>
                        </DataGridTemplateColumn>
                        <fw:TDataGridTextColumn Header="出厂编号"  Width="70" IsReadOnly="True"  Binding="{Binding Path=ManufacturingNo}"></fw:TDataGridTextColumn>
                    </DataGrid.Columns>
                
                </DataGrid>
            </Grid>

        </GroupBox>
    </Grid>
</fw:NChildWindow>



