コード例 #1
0
        private void DelLessonBut_Click(object sender, EventArgs e)
        {
            var c = dataGridView1.SelectedCells;

            int indrow;

            if (c.Count == 0)
            {
                return;
            }

            indrow = c[0].RowIndex;

            var s = dataGridView1.Rows[indrow];

            var dels = (int)s.Cells[0].Value;

            BD.SchoolEntities entities = new BD.SchoolEntities();

            BD.Lessons dt = entities.Lessons.Find(dels);

            entities.Lessons.Remove(dt);

            entities.SaveChanges();

            MessageBox.Show("Lesson delited!");
        }
コード例 #2
0
        private void AddTeachearsBut_Click(object sender, EventArgs e)
        {
            BD.SchoolEntities entities = new BD.SchoolEntities();

            BD.Teachers teachers = new BD.Teachers();

            teachers.NameT = NameBox.Text;

            teachers.SurNameT = SurNameBox.Text;

            entities.Teachers.Add(teachers);

            entities.SaveChanges();

            MessageBox.Show("Add Teacher!");
        }
コード例 #3
0
ファイル: Form2.cs プロジェクト: DeD-JIexa/BDshool
        private void AddStudsBut_Click(object sender, EventArgs e)
        {
            BD.SchoolEntities entities = new BD.SchoolEntities();

            BD.Studs studs = new BD.Studs();

            studs.NameS = NameBox.Text;

            studs.SurNameS = SurNameBox.Text;

            var cl = comboBox1.SelectedItem as BD.Classes;

            studs.IdCl = cl.IdCl;

            entities.Studs.Add(studs);

            entities.SaveChanges();

            MessageBox.Show("Stud add!");
        }