private void button2_Click(object sender, EventArgs e) { textBox1Name.Text = ""; BAmounbt.ResetText(); comboBox2BloodG.ResetText(); comboBox1BGsearch.ResetText(); }
private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked != true && radioButton2.Checked != true) { MessageBox.Show("Select Donor or Employee", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (radioButton1.Checked == true) { if (textBox1Name.Text != string.Empty && comboBox2BloodG.Text != string.Empty && BAmounbt.Text != string.Empty) { try { database.con.Open(); SqlCommand csd = new SqlCommand("insert into Employee_D values('" + listBox2.SelectedItem + "','" + textBox1Name.Text + "','" + BAmounbt.Text.ToString() + "','" + DonationDate.Text + "','" + comboBox2BloodG.Text + "')", database.con); csd.ExecuteNonQuery(); MessageBox.Show("Info Added", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); textBox1Name.Text = ""; BAmounbt.ResetText(); comboBox2BloodG.ResetText(); DonationDate.ResetText(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { database.con.Close(); } } else { MessageBox.Show("Fill All Fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (radioButton2.Checked == true) { if (textBox1Name.Text != string.Empty && comboBox2BloodG.Text != string.Empty && BAmounbt.Text != string.Empty) { try { database.con.Open(); SqlCommand csd = new SqlCommand("insert into Donor_Donation values('" + listBox1.SelectedItem + "','" + textBox1Name.Text + "','" + comboBox2BloodG.Text + "','" + BAmounbt.Text.ToString() + "','" + DonationDate.Text + "')", database.con); csd.ExecuteNonQuery(); MessageBox.Show("Info Added", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); textBox1Name.Text = ""; BAmounbt.ResetText(); comboBox2BloodG.ResetText(); DonationDate.ResetText(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { database.con.Close(); } } else { MessageBox.Show("Fill All Fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }