Fred Stilms

Fred Stilms

  • NA
  • 6
  • 0

Small project code still having some Bugs

Dec 9 2009 2:50 AM

each time if i press the coin button it disables a click to late.
Examle when the inserted coin reach the same/Bigger rate you need to click it one more time before it disables.
 
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
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
Drankmaatje
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
decimal cola;
decimal water;
decimal koffie;
decimal soep;
decimal tweeEuro;
decimal eenEuro;
decimal vijtigCent;
decimal twintigCent;
decimal tienCent;
decimal vijfCent;
decimal keuze;
decimal verschil;
decimal totaal;
public Window1()
{
InitializeComponent();
}
private void btnCola_Click(object sender, RoutedEventArgs e)
{
cola = 0.60M;
keuze = cola;
lblKeuze.Content = keuze;
gbGeldInworp.IsEnabled =
true;
lblStatus.Content =
"Betaal";
}
private void btnWater_Click(object sender, RoutedEventArgs e)
{
water = 0.50M;
keuze = water;
lblKeuze.Content = keuze;
gbGeldInworp.IsEnabled =
true;
lblStatus.Content =
"Betaal";
 
}
private void btnkoffie_Click(object sender, RoutedEventArgs e)
{
koffie = 1.50M;
keuze = koffie;
lblKeuze.Content = keuze;
gbGeldInworp.IsEnabled =
true;
lblStatus.Content =
"Betaal";
}
private void btnsoep_Click(object sender, RoutedEventArgs e)
{
soep = 4.50M;
keuze = soep;
lblKeuze.Content = keuze;
gbGeldInworp.IsEnabled =
true;
lblStatus.Content =
"Betaal";
}
private void btnTweeEuro_Click(object sender, RoutedEventArgs e)
{
btnCancel.IsEnabled =
true;
tweeEuro = 2.00M;
if (keuze >= totaal)
totaal = totaal + tweeEuro;
else
btnKoop.IsEnabled =
true;
lblTotaalInwerp.Content = totaal;
lblStatus.Content =
"Koop";
}
private void btnEenEuro_Click(object sender, RoutedEventArgs e)
{
btnCancel.IsEnabled =
true;
eenEuro = 1.00M;
if (keuze >= totaal)
totaal = totaal + eenEuro;
else
btnKoop.IsEnabled =
true;
lblTotaalInwerp.Content = totaal;
lblStatus.Content =
"Koop";
 
}
private void btnVijtigCent_Click(object sender, RoutedEventArgs e)
{
btnCancel.IsEnabled =
true;
vijtigCent = 0.50M;
if (keuze >= totaal)
totaal = totaal + vijtigCent;
else
btnKoop.IsEnabled =
true;
lblTotaalInwerp.Content = totaal;
lblStatus.Content =
"Koop";
}
private void btnTwintigCent_Click(object sender, RoutedEventArgs e)
{
btnCancel.IsEnabled =
true;
twintigCent = 0.20M;
if (keuze >= totaal)
totaal = totaal + twintigCent;
else
btnKoop.IsEnabled =
true;
lblTotaalInwerp.Content = totaal;
lblStatus.Content =
"Koop";
}
private void btnTienCent_Click(object sender, RoutedEventArgs e)
{
btnCancel.IsEnabled =
true;
tienCent = 0.10M;
if (keuze >= totaal)
totaal = totaal + tienCent;
else
btnKoop.IsEnabled =
true;
lblTotaalInwerp.Content = totaal;
lblStatus.Content =
"Koop";
}
private void btnVijfCent_Click(object sender, RoutedEventArgs e)
{
btnCancel.IsEnabled =
true;
vijfCent = 0.05M;

if (keuze >= totaal)
totaal = totaal + vijfCent;
else
btnKoop.IsEnabled =
true;
lblTotaalInwerp.Content = totaal;
lblStatus.Content =
"Koop";

}
private void btnKoop_Click(object sender, RoutedEventArgs e)
{
gbGeldInworp.IsEnabled =
false;
gbKeuzeDrank.IsEnabled =
false;
btnCancel.IsEnabled =
false;
btnKoop.IsEnabled =
false;
lblStatus.Content =
"Neem";
int count2E = 0;
int count1E = 0;
int count50C = 0;
int count20C = 0;
int count10C = 0;
int count5C = 0;
verschil = totaal - keuze;
/* lblMelding.Content = verschil;*/
 

do
{
if (verschil >= 2M)
{
count2E++;
verschil = verschil - 2M;
}
else if (verschil >= 1M)
{
count1E++;
verschil = verschil - 1M;
}
else if (verschil >= 0.50M)
{
count50C++;
verschil = verschil - 0.50M;
}
else if (verschil >= 0.20M)
{
count20C++;
verschil = verschil - 0.20M;
}
else if (verschil >= 0.10M)
{
count10C++;
verschil = verschil - 0.10M;
}
else if (verschil >= 0.05M)
{
count5C++;
verschil = verschil - 0.05M;
}
else
{
}
}
while (verschil != 0);
{
if (count2E != 0)
listBox1.Items.Add(count2E +
" x 2 Euro ");
if (count1E != 0)
listBox1.Items.Add(count1E +
" x 1 Euro ");
if (count50C != 0)
listBox1.Items.Add(count50C +
" x 50Cent ");
if (count20C != 0)
listBox1.Items.Add(count20C +
" x 20Cent ");
if (count10C != 0)
listBox1.Items.Add(count10C +
" x 10Cent ");
if (count5C != 0)
listBox1.Items.Add(count5C +
" x 5 Cent");
btnNeemDrank.Visibility =
Visibility.Visible;
 
 
 
 
 
 
}
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
gbGeldInworp.IsEnabled =
false;
btnCancel.IsEnabled =
false;
btnKoop.IsEnabled =
false;
btnNeemDrank.Visibility =
Visibility.Hidden;
lblStatus.Content =
"Kies";
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
gbGeldInworp.IsEnabled =
false;
btnCancel.IsEnabled =
false;
btnKoop.IsEnabled =
false;
lblKeuze.Content =
"";
lblStatus.Content =
"Kies";
lblTotaalInwerp.Content=
"";




}
private void btnNeemDrank_Click(object sender, RoutedEventArgs e)
{
gbGeldInworp.IsEnabled =
false;
gbKeuzeDrank.IsEnabled =
true;
btnCancel.IsEnabled =
false;
btnKoop.IsEnabled =
false;
lblStatus.Content =
"Kies";
lblKeuze.Content =
"";
lblTotaalInwerp.Content =
"";
btnNeemDrank.Visibility =
Visibility.Hidden;
listBox1.Items.Clear();
}
}
}
 
 
 
 
 


Answers (1)