Advertisement
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.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- int buy=0,num,total=0;
- string item;
- if (radio1.Checked)
- {
- buy = 15;
- item = "น้ำส้ม";
- }
- if (radio2.Checked)
- {
- buy = 20;
- item = "น้ำมะนาว";
- }
- if (radio3.Checked)
- {
- buy = 25;
- item = "น้ำมะพร้าว";
- }
- num = int.Parse(txtbMoney.Text);
- total = num - buy;
- if (total >= 0)
- {
- lblResult.Text = string.Format("จำนวนเงิน {0} บาท \nซื้อ {1} {2} บาท\nเงินทอน {3} บาท", num.ToString("#,##0.#0"), item , buy.ToString("#,##0.#0"), total.ToString("#,##0.#0"));
- }
- else
- {
- lblResult.Text = "จำนวนเงินไม่พอ";
- }
- }
- private void txtbMoney_TextChanged(object sender, EventArgs e)
- {
- if (txtbMoney.Text == "")
- {
- button1.Enabled = false;
- }
- else
- {
- button1.Enabled = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement