Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace PizzaOrder
- {
- public partial class Form1 : Form
- {
- /*
- ** author: Damjan Miloshevski
- ** contact: [email protected];
- ** skype: damjan.milosevski
- ** phone: +38978566409;
- ** web: https://www.facebook.com/damjan.miloshevski
- http://miloshevski.us.to/
- */
- public float f = 0;
- public Form1()
- {
- InitializeComponent();
- Dessert d = new Dessert();
- d.Name = "Овошна салата";
- d.Price = 80;
- lstDeserti.Items.Add(d);
- Dessert d1 = new Dessert();
- d1.Name = "Сладолед";
- d1.Price = 120;
- lstDeserti.Items.Add(d1);
- Dessert d2 = new Dessert();
- d2.Name = "Торта";
- d2.Price = 160;
- lstDeserti.Items.Add(d2);
- }
- public void calculateTotal()
- {
- // ... vasiot kod ovde ...
- float total = 0;
- tbVkupnoNaplata.Text = tbMala.Text;
- if (rbMala.Checked)
- {
- if (float.TryParse(tbMala.Text, out f))
- {
- total += f;
- tbVkupnoNaplata.Text = total.ToString();
- }
- }
- if (rbSredna.Checked)
- {
- if (float.TryParse(tbSredna.Text, out f))
- {
- total += f;
- tbVkupnoNaplata.Text = total.ToString();
- }
- }
- if (rbGolema.Checked)
- {
- if (float.TryParse(tbGolema.Text, out f))
- {
- total += f;
- tbVkupnoNaplata.Text = total.ToString();
- }
- }
- if (cbPeperoni.Checked)
- {
- if (float.TryParse(tbPeperoni.Text, out f))
- {
- total += f;
- tbVkupnoNaplata.Text = total.ToString();
- }
- }
- if (cbExtraCheese.Checked)
- {
- if (float.TryParse(tbExtraCheese.Text, out f))
- {
- total += f;
- tbVkupnoNaplata.Text = total.ToString();
- }
- }
- if (cbKetchup.Checked)
- {
- if (float.TryParse(tbKetchup.Text, out f))
- {
- total += f;
- tbVkupnoNaplata.Text = total.ToString();
- }
- }
- if (float.TryParse(tbVkupnoCoke.Text, out f))
- {
- total += f;
- tbVkupnoNaplata.Text = total.ToString();
- }
- if (float.TryParse(tbVkupnoBeer.Text, out f))
- {
- total += f;
- tbVkupnoNaplata.Text = total.ToString();
- }
- if (float.TryParse(tbVkupnoJuice.Text, out f))
- {
- total += f;
- tbVkupnoNaplata.Text = total.ToString();
- }
- if (float.TryParse(tbCenaDesert.Text, out f))
- {
- total += f;
- tbVkupnoNaplata.Text = total.ToString();
- }
- }
- private void rbMala_CheckedChanged(object sender, EventArgs e)
- {
- calculateTotal();
- }
- private void rbSredna_CheckedChanged(object sender, EventArgs e)
- {
- calculateTotal();
- }
- private void rbGolema_CheckedChanged(object sender, EventArgs e)
- {
- calculateTotal();
- }
- private void cbPeperoni_CheckedChanged(object sender, EventArgs e)
- {
- calculateTotal();
- }
- private void cbExtraCheese_CheckedChanged(object sender, EventArgs e)
- {
- calculateTotal();
- }
- private void cbKetchup_CheckedChanged(object sender, EventArgs e)
- {
- calculateTotal();
- }
- private void tbKolicinaCoke_TextChanged(object sender, EventArgs e)
- {
- float total = 0;
- float cena = 0;
- float quantity = 0;
- if (float.TryParse(tbCenaCoke.Text, out f))
- {
- cena = f;
- }
- if (float.TryParse(tbKolicinaCoke.Text, out f))
- {
- quantity = f;
- }
- total = quantity * cena;
- tbVkupnoCoke.Text = total.ToString();
- calculateTotal();
- }
- private void tbCenaCoke_TextChanged(object sender, EventArgs e)
- {
- float total = 0;
- float cena = 0;
- float quantity = 0;
- if (float.TryParse(tbCenaCoke.Text, out f))
- {
- cena = f;
- }
- if (float.TryParse(tbKolicinaCoke.Text, out f))
- {
- quantity = f;
- }
- total = quantity * cena;
- tbVkupnoCoke.Text = total.ToString();
- calculateTotal();
- }
- private void tbKolicinaJuice_TextChanged(object sender, EventArgs e)
- {
- float total = 0;
- float cena = 0;
- float quantity = 0;
- if (float.TryParse(tbCenaJuice.Text, out f))
- {
- cena = f;
- }
- if (float.TryParse(tbKolicinaJuice.Text, out f))
- {
- quantity = f;
- }
- total = quantity * cena;
- tbVkupnoJuice.Text = total.ToString();
- calculateTotal();
- }
- private void tbCenaJuice_TextChanged(object sender, EventArgs e)
- {
- float total = 0;
- float cena = 0;
- float quantity = 0;
- if (float.TryParse(tbCenaJuice.Text, out f))
- {
- cena = f;
- }
- if (float.TryParse(tbKolicinaJuice.Text, out f))
- {
- quantity = f;
- }
- total = quantity * cena;
- tbVkupnoCoke.Text = total.ToString();
- calculateTotal();
- }
- private void tbKolicinaBeer_TextChanged(object sender, EventArgs e)
- {
- float total = 0;
- float cena = 0;
- float quantity = 0;
- if (float.TryParse(tbCenaBeer.Text, out f))
- {
- cena = f;
- }
- if (float.TryParse(tbKolicinaBeer.Text, out f))
- {
- quantity = f;
- }
- total = quantity * cena;
- tbVkupnoBeer.Text = total.ToString();
- calculateTotal();
- }
- private void tbCenaBeer_TextChanged(object sender, EventArgs e)
- {
- float total = 0;
- float cena = 0;
- float quantity = 0;
- if (float.TryParse(tbCenaBeer.Text, out f))
- {
- cena = f;
- }
- if (float.TryParse(tbKolicinaBeer.Text, out f))
- {
- quantity = f;
- }
- total = quantity * cena;
- tbVkupnoBeer.Text = total.ToString();
- calculateTotal();
- }
- private void lstDeserti_SelectedIndexChanged(object sender, EventArgs e)
- {
- Dessert d = lstDeserti.SelectedItem as Dessert;
- if (d != null)
- {
- tbCenaDesert.Text = Convert.ToString(d.Price);
- }
- calculateTotal();
- }
- private void btnNaracaj_Click(object sender, EventArgs e)
- {
- StringBuilder sb = new StringBuilder();
- if (rbMala.Checked)
- {
- sb.Append("Мала пица");
- sb.Append("\n");
- }
- else if (rbSredna.Checked)
- {
- sb.Append("Средна пица");
- sb.Append("\n");
- }
- else
- {
- sb.Append("Голема пица");
- sb.Append("\n");
- }
- sb.Append("Додатоци:");
- sb.Append("\n");
- if (cbPeperoni.Checked)
- {
- sb.Append(cbPeperoni.Text);
- sb.Append("\n");
- }
- if (cbKetchup.Checked)
- {
- sb.Append(cbKetchup.Text);
- sb.Append("\n");
- }
- if (cbExtraCheese.Checked)
- {
- sb.Append(cbExtraCheese.Text);
- sb.Append("\n");
- }
- if (lstDeserti.SelectedIndex != -1)
- {
- sb.Append("Десерт:");
- sb.Append("\n");
- sb.Append(lstDeserti.SelectedItem.ToString());
- }
- DialogResult result = MessageBox.Show(sb.ToString(), "Вашата нарачка", MessageBoxButtons.OK
- , MessageBoxIcon.None);
- }
- private void btnOtkazi_Click(object sender, EventArgs e)
- {
- DialogResult result = MessageBox.Show("Дали сакате да ја откажете нарачката?", "Откажи",
- MessageBoxButtons.YesNoCancel, // vid na dijalogot
- MessageBoxIcon.Question); // ikona na dijalogot
- if (result == DialogResult.Yes)
- {
- Application.Exit();
- }
- }
- private void tbNaplateno_TextChanged(object sender, EventArgs e)
- {
- float naplateno = 0;
- if (float.TryParse(tbNaplateno.Text, out f))
- {
- naplateno = f;
- }
- }
- private void tbZaVrakjanje_TextChanged(object sender, EventArgs e)
- {
- string naplateno = tbNaplateno.Text;
- float _naplateno = 0;
- if (float.TryParse(naplateno, out f))
- {
- _naplateno = f;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment