Automatically load data from DB

This commit is contained in:
Manuel Thalmann 2024-06-06 19:33:45 +02:00
parent 700bd69798
commit 5c1262355d
10 changed files with 2097 additions and 21 deletions

View file

@ -1,5 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="DataAdapter.Properties.Settings.FlughafenDBConnectionString"
connectionString="Data Source=(local);Initial Catalog=FlughafenDB;Integrated Security=True;TrustServerCertificate=True"
providerName="Microsoft.Data.SqlClient" />
</connectionStrings>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1" />
</startup> </startup>

View file

@ -170,6 +170,11 @@
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="FlughafenDBDataSet.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>FlughafenDBDataSet.xsd</DependentUpon>
</Compile>
<Compile Include="MainWindow.xaml.cs"> <Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
@ -193,6 +198,17 @@
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<None Include="FlughafenDBDataSet.xsc">
<DependentUpon>FlughafenDBDataSet.xsd</DependentUpon>
</None>
<None Include="FlughafenDBDataSet.xsd">
<Generator>MSDataSetGenerator</Generator>
<LastGenOutput>FlughafenDBDataSet.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</None>
<None Include="FlughafenDBDataSet.xss">
<DependentUpon>FlughafenDBDataSet.xsd</DependentUpon>
</None>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--<autogenerated>
This code was generated by a tool.
Changes to this file may cause incorrect behavior and will be lost if
the code is regenerated.
</autogenerated>-->
<DataSetUISetting Version="1.00" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TableUISettings>
<TableUISetting Name="Flug">
<ColumnUISettings>
<ColumnUISetting Name="Flug_ID">
<ControlSettings>
<ControlSetting ArtifactName="Microsoft:System.Windows:WPF">
<BindableControlInfo Name="[None]" Type="Microsoft.VSDesigner.Data.BindManager.NoneControlPlaceHolder" />
</ControlSetting>
</ControlSettings>
</ColumnUISetting>
</ColumnUISettings>
</TableUISetting>
</TableUISettings>
</DataSetUISetting>

View file

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="FlughafenDBDataSet" targetNamespace="http://tempuri.org/FlughafenDBDataSet.xsd" xmlns:mstns="http://tempuri.org/FlughafenDBDataSet.xsd" xmlns="http://tempuri.org/FlughafenDBDataSet.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:annotation>
<xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
<DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<Connections>
<Connection AppSettingsObjectName="Settings" AppSettingsPropertyName="FlughafenDBConnectionString" ConnectionStringObject="" IsAppSettingsProperty="true" Modifier="Assembly" Name="FlughafenDBConnectionString (Settings)" ParameterPrefix="@" PropertyReference="ApplicationSettings.DataAdapter.Properties.Settings.GlobalReference.Default.FlughafenDBConnectionString" Provider="Microsoft.Data.SqlClient" />
</Connections>
<Tables>
<TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="FlugTableAdapter" GeneratorDataComponentClassName="FlugTableAdapter" Name="Flug" UserDataComponentName="FlugTableAdapter">
<MainSource>
<DbSource ConnectionRef="FlughafenDBConnectionString (Settings)" DbObjectName="FlughafenDB.dbo.Flug" DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="true" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="true" UserGetMethodName="GetData" UserSourceName="Fill">
<DeleteCommand>
<DbCommand CommandType="Text" ModifiedByUser="false">
<CommandText>DELETE FROM [dbo].[Flug] WHERE (([Flug_ID] = @Original_Flug_ID) AND ([Flugnr] = @Original_Flugnr) AND ([Von] = @Original_Von) AND ([Nach] = @Original_Nach) AND ([Abflug] = @Original_Abflug) AND ([Ankunft] = @Original_Ankunft) AND ([Fluglinie_ID] = @Original_Fluglinie_ID) AND ([Flugzeug_ID] = @Original_Flugzeug_ID))</CommandText>
<Parameters>
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Flug_ID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Flug_ID" SourceColumnNullMapping="false" SourceVersion="Original" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_Flugnr" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="Flugnr" SourceColumnNullMapping="false" SourceVersion="Original" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int16" Direction="Input" ParameterName="@Original_Von" Precision="0" ProviderType="SmallInt" Scale="0" Size="0" SourceColumn="Von" SourceColumnNullMapping="false" SourceVersion="Original" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int16" Direction="Input" ParameterName="@Original_Nach" Precision="0" ProviderType="SmallInt" Scale="0" Size="0" SourceColumn="Nach" SourceColumnNullMapping="false" SourceVersion="Original" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@Original_Abflug" Precision="0" ProviderType="DateTime" Scale="0" Size="0" SourceColumn="Abflug" SourceColumnNullMapping="false" SourceVersion="Original" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@Original_Ankunft" Precision="0" ProviderType="DateTime" Scale="0" Size="0" SourceColumn="Ankunft" SourceColumnNullMapping="false" SourceVersion="Original" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Fluglinie_ID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Fluglinie_ID" SourceColumnNullMapping="false" SourceVersion="Original" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Flugzeug_ID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Flugzeug_ID" SourceColumnNullMapping="false" SourceVersion="Original" />
</Parameters>
</DbCommand>
</DeleteCommand>
<InsertCommand>
<DbCommand CommandType="Text" ModifiedByUser="false">
<CommandText>INSERT INTO [dbo].[Flug] ([Flugnr], [Von], [Nach], [Abflug], [Ankunft], [Fluglinie_ID], [Flugzeug_ID]) VALUES (@Flugnr, @Von, @Nach, @Abflug, @Ankunft, @Fluglinie_ID, @Flugzeug_ID);
SELECT Flug_ID, Flugnr, Von, Nach, Abflug, Ankunft, Fluglinie_ID, Flugzeug_ID FROM Flug WHERE (Flug_ID = SCOPE_IDENTITY())</CommandText>
<Parameters>
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Flugnr" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="Flugnr" SourceColumnNullMapping="false" SourceVersion="Current" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int16" Direction="Input" ParameterName="@Von" Precision="0" ProviderType="SmallInt" Scale="0" Size="0" SourceColumn="Von" SourceColumnNullMapping="false" SourceVersion="Current" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int16" Direction="Input" ParameterName="@Nach" Precision="0" ProviderType="SmallInt" Scale="0" Size="0" SourceColumn="Nach" SourceColumnNullMapping="false" SourceVersion="Current" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@Abflug" Precision="0" ProviderType="DateTime" Scale="0" Size="0" SourceColumn="Abflug" SourceColumnNullMapping="false" SourceVersion="Current" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@Ankunft" Precision="0" ProviderType="DateTime" Scale="0" Size="0" SourceColumn="Ankunft" SourceColumnNullMapping="false" SourceVersion="Current" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Fluglinie_ID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Fluglinie_ID" SourceColumnNullMapping="false" SourceVersion="Current" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Flugzeug_ID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Flugzeug_ID" SourceColumnNullMapping="false" SourceVersion="Current" />
</Parameters>
</DbCommand>
</InsertCommand>
<SelectCommand>
<DbCommand CommandType="Text" ModifiedByUser="false">
<CommandText>SELECT Flug_ID, Flugnr, Von, Nach, Abflug, Ankunft, Fluglinie_ID, Flugzeug_ID FROM dbo.Flug</CommandText>
<Parameters />
</DbCommand>
</SelectCommand>
<UpdateCommand>
<DbCommand CommandType="Text" ModifiedByUser="false">
<CommandText>UPDATE [dbo].[Flug] SET [Flugnr] = @Flugnr, [Von] = @Von, [Nach] = @Nach, [Abflug] = @Abflug, [Ankunft] = @Ankunft, [Fluglinie_ID] = @Fluglinie_ID, [Flugzeug_ID] = @Flugzeug_ID WHERE (([Flug_ID] = @Original_Flug_ID) AND ([Flugnr] = @Original_Flugnr) AND ([Von] = @Original_Von) AND ([Nach] = @Original_Nach) AND ([Abflug] = @Original_Abflug) AND ([Ankunft] = @Original_Ankunft) AND ([Fluglinie_ID] = @Original_Fluglinie_ID) AND ([Flugzeug_ID] = @Original_Flugzeug_ID));
SELECT Flug_ID, Flugnr, Von, Nach, Abflug, Ankunft, Fluglinie_ID, Flugzeug_ID FROM Flug WHERE (Flug_ID = @Flug_ID)</CommandText>
<Parameters>
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Flugnr" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="Flugnr" SourceColumnNullMapping="false" SourceVersion="Current" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int16" Direction="Input" ParameterName="@Von" Precision="0" ProviderType="SmallInt" Scale="0" Size="0" SourceColumn="Von" SourceColumnNullMapping="false" SourceVersion="Current" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int16" Direction="Input" ParameterName="@Nach" Precision="0" ProviderType="SmallInt" Scale="0" Size="0" SourceColumn="Nach" SourceColumnNullMapping="false" SourceVersion="Current" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@Abflug" Precision="0" ProviderType="DateTime" Scale="0" Size="0" SourceColumn="Abflug" SourceColumnNullMapping="false" SourceVersion="Current" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@Ankunft" Precision="0" ProviderType="DateTime" Scale="0" Size="0" SourceColumn="Ankunft" SourceColumnNullMapping="false" SourceVersion="Current" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Fluglinie_ID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Fluglinie_ID" SourceColumnNullMapping="false" SourceVersion="Current" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Flugzeug_ID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Flugzeug_ID" SourceColumnNullMapping="false" SourceVersion="Current" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Flug_ID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Flug_ID" SourceColumnNullMapping="false" SourceVersion="Original" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="AnsiString" Direction="Input" ParameterName="@Original_Flugnr" Precision="0" ProviderType="VarChar" Scale="0" Size="0" SourceColumn="Flugnr" SourceColumnNullMapping="false" SourceVersion="Original" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int16" Direction="Input" ParameterName="@Original_Von" Precision="0" ProviderType="SmallInt" Scale="0" Size="0" SourceColumn="Von" SourceColumnNullMapping="false" SourceVersion="Original" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int16" Direction="Input" ParameterName="@Original_Nach" Precision="0" ProviderType="SmallInt" Scale="0" Size="0" SourceColumn="Nach" SourceColumnNullMapping="false" SourceVersion="Original" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@Original_Abflug" Precision="0" ProviderType="DateTime" Scale="0" Size="0" SourceColumn="Abflug" SourceColumnNullMapping="false" SourceVersion="Original" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="DateTime" Direction="Input" ParameterName="@Original_Ankunft" Precision="0" ProviderType="DateTime" Scale="0" Size="0" SourceColumn="Ankunft" SourceColumnNullMapping="false" SourceVersion="Original" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Fluglinie_ID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Fluglinie_ID" SourceColumnNullMapping="false" SourceVersion="Original" />
<Parameter AllowDbNull="false" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="@Original_Flugzeug_ID" Precision="0" ProviderType="Int" Scale="0" Size="0" SourceColumn="Flugzeug_ID" SourceColumnNullMapping="false" SourceVersion="Original" />
<Parameter AllowDbNull="false" AutogeneratedName="Flug_ID" ColumnName="Flug_ID" DataSourceName="FlughafenDB.dbo.Flug" DataTypeServer="int" DbType="Int32" Direction="Input" ParameterName="@Flug_ID" Precision="0" ProviderType="Int" Scale="0" Size="4" SourceColumn="Flug_ID" SourceColumnNullMapping="false" SourceVersion="Current" />
</Parameters>
</DbCommand>
</UpdateCommand>
</DbSource>
</MainSource>
<Mappings>
<Mapping SourceColumn="Flug_ID" DataSetColumn="Flug_ID" />
<Mapping SourceColumn="Flugnr" DataSetColumn="Flugnr" />
<Mapping SourceColumn="Von" DataSetColumn="Von" />
<Mapping SourceColumn="Nach" DataSetColumn="Nach" />
<Mapping SourceColumn="Abflug" DataSetColumn="Abflug" />
<Mapping SourceColumn="Ankunft" DataSetColumn="Ankunft" />
<Mapping SourceColumn="Fluglinie_ID" DataSetColumn="Fluglinie_ID" />
<Mapping SourceColumn="Flugzeug_ID" DataSetColumn="Flugzeug_ID" />
</Mappings>
<Sources />
</TableAdapter>
</Tables>
<Sources />
</DataSource>
</xs:appinfo>
</xs:annotation>
<xs:element name="FlughafenDBDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:EnableTableAdapterManager="True" msprop:Generator_UserDSName="FlughafenDBDataSet" msprop:Generator_DataSetName="FlughafenDBDataSet">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Flug" msprop:Generator_RowEvHandlerName="FlugRowChangeEventHandler" msprop:Generator_RowDeletedName="FlugRowDeleted" msprop:Generator_RowDeletingName="FlugRowDeleting" msprop:Generator_RowEvArgName="FlugRowChangeEvent" msprop:Generator_TablePropName="Flug" msprop:Generator_RowChangedName="FlugRowChanged" msprop:Generator_RowChangingName="FlugRowChanging" msprop:Generator_TableClassName="FlugDataTable" msprop:Generator_RowClassName="FlugRow" msprop:Generator_TableVarName="tableFlug" msprop:Generator_UserTableName="Flug">
<xs:complexType>
<xs:sequence>
<xs:element name="Flug_ID" msdata:ReadOnly="true" msdata:AutoIncrement="true" msdata:AutoIncrementSeed="-1" msdata:AutoIncrementStep="-1" msprop:Generator_ColumnPropNameInRow="Flug_ID" msprop:Generator_ColumnPropNameInTable="Flug_IDColumn" msprop:Generator_ColumnVarNameInTable="columnFlug_ID" msprop:Generator_UserColumnName="Flug_ID" type="xs:int" />
<xs:element name="Flugnr" msprop:Generator_ColumnPropNameInRow="Flugnr" msprop:Generator_ColumnPropNameInTable="FlugnrColumn" msprop:Generator_ColumnVarNameInTable="columnFlugnr" msprop:Generator_UserColumnName="Flugnr">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="8" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Von" msprop:Generator_ColumnPropNameInRow="Von" msprop:Generator_ColumnPropNameInTable="VonColumn" msprop:Generator_ColumnVarNameInTable="columnVon" msprop:Generator_UserColumnName="Von" type="xs:short" />
<xs:element name="Nach" msprop:Generator_ColumnPropNameInRow="Nach" msprop:Generator_ColumnPropNameInTable="NachColumn" msprop:Generator_ColumnVarNameInTable="columnNach" msprop:Generator_UserColumnName="Nach" type="xs:short" />
<xs:element name="Abflug" msprop:Generator_ColumnPropNameInRow="Abflug" msprop:Generator_ColumnPropNameInTable="AbflugColumn" msprop:Generator_ColumnVarNameInTable="columnAbflug" msprop:Generator_UserColumnName="Abflug" type="xs:dateTime" />
<xs:element name="Ankunft" msprop:Generator_ColumnPropNameInRow="Ankunft" msprop:Generator_ColumnPropNameInTable="AnkunftColumn" msprop:Generator_ColumnVarNameInTable="columnAnkunft" msprop:Generator_UserColumnName="Ankunft" type="xs:dateTime" />
<xs:element name="Fluglinie_ID" msprop:Generator_ColumnPropNameInRow="Fluglinie_ID" msprop:Generator_ColumnPropNameInTable="Fluglinie_IDColumn" msprop:Generator_ColumnVarNameInTable="columnFluglinie_ID" msprop:Generator_UserColumnName="Fluglinie_ID" type="xs:int" />
<xs:element name="Flugzeug_ID" msprop:Generator_ColumnPropNameInRow="Flugzeug_ID" msprop:Generator_ColumnPropNameInTable="Flugzeug_IDColumn" msprop:Generator_ColumnVarNameInTable="columnFlugzeug_ID" msprop:Generator_UserColumnName="Flugzeug_ID" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:Flug" />
<xs:field xpath="mstns:Flug_ID" />
</xs:unique>
</xs:element>
</xs:schema>

View file

@ -0,0 +1 @@


View file

@ -5,8 +5,71 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DataAdapter" xmlns:local="clr-namespace:DataAdapter"
mc:Ignorable="d" mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800"> Title="MainWindow" Height="800" Width="800" Loaded="Window_Loaded">
<Grid> <Window.Resources>
<local:FlughafenDBDataSet x:Key="flughafenDBDataSet"/>
<CollectionViewSource x:Key="flugViewSource" Source="{Binding Flug, Source={StaticResource flughafenDBDataSet}}"/>
</Window.Resources>
<Grid DataContext="{StaticResource flugViewSource}">
<Grid.RowDefinitions>
<RowDefinition Height="75" />
<RowDefinition Height="300" />
<RowDefinition/>
</Grid.RowDefinitions>
<Button HorizontalAlignment="Left" Margin="22,20,0,24" Name="backButton" Width="75" Click="BackButton_Click">&#60;</Button>
<Button HorizontalAlignment="Left" Margin="116,20,0,24" Name="nextButton" Width="75" Click="NextButton_Click">&#62;</Button>
<Button HorizontalAlignment="Right" Margin="0,21,46,24" Name="saveButton" Width="110" Click="saveButton_Click">Save changes</Button>
<Grid x:Name="grid1" DataContext="{StaticResource flugViewSource}" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</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 Grid.Column="0" Content="Flugnr:" HorizontalAlignment="Left" Margin="3" Grid.Row="0" VerticalAlignment="Center"/>
<TextBox x:Name="flugnrTextBox" Grid.Column="1" HorizontalAlignment="Left" Height="NaN" Margin="3" Grid.Row="0" Text="{Binding Flugnr, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="120"/>
<Label Grid.Column="0" Content="Von:" HorizontalAlignment="Left" Margin="3" Grid.Row="1" VerticalAlignment="Center"/>
<TextBox x:Name="vonTextBox" Grid.Column="1" HorizontalAlignment="Left" Height="NaN" Margin="3" Grid.Row="1" Text="{Binding Von, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="120"/>
<Label Grid.Column="0" Content="Nach:" HorizontalAlignment="Left" Margin="3" Grid.Row="2" VerticalAlignment="Center"/>
<TextBox x:Name="nachTextBox" Grid.Column="1" HorizontalAlignment="Left" Height="NaN" Margin="3" Grid.Row="2" Text="{Binding Nach, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="120"/>
<Label Grid.Column="0" Content="Abflug:" HorizontalAlignment="Left" Margin="3" Grid.Row="3" VerticalAlignment="Center"/>
<DatePicker x:Name="abflugDatePicker" Grid.Column="1" HorizontalAlignment="Left" Margin="3" Grid.Row="3" SelectedDate="{Binding Abflug, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" VerticalAlignment="Center"/>
<Label Grid.Column="0" Content="Ankunft:" HorizontalAlignment="Left" Margin="3" Grid.Row="4" VerticalAlignment="Center"/>
<DatePicker x:Name="ankunftDatePicker" Grid.Column="1" HorizontalAlignment="Left" Margin="3" Grid.Row="4" SelectedDate="{Binding Ankunft, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" VerticalAlignment="Center"/>
<Label Grid.Column="0" Content="Fluglinie ID:" HorizontalAlignment="Left" Margin="3" Grid.Row="5" VerticalAlignment="Center"/>
<TextBox x:Name="fluglinie_IDTextBox" Grid.Column="1" HorizontalAlignment="Left" Height="NaN" Margin="3" Grid.Row="5" Text="{Binding Fluglinie_ID, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="120"/>
<Label Grid.Column="0" Content="Flugzeug ID:" HorizontalAlignment="Left" Margin="3" Grid.Row="6" VerticalAlignment="Center"/>
<TextBox x:Name="flugzeug_IDTextBox" Grid.Column="1" HorizontalAlignment="Left" Height="NaN" Margin="3" Grid.Row="6" Text="{Binding Flugzeug_ID, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" VerticalAlignment="Center" Width="120"/>
</Grid>
<DataGrid x:Name="flugDataGrid" AutoGenerateColumns="False" EnableRowVirtualization="True" ItemsSource="{Binding}" RowDetailsVisibilityMode="VisibleWhenSelected" Grid.Row="2">
<DataGrid.Columns>
<DataGridTextColumn x:Name="flugnrColumn" Binding="{Binding Flugnr}" Header="Flugnr" Width="SizeToHeader"/>
<DataGridTextColumn x:Name="vonColumn" Binding="{Binding Von}" Header="Von" Width="SizeToHeader"/>
<DataGridTextColumn x:Name="nachColumn" Binding="{Binding Nach}" Header="Nach" Width="SizeToHeader"/>
<DataGridTemplateColumn x:Name="abflugColumn" Header="Abflug" Width="SizeToHeader">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<DatePicker SelectedDate="{Binding Abflug, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn x:Name="ankunftColumn" Header="Ankunft" Width="SizeToHeader">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<DatePicker SelectedDate="{Binding Ankunft, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn x:Name="fluglinie_IDColumn" Binding="{Binding Fluglinie_ID}" Header="Fluglinie ID" Width="SizeToHeader"/>
<DataGridTextColumn x:Name="flugzeug_IDColumn" Binding="{Binding Flugzeug_ID}" Header="Flugzeug ID" Width="SizeToHeader"/>
</DataGrid.Columns>
</DataGrid>
</Grid> </Grid>
</Window> </Window>

View file

@ -20,9 +20,39 @@ namespace DataAdapter
/// </summary> /// </summary>
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
private FlughafenDBDataSet flughafenDBDataSet;
private FlughafenDBDataSetTableAdapters.FlugTableAdapter flughafenDBDataSetFlugTableAdapter;
private CollectionViewSource flugViewSource;
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
} }
private void Window_Loaded(object sender, RoutedEventArgs e)
{
flughafenDBDataSet = (FlughafenDBDataSet)FindResource("flughafenDBDataSet");
// Load data into the table Flug. You can modify this code as needed.
flughafenDBDataSetFlugTableAdapter = new FlughafenDBDataSetTableAdapters.FlugTableAdapter();
flughafenDBDataSetFlugTableAdapter.Fill(flughafenDBDataSet.Flug);
flugViewSource = (CollectionViewSource)FindResource("flugViewSource");
flugViewSource.View.MoveCurrentToFirst();
}
private void BackButton_Click(object sender, RoutedEventArgs e)
{
flugViewSource.View.MoveCurrentToPrevious();
}
private void NextButton_Click(object sender, RoutedEventArgs e)
{
flugViewSource.View.MoveCurrentToNext();
}
private void saveButton_Click(object sender, RoutedEventArgs e)
{
flughafenDBDataSetFlugTableAdapter.Update(flughafenDBDataSet.Flug);
}
} }
} }

View file

@ -8,23 +8,30 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace DataAdapter.Properties namespace DataAdapter.Properties {
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default public static Settings Default {
{ get {
get
{
return defaultInstance; return defaultInstance;
} }
} }
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
[global::System.Configuration.DefaultSettingValueAttribute("Data Source=(local);Initial Catalog=FlughafenDB;Integrated Security=True;TrustSer" +
"verCertificate=True")]
public string FlughafenDBConnectionString {
get {
return ((string)(this["FlughafenDBConnectionString"]));
}
}
} }
} }

View file

@ -1,7 +1,14 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="DataAdapter.Properties" GeneratedClassName="Settings">
<Profiles> <Profiles />
<Profile Name="(Default)" /> <Settings>
</Profiles> <Setting Name="FlughafenDBConnectionString" Type="(Connection string)" Scope="Application">
<Settings /> <DesignTimeValue Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;SerializableConnectionString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
&lt;ConnectionString&gt;Data Source=(local);Initial Catalog=FlughafenDB;Integrated Security=True;TrustServerCertificate=True&lt;/ConnectionString&gt;
&lt;ProviderName&gt;Microsoft.Data.SqlClient&lt;/ProviderName&gt;
&lt;/SerializableConnectionString&gt;</DesignTimeValue>
<Value Profile="(Default)">Data Source=(local);Initial Catalog=FlughafenDB;Integrated Security=True;TrustServerCertificate=True</Value>
</Setting>
</Settings>
</SettingsFile> </SettingsFile>