Ejemplo n.º 1
0
 private void button3_Click(object sender, EventArgs e)
 {
     //se sterge membrul cand apesi delete
     entities.Members.Remove(memberToBeDeletedInCase);
     entities.SaveChanges();
     MessageBox.Show("Member's Registration has been deleted", "Success", MessageBoxButtons.OK);
 }
Ejemplo n.º 2
0
        //adaugare dietplan la membri
        private void Btn_Add_Click(object sender, EventArgs e)
        {
            //setarea numelor dietplan dupa butoane
            string DietPlan = " ";

            if (rdplan1.Checked == true)
            {
                DietPlan = "Diet Plan 1";
            }
            else if (rdPlan2.Checked == true)
            {
                DietPlan = "Diet Plan 2";
            }
            else if (rdplan3.Checked == true)
            {
                DietPlan = "Diet Plan 3";
            }

            //ia id-ul de la diet plan dupa selectarea facuta
            string dietPlan = (from plan in entites.Diet_Plans
                               where plan.PlanName == DietPlan
                               select plan.PlanID).FirstOrDefault();
            //retine numele ales in combobox
            string MemberName = comboBox1.Text;
            //se alege un membru existent in baza de date
            var selectedMember = (from member in entites.Members
                                  where member.Member_Name == MemberName
                                  select member).FirstOrDefault();

            //Seteaza alegerea facuta
            selectedMember.DietPlanID = dietPlan;
            //Salvare
            entites.SaveChanges();
            MessageBox.Show("Diet Plan Updated", "Success", MessageBoxButtons.OK);
        }
Ejemplo n.º 3
0
        //Adaugare antrenor
        private void Btn_Add_Click(object sender, EventArgs e)
        {
            //se creeaza o noua instanta in tabelul antrenori
            Trainer trainer = new Trainer()
            {
                Trainer_ID          = new Random().Next(1, 100000).ToString(),
                Trainer_Address     = txbx_address.Text,
                Trainer_Name        = txbx_name.Text,
                Trainer_PhoneNumber = txbx_contact.Text
            };

            //Se adauga in baza de date
            entities.Trainers.Add(trainer);
            //Salvare
            entities.SaveChanges();
            MessageBox.Show("Trainer has been Added", "Success", MessageBoxButtons.OK);
            //Refresh formular
            Form1 form = new Form1();

            ((Form1)this.TopLevelControl).Close();
            form.Show();
        }
Ejemplo n.º 4
0
        //Adaugarea membrului
        private void Btn_Add_Click(object sender, EventArgs e)
        {
            //retine abonamentul selectat
            string comboxBoxPackagesText = cmbx_package.Text;

            // Atribuirea codurilor conform bazei de date prin utilizarea structurilor de control
            if (cmbx_package.Text == "Monthly")
            {
                comboxBoxPackagesText = "1";
            }
            else if (cmbx_package.Text == "3 Months")
            {
                comboxBoxPackagesText = "3";
            }
            else if (cmbx_package.Text == "6 Months")
            {
                comboxBoxPackagesText = "6";
            }
            else if (cmbx_package.Text == "1 Year")
            {
                comboxBoxPackagesText = "12";
            }
            //Se ia cheia primară din packages cu interogare in baza de date
            var getPackagesID = (from package in entities.Packages
                                 where package.Package_Time == comboxBoxPackagesText
                                 select new { package.Package_ID, package.Package_Time }).FirstOrDefault();
            //selecteaza genul
            string gender = " ";

            if (malerb.Checked == true)
            {
                gender = "Male";
            }
            else if (femalrb.Checked == true)
            {
                gender = "Female";
            }
            string getTrainerID = " ";
            //Retine numele antrenorului
            string trainerSelected = cmbx_Trainer.Text;

            //Se ia id-ul din tabelul Trainer, după numele selectat
            getTrainerID = (from trainer in entities.Trainers
                            where trainer.Trainer_Name == trainerSelected
                            select trainer.Trainer_ID).FirstOrDefault();

            //se creeaza o noua instanta membru si se atribuie valori
            Member member = new Member()
            {
                Member_ID            = new Random().Next(1, 100000000).ToString(),
                Member_Date          = dateTimePicker2.Value.Date.ToShortDateString(),
                Member_Name          = namebox.Text.Trim(),
                Member_sex           = gender,
                Package_ID           = getPackagesID.Package_ID,
                Member_PackageExpiry = dateTimePicker1.Value.Date.AddMonths(int.Parse(getPackagesID.Package_Time)),
                Member_Email         = emailbox.Text.Trim(),
                AddedBy    = loginform.AddedBy,
                Trainer_ID = getTrainerID
            };

            //Se adauga in baza de date
            entities.Members.Add(member);
            //Call la save changes pentru a da update la database
            entities.SaveChanges();
            MessageBox.Show("Member has been Added Successfully", "Added", MessageBoxButtons.OK);
            //Refresh la form pentru a vedea updateul
            Form1 form = new Form1();

            ((Form1)this.TopLevelControl).Close();
            form.Show();
        }