Commit fc269ae8 authored by islater's avatar islater
Browse files

there is a better way to do this but i am tired and want to sleep

parent 2ece5fe5
......@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:PointOfSale"
mc:Ignorable="d"
Width="120" Height="120"
d:DesignHeight="120" d:DesignWidth="120">
d:DesignHeight="100" d:DesignWidth="120">
<Border BorderBrush="Gray" BorderThickness="1" Padding="5">
<Grid>
<Grid.ColumnDefinitions>
......@@ -18,13 +18,13 @@
<RowDefinition Height="4*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<Border BorderThickness="10" BorderBrush="ForestGreen" Grid.ColumnSpan="3" Background="Green" Grid.Column="0">
<!--<TextBlock Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:BillControll}}}"/>-->
<Border BorderThickness="10" BorderBrush="DarkGreen" Grid.ColumnSpan="3" Background="Green" Grid.Column="0">
<TextBox BorderThickness="0" Grid.Row="1" Background="Green" FontSize="25" Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:BillControll}},Path=Denomination}"/>
</Border>
<Button Grid.Row="1" Grid.Column="0" Click="OnDecreaseClicked" Content="-"/>
<!--<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:BillControll}}, Path=Quantity}"/>-->
<Button Grid.Row="1" Grid.Column="2" Click="OnIncreaseClicked" Content="+"/>
<Button Grid.Column="0" FontSize="10" Click="OnDecreaseClicked" Content="-" Margin="-5,50,5,0" Grid.RowSpan="2"/>
<TextBox FontSize="25" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:BillControll}}, Path=Quantity}" Grid.ColumnSpan="3" Margin="34,50,34,0" Grid.RowSpan="2"/>
<Button Grid.Column="2" FontSize="10" Click="OnIncreaseClicked" Content="+" Margin="5,50,-5,0" Grid.RowSpan="2"/>
</Grid>
</Border>
</UserControl>
<Window x:Class="PointOfSale.CashControll"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PointOfSale"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<UserControl x:Class="PointOfSale.CashControll"
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:PointOfSale"
mc:Ignorable="d"
DataContext="Data.CashRegisterModelView"
d:DesignHeight="500" d:DesignWidth="700">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition Height="120" />
<RowDefinition Height="120" />
<RowDefinition Height="120" />
<RowDefinition Height="120" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center">
<local:BillControll Denomination="One" Quantity="{Binding Path=Ones}"/>
......@@ -17,17 +21,23 @@
<local:BillControll Denomination="Five" Quantity="{Binding Path=Fives}"/>
<local:BillControll Denomination="Ten" Quantity="{Binding Path=Tens}"/>
<local:BillControll Denomination="Twenty" Quantity="{Binding Path=Twenties}"/>
</StackPanel>
<StackPanel Orientation ="Horizontal" Grid.Row="1" VerticalAlignment="Top" HorizontalAlignment="Center">
<local:BillControll Denomination="Fifty" Quantity="{Binding Path=Fifties}"/>
<local:BillControll Denomination="Hundred" Quantity="{Binding Path=Hundreds}"/>
<local:CoinControll Width="170" Denomination="Penny" Quantity="{Binding Path=Pennies}"/>
<local:CoinControll Width="170" Denomination="Nickel" Quantity="{Binding Path=Nickels}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1" VerticalAlignment="Top" HorizontalAlignment="Center">
<local:CoinControll Denomination="Penny" Quantity="{Binding Path=Pennies}"/>
<local:CoinControll Denomination="Nickel" Quantity="{Binding Path=Nickels}"/>
<local:CoinControll Denomination="Dime" Quantity="{Binding Path=Dimes}"/>
<local:CoinControll Denomination="Quarter" Quantity="{Binding Path=Quarters}"/>
<local:CoinControll Denomination="HalfDollar" Quantity="{Binding Path=HalfDollars}"/>
<local:CoinControll Denomination="Dollar" Quantity="{Binding Path=Dollars}"/>
<StackPanel Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center">
<local:CoinControll Width="170" Denomination="Dime" Quantity="{Binding Path=Dimes}" />
<local:CoinControll Width="170" Denomination="Quarter" Quantity="{Binding Path=Quarters}"/>
<local:CoinControll Width="170" Denomination="HalfDollar" Quantity="{Binding Path=HalfDollars}"/>
<local:CoinControll Width="170" Denomination="Dollar" Quantity="{Binding Path=Dollars}"/>
</StackPanel>
<Button Content="Button" HorizontalAlignment="Center" Grid.Row="3" VerticalAlignment="Top" Height="62" Width="157" Margin="0,10,0,0" Click="Button_Click"/>
</Grid>
</Window>
</UserControl>
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;
......@@ -12,22 +10,28 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using CashRegister;
namespace PointOfSale
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// Interaction logic for CashControll.xaml
/// </summary>
public partial class CashControll : Window
public partial class CashControll : UserControl
{
public CashControll()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var a = (CashRegisterModelView)DataContext;
double total = a.TotalValue;
//public List<typeof(Pennoes)> = new List<T>{Pennies,};
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using CashRegister;
using System.ComponentModel;
namespace MVVMDataBinding
namespace PointOfSale
{
public class CashRegisterModelView : INotifyPropertyChanged
{
......@@ -32,42 +32,40 @@ namespace MVVMDataBinding
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("TotalValue"));
}
private int pennies = 0;
public int Pennies
{
get => drawer.Pennies;
get => pennies;
set
{
if (drawer.Pennies == value || value < 0)
if (pennies + value < 0)
return;
var quantity = value - drawer.Pennies;
if (quantity > 0)
drawer.AddCoin(Coins.Penny, quantity);
else
drawer.RemoveCoin(Coins.Penny, -quantity);
InvokePropertyChanger("Pennies");
pennies += value;
}
}
private int nickles = 0;
public int Nickles
{
get => drawer.Nickels;
get => nickles;
set
{
if (drawer.Nickels == value || value < 0)
if (nickles == value || value < 0)
return;
var quantity = value - drawer.Nickels;
var quantity = value - nickles;
if (quantity > 0)
drawer.AddCoin(Coins.Nickel, quantity);
pennies += quantity;
else
drawer.RemoveCoin(Coins.Nickel, -quantity);
InvokePropertyChanger("Nickels");
pennies -= quantity;
}
}
private int dimes = 0;
public int Dimes
{
get => drawer.Dimes;
get => dimes;
set
{
if (drawer.Dimes == value || value < 0)
......@@ -80,10 +78,10 @@ namespace MVVMDataBinding
InvokePropertyChanger("Dimes");
}
}
private int quarters = 0;
public int Quarters
{
get => drawer.Quarters;
get => quarters;
set
{
if (drawer.Quarters == value || value < 0)
......@@ -96,12 +94,13 @@ namespace MVVMDataBinding
InvokePropertyChanger("Quarters");
}
}
private int halfdollars = 0;
public int HalfDollers
{
get => drawer.HalfDollars;
get => halfdollars;
set
{
halfdollars++;
if (drawer.HalfDollars == value || value < 0)
return;
var quantity = value - drawer.HalfDollars;
......@@ -112,12 +111,13 @@ namespace MVVMDataBinding
InvokePropertyChanger("HalfDollars");
}
}
private int dollars = 0;
public int Dollars
{
get => drawer.Dollars;
get => dollars;
set
{
if (drawer.Dollars == value || value < 0)
return;
var quantity = value - drawer.Dollars;
......@@ -128,122 +128,168 @@ namespace MVVMDataBinding
InvokePropertyChanger("Dollars");
}
}
private int ones = 0;
public int Ones
{
get => drawer.Ones;
get => ones;
set
{
if (drawer.Ones == value || value < 0)
return;
var quantity = value - drawer.Ones;
if (quantity > 0)
{
drawer.AddBill(Bills.One, quantity);
ones += quantity;
}
else
{
drawer.RemoveBill(Bills.One, -quantity);
ones -= quantity;
}
InvokePropertyChanger("Ones");
}
}
private int twos = 0;
public int Twos
{
get => drawer.Twos;
get => twos;
set
{
if (drawer.Twos == value || value < 0)
return;
var quantity = value - drawer.Twos;
if (quantity > 0)
{
drawer.AddBill(Bills.Two, quantity);
twos += quantity;
}
else
{
drawer.RemoveBill(Bills.Two, -quantity);
twos += quantity;
}
InvokePropertyChanger("Twos");
}
}
private int fives = 0;
public int Fives
{
get => drawer.Fives;
get => fives;
set
{
if (drawer.Fives == value || value < 0)
return;
var quantity = value - drawer.Fives;
if (quantity > 0)
{
drawer.AddBill(Bills.Five, quantity);
fives += quantity;
}
else
{
drawer.RemoveBill(Bills.Five, -quantity);
fives -= quantity;
}
InvokePropertyChanger("Fives");
}
}
private int tens = 0;
public int Tens
{
get => drawer.Tens;
get => tens;
set
{
if (drawer.Tens == value || value < 0)
return;
var quantity = value - drawer.Tens;
if (quantity > 0)
{
drawer.AddBill(Bills.Ten, quantity);
tens += quantity;
}
else
{
drawer.RemoveBill(Bills.Ten, -quantity);
tens -= quantity;
}
InvokePropertyChanger("Tens");
}
}
private int twenties = 0;
public int Twenties
{
get => drawer.Twenties;
get => twenties;
set
{
if (drawer.Twenties == value || value < 0)
return;
var quantity = value - drawer.Twenties;
if (quantity > 0)
{
drawer.AddBill(Bills.Twenty, quantity);
twenties += quantity;
}
else
{
drawer.RemoveBill(Bills.Twenty, -quantity);
twenties -= quantity;
}
InvokePropertyChanger("Twenties");
}
}
private int fifties = 0;
public int Fifties
{
get => drawer.Fifties;
get => fifties;
set
{
if (drawer.Fifties == value || value < 0)
return;
var quantity = value - drawer.Fifties;
if (quantity > 0)
{
drawer.AddBill(Bills.Fifty, quantity);
fifties += quantity;
}
else
{
fifties -= quantity;
drawer.RemoveBill(Bills.Fifty, -quantity);
}
InvokePropertyChanger("Fifties");
}
}
private int hundreds = 0;
public int Hundreds
{
get => drawer.Hundreds;
get => hundreds;
set
{
if (drawer.Hundreds == value || value < 0)
return;
var quantity = value - drawer.Hundreds;
if (quantity > 0)
{
drawer.AddBill(Bills.Hundred, quantity);
hundreds += quantity;
}
else
{
drawer.RemoveBill(Bills.Hundred, -quantity);
InvokePropertyChanger("Hundreds");
hundreds -= quantity;
}
InvokePropertyChanger("Hundreds");
}
}
}
}
......@@ -18,12 +18,12 @@
<RowDefinition Height="4*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<Border BorderThickness="1" BorderBrush="Goldenrod" CornerRadius="50" Background="Gold" Margin="-8 0" Grid.Column="1">
<!--<TextBlock VerticalAlignment="Center" TextAlignment="Center" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:CoinControll}}}"/>-->
<Border BorderThickness="1" Width="100" BorderBrush="Goldenrod" Grid.ColumnSpan="3" CornerRadius="50" Background="Gold" Margin="-8 0" >
<TextBox Grid.ColumnSpan="2" BorderThickness="0" Background="Transparent" Grid.Row="1" FontSize="25" Grid.Column="1" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:CoinControll}},Path=Denomination}"/>
</Border>
<Button Grid.Row="1" Grid.Column="0" Click="OnDecreaseClicked" Content="-"/>
<!--<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:CoinControll}}, Path=Quantity}"/>-->
<TextBox Grid.Row="1" FontSize="25" Grid.Column="1" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:CoinControll}}, Path=Quantity}"/>
<Button Grid.Row="1" Grid.Column="2" Click="OnIncreaseClicked" Content="+"/>
</Grid>
</Border>
......
......@@ -22,6 +22,7 @@ namespace PointOfSale
public CoinControll()
{
InitializeComponent();
//denominationTextBox.Text = Denomination.ToString();
}
......
......@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PointOfSale"
mc:Ignorable="d"
Title="MainWindow" Height="632" Width="1000">
Title="MainWindow" Height="700" Width="1000">
<Grid RenderTransformOrigin="0.568,0.499">
<Grid.RowDefinitions>
......
......@@ -7,7 +7,7 @@
mc:Ignorable="d"
d:DesignHeight="420" d:DesignWidth="700">
<UserControl.Resources>
<UserControl.Resources>
<Style TargetType="Button">
<Setter Property="Height" Value="45"/>
<Setter Property="Width" Value="200"/>
......
......@@ -30,6 +30,7 @@ namespace PointOfSale
InitializeComponent();
}
private RegisterControll registercontroll = null;
private void AngryChickenButton_Click(object sender, RoutedEventArgs e)
{
AngryChicken ac = new AngryChicken();
......@@ -214,7 +215,14 @@ namespace PointOfSale
{
if (o == null)
MainWindow.Child = new OrderControl();
else
else if (o is RegisterControll)
{
if (registercontroll == null)
registercontroll = new RegisterControll();
registercontroll.Clear_Order();
MainWindow.Child = registercontroll;
}
else
MainWindow.Child = o;
}
......
......@@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:PointOfSale"
mc:Ignorable="d"
d:DesignHeight="570" d:DesignWidth="300">
d:DesignHeight="700" d:DesignWidth="300">
<UserControl.Resources>
<Style TargetType="TextBlock">
<Setter Property = "FontSize" Value = "20" />
......@@ -15,7 +15,7 @@
<Grid>
<Border BorderThickness="1" BorderBrush="Black" Margin="10,38,10,60">
<Border BorderThickness="1" Height="550" BorderBrush="Black" Margin="10,35,10,115">
<ListBox Name="ticket" HorizontalContentAlignment="Stretch" ItemsSource="{Binding Path=Items}" Margin="0,0,-1,-1">
<ListBox.ItemTemplate >
<DataTemplate >
......@@ -38,9 +38,9 @@
</ListBox.ItemTemplate>
</ListBox>
</Border>
<TextBlock Name="SubtotalTextBox" HorizontalAlignment="Right" Margin="0,533,10,0" FontSize="20" Text="{Binding Path=Subtotal, StringFormat=c}" TextWrapping="Wrap" VerticalAlignment="Top" Height="31" Width="84"/>
<TextBlock HorizontalAlignment="Left" Margin="7,534,0,0" FontSize="20" TextWrapping="Wrap" VerticalAlignment="Top" Height="30" Width="90">Subtotal</TextBlock>
<TextBlock Name="SubtotalTextBox" HorizontalAlignment="Right" Margin="0,604,7,0" FontSize="20" Text="{Binding Path=Subtotal, StringFormat=c}" TextWrapping="Wrap" VerticalAlignment="Top" Height="31" Width="84"/>
<TextBlock HorizontalAlignment="Left" Margin="10,605,0,0" FontSize="20" TextWrapping="Wrap" VerticalAlignment="Top" Height="30" Width="90">Subtotal</TextBlock>
<TextBlock HorizontalAlignment="Left" Margin="10,-2,0,0" Text="Ticket" FontSize="20" TextWrapping="Wrap" VerticalAlignment="Top" Width="70"/>
<TextBlock x:Name="OrderNumber" HorizontalAlignment="Left" Margin="206,2,0,0" FontSize="20" Text="{Binding OrderNumber}" TextWrapping="Wrap" VerticalAlignment="Top" Height="31" Width="84"/>
......
<UserControl x:Class="PointOfSale.RegisterControll"
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:PointOfSale"
mc:Ignorable="d"
d:DesignHeight="420" d:DesignWidth="700">
<UserControl.Resources>
<Style TargetType="Button">
<Setter Property="Height" Value="30"/>
<Setter Property="Width" Value="60"/>
<Setter Property = "VerticalAlignment" Value = "Bottom" />
<Setter Property = "FontSize" Value = "30" />
</Style>
<Style TargetType="TextBlock">
<Setter Property = "TextAlignment" Value = "Center" />
<Setter Property = "FontSize" Value = "20" />
<Setter Property = "Height" Value = "50" />
<Setter Property = "VerticalAlignment" Value = "Top" />
</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="105"/>
<RowDefinition Height="105"/>
<RowDefinition Height="105"/>
<RowDefinition Height="105"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="Pennies" />
<Button Content="-" HorizontalAlignment="Left" Width="36" Height="43" Click="Pennies_minus" />
<TextBlock Text="0" Name="PenniesText" HorizontalAlignment="Center" Margin="41,70,41,0" Height="36" />
<Button Content="+" HorizontalAlignment="Right" Width="36" Height="43" Click="Pennies_add" />
<TextBlock Text="Nickles" Grid.Column="1" Grid.Row="0"/>
<Button Content="-" HorizontalAlignment="Left" Width="36" Height="43" Grid.Column="1" Grid.Row="0" Click="Nickles_minus"/>
<TextBlock Text="0" Name="NicklesText" HorizontalAlignment="Center" Margin="41,70,41,0" Height="36" Grid.Column="1" Grid.Row="0" />
<Button Content="+" HorizontalAlignment="Right" Width="36" Height="43" Grid.Column="1" Grid.Row="0" Click="Nickles_add"/>
<TextBlock Text="Dimes" Grid.Column="2" Grid.Row="0"/>
<Button Content="-" Click="Dimes_minus" HorizontalAlignment="Left" Width="36" Height="43" Grid.Column="2" Grid.Row="0" />
<TextBlock Text="0" Name="DimesText" HorizontalAlignment="Center" Margin="41,70,41,0" Height="36" Grid.Column="2" Grid.Row="0" />
<Button Content="+" Click="Dimes_add" HorizontalAlignment="Right" Width="36" Height="43" Grid.Column="2" Grid.Row="0"/>
<TextBlock Text="Quarters" Grid.Column="3" Grid.Row="0"/>
<Button Content="-" Click="Quarters_minus" HorizontalAlignment="Left" Width="36" Height="43" Grid.Column="3" Grid.Row="0" />
<TextBlock Text="0" Name="QuartersText" HorizontalAlignment="Center" Margin="41,70,41,0" Height="36" Grid.Column="3" Grid.Row="0" />
<Button Content="+" Click="Quarters_add" HorizontalAlignment="Right" Width="36" Height="43" Grid.Column="3" Grid.Row="0"/>
<TextBlock Text="Half Dollars" Grid.Column="4" Grid.Row="0"/>
<Button Content="-" Click="HalfDollars_minus" HorizontalAlignment="Left" Width="36" Height="43" Grid.Column="4" Grid.Row="0" />
<TextBlock Text="0" Name="HalfDollarsText" HorizontalAlignment="Center" Margin="41,70,41,0" Height="36" Grid.Column="4" Grid.Row="0" />
<Button Content="+" Click="HalfDollars_add" HorizontalAlignment="Right" Width="36" Height="43" Grid.Column="4" Grid.Row="0"/>
<TextBlock Text="Dollars" Grid.Column="0" Grid.Row="1"/>
<Button Content="-" Click="Dollars_minus" HorizontalAlignment="Left" Width="36" Height="43" Grid.Column="0" Grid.Row="1" />
<TextBlock Text="0" Name="DollarsText" HorizontalAlignment="Center" Margin="41,70,41,0" Height="36" Grid.Column="0" Grid.Row="1" />
<Button Content="+" Click="Dollars_add" HorizontalAlignment="Right" Width="36" Height="43" Grid.Column="0" Grid.Row="1"/>
<TextBlock Text="Ones" Grid.Column="1" Grid.Row="1"/>
<Button Content="-" Click="Ones_minus" HorizontalAlignment="Left" Width="36" Height="43" Grid.Column="1" Grid.Row="1" />
<TextBlock Text="0" Name="OnesText" HorizontalAlignment="Center" Margin="41,70,41,0" Height="36" Grid.Column="1" Grid.Row="1" />
<Button Content="+" Click="Ones_add" HorizontalAlignment="Right" Width="36" Height="43" Grid.Column="1" Grid.Row="1"/>
<TextBlock Text="Twos" Grid.Column="2" Grid.Row="1"/>
<Button Content="-" Click="Twos_minus" HorizontalAlignment="Left" Width="36" Height="43" Grid.Column="2" Grid.Row="1" />
<TextBlock Text="0" Name="TwosText" HorizontalAlignment="Center" Margin="41,70,41,0" Height="36" Grid.Column="2" Grid.Row="1" />
<Button Content="+" Click="Twos_add" HorizontalAlignment="Right" Width="36" Height="43" Grid.Column="2" Grid.Row="1"/>
<TextBlock Text="Fives" Grid.Column="3" Grid.Row="1"/>
<Button Content="-" Click="Fives_minus" HorizontalAlignment="Left" Width="36" Height="43" Grid.Column="3" Grid.Row="1" />
<TextBlock Text="0" Name="FivesText" HorizontalAlignment="Center" Margin="41,70,41,0" Height="36" Grid.Column="3" Grid.Row="1" />