コード例 #1
0
ファイル: MainForm.cs プロジェクト: karolinakra/LinqQueries
        private void GetResults_Click(object sender, EventArgs e)
        {
            ObjectRepo repo = new ObjectRepo();

            repo.Add(new Person {
                ID = 1000, Name = "XYZ"
            });
            dgv.DataSource = People.PeopleList.OrderByDescending(a => a.ID).ToList();
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: kajacek/LinqQueries
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ObjectRepo repo = new ObjectRepo();
            //Person person = new Person();
            //person.Name = tbName.Text;
            //person.LastName = tbLastName.Text;
            //person.BirthDate = dtpBirth.Value;
            //person.Weight = Convert.ToInt32(mtbWeight.Text);
            //person.Height = Convert.ToInt32(mtbHeight.Text);
            Person person = new Person()
            {
                Name      = tbName.Text,
                LastName  = tbLastName.Text,
                BirthDate = dtpBirth.Value,
                Weight    = Convert.ToInt32(mtbWeight.Text),
                Height    = Convert.ToInt32(mtbHeight.Text),
            };

            repo.Add(person);
            MessageBox.Show("OK");
            getResult_Click(null, null);        // wywołanie metody z przycisku, bez obciążania pamięci
            //getResult_Click(sender, e);        // wywołanie metody z przycisku
        }