Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (text_Name.Text != string.Empty && Father_name.Text != string.Empty && DOB.Text != string.Empty && CNIC.Text != string.Empty && PhoneNo.Text != string.Empty && genderCombo.Text != string.Empty && textBox_Address.Text != string.Empty && height.Text != string.Empty && textBox_diseases.Text != string.Empty && BGroup.Text != string.Empty && donated_Date.Text != string.Empty)
            {
                try
                {
                    if (Donated_YES_rbtn.Checked == true)
                    {
                        database.con.Open();
                        SqlCommand csd = new SqlCommand("insert into Donor values('" + text_Name.Text + "','" + Father_name.Text + "','" + DOB.Text + "','" + CNIC.Text + "','" + PhoneNo.Text + "','" + genderCombo.Text + "','" + textBox_Address.Text + "','" + height.Text.ToString() + "','" + textBox_diseases.Text + "','" + BGroup.Text + "','" + Donated_YES_rbtn.Text + "','" + donated_Date.Text + "');", database.con);
                        csd.ExecuteNonQuery();
                        database.con.Close();
                        listboxdata();
                        MessageBox.Show("Info Added", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        database.con.Open();
                        SqlCommand csd = new SqlCommand("insert into Donor values('" + text_Name.Text + "','" + Father_name.Text + "','" + DOB.Text + "','" + CNIC.Text + "','" + PhoneNo.Text + "','" + genderCombo.Text + "','" + textBox_Address.Text + "','" + height.Text.ToString() + "','" + textBox_diseases.Text + "','" + BGroup.Text + "','" + Donated_NO_rbtn.Text + "','" + donated_Date.Text + "');", database.con);
                        csd.ExecuteNonQuery();
                        database.con.Close();
                        listboxdata();
                        MessageBox.Show("Info Added", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    text_Name.ResetText();
                    DOB.ResetText();
                    Father_name.ResetText();
                    textBox_diseases.ResetText();
                    textBox_Address.ResetText();
                    BGroup.ResetText();
                    CNIC.ResetText();
                    PhoneNo.ResetText();
                    height.ResetText();
                    ID.Text = "ID: ------";
                }

                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);
            }
        }
Exemplo n.º 2
0
 private void button2_Click(object sender, EventArgs e)
 {
     text_Name.ResetText();
     DOB.ResetText();
     Father_name.ResetText();
     textBox_diseases.ResetText();
     textBox_Address.ResetText();
     BGroup.ResetText();
     CNIC.ResetText();
     PhoneNo.ResetText();
     height.ResetText();
     ID.Text          = "ID: ------";
     genderCombo.Text = "";
 }