Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 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.Windows.Forms;
  9.  
  10. namespace WindowsFormsApplication1
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.  
  18.         }
  19.  
  20.         private void button1_Click(object sender, EventArgs e)
  21.         {
  22.             int buy=0,num,total=0;
  23.             string item;
  24.             if (radio1.Checked)
  25.             {
  26.                 buy = 15;
  27.                 item = "น้ำส้ม";
  28.             }
  29.             if (radio2.Checked)
  30.             {
  31.                 buy = 20;
  32.                 item = "น้ำมะนาว";
  33.             }
  34.             if (radio3.Checked)
  35.             {
  36.                 buy = 25;
  37.                 item = "น้ำมะพร้าว";
  38.             }
  39.  
  40.             num = int.Parse(txtbMoney.Text);
  41.             total = num - buy;
  42.  
  43.             if (total >= 0)
  44.             {
  45.  
  46.                lblResult.Text = string.Format("จำนวนเงิน {0} บาท \nซื้อ {1} {2} บาท\nเงินทอน {3}          บาท", num.ToString("#,##0.#0"), item , buy.ToString("#,##0.#0"), total.ToString("#,##0.#0"));
  47.             }
  48.             else
  49.             {
  50.                 lblResult.Text = "จำนวนเงินไม่พอ";
  51.             }
  52.  
  53.  
  54.         }
  55.  
  56.         private void txtbMoney_TextChanged(object sender, EventArgs e)
  57.         {
  58.             if (txtbMoney.Text == "")
  59.             {
  60.                 button1.Enabled = false;
  61.             }
  62.             else
  63.             {
  64.                 button1.Enabled = true;
  65.             }
  66.         }
  67.  
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement