<localView:BeWoView x:Class="BeWo.View.Detail.Accounting.EquityInvoiceItemEditView" 
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:localView="clr-namespace:BeWo.View" 
                    xmlns:localViewModel="clr-namespace:BeWo.ViewModel" 
                    xmlns:localViewDetail="clr-namespace:BeWo.View.Detail.Accounting" 
                    xmlns:val="clr-namespace:BeWo.Validation" 
                    xmlns:proxy="clr-namespace:BeWo.ServiceProxy" 
                    xmlns:uc="clr-namespace:BeWo.Controls;assembly=BeWo.Controls" 
                    xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" 
                    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" Height="Auto" Width="Auto" HorizontalAlignment="Stretch" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:r="clr-namespace:BeWo.Security" VerticalAlignment="Stretch" Focusable="True" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic">

    <GroupBox MinHeight="200" Width="800" Style="{StaticResource PopUpWindowStyle}">

        <GroupBox.Header>
            <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,0,0,0">
                <Image Source="..\..\Ressources\Icons\CoinsDisabled.png" Height="28" />
                <TextBox Text="Rechnung bearbeiten" Margin="10,4,0,0" Background="{x:Null}" Foreground="{DynamicResource MainGroupBoxForegroundBrush}" FontSize="20" BorderBrush="{x:Null}" VerticalAlignment="Stretch" BorderThickness="0,0,0,0" Padding="0,0,0,0" />
            </StackPanel>
        </GroupBox.Header>

        <Grid Background="{StaticResource ObjectEditBackgroundBrush}">

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Rectangle Fill="{DynamicResource AccountingContentBrush}" VerticalAlignment="Top" Height="6" />

            <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
                <Grid Grid.IsSharedSizeScope="True" Margin="10,10,0,10">

                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <GroupBox Margin="3 6 3 6" Style="{StaticResource ObjectEditGroupBox}" Grid.ColumnSpan="2" Header="Rechnungsdetails">

                        <Grid>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <Label Content="Rechnungsnummer" />
                            <TextBox Margin="3" Height="23" Grid.Column="1" Text="{Binding Path=InvoiceNumber}" />

                            <Label Content="Ersteller Vorname" Grid.Row="0" Grid.Column="2" />
                            <TextBox Margin="3" Grid.Row="0" Grid.Column="3" Text="{Binding  CreatorFirstName}" Height="23" />

                            <Label Content="Ersteller Nachname" Grid.Row="0" Grid.Column="4" />
                            <TextBox Margin="3" Height="23" Grid.Row="0" Grid.Column="5" Text="{Binding  CreatorLastName}" />

                            <Label Content="Rechnungsdatum" Grid.Row="1" Grid.Column="0" />
                            <dxe:DateEdit MaskType="DateTimeAdvancingCaret" BorderThickness="1" Margin="3" Height="23" Grid.Row="1" Grid.Column="1" EditValue="{val:ValidationBinding Path=InvoiceDate, Mode=TwoWay}" />

                            <Label Content="Abrechnungszeitraum von" Grid.Row="1" Grid.Column="2" />
                            <dxe:DateEdit MaskType="DateTimeAdvancingCaret" BorderThickness="1" Height="23" Margin="3" Grid.Row="1" Grid.Column="3" EditValue="{val:ValidationBinding Path=AccountingPeriodStart}" />

                            <Label Content="Abrechnungszeitraum bis" Grid.Row="1" Grid.Column="4" />
                            <dxe:DateEdit MaskType="DateTimeAdvancingCaret" BorderThickness="1" Height="23" Margin="3" Grid.Row="1" Grid.Column="5" EditValue="{val:ValidationBinding Path=AccountingPeriodEnd}" />

                            <Label Grid.Column="0" Grid.Row="2" Content="anz Mahnungen" />
                            <dxe:SpinEdit MinValue="0" IsFloatValue="False" AllowNullInput="True" EditValue="{Binding Path=DunningLetterCount, Converter={StaticResource Int2DecimalConverter}}" Height="23" Margin="3" Grid.Row="2" Grid.Column="1" />

                            <Label Content="Bemerkung" Grid.Row="2" Grid.Column="2" />
                            <TextBox Grid.Row="2" Grid.Column="3" Grid.ColumnSpan="3" Margin="3" AcceptsReturn="True" TextWrapping="Wrap" Height="23" Text="{Binding  Notice}" />

                        </Grid>

                    </GroupBox>

                    <GroupBox Margin="3 6 6 3" Grid.Row="1" Style="{StaticResource ObjectEditGroupBox}" Header="Empfänger">

                        <Grid>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" SharedSizeGroup="col1" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" SharedSizeGroup="col3" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <Label Content="Vorname" />
                            <TextBox Margin="3" Grid.Row="0" Grid.Column="1" Text="{val:ValidationBinding Path=RecipientPersonFirstName}" Height="23" />

                            <Label Content="Nachname" Grid.Row="0" Grid.Column="2" />
                            <TextBox Margin="3" Grid.Row="0" Grid.Column="3" Text="{val:ValidationBinding Path=RecipientPersonLastName}" Height="23" />


                            <Label Content="Aktenzeichen" Grid.Row="1" Grid.Column="0" />
                            <TextBox Margin="3" Height="23" Grid.Row="1" Grid.Column="1" Text="{Binding  CustomerReferenceNumber}" />

                            <Label Content="Strasse" Grid.Row="1" Grid.Column="2" />
                            <TextBox Margin="3" Grid.Row="1" Grid.Column="3" Text="{val:ValidationBinding Path=RecipientStreet}" Height="23" />

                            <Label Content="Postleitzahl" Grid.Row="2" Grid.Column="0" />
                            <TextBox Margin="3,3,3,0" Grid.Row="2" Grid.Column="1" Text="{val:ValidationBinding Path=RecipientPostCode}" Height="23" />

                            <Label Content="Ort" Grid.Row="2" Grid.Column="2" />
                            <TextBox Margin="3" Grid.Row="2" Grid.Column="3" Text="{val:ValidationBinding Path=RecipientTown}" Height="23" />

                        </Grid>
                    </GroupBox>

                    <GroupBox Margin="6 6 3 3" Style="{StaticResource ObjectEditGroupBox}" Grid.Row="1" Grid.Column="2" Header="Absender">
                        <Grid>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" SharedSizeGroup="col1" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" SharedSizeGroup="col3" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <Label Content="Vorname" />
                            <TextBox Margin="3" Grid.Row="0" Grid.Column="1" Text="{Binding  SenderFirstName}" Height="23" />

                            <Label Content="Nachname" Grid.Row="0" Grid.Column="2" />
                            <TextBox Margin="3" Grid.Row="0" Grid.Column="3" Text="{Binding  SenderLastName}" Height="23" />

                            <Label Content="Organisation" Grid.Row="1" />
                            <TextBox Margin="3" Grid.Row="1" Grid.Column="1" Text="{Binding  SenderOrganisation}" Height="23" />

                            <Label Content="Abteilung" Grid.Row="1" Grid.Column="2" />
                            <TextBox Margin="3" Grid.Row="1" Grid.Column="3" Text="{Binding  SenderDivision}" Height="23" />

                            <Label Content="Fax" Grid.Row="2" Grid.Column="0" />
                            <TextBox Margin="3" Grid.Row="2" Grid.Column="1" Text="{Binding  SenderFax}" Height="23" />

                            <Label Content="Telefon" Grid.Row="2" Grid.Column="2" />
                            <TextBox Margin="3" Grid.Row="2" Grid.Column="3" Text="{Binding  SenderPhone}" Height="23" />


                        </Grid>

                    </GroupBox>

                    <GroupBox Margin="3 6 3 3" Style="{StaticResource ObjectEditGroupBox}" Grid.ColumnSpan="2" Grid.Row="2" Header="Rechnungsposten">

                        <dxg:GridControl MaxHeight="200" SnapsToDevicePixels="True" Margin="3" x:Name="datagrid_invoiceItems" DataSource="{Binding InvoiceItems.VMList}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                            <dxg:GridControl.Columns>
                                <dxg:GridColumn FieldName="Notice" Header="" FixedWidth="True" Width="24" ReadOnly="True">
                                    <dxg:GridColumn.CellTemplate>
                                        <DataTemplate>
                                            <Button Content="r" FontFamily="Webdings" Click="DeleteButton_Click" Width="18" Height="18" VerticalAlignment="Center" />
                                        </DataTemplate>
                                    </dxg:GridColumn.CellTemplate>
                                </dxg:GridColumn>
                                <dxg:GridColumn x:Name="colItemPeriodStart" FieldName="ItemPeriodStart" Header="Von" EditSettings="{dxe:DateSettings DisplayFormat=d}" Width="80" />
                                <dxg:GridColumn x:Name="colItemPeriodEnd" FieldName="ItemPeriodEnd" Header="Bis" EditSettings="{dxe:DateSettings DisplayFormat=d}" Width="80" />
                                <dxg:GridColumn FieldName="ItemDescription" Header="Posten" Width="150" />
                                <dxg:GridColumn x:Name="colAmountPerUnit" FieldName="AmountPerUnit" Header="Satz" Width="80">
                                    <dxg:GridColumn.EditSettings>
                                        <dxe:TextEditSettings DisplayFormat="c" Mask="c" MaskType="Numeric"></dxe:TextEditSettings>
                                    </dxg:GridColumn.EditSettings>
                                </dxg:GridColumn>
                                <dxg:GridColumn x:Name="colUnitCount" FieldName="UnitCount" Header="Anzahl" Width="80" />
                                <dxg:GridColumn x:Name="colAmountTotal" FieldName="AmountTotal" Header="Betrag">
                                    <dxg:GridColumn.CellStyle>
                                        <Style TargetType="dxg:CellContentPresenter">
                                            <Setter Property="FontWeight" Value="Bold" />
                                        </Style>
                                    </dxg:GridColumn.CellStyle>
                                    <dxg:GridColumn.EditSettings>
                                        <dxe:TextEditSettings DisplayFormat="c" Mask="c" MaskType="Numeric"></dxe:TextEditSettings>
                                    </dxg:GridColumn.EditSettings>
                                </dxg:GridColumn>
                            </dxg:GridControl.Columns>
                            <dxg:GridControl.View>
                                <dxg:TableView NewItemRowPosition="Top" Loaded="gridView_Loaded" x:Name="gridView" NavigationStyle="Cell" ShowGroupPanel="False" SnapsToDevicePixels="True" Margin="3" />
                            </dxg:GridControl.View>
                        </dxg:GridControl>

                    </GroupBox>

                </Grid>
            </ScrollViewer>

            <StackPanel Grid.ColumnSpan="2" Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Center" Height="Auto" Margin="5 0 5 5" HorizontalAlignment="Right">
                <Button x:Name="btnSave" Content="Speichern und schließen" Margin="5" Command="ApplicationCommands.Save" Height="25" />
                <Button x:Name="btnClose" Content="Abbrechen" Margin="5" Command="ApplicationCommands.Close" Height="25" />
            </StackPanel>

        </Grid>
    </GroupBox>

</localView:BeWoView>