public DataTable searchBS() { BirthC c = new BirthC();; //DataSet ds = new DataSet(); DataTable dt2 = new DataTable(); SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Bishal\Desktop\Municipal management\Birth_Certificate.mdf;Integrated Security=True;Connect Timeout=30"); con.Open(); SqlCommand cmd = new SqlCommand("select * from BS", con); try { SqlDataAdapter adapter = new SqlDataAdapter(cmd); adapter.Fill(dt2); //dt2 = ds.Tables[0]; return(dt2); } catch { con.Close(); throw; } }
//insert into birth certificate public int insertBS(BirthC b) { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Bishal\Desktop\Municipal management\Birth_Certificate.mdf;Integrated Security=True;Connect Timeout=30"); con.Open(); SqlCommand cmd = new SqlCommand("insert into BS(DateofIssue,Name,FathersName,MothersName,DateofBirth,PermanentAddress,PresentAddress,Nationality,Gender)values('" + b.dateofIssue + "','" + b.Name + "','" + b.fathersName + "','" + b.mothersName + "','" + b.dob + "','" + b.permanentAddress + "','" + b.presentAddress + "','" + b.nationality + "','" + b.gender + "')", con); try { return(cmd.ExecuteNonQuery()); } catch { con.Close(); throw; } }
private void submitButton_Click(object sender, EventArgs e) { BirthC br = new BirthC(); br.dateofIssue = dateTimePicker1.Text; br.Name = nametextBox.Text; br.fathersName = fnBox.Text; br.mothersName = mnBox.Text; br.dob = dateTimePicker2.Text; br.permanentAddress = pAddressbox.Text; br.presentAddress = presentaddressBox.Text; br.nationality = nationalityBox.Text; //Connection cn = new Connection(); if (MButton.Checked == true) { Gender = "Male"; } else if (fmlButton.Checked == true) { Gender = "Female"; } br.gender = Gender; int rows = br.getBs(br); if (rows > 0) { MessageBox.Show("Submitted..Wait for your Registration No"); } else { MessageBox.Show("Error!!!"); } }
private void BcBtn_Click(object sender, EventArgs e) { BirthC b = new BirthC(); birthGridView.DataSource = b.getdata(); }