CreatePerson UI tillaggt

This commit is contained in:
2020-05-17 20:30:24 +02:00
parent c13e2f3ccb
commit 94056f5f08
8 changed files with 180 additions and 3 deletions

View File

@ -0,0 +1,14 @@
using Caliburn.Micro;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TrackerWPFUI
{
public static class EventAggregationProvider
{
public static EventAggregator TrackerEventAggregator { get; set; } = new EventAggregator();
}
}

View File

@ -71,9 +71,14 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="BootStrapper.cs" />
<Compile Include="EventAggregationProvider.cs" />
<Compile Include="ViewModels\CreatePersonViewModel.cs" />
<Compile Include="ViewModels\CreatePrizeViewModel.cs" />
<Compile Include="ViewModels\CreateTeamViewModel.cs" />
<Compile Include="ViewModels\ShellViewModel.cs" />
<Compile Include="Views\CreatePersonView.xaml.cs">
<DependentUpon>CreatePersonView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\CreatePrizeView.xaml.cs">
<DependentUpon>CreatePrizeView.xaml</DependentUpon>
</Compile>
@ -87,6 +92,10 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Views\CreatePersonView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\CreatePrizeView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -0,0 +1,79 @@
using Caliburn.Micro;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TrackerLibrary;
using TrackerLibrary.Models;
namespace TrackerWPFUI.ViewModels
{
public class CreatePersonViewModel:Screen
{
private string _firstName="";
private string _lastName = "";
private string _email = "";
private string _cellphone = "";
public string FirstName
{
get { return _firstName; }
set { _firstName = value;
NotifyOfPropertyChange(() => FirstName);
}
}
public string LastName
{
get { return _lastName; }
set { _lastName = value;
NotifyOfPropertyChange(() => LastName);
}
}
public string Email
{
get { return _email; }
set { _email = value;
NotifyOfPropertyChange(() => Email);
}
}
public string Cellphone
{
get { return _cellphone; }
set { _cellphone = value;
NotifyOfPropertyChange(() => Cellphone);
}
}
public bool CanCreatePerson(string firstName, string lastName, string email, string cellphone)
{
if(firstName.Length>0 && lastName.Length>0 && email.Length>0 && cellphone.Length > 0)
{
return true;
}
else
{
return false;
}
}
public void CreatePerson(string firstName, string lastName, string email,string cellphone)
{
PersonModel p = new PersonModel();
p.FirstName = firstName;
p.LastName = lastName;
p.EmailAddress = email;
p.CellPhoneNumber = cellphone;
GlobalConfig.Connection.CreatePerson(p);
//TODO - Send results back to parent and close
}
}
}

View File

@ -18,7 +18,8 @@ namespace TrackerWPFUI.ViewModels
GlobalConfig.InitializeConnections(DatabaseType.Sql);
_existingTournaments = new BindableCollection<TournamentModel>(GlobalConfig.Connection.GetTournament_All());
//ActivateItem(new CreatePrizeViewModel());
ActivateItem(new CreateTeamViewModel());
//ActivateItem(new CreateTeamViewModel());
ActivateItem(new CreatePersonViewModel());
}
public void CreateTournament()
{

View File

@ -0,0 +1,46 @@
<UserControl x:Class="TrackerWPFUI.Views.CreatePersonView"
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:TrackerWPFUI.Views"
mc:Ignorable="d" Background="White"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<StackPanel Orientation="Vertical">
<TextBlock FontSize="24" Margin="0 0 0 10" >Create Person</TextBlock>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--row 0-->
<TextBlock Margin="5 0 10 10" Grid.Column="0" Grid.Row="0">First Name</TextBlock>
<TextBox x:Name="FirstName" Margin="0 0 5 10" Grid.Column="1" Grid.Row="0"></TextBox>
<!--row 1-->
<TextBlock Margin="5 0 10 10" Grid.Column="0" Grid.Row="1">Last Name</TextBlock>
<TextBox x:Name="LastName" Margin="0 0 5 10" Grid.Column="1" Grid.Row="1"></TextBox>
<!--row 2-->
<TextBlock Margin="5 0 10 10" Grid.Column="0" Grid.Row="2">Email</TextBlock>
<TextBox x:Name="Email" Margin="0 0 5 10" Grid.Column="2" Grid.Row="2"></TextBox>
<!--row 3-->
<TextBlock Margin="5 0 10 10" Grid.Column="0" Grid.Row="3">Cellphone</TextBlock>
<TextBox x:Name="Cellphone" Margin="0 0 5 10" Grid.Column="2" Grid.Row="3"></TextBox>
<!--row 4-->
<Button x:Name="CreatePerson" Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="2" Padding="10" Margin="5 0 ">
Create Person
</Button>
</Grid>
</StackPanel>
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace TrackerWPFUI.Views
{
/// <summary>
/// Interaction logic for CreatePersonView.xaml
/// </summary>
public partial class CreatePersonView : UserControl
{
public CreatePersonView()
{
InitializeComponent();
}
}
}

View File

@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:TrackerWPFUI.Views"
mc:Ignorable="d" Background="White"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<StackPanel Orientation="Vertical">

View File

@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:TrackerWPFUI.Views"
mc:Ignorable="d" Background="White"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<StackPanel Orientation="Vertical" >