示例#1
0
        private void DeleteButt_Click(object sender, EventArgs e)
        {
            FitnessClubDBEntities1 database = new FitnessClubDBEntities1();

            database.Entry(Form4.thisUser).State    = System.Data.Entity.EntityState.Deleted;
            database.Entry(Form4.thisLog).State     = System.Data.Entity.EntityState.Deleted;
            database.Entry(Form4.thisContact).State = System.Data.Entity.EntityState.Deleted;
            database.UserInformations.Remove(Form4.thisUser);
            database.UserLogs.Remove(Form4.thisLog);
            database.UserContacts.Remove(Form4.thisContact);
            database.SaveChanges();

            this.Hide();
            MessageBox.Show("Your account was deleted!");
        }
示例#2
0
        private void CreateUserBox_Click(object sender, EventArgs e)
        {           
               
            {
                if (FirstNameBox.Text == "" || LastNameBox.Text == "" || LastNameBox.Text == "" ||
                PasswordBox.Text == "" || HeightBox.Text == "" || weightlabel.Text == "" || AgeBox.Text == "" || EmailBox.Text == "" ||
                PhoneNumberBox.Text == "" || LoginBox.Text == "")
                {
                    MessageBox.Show("Be sure you've filled all gaps!");
                }
                else
                {
                    client.loginID = randomise.Next();
                    client.userID = client.loginID;

                    client.firstname = FirstNameBox.Text;
                    client.lastname = LastNameBox.Text;
                    client.height = int.Parse(HeightBox.Text);
                    client.weight = int.Parse(WeightBox.Text);

                    if(RadioButtMale.Checked == true) { client.gender = "male"; }
                    if (RadioButtFemale.Checked == true) { client.gender = "female"; }


                    
                    aaa.loginID = client.loginID;

                    aaa.Login = LoginBox.Text;
                    aaa.Password = PasswordBox.Text;

                    bbb.PhoneNumber = PhoneNumberBox.Text;
                    bbb.Email = EmailBox.Text;

                    using(FitnessClubDBEntities1 database = new FitnessClubDBEntities1())
                    {
                        database.UserInformations.Add(client);
                        database.UserLogs.Add(aaa);
                        database.UserContacts.Add(bbb);
                        database.SaveChanges();
                    }

                    MessageBox.Show("Congratulations!!!! Now you are ready to work");
                }
            }
        }
示例#3
0
 private void UpdateButt_Click(object sender, EventArgs e)
 {
     if (FirstNameBox.Text != "" && LastNameBox.Text != "" &&
         PasswordBox.Text != "" && PhoneNumberBox.Text != "" &&
         EmailBox.Text != "")
     {
         FitnessClubDBEntities1 database = new FitnessClubDBEntities1();
         database.UserInformations.Find(Form4.thisUser.userID).firstname      = FirstNameBox.Text;
         database.UserInformations.Find(Form4.thisUser.userID).lastname       = LastNameBox.Text;
         database.UserLogs.Find(Form4.thisUser.loginID).Password              = PasswordBox.Text;
         database.UserContacts.Find(Form4.thisUser.userContactID).PhoneNumber = PhoneNumberBox.Text;
         database.UserContacts.Find(Form4.thisUser.userContactID).Email       = EmailBox.Text;
         database.SaveChanges();
         MessageBox.Show("Operation completed successfully");
     }
     else
     {
         MessageBox.Show("Please, fill all fields!");
     }
 }