private void button2_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"); //Information info = new Information(); //Donor_Info pr = new Donor_Info //{ // Name = Convert.ToString(donornam.Text), // Address = add.Text, // Password = pass.Text, // Phone = Convert.ToInt32(ph.Text), //}; var x = from a in D.DonorInfos where a.DonorId == d select a; if (donornam.Text != "") { // var a = x.First().Name; //donornam.Text = a; x.First().Name = donornam.Text; } if (add.Text != "") { x.First().Address = add.Text; } if (pass.Text != "") { x.First().Password = pass.Text; } if (ph.Text != "") { x.First().Phone = ph.Text; } //D.Donor_Infos.InsertOnSubmit(pr); D.SubmitChanges(); MessageBox.Show("Successfully Update"); //Donor c = new Donor(); donor.Show(); donor.show(); this.Hide(); }
private void button2_Click(object sender, EventArgs e) { don.Show(); this.Hide(); }
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"); string s = textBox1.Text; if (textBox1.Text != "" && textBox2.Text != "") { if (s[0] == '$') { try { var y = from b in D.AdminInfos where b.Username.Equals(textBox1.Text) select b; if ((y.FirstOrDefault().Password == textBox2.Text)) { Admin admin = new Admin(this, textBox1.Text); admin.Show(); textBox1.Clear(); textBox2.Clear(); this.Hide(); } else { MessageBox.Show("Wrong Password"); } } catch (NullReferenceException) { MessageBox.Show("Wrong Username"); } catch (Exception) { MessageBox.Show("Fill your Username and Password"); } } else { try { var x = from a in D.DonorInfos where a.UserID == textBox1.Text select a; if (x.FirstOrDefault().Password == textBox2.Text) { Donor donor = new Donor(this, textBox2.Text); donor.Show(); textBox1.Clear(); textBox2.Clear(); this.Hide(); } else { MessageBox.Show("Wrong Password"); } } catch (NullReferenceException) { MessageBox.Show("Wrong UserId"); } catch (Exception) { MessageBox.Show("Fill your Username and Password"); } } } else { MessageBox.Show("Fill your Username and Password"); } }