Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15.  
  16. namespace WpfApp2
  17. {
  18. /// <summary>
  19. /// Logika interakcji dla klasy MainWindow.xaml
  20. /// </summary>
  21. public partial class MainWindow : Window
  22. {
  23. public MainWindow()
  24. {
  25. InitializeComponent();
  26. }
  27. int cena = 0, cena2 = 0, cena3 = 0;
  28. int kwota = 2, kwota2 = 0, kwota3 = 0;
  29.  
  30. private void klik(Object sender, RoutedEventArgs e)
  31. {
  32. string stri = "Wielkość:\n ";
  33.  
  34. foreach (RadioButton cbx in wielkosc.Children)
  35. {
  36. if (cbx.IsChecked == true)
  37. {
  38. stri += cbx.Tag;
  39. }
  40. }
  41. wybor.Content = stri;
  42. if (radiobutton1.IsChecked == true) kwota2 = 20;
  43. else if (radiobutton2.IsChecked == true) kwota2 = 27;
  44. else if (radiobutton3.IsChecked == true) kwota2 = 32;
  45. else kwota2 = 40;
  46.  
  47. string str = "Dodatki:\n ";
  48. foreach (CheckBox cbx in Dodatki.Children)
  49. {
  50. if (cbx.IsChecked == true)
  51. {
  52. str += cbx.Tag + ",\n ";
  53. cena += kwota;
  54. }
  55. }
  56. cena2 = cena;
  57. cena = 0;
  58.  
  59. wybor2.Content = str;
  60. }
  61.  
  62. private void zamow_Click(object sender, RoutedEventArgs e)
  63. {
  64.  
  65. cena2 = cena2 + kwota2;
  66. if (cena2 > 40)
  67. {
  68. MessageBoxResult result = MessageBox.Show("Koszt Pizzy: " + cena2 + "zł",
  69. "Zamów",
  70. MessageBoxButton.YesNo,
  71. MessageBoxImage.Question);
  72. if (result == MessageBoxResult.Yes)
  73. {
  74. Application.Current.Shutdown();
  75. }
  76. }
  77. else
  78. {
  79. MessageBoxResult result = MessageBox.Show("Koszt Pizzy: " + cena2+ "zł\n" + "koszta dostawy: " + 5 + "zł",
  80. "Zamów",
  81. MessageBoxButton.YesNo,
  82. MessageBoxImage.Question);
  83. if (result == MessageBoxResult.Yes)
  84. {
  85. Application.Current.Shutdown();
  86. }
  87. }
  88.  
  89. }
  90.  
  91. private void rodzaj_SelectionChanged(object sender, SelectionChangedEventArgs e)
  92. {
  93.  
  94. switch (rodzaj.SelectedIndex)
  95. {
  96. case 0:
  97. zamow.IsEnabled = true;
  98. break;
  99. case 1:
  100. zamow.IsEnabled = true;
  101. break;
  102. case 2:
  103. zamow.IsEnabled = true;
  104. break;
  105. case 3:
  106. zamow.IsEnabled = true;
  107. break;
  108. case 4:
  109. zamow.IsEnabled = true;
  110. break;
  111. }
  112. }
  113. }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement