/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="name"></param> public static void InsertSubject(string id, string name, string type, string dept) { var subject = new PR_Bomon() { MaBoMon = id, TenBoMon = name, CreateBy = type, CreateDate = DateTime.Now, ModifyDate = DateTime.Now, }; if (dept != null) { subject.Dept = dept; } try { using (var context = new EducationSkillsDbContext()) { context.PR_Bomon.Add(subject); context.SaveChanges(); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public FormAddSubject(string id) { InitializeComponent(); context = new EducationSkillsDbContext(); if (id != "") { lblTitle.Text = "Sửa môn học"; _subject = SubjectDataProvider.GetSubjectById(id); txtSubjectID.Text = _subject.MaBoMon; txtSubjectName.Text = _subject.TenBoMon; txtSubjectID.Enabled = false; } else { lblTitle.Text = "Thêm môn học"; btnDel.Visible = false; } GetDepartments(); }