blob: 544828a37fb7313099d1d9716821bef36c13c02d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
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 Software_Sales
{
public partial class softwareSales : Form
{
public softwareSales()
{
InitializeComponent();
}
private void calculateButton_Click(object sender, EventArgs e)
{
try {
const decimal PRICE = 99.00m;
int packages = int.Parse(packagesTextBox.Text);
decimal discount, cost;
if (packages > 99)
discount = 0.5m;
else if (packages > 49)
discount = 0.4m;
else if (packages > 19)
discount = 0.3m;
else if (packages > 9)
discount = 0.2m;
else
discount = 0m;
cost = packages * PRICE * (1 - discount);
discountLabel.Text = discount.ToString("p0");
costLabel.Text = cost.ToString("c");
}
catch (Exception ex) {
MessageBox.Show(ex.Message);
}
}
private void button2_Click(object sender, EventArgs e)
{
packagesTextBox.Text = "";
discountLabel.Text = "";
costLabel.Text = "";
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
|