private void BtnOK_Click(object sender, EventArgs e) { try { int dollor = Convert.ToInt32(Txtdollor.Text); double tax = 0; string msg = ""; if (dollor < 300000) { tax = 0; } else if (dollor >= 300000 && dollor < 600000) { tax = dollor * 0.03; } else if (dollor >= 600000 && dollor < 900000) { tax = dollor * 0.06; } else if (dollor >= 900000 && dollor < 1500000) { tax = dollor * 0.12; } else if (dollor >= 1500000 && dollor < 5000000) { tax = dollor * 0.2; } else { tax = dollor * 0.3; } msg = "年所得" + dollor.ToString("C") + "\n應繳所得稅" + tax.ToString("C2"); LblMsg.Text = msg; } catch { MessageBox.Show("請輸入數值"); Txtdollor.Focus(); } }
private void Txtdollor_Enter(object sender, EventArgs e) { Txtdollor.Clear(); }