private void LoadingDef() { using (ZoraModel db = new ZoraModel()) { var result = (from lectures in db.Lectures join subject in db.Subject on lectures.Subject_Id equals subject.id join professor in db.Professors on subject.Professor_Id equals professor.id join students in db.Students on lectures.Studen_Id equals students.id join gope in db.Group_1 on students.Group_Id equals gope.id select new { Id = lectures.id, SValue = subject.id, Data = lectures.Date, SubjectName = subject.Modul_Name, Professor = professor.FirstName, Student = students.FirstName, Group = gope.Group_Name, Mark = lectures.Mark, Student_Id = students.id }).ToList(); dataGridView1.DataSource = result; dataGridView1.Refresh(); } }
private void btnDell_Click(object sender, EventArgs e) { try { if (lectures.id >= 0) { using (ZoraModel db = new ZoraModel()) { lectures = db.Lectures.Find(lectures.id); db.Lectures.Remove(lectures); db.SaveChanges(); LoadingDef(); MessageBox.Show("Операция завершена успешно"); } } else { MessageBox.Show("Выберите объект из таблицы"); } } catch (Exception) { MessageBox.Show("Выберите объект из таблицы"); } }
private void button1_Click(object sender, EventArgs e) { if (lectures.id >= 0) { using (ZoraModel db = new ZoraModel()) { lectures = db.Lectures.Find(lectures.id); AddValue(); db.SaveChanges(); LoadingDef(); MessageBox.Show("Операция завершена успешно"); } } else { MessageBox.Show("Выберите объект из таблицы"); } }
private void btnAdd_Click(object sender, EventArgs e) { try { lectures = new Lectures(); AddValue(); using (ZoraModel db = new ZoraModel()) { db.Lectures.Add(lectures); db.SaveChanges(); LoadingDef(); MessageBox.Show("Операция завершена успешно"); } } catch (Exception) { MessageBox.Show("Error: Date error format"); } }