Exemple #1
0
        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");
            }
        }
Exemple #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     a.Show();
     this.Hide();
 }
Exemple #3
0
        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.AdminInfos
                    where a.AdminId.Equals(s)

                    select a;

            string st = textBox1.Text;

            if (st[0] == '$')
            {
                if (donornam.Text != "")
                {
                    //var a = x.First().Name;
                    // donornam.Text =x.First().Name;
                    x.First().Name = donornam.Text;
                }
                if (textBox1.Text != "")
                {
                    x.First().Username = textBox1.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");
                ad.Show();
                ad.show();
                this.Hide();
            }
            else if (s.Equals(null))
            {
                if (donornam.Text != "")
                {
                    //var a = x.First().Name;
                    // donornam.Text =x.First().Name;
                    x.First().Name = donornam.Text;
                }


                if (pass.Text != "")
                {
                    x.First().Password = pass.Text;
                }
                if (ph.Text != "")
                {
                    x.First().Phone = ph.Text;
                }
                D.SubmitChanges();
                MessageBox.Show("Successfully Update");
                ad.Show();
                ad.show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Update user name with $");
            }
        }