DamSi

Untitled

Mar 13th, 2015
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace PizzaOrder
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         /*
  16.          ** author: Damjan Miloshevski
  17.          ** contact: [email protected];
  18.          ** skype: damjan.milosevski
  19.          ** phone: +38978566409;
  20.          ** web: https://www.facebook.com/damjan.miloshevski
  21.                  http://miloshevski.us.to/
  22.        */
  23.  
  24.         public float f = 0;
  25.         public Form1()
  26.         {
  27.             InitializeComponent();
  28.             Dessert d = new Dessert();
  29.             d.Name = "Овошна салата";
  30.             d.Price = 80;
  31.             lstDeserti.Items.Add(d);
  32.  
  33.             Dessert d1 = new Dessert();
  34.             d1.Name = "Сладолед";
  35.             d1.Price = 120;
  36.             lstDeserti.Items.Add(d1);
  37.  
  38.             Dessert d2 = new Dessert();
  39.             d2.Name = "Торта";
  40.             d2.Price = 160;
  41.             lstDeserti.Items.Add(d2);
  42.  
  43.         }
  44.         public void calculateTotal()
  45.         {
  46.             // ... vasiot kod ovde ...
  47.             float total = 0;
  48.             tbVkupnoNaplata.Text = tbMala.Text;
  49.             if (rbMala.Checked)
  50.             {
  51.                 if (float.TryParse(tbMala.Text, out f))
  52.                 {
  53.                     total += f;
  54.                     tbVkupnoNaplata.Text = total.ToString();
  55.                 }
  56.             }
  57.             if (rbSredna.Checked)
  58.             {
  59.                 if (float.TryParse(tbSredna.Text, out f))
  60.                 {
  61.                     total += f;
  62.                     tbVkupnoNaplata.Text = total.ToString();
  63.                 }
  64.             }
  65.             if (rbGolema.Checked)
  66.             {
  67.                 if (float.TryParse(tbGolema.Text, out f))
  68.                 {
  69.                     total += f;
  70.                     tbVkupnoNaplata.Text = total.ToString();
  71.                 }
  72.             }
  73.             if (cbPeperoni.Checked)
  74.             {
  75.                 if (float.TryParse(tbPeperoni.Text, out f))
  76.                 {
  77.                     total += f;
  78.                     tbVkupnoNaplata.Text = total.ToString();
  79.                 }
  80.             }
  81.             if (cbExtraCheese.Checked)
  82.             {
  83.                 if (float.TryParse(tbExtraCheese.Text, out f))
  84.                 {
  85.                     total += f;
  86.                     tbVkupnoNaplata.Text = total.ToString();
  87.                 }
  88.             }
  89.             if (cbKetchup.Checked)
  90.             {
  91.                 if (float.TryParse(tbKetchup.Text, out f))
  92.                 {
  93.                     total += f;
  94.                     tbVkupnoNaplata.Text = total.ToString();
  95.                 }
  96.             }
  97.             if (float.TryParse(tbVkupnoCoke.Text, out f))
  98.             {
  99.                 total += f;
  100.                 tbVkupnoNaplata.Text = total.ToString();
  101.             }
  102.             if (float.TryParse(tbVkupnoBeer.Text, out f))
  103.             {
  104.                 total += f;
  105.                 tbVkupnoNaplata.Text = total.ToString();
  106.             }
  107.             if (float.TryParse(tbVkupnoJuice.Text, out f))
  108.             {
  109.                 total += f;
  110.                 tbVkupnoNaplata.Text = total.ToString();
  111.             }
  112.             if (float.TryParse(tbCenaDesert.Text, out f))
  113.             {
  114.                 total += f;
  115.                 tbVkupnoNaplata.Text = total.ToString();
  116.             }
  117.         }
  118.  
  119.         private void rbMala_CheckedChanged(object sender, EventArgs e)
  120.         {
  121.             calculateTotal();
  122.         }
  123.  
  124.         private void rbSredna_CheckedChanged(object sender, EventArgs e)
  125.         {
  126.             calculateTotal();
  127.         }
  128.  
  129.         private void rbGolema_CheckedChanged(object sender, EventArgs e)
  130.         {
  131.             calculateTotal();
  132.         }
  133.  
  134.         private void cbPeperoni_CheckedChanged(object sender, EventArgs e)
  135.         {
  136.             calculateTotal();
  137.         }
  138.  
  139.         private void cbExtraCheese_CheckedChanged(object sender, EventArgs e)
  140.         {
  141.             calculateTotal();
  142.         }
  143.  
  144.         private void cbKetchup_CheckedChanged(object sender, EventArgs e)
  145.         {
  146.             calculateTotal();
  147.         }
  148.         private void tbKolicinaCoke_TextChanged(object sender, EventArgs e)
  149.         {
  150.             float total = 0;
  151.             float cena = 0;
  152.             float quantity = 0;
  153.             if (float.TryParse(tbCenaCoke.Text, out f))
  154.             {
  155.                 cena = f;
  156.             }
  157.             if (float.TryParse(tbKolicinaCoke.Text, out f))
  158.             {
  159.                 quantity = f;
  160.             }
  161.             total = quantity * cena;
  162.             tbVkupnoCoke.Text = total.ToString();
  163.             calculateTotal();
  164.         }
  165.  
  166.         private void tbCenaCoke_TextChanged(object sender, EventArgs e)
  167.         {
  168.             float total = 0;
  169.             float cena = 0;
  170.             float quantity = 0;
  171.             if (float.TryParse(tbCenaCoke.Text, out f))
  172.             {
  173.                 cena = f;
  174.             }
  175.             if (float.TryParse(tbKolicinaCoke.Text, out f))
  176.             {
  177.                 quantity = f;
  178.             }
  179.             total = quantity * cena;
  180.             tbVkupnoCoke.Text = total.ToString();
  181.             calculateTotal();
  182.         }
  183.  
  184.         private void tbKolicinaJuice_TextChanged(object sender, EventArgs e)
  185.         {
  186.             float total = 0;
  187.             float cena = 0;
  188.             float quantity = 0;
  189.             if (float.TryParse(tbCenaJuice.Text, out f))
  190.             {
  191.                 cena = f;
  192.             }
  193.             if (float.TryParse(tbKolicinaJuice.Text, out f))
  194.             {
  195.                 quantity = f;
  196.             }
  197.             total = quantity * cena;
  198.             tbVkupnoJuice.Text = total.ToString();
  199.             calculateTotal();
  200.         }
  201.  
  202.         private void tbCenaJuice_TextChanged(object sender, EventArgs e)
  203.         {
  204.             float total = 0;
  205.             float cena = 0;
  206.             float quantity = 0;
  207.             if (float.TryParse(tbCenaJuice.Text, out f))
  208.             {
  209.                 cena = f;
  210.             }
  211.             if (float.TryParse(tbKolicinaJuice.Text, out f))
  212.             {
  213.                 quantity = f;
  214.             }
  215.             total = quantity * cena;
  216.             tbVkupnoCoke.Text = total.ToString();
  217.             calculateTotal();
  218.         }
  219.  
  220.         private void tbKolicinaBeer_TextChanged(object sender, EventArgs e)
  221.         {
  222.             float total = 0;
  223.             float cena = 0;
  224.             float quantity = 0;
  225.             if (float.TryParse(tbCenaBeer.Text, out f))
  226.             {
  227.                 cena = f;
  228.             }
  229.             if (float.TryParse(tbKolicinaBeer.Text, out f))
  230.             {
  231.                 quantity = f;
  232.             }
  233.             total = quantity * cena;
  234.             tbVkupnoBeer.Text = total.ToString();
  235.             calculateTotal();
  236.         }
  237.  
  238.         private void tbCenaBeer_TextChanged(object sender, EventArgs e)
  239.         {
  240.             float total = 0;
  241.             float cena = 0;
  242.             float quantity = 0;
  243.             if (float.TryParse(tbCenaBeer.Text, out f))
  244.             {
  245.                 cena = f;
  246.             }
  247.             if (float.TryParse(tbKolicinaBeer.Text, out f))
  248.             {
  249.                 quantity = f;
  250.             }
  251.             total = quantity * cena;
  252.             tbVkupnoBeer.Text = total.ToString();
  253.             calculateTotal();
  254.         }
  255.         private void lstDeserti_SelectedIndexChanged(object sender, EventArgs e)
  256.         {
  257.             Dessert d = lstDeserti.SelectedItem as Dessert;
  258.             if (d != null)
  259.             {
  260.                 tbCenaDesert.Text = Convert.ToString(d.Price);
  261.             }
  262.             calculateTotal();
  263.         }
  264.         private void btnNaracaj_Click(object sender, EventArgs e)
  265.         {
  266.             StringBuilder sb = new StringBuilder();
  267.             if (rbMala.Checked)
  268.             {
  269.                 sb.Append("Мала пица");
  270.                 sb.Append("\n");
  271.             }
  272.             else if (rbSredna.Checked)
  273.             {
  274.                 sb.Append("Средна пица");
  275.                 sb.Append("\n");
  276.             }
  277.             else
  278.             {
  279.                 sb.Append("Голема пица");
  280.                 sb.Append("\n");
  281.             }
  282.             sb.Append("Додатоци:");
  283.             sb.Append("\n");
  284.             if (cbPeperoni.Checked)
  285.             {
  286.                 sb.Append(cbPeperoni.Text);
  287.                 sb.Append("\n");
  288.             }
  289.             if (cbKetchup.Checked)
  290.             {
  291.                 sb.Append(cbKetchup.Text);
  292.                 sb.Append("\n");
  293.             }
  294.             if (cbExtraCheese.Checked)
  295.             {
  296.                 sb.Append(cbExtraCheese.Text);
  297.                 sb.Append("\n");
  298.             }
  299.             if (lstDeserti.SelectedIndex != -1)
  300.             {
  301.                 sb.Append("Десерт:");
  302.                 sb.Append("\n");
  303.                 sb.Append(lstDeserti.SelectedItem.ToString());
  304.             }
  305.             DialogResult result = MessageBox.Show(sb.ToString(), "Вашата нарачка", MessageBoxButtons.OK
  306.                 , MessageBoxIcon.None);
  307.         }
  308.         private void btnOtkazi_Click(object sender, EventArgs e)
  309.         {
  310.             DialogResult result = MessageBox.Show("Дали сакате да ја откажете нарачката?", "Откажи",
  311.               MessageBoxButtons.YesNoCancel, // vid na dijalogot
  312.               MessageBoxIcon.Question); // ikona na dijalogot
  313.             if (result == DialogResult.Yes)
  314.             {
  315.                 Application.Exit();
  316.             }
  317.         }
  318.  
  319.         private void tbNaplateno_TextChanged(object sender, EventArgs e)
  320.         {
  321.             float naplateno = 0;
  322.             if (float.TryParse(tbNaplateno.Text, out f))
  323.             {
  324.                 naplateno = f;
  325.             }
  326.         }
  327.  
  328.         private void tbZaVrakjanje_TextChanged(object sender, EventArgs e)
  329.         {
  330.             string naplateno = tbNaplateno.Text;
  331.             float _naplateno = 0;
  332.             if (float.TryParse(naplateno, out f))
  333.             {
  334.                 _naplateno = f;
  335.             }
  336.         }
  337.     }
  338. }
Advertisement
Add Comment
Please, Sign In to add comment