Пример #1
0
 public static List <LearningHistory> GetListFromFile(string path, string idStudent)
 {
     if (File.Exists(path))
     {
         var lines = File.ReadAllLines(path);
         List <LearningHistory> rs = new List <LearningHistory>();
         foreach (var line in lines)
         {
             var             items   = line.Split(new char[] { '#' });
             LearningHistory history = new LearningHistory
             {
                 Id        = items[0],
                 FromYear  = int.Parse(items[1]),
                 ToYear    = int.Parse(items[2]),
                 Address   = items[3],
                 IdStudent = items[4]
             };
             if (history.IdStudent == idStudent)
             {
                 rs.Add(history);
             }
         }
         return(rs);
     }
     else
     {
         return(null);
     }
 }
Пример #2
0
 private void btnCapnhat_Click(object sender, EventArgs e)
 {
     if (LaThemMoi)
     {
         var history = new LearningHistory
         {
             Id        = Guid.NewGuid().ToString(),
             YearFrom  = (int)numTuNam.Value,
             YearEnd   = (int)numDenNam.Value,
             Address   = txtHocTai.Text,
             IdStudent = student.Id,
             Student   = student
         };
         LearningHistoryService.Add(frmHistoryLearning.pathHistory, history);
         DialogResult = DialogResult.OK;
     }
     else
     {
         history.YearFrom = (int)numTuNam.Value;
         history.YearEnd  = (int)numDenNam.Value;
         history.Address  = txtHocTai.Text;
         LearningHistoryService.Update(frmHistoryLearning.pathHistory, history);
         DialogResult = DialogResult.OK;
     }
 }
Пример #3
0
        public static List <LearningHistory> GetList(string path, string idStudent)
        {
            List <LearningHistory> rs = new List <LearningHistory>();

            if (File.Exists(path))
            {
                var lines = File.ReadAllLines(path);
                foreach (var line in lines)
                {
                    var             listItem = line.Split(new char[] { '#' });
                    LearningHistory learning = new LearningHistory
                    {
                        Id        = listItem[0],
                        FromYear  = Int32.Parse(listItem[1]),
                        ToYear    = Int32.Parse(listItem[2]),
                        Address   = listItem[3],
                        IdStudent = listItem[4]
                    };

                    rs.Add(learning);
                }
                return(rs);
            }

            else
            {
                return(null);
            }
        }
Пример #4
0
        /// <summary>
        /// Lấy danh sách học tập của 1 sinh viên
        /// </summary>
        /// <param name="idStudent">Mã sinh viên</param>
        /// <returns>Danh sách quá trình học tập</returns>
        public static List <LearningHistory> GetList(string idStudent)
        {
            List <LearningHistory> rs = new List <LearningHistory>();

            for (int i = 1; i <= 12; i++)
            {
                LearningHistory learning = new LearningHistory
                {
                    Id        = i.ToString(),
                    FromYear  = 2007 + i,
                    ToYear    = 2008 + i,
                    IdStudent = idStudent
                };
                if (i <= 5)
                {
                    learning.Address = "Tiểu học Phan Bội Châu";
                }
                else if (i <= 9)
                {
                    learning.Address = "Trung học Phan Đăng Lưu";
                }
                else
                {
                    learning.Address = "Phổ Thông Quốc học";
                }
                rs.Add(learning);
            }
            return(rs);
        }
Пример #5
0
 /// <summary>
 /// Lấy danh sách lịch sử học tập của sinh viên
 /// </summary>
 /// <param name="pathHistoryLeaningFileName">Link file</param>
 /// <param name="idStudent"><Mã sinh viên</param>
 /// <returns></returns>
 public static List <LearningHistory> getHistoryLearningFromFile(string pathHistoryLeaningFileName, string idStudent)
 {
     if (File.Exists(pathHistoryLeaningFileName))
     {
         List <LearningHistory> historyLearnings = new List <LearningHistory>();
         var lines = File.ReadAllLines(pathHistoryLeaningFileName);
         //Mã#Từ Năm # Đến Năm #Nơi học # Mã sinh viên
         foreach (var line in lines)
         {
             if (!line.Equals(""))
             {
                 var             rs = line.Split(new char[] { '#' });
                 LearningHistory historyLearning = new LearningHistory
                 {
                     Id        = rs[0],
                     YearFrom  = int.Parse(rs[1]),
                     YearEnd   = int.Parse(rs[2]),
                     Address   = rs[3],
                     IdStudent = rs[4]
                 };
                 if (historyLearning.IdStudent == idStudent)
                 {
                     historyLearnings.Add(historyLearning);
                 }
             }
         }
         return(historyLearnings);
     }
     else
     {
         return(null);
     }
 }
Пример #6
0
 public static void Update(string path, LearningHistory history)
 {
     if (File.Exists(path))
     {
         var lines = File.ReadAllLines(path);
         File.WriteAllText(path, "");
         foreach (var line in lines)
         {
             var end = "";
             if (line == lines[lines.Length - 1])
             {
                 end = "";
             }
             else
             {
                 end = "\n";
             }
             var items = line.Split(new char[] { '#' });
             if (items[0] != history.Id)
             {
                 File.AppendAllText(path, line + end);////Append là thêm vào, chèn vào sau chuỗi có trước
             }
             else
             {
                 string lineEdit = history.Id + "#" + history.YearFrom + "#" + history.YearEnd + "#" + history.Address + "#" + history.IdStudent;
                 File.AppendAllText(path, lineEdit + end);
             }
         }
     }
 }
Пример #7
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (LaThemMoi)
            {
                var history = new LearningHistory
                {
                    Id        = Guid.NewGuid().ToString(),
                    FromYear  = (int)numTuNam.Value,
                    ToYear    = (int)numDenNam.Value,
                    Address   = tbHocTai.Text,
                    IdStudent = "102T102"
                };

                LearningHistoryService.Add(Form1.pathDataHistory, history);
                DialogResult = DialogResult.OK;
            }
            else
            {
                learningHistory.FromYear = (int)numTuNam.Value;
                learningHistory.ToYear   = (int)numDenNam.Value;
                learningHistory.Address  = tbHocTai.Text;
                LearningHistoryService.Update(Form1.pathDataHistory, learningHistory);
                DialogResult = DialogResult.OK;
            }
        }
Пример #8
0
 public static void Add(string path, LearningHistory history)
 {
     if (File.Exists(path))
     {
         string line = history.Id + "#" + history.YearFrom + "#" + history.YearEnd + "#" + history.Address + "#" + history.IdStudent;
         File.AppendAllText(path, "\n" + line);
     }
 }
Пример #9
0
 public Form2(LearningHistory history)
 {
     InitializeComponent();
     this.learningHistory = history;
     numTuNam.Value       = history.FromYear;
     numDenNam.Value      = history.ToYear;
     tbHocTai.Text        = history.Address;
     LaThemMoi            = false;
 }
Пример #10
0
        public Form4(LearningHistory history)
        {
            InitializeComponent();
            this.Text = "Chỉnh sửa quá trình học tập";

            this.learningHistory = history;
            numTuNam.Value       = history.YearFrom;
            numDenNam.Value      = history.YearEnd;
            txtHocTai.Text       = history.Address;

            LaThemMoi = false;
        }
Пример #11
0
        public static void Update(string path, LearningHistory history)
        {
            List <LearningHistory> historyLearnings = new List <LearningHistory>();
            var lines = File.ReadAllLines(path);

            foreach (var line in lines)
            {
                var             rs = line.Split(new char[] { '#' });
                LearningHistory historyLearning = new LearningHistory
                {
                    Id        = rs[0],
                    YearFrom  = int.Parse(rs[1]),
                    YearEnd   = int.Parse(rs[2]),
                    Address   = rs[3],
                    IdStudent = rs[4]
                };
                historyLearnings.Add(historyLearning);
            }

            List <string> lineWrites = new List <string>();

            foreach (var historyLearning in historyLearnings)
            {
                if (historyLearning.Id == history.Id)
                {
                    historyLearning.YearFrom = history.YearFrom;
                    historyLearning.YearEnd  = history.YearEnd;
                    historyLearning.Address  = history.Address;
                }

                string lineWrite = historyLearning.Id + "#"
                                   + historyLearning.YearFrom + "#"
                                   + historyLearning.YearEnd + "#"
                                   + historyLearning.Address + "#"
                                   + historyLearning.IdStudent;
                lineWrites.Add(lineWrite);
            }
            File.WriteAllLines(path, lineWrites);
        }
Пример #12
0
        public static void Add(String path, LearningHistory history)
        {
            // Lấy danh sách HistoryLearning trong file
            List <LearningHistory> historyLearnings = new List <LearningHistory>();
            var lines = File.ReadAllLines(path);

            foreach (var line in lines)
            {
                var             rs = line.Split(new char[] { '#' });
                LearningHistory historyLearning = new LearningHistory
                {
                    Id        = rs[0],
                    YearFrom  = int.Parse(rs[1]),
                    YearEnd   = int.Parse(rs[2]),
                    Address   = rs[3],
                    IdStudent = rs[4]
                };
                historyLearnings.Add(historyLearning);
            }

            // Thêm HistoryLearning mới vào trong danh sách
            historyLearnings.Add(history);

            // Ghi lại vào file
            List <string> lineWrites = new List <string>();

            foreach (var historyLearning in historyLearnings)
            {
                string lineWrite = historyLearning.Id + "#"
                                   + historyLearning.YearFrom + "#"
                                   + historyLearning.YearEnd + "#"
                                   + historyLearning.Address + "#"
                                   + historyLearning.IdStudent;
                lineWrites.Add(lineWrite);
            }
            File.WriteAllLines(path, lineWrites);
        }
Пример #13
0
 internal static void Update(string pathDataHistory, LearningHistory learningHistory)
 {
     throw new NotImplementedException();
 }
Пример #14
0
 internal static void Add(string pathDataHistory, LearningHistory history)
 {
     // throw new NotImplementedException();
 }
 public static void Update(string path, LearningHistory history)
 {
 }
 public static void Add(string path, LearningHistory history)
 {
 }