Пример #1
0
 public static void Remove(string path, HistoryLearning history)
 {
     if (File.Exists(path))
     {
         List <string> rs    = new List <string>();
         var           lines = File.ReadAllLines(path);
         foreach (var line in lines)
         {
             var data = HistoryLearning.Parse(line);
             if (data.ID != history.ID)
             {
                 rs.Add(line);
             }
         }
         File.WriteAllLines(path, rs);
     }
     else
     {
         throw new Exception("File dữ liệu không có tồn tại");
     }
 }
Пример #2
0
        /// <summary>
        /// Lấy danh sách quá trình học tập của một sinh viên dựa vào file
        /// </summary>
        /// <param name="path">Đường dẫn chứa file dữ liệu</param>
        /// <param name="idStudent">Mã sinh viên</param>
        /// <returns>Danh sách quá trình học tập của 1 sinh viên</returns>
        public static List <HistoryLearning> GetListHistoryLearning(
            string path, string idStudent)
        {
            List <HistoryLearning> rs = new List <HistoryLearning>();

            if (File.Exists(path))
            {
                var lines = File.ReadAllLines(path);
                foreach (var line in lines)
                {
                    //Line: ma#tuNam#denNam#noiHoc#masv
                    var history = HistoryLearning.Parse(line);
                    if (history.IDStudent == idStudent)
                    {
                        rs.Add(history);
                    }
                }
                return(rs);
            }
            else
            {
                return(null);
            }
        }