Tuần 1 - Bài 2
Source fBai2.cs
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 Bai2 { public partial class fBai2 : Form { const int USD = 17861; const int EUR = 27043; public fBai2() { InitializeComponent(); } private void fBai2_FormClosing(object sender, FormClosingEventArgs e) { DialogResult r; r = MessageBox.Show("Thí chủ có muốn thoát chăng?", "Thông báo!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); ; if (r == DialogResult.No) e.Cancel = true; } private void txbInputChange_TextChanged(object sender, EventArgs e) { Control ctr = (Control)sender; if (ctr.Text.Length > 0 && !Char.IsDigit(ctr.Text[ctr.Text.Length - 1])) this.errorProvider1.SetError(ctr, "This is not value number!"); else this.errorProvider1.Clear(); } private void btnVNDtoUSD_Click(object sender, EventArgs e) { try { double moneyInput = Convert.ToDouble(txbInputChange.Text); double result = moneyInput / (double)USD; result = Math.Round(result, 2); txbResultChange.Text = result.ToString() + " USD"; } catch { txbResultChange.Text = "0 USD"; } } private void btnVNDtoEUR_Click(object sender, EventArgs e) { try { double moneyInput = Convert.ToDouble(txbInputChange.Text); double result = moneyInput / (double)EUR; result = Math.Round(result, 2); txbResultChange.Text = result.ToString() + " EUR"; } catch { txbResultChange.Text = "0 EUR"; } } private void btnUSDtoVND_Click(object sender, EventArgs e) { try { double moneyInput = Convert.ToDouble(txbInputChange.Text); double result = moneyInput * USD; result = Math.Round(result, 2); txbResultChange.Text = result.ToString() + " VND"; } catch { txbResultChange.Text = "0 VND"; } } private void btnEURtoVND_Click(object sender, EventArgs e) { try { double moneyInput = Convert.ToDouble(txbInputChange.Text); double result = moneyInput * EUR; result = Math.Round(result, 2); txbResultChange.Text = result.ToString() + " VND"; } catch { txbResultChange.Text = "0 VND"; } } } }
No Comment to " Tuần 1 - Bài 2 "