First connection with entity object UI to Object

This commit is contained in:
2025-08-19 07:39:54 +02:00
parent 0d46bd3ade
commit 44419a880d
7 changed files with 124 additions and 32 deletions

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,44 @@
namespace AdventureWorks.EntityLayer.EntityClasses
{
public class User
{
public User()
{
LoginId = string.Empty;
FirstName = string.Empty;
LastName = string.Empty;
Email = string.Empty;
Password = string.Empty;
Phone = string.Empty;
PhoneType = string.Empty;
//IsFullTime = true;
//IsEnrolledIn401k = true;
//IsEnrolledInFlexTime = true;
//IsEnrolledInHealthCare = true;
//IsEnrolledInHSA = false;
//IsActive = true;
//BirthDate = "10-03-1975";
StartTime = new TimeSpan(6, 0, 0);
}
public int UserId { get; set; }
public string LoginId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public string Phone { get; set; }
public string PhoneType { get; set; }
public bool IsFullTime { get; set; }
public bool IsEnrolledIn401k { get; set; }
public bool IsEnrolledInFlexTime { get; set; }
public bool IsEnrolledInHealthCare { get; set; }
public bool IsEnrolledInHSA { get; set; }
public bool IsActive { get; set; }
public DateTime BirthDate { get; set; }
public TimeSpan StartTime { get; set; }
}
}

View File

@ -5,6 +5,8 @@ VisualStudioVersion = 17.14.36408.4
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventureWorks.MAUI", "AdventureWorks.MAUI\AdventureWorks.MAUI.csproj", "{403BA6B6-E816-4A0A-992D-E54FDCEA7E7D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventureWorks.MAUI", "AdventureWorks.MAUI\AdventureWorks.MAUI.csproj", "{403BA6B6-E816-4A0A-992D-E54FDCEA7E7D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventureWorks.EntityLayer", "AdventureWorks.EntityLayer\AdventureWorks.EntityLayer.csproj", "{33E62110-0EA1-48B1-B62F-CA856D13B114}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -13,8 +15,13 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{403BA6B6-E816-4A0A-992D-E54FDCEA7E7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {403BA6B6-E816-4A0A-992D-E54FDCEA7E7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{403BA6B6-E816-4A0A-992D-E54FDCEA7E7D}.Debug|Any CPU.Build.0 = Debug|Any CPU {403BA6B6-E816-4A0A-992D-E54FDCEA7E7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{403BA6B6-E816-4A0A-992D-E54FDCEA7E7D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{403BA6B6-E816-4A0A-992D-E54FDCEA7E7D}.Release|Any CPU.ActiveCfg = Release|Any CPU {403BA6B6-E816-4A0A-992D-E54FDCEA7E7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{403BA6B6-E816-4A0A-992D-E54FDCEA7E7D}.Release|Any CPU.Build.0 = Release|Any CPU {403BA6B6-E816-4A0A-992D-E54FDCEA7E7D}.Release|Any CPU.Build.0 = Release|Any CPU
{33E62110-0EA1-48B1-B62F-CA856D13B114}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33E62110-0EA1-48B1-B62F-CA856D13B114}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33E62110-0EA1-48B1-B62F-CA856D13B114}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33E62110-0EA1-48B1-B62F-CA856D13B114}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -64,6 +64,10 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AdventureWorks.EntityLayer\AdventureWorks.EntityLayer.csproj" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Update="Views\LoginView.xaml.cs"> <Compile Update="Views\LoginView.xaml.cs">
<DependentUpon>LoginView.xaml</DependentUpon> <DependentUpon>LoginView.xaml</DependentUpon>

View File

@ -5,6 +5,11 @@
x:Class="AdventureWorks.MAUI.App"> x:Class="AdventureWorks.MAUI.App">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<x:Array x:Key="phoneTypes" Type="{x:Type x:String}">
<x:String>Home</x:String>
<x:String>Mobile</x:String>
<x:String>Other</x:String>
</x:Array>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" /> <ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" /> <ResourceDictionary Source="Resources/Styles/Styles.xaml" />

View File

@ -4,13 +4,31 @@
x:Class="AdventureWorks.MAUI.Views.UserDetailView" x:Class="AdventureWorks.MAUI.Views.UserDetailView"
xmlns:partial="clr-namespace:AdventureWorks.MAUI.ViewsPartial" xmlns:partial="clr-namespace:AdventureWorks.MAUI.ViewsPartial"
xmlns:converters="clr-namespace:AdventureWorks.MAUI.Converters" xmlns:converters="clr-namespace:AdventureWorks.MAUI.Converters"
xmlns:vm="clr-namespace:AdventureWorks.EntityLayer.EntityClasses;assembly=AdventureWorks.EntityLayer"
x:DataType="vm:User"
Title="User Information"> Title="User Information">
<ContentPage.Resources> <ContentPage.Resources>
<converters:InvertedBoolConverter x:Key="invertedBoolean" /> <converters:InvertedBoolConverter x:Key="invertedBoolean" />
<vm:User x:Key="viewModel"
LoginId="JohnSmith123"
FirstName="John222"
LastName="Smith"
Email="john@smith.com"
Phone="615.222.2333"
PhoneType="Mobile"
IsFullTime="True"
IsEnrolledIn401k="True"
IsEnrolledInFlexTime="False"
IsEnrolledInHealthCare="True"
IsEnrolledInHSA="False"
IsActive="True"
BirthDate="10-03-1975"
/>
</ContentPage.Resources> </ContentPage.Resources>
<Border Style="{StaticResource Border.Page}"> <Border Style="{StaticResource Border.Page}"
BindingContext="{StaticResource viewModel}" >
<ScrollView> <ScrollView>
<Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto,Auto, Auto, Auto , Auto" <Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto,Auto, Auto, Auto , Auto"
ColumnDefinitions="Auto, *" ColumnDefinitions="Auto, *"
@ -23,11 +41,11 @@
ViewDescription="Use this Screen to Modify User Information." /> ViewDescription="Use this Screen to Modify User Information." />
<Label Grid.Row="1" <Label Grid.Row="1"
Text="Login ID" /> Text="Login ID" />
<VerticalStackLayout Grid.Row="3" <VerticalStackLayout Grid.Row="1"
Grid.Column="1"> Grid.Column="1">
<Entry Text="" <Entry Text="{Binding LoginId}"
Placeholder="Please use a combination of letters and numbers."/> Placeholder="Please use a combination of letters and numbers."/>
<Label FontSize="Micro" <Label FontSize="Micro"
Text="Please use a combination of letters and numbers." /> Text="Please use a combination of letters and numbers." />
@ -36,17 +54,17 @@
Text="First Name" /> Text="First Name" />
<Entry Grid.Row="2" <Entry Grid.Row="2"
Grid.Column="1" Grid.Column="1"
Text=""/> Text="{Binding FirstName}"/>
<Label Grid.Row="3" <Label Grid.Row="3"
Text="Last Name" /> Text="Last Name" />
<Entry Grid.Row="3" <Entry Grid.Row="3"
Grid.Column="1" Grid.Column="1"
Text=""/> Text="{Binding LastName}"/>
<Label Grid.Row="4" <Label Grid.Row="4"
Text="Email Address" /> Text="Email Address" />
<Entry Grid.Row="4" <Entry Grid.Row="4"
Grid.Column="1" Grid.Column="1"
Text=""/> Text="{Binding Email}"/>
<Label Grid.Row="5" Text="Is Enrolled ?"/> <Label Grid.Row="5" Text="Is Enrolled ?"/>
<FlexLayout Grid.Row="5" <FlexLayout Grid.Row="5"
@ -55,26 +73,27 @@
Direction="Row"> Direction="Row">
<HorizontalStackLayout> <HorizontalStackLayout>
<Label Text="401k?"/> <Label Text="401k?"/>
<CheckBox IsChecked="True"/> <CheckBox IsChecked="{Binding IsEnrolledIn401k}"/>
</HorizontalStackLayout> </HorizontalStackLayout>
<HorizontalStackLayout > <HorizontalStackLayout >
<Label Text="Flex Time?"/> <Label Text="Flex Time?"/>
<CheckBox x:Name="FlexTime"/> <CheckBox x:Name="FlexTime" IsChecked="{Binding IsEnrolledInFlexTime}"/>
</HorizontalStackLayout> </HorizontalStackLayout>
<HorizontalStackLayout > <HorizontalStackLayout >
<Label Text="Health Care?"/> <Label Text="Health Care?"/>
<CheckBox IsChecked="True"/> <CheckBox IsChecked="{Binding IsEnrolledInHealthCare}"/>
</HorizontalStackLayout> </HorizontalStackLayout>
<HorizontalStackLayout > <HorizontalStackLayout >
<Label Text="Health Savings Account?"/> <Label Text="Health Savings Account?"/>
<CheckBox IsChecked="True"/> <CheckBox IsChecked="{Binding IsEnrolledInHSA}"/>
</HorizontalStackLayout> </HorizontalStackLayout>
</FlexLayout> </FlexLayout>
<Label Grid.Row="6" <Label Grid.Row="6"
Text="Still Employed"/> Text="Still Employed"/>
<Switch Grid.Row="6" <Switch Grid.Row="6"
Grid.Column="1"/> Grid.Column="1"
IsToggled="{Binding IsActive}"/>
<Label Text="Employee Type" <Label Text="Employee Type"
Grid.Row="7"/> Grid.Row="7"/>
<FlexLayout Grid.Row="7" <FlexLayout Grid.Row="7"
@ -84,12 +103,12 @@
<HorizontalStackLayout> <HorizontalStackLayout>
<Label Text="Full-Time"/> <Label Text="Full-Time"/>
<RadioButton x:Name="FullTime" <RadioButton x:Name="FullTime"
IsChecked="True" IsChecked="{Binding IsFullTime}"
GroupName="EmployeeType"/> GroupName="EmployeeType"/>
</HorizontalStackLayout> </HorizontalStackLayout>
<HorizontalStackLayout> <HorizontalStackLayout>
<Label Text="Part-Time"/> <Label Text="Part-Time"/>
<RadioButton GroupName="EmployeeType"/> <RadioButton GroupName="EmployeeType" IsChecked="{Binding IsFullTime, Converter={StaticResource invertedBoolean}}"/>
</HorizontalStackLayout> </HorizontalStackLayout>
</FlexLayout> </FlexLayout>
@ -97,14 +116,14 @@
Grid.Row="8"/> Grid.Row="8"/>
<DatePicker Grid.Row="8" <DatePicker Grid.Row="8"
Grid.Column="1" Grid.Column="1"
Date="{Binding BirthDate}"
HorizontalOptions="Start"/> HorizontalOptions="Start"/>
<Label Text="Start Time" <Label Text="Start Time"
Grid.Row="9"/> Grid.Row="9"/>
<TimePicker Grid.Row="9" <TimePicker Grid.Row="9"
Grid.Column="1" Grid.Column="1"
Time="06:00:00" Time="{Binding StartTime}"
BindingContext="{x:Reference FullTime}" IsEnabled="{Binding IsFullTime, Converter={StaticResource invertedBoolean}}"/>
IsEnabled="{Binding IsChecked, Converter={StaticResource invertedBoolean}}"/>
<Label Text="Phone" <Label Text="Phone"
Grid.Row="10"/> Grid.Row="10"/>
@ -113,18 +132,12 @@
Wrap="Wrap" Wrap="Wrap"
Direction="Row"> Direction="Row">
<HorizontalStackLayout> <HorizontalStackLayout>
<Entry MinimumWidthRequest="120"/> <Entry MinimumWidthRequest="120"
Text="{Binding Phone}"/>
</HorizontalStackLayout> </HorizontalStackLayout>
<HorizontalStackLayout> <HorizontalStackLayout>
<Picker> <Picker ItemsSource="{StaticResource phoneTypes}"
<Picker.ItemsSource> SelectedItem="{Binding PhoneType}"/>
<x:Array Type="{x:Type x:String}">
<x:String>Home</x:String>
<x:String>Mobile</x:String>
<x:String>Other</x:String>
</x:Array>
</Picker.ItemsSource>
</Picker>
</HorizontalStackLayout> </HorizontalStackLayout>
</FlexLayout> </FlexLayout>
@ -134,7 +147,7 @@
<HorizontalStackLayout Grid.Row="12" <HorizontalStackLayout Grid.Row="12"
Grid.Column="1" Grid.Column="1"
Spacing="5"> Spacing="5">
<Button Text="Save" /> <Button Text="Save" Clicked="SaveButton_Clicked"/>
<Button Text="Cancel" /> <Button Text="Cancel" />
</HorizontalStackLayout> </HorizontalStackLayout>
</Grid> </Grid>

View File

@ -1,9 +1,19 @@
using AdventureWorks.EntityLayer.EntityClasses;
namespace AdventureWorks.MAUI.Views; namespace AdventureWorks.MAUI.Views;
public partial class UserDetailView : ContentPage public partial class UserDetailView : ContentPage
{ {
public UserDetailView() public UserDetailView()
{ {
InitializeComponent(); InitializeComponent();
} UserObject = (User)this.Resources["viewModel"];
}
public User UserObject { get; set; }
private void SaveButton_Clicked(object sender, EventArgs e)
{
System.Diagnostics.Debugger.Break();
}
} }