private void button1_Click(object sender, EventArgs e) { BloodDataContext D = new BloodDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# projects\finalProject\Blood Donation\Blood.mdf;Integrated Security=True;Connect Timeout=30"); GuestInfo pr = new GuestInfo(); if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "") { pr.GName = textBox2.Text; pr.GPhone = textBox3.Text; pr.GAddress = textBox4.Text; D.GuestInfos.InsertOnSubmit(pr); D.SubmitChanges(); RequestInfo rq = new RequestInfo(); rq.DonorId = Convert.ToInt32(textBox1.Text); rq.Gphone = textBox3.Text; var x = from a in D.GuestInfos where a.GPhone.Equals(textBox3.Text) select a; int str = x.First().Gid; rq.Gid = str; D.RequestInfos.InsertOnSubmit(rq); MessageBox.Show("Request Send"); this.Hide(); D.SubmitChanges(); } else { MessageBox.Show("Please fill up all information"); } }
private void button1_Click(object sender, EventArgs e) { BloodDataContext D = new BloodDataContext(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=F:\C# projects\finalProject\Blood Donation\Blood.mdf;Integrated Security=True;Connect Timeout=30"); //RequestInfo j = D.RequestInfos.SingleOrDefault(x => x.DonorId == Convert.ToInt32(textBox1.Text)); var y = from a in D.RequestInfos where a.Gid == Convert.ToInt32(textBox1.Text) select a; if (y.Any()) { foreach (var a in y) { D.RequestInfos.DeleteOnSubmit(a); } GuestInfo i = D.GuestInfos.SingleOrDefault(t => t.Gid == Convert.ToInt32(textBox1.Text)); D.GuestInfos.DeleteOnSubmit(i); D.SubmitChanges(); s.showde(); } else { MessageBox.Show("Guest Id Invalid"); } }
partial void UpdateGuestInfo(GuestInfo instance);
partial void DeleteGuestInfo(GuestInfo instance);
partial void InsertGuestInfo(GuestInfo instance);