static public void AddExercise(string title, int time, string[] lines) { List <string> text = new List <string>(); foreach (string s in lines) { text.Add(s); } DTO_Exercise exercise = new DTO_Exercise("Paragraph", time, title, text, getFileName(), time, 0, 0); DAO_Exercise.AddExercise(exercise); }
static public List <DTO_Exercise> FindAllExercise() //Tìm toàn bộ bài tập trong file Exercise.Xml { List <DTO_Exercise> objects = new List <DTO_Exercise>(); List <string> warningTitles = new List <string>(); objects = DAO_Exercise.FindAllExercise(ref warningTitles); //Hiển thị thông báo các bài tập bị lỗi foreach (string title in warningTitles) { MessageBox.Show("Exercise \"" + title + "\" has been corrupted or deleted. It will be removed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); DeleteExercise(title); } return(objects); }
static public bool FileTxtExist(string fileName) { return(DAO_Exercise.FileTxtExist(fileName)); }
static public bool IsExist(string title) { return(DAO_Exercise.IsExist(title)); }
static public void DeleteExercise(string title) { DAO_Exercise.DeleteExercise(title); }
static public bool UpdateExercise(DTO_Exercise ob) { return(DAO_Exercise.UpdateExercise(ob)); }
static public List <Label> SearchLessonSections(LessonTag tag, object sender, ref List <Label> buttons) { List <DTO_Lesson> lessons = DAO_Lesson.SearchLessons(tag.courseId); //Tạo label chứa số thứ tự các bài học int repetition = 1; foreach (DTO_Lesson lesson in lessons) { //Tạo tag cho các label LessonTag lessonCntTag = new LessonTag(); lessonCntTag.courseId = tag.courseId; lessonCntTag.lessonNumber = repetition; lessonCntTag.lesson = lesson; //Tạo các nút bấm để di chuyển giữa các bài học Label lbLessonCnt = new Label(); lbLessonCnt.Text = repetition.ToString(); lbLessonCnt.Tag = lessonCntTag; lbLessonCnt.Location = new Point((repetition - 1) * 30, 0); lbLessonCnt.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; lbLessonCnt.Cursor = System.Windows.Forms.Cursors.Hand; lbLessonCnt.Font = new System.Drawing.Font("Century Gothic", 12.75F, System.Drawing.FontStyle.Bold); lbLessonCnt.Location = new System.Drawing.Point((repetition - 1) * 65 + 25, 6); lbLessonCnt.Size = new System.Drawing.Size(33, 23); lbLessonCnt.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; buttons.Add(lbLessonCnt); repetition++; } List <DTO_LessonSection> sections = tag.lesson.Sections; List <Label> labels = new List <Label>(); repetition = 1; foreach (DTO_LessonSection section in sections) { Label lbSectionCnt = new Label(); lbSectionCnt.Text = tag.lessonNumber + ". " + repetition; lbSectionCnt.Location = new Point(20, (repetition - 1) * 60 + 10); lbSectionCnt.AutoSize = true; lbSectionCnt.Font = new System.Drawing.Font("Century Gothic", 12.75F, System.Drawing.FontStyle.Bold); lbSectionCnt.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); Label lbSection = new Label(); lbSection.Text = section.Name; lbSection.Location = new Point(100, (repetition - 1) * 60 + 10); lbSection.AutoSize = true; lbSection.Cursor = System.Windows.Forms.Cursors.Hand; lbSection.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); lbSection.ForeColor = System.Drawing.Color.Black; lbSection.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); lbSection.Tag = DAO_Exercise.CreateExercise(section); lbSection.MouseEnter += new EventHandler(ChangeColor); lbSection.MouseLeave += new EventHandler(ChangeColor); labels.AddRange(new List <Label> { lbSectionCnt, lbSection }); repetition++; } return(labels); }