Exemple #1
0
        private void addToDB(List <string> cList)
        {
            DbEntities db = new DbEntities();

            foreach (var str in cList)
            {
                string[]    wordArray = str.Split(',');
                Participant tested    = new Participant();
                tested.Name     = wordArray[0];
                tested.Surname  = wordArray[1];
                tested.Age      = wordArray[2];
                tested.Capacity = "23";
                tested.Date     = DateTime.Now;
                tested.Rating   = "28";
                db.Participants.Add(tested);
            }

            db.SaveChanges();
        }
Exemple #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            DbEntities  db     = new DbEntities();
            Participant Person = new Participant();

            Person.Name     = txtInputName.Text;
            Person.Surname  = txtInputSurname.Text;
            Person.Age      = txtInputAge.Text;
            Person.Capacity = lblCapacityValue.Text;
            Person.Date     = DateTime.Now;
            Person.Rating   = lblNormValue.Text;
            db.Participants.Add(Person);
            db.SaveChanges();

            DialogResult result = MessageBox.Show("Participant added successfully, do you want to add another person and clear the form?", "Warning",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result == DialogResult.Yes)
            {
                txtInputName.Text     = "";
                txtInputSurname.Text  = "";
                txtInputAge.Text      = "";
                txtHR1.Text           = "";
                txtHR2.Text           = "";
                txtHR3.Text           = "";
                txtHR4.Text           = "";
                txtHR5.Text           = "";
                lblCapacityValue.Text = "";
                lblNormValue.Text     = "";
                sexFlag     = 0;
                cmbSex.Text = "";
                chkContraIndications.Checked = false;
                chkLifestyle.Checked         = false;
                chkReadinessCheck.Checked    = false;
                btnAdd.Enabled = false;
            }
            else if (result == DialogResult.No)
            {
            }
        }
Exemple #3
0
        private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            var                s  = dataGridView1.Columns[e.ColumnIndex].HeaderText;
            DbEntities         db = new DbEntities();
            List <Participant> testedList;

            switch (e.ColumnIndex)
            {
            case 0:
                testedList = db.Participants.OrderBy(c => c.Id).ToList();
                break;

            case 1:
                testedList = db.Participants.OrderBy(c => c.Name).ToList();
                break;

            case 2:
                testedList = db.Participants.OrderBy(c => c.Surname).ToList();
                break;

            case 3:
                testedList = db.Participants.OrderBy(c => c.Age).ToList();
                break;

            case 4:
                testedList = db.Participants.OrderBy(c => c.Date).ToList();
                break;

            case 5:
                testedList = db.Participants.OrderBy(c => c.Capacity).ToList();
                break;

            default:
                testedList = db.Participants.ToList();
                break;
            }
            populateGrid(testedList);
        }
Exemple #4
0
        private void TabSelection_Selecting(object sender, TabControlCancelEventArgs e)
        {
            DbEntities db = new DbEntities();

            populateGrid(db.Participants.ToList());
        }