public string Save() { string error = ""; try { using (SQLDatabaseDataContext db = new SQLDatabaseDataContext()) { DepartmentLecture departmentLecture = new DepartmentLecture(); if (this.ID > 0) { departmentLecture = (from dl in db.DepartmentLectures where dl.ID == this.ID select dl).FirstOrDefault(); } departmentLecture.LectureID = this.LectureID; departmentLecture.DepartmentID = this.DepartmentID; departmentLecture.StartDate = this.StartDate; departmentLecture.FinishDate = this.FinishDate; departmentLecture.SubjectID = this.SubjectID; if (this.ID == 0) { db.DepartmentLectures.InsertOnSubmit(departmentLecture); } db.SubmitChanges(); } } catch (Exception ex) { error = ex.Message; } return(error); }
public TDepartmentLectrure(DepartmentLecture dl) { this.ID = dl.ID; this.LectureID = dl.LectureID; this.DepartmentID = dl.DepartmentID; this.StartDate = dl.StartDate; this.FinishDate = dl.FinishDate; this.SubjectID = dl.SubjectID; }