private void BtnUpdate_Click(object sender, RoutedEventArgs e) { DonorContext dc = new DonorContext("server=.;Integrated Security=true;database=Sep23db"); int id = Int32.Parse(txtDonorID.Text); Donor myDonor = dc.Donors.Find(id); myDonor.City = txtCity.Text; dc.SaveChanges(); System.Windows.Forms.MessageBox.Show("Donor Details Updated.."); }
private void BtnDelete_Click(object sender, RoutedEventArgs e) { DonorContext dc = new DonorContext("server=.;Integrated Security=true;database=Sep23db"); int id = Int32.Parse(txtDonorID.Text); Donor myDonor = dc.Donors.Find(id); if (myDonor != null) { dc.Donors.Remove(myDonor); dc.SaveChanges(); System.Windows.Forms.MessageBox.Show("Record Deleted .."); ResetTextBoxes(); } }
private void BtnAdd_Click(object sender, RoutedEventArgs e) { DonorContext dc = new DonorContext("server=.;Integrated Security=true;database=Sep23db"); Donor d1 = new Donor(); d1.DonorID = Int32.Parse(txtDonorID.Text); d1.Name = txtName.Text; d1.BloodGrp = txtBldGroup.Text; d1.City = txtCity.Text; dc.Donors.Add(d1); dc.SaveChanges(); System.Windows.Forms.MessageBox.Show("Donor Details Recorded.."); ResetTextBoxes(); }
private void BtnSearch_Click(object sender, RoutedEventArgs e) { DonorContext dc = new DonorContext("server=.;Integrated Security=true;database=Sep23db"); int id = Int32.Parse(txtDonorID.Text); Donor myDonor = dc.Donors.Find(id); //Assigning Object Data to UI Controls if (myDonor != null) { txtName.Text = myDonor.Name; txtBldGroup.Text = myDonor.BloodGrp; txtCity.Text = myDonor.City; } else { System.Windows.Forms.MessageBox.Show("No Record Found..."); } }
private void BtnAddPatient_Click(object sender, RoutedEventArgs e) { try { DonorContext dbCon = new DonorContext("server=.;Integrated Security=true;database=Sep23Db"); //Init Patient Object Patient p1 = new Patient(); p1.PatientNo = 101; p1.Name = "Alok"; p1.City = "Munnar"; //Adding Data to Table dbCon.Patients.Add(p1); //Commit Changes dbCon.SaveChanges(); System.Windows.Forms.MessageBox.Show("Patient Details Added"); } catch (Exception e1) { System.Windows.Forms.MessageBox.Show(e1.Message); } }