Anda di halaman 1dari 1

private void button1_Click(object sender, EventArgs e)

{
int a = 0;
foreach (Control c in this.Controls)
{

if (c is TextBox)
{
TextBox textBox = c as TextBox;
if (textBox.Text == string.Empty)
{
MessageBox.Show("Some Text Missing");
textBox.Focus();
a = 1;
break;
}

}


}
if (a >= 1)
{

}
else
{
connection.Open();
string k = Convert.ToString(textBox2.Text);
string c = "Dr.";
string l = Convert.ToString(String.Concat(c, k));
OleDbCommand cmd = new OleDbCommand("insert into doctor values ('" +
textBox1.Text + "','" + l + "','" + dateTimePicker1.Text + "','" + comboBox1.Te
xt + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "',
'" + comboBox2.Text + "','" + "" + "','" + textBox7.Text + "')", connection);
cmd.ExecuteNonQuery();
connection.Close();
this.Close();
}

Anda mungkin juga menyukai