private void button3_Click(object sender, EventArgs e) { bool valid = false; if (!Convert.ToBoolean(textBox8.Text)) { if (textBox4.Text == DateTime.Today.ToString("yyyy-MM-dd")) { valid = true; } else { MessageBox.Show("You can cancel todays tokens only."); } } else { MessageBox.Show("Patient already visited doctor. Token cannot be canceled."); } if (valid) { opd opd = new opd(); opd.cancelToken(textBox1.Text); MessageBox.Show("Token canceled sucessfully!"); clearData(); } }