Esempio n. 1
0
 public frmQTHTChiTiet(QTHT qtht = null, string pathQTHT = null)
 {
     InitializeComponent();
     this.qtht     = qtht;
     this.pathQTHT = pathQTHT;
     if (qtht != null)
     {
         this.Text       = "Chỉnh sửa quá trình học tập";
         numTuNam.Value  = qtht.FromYear;
         numDenNam.Value = qtht.ToYear;
         txtNoiHoc.Text  = qtht.SchoolName;
     }
     else
     {
         this.Text = "Thêm quá trình học tập";
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="idStudent"></param>
 /// <returns></returns>
 public static List<QTHT> getQTHT(string idStudent)
 {
     List<QTHT> list = new List<QTHT>();
     for(int i=1; i<=12; i++)
     {
         QTHT qtht = new QTHT
         {
             ID = i.ToString(),
             FromYear = 2000 + i,
             ToYear = 2001 + i,
             SchoolName = "Hương Thủy",
             IDStudent = idStudent,
             
         };
         list.Add(qtht);
         
     }
     return list;
 }
 public static void Remove(string path, QTHT qtht)
 {
     if (File.Exists(path))
     {
         List<string> rs = new List<string>();
         var lines = File.ReadAllLines(path);
         foreach(var line in lines)
         {
             var data = QTHT.Parse(line);
             if(data.ID != qtht.ID)
             {
                 rs.Add(line);
             }
         }
         File.WriteAllLines(path, rs);
     }
     else
     {
         throw new Exception("File du lieu khong ton tai!");
     }
 }
 /// <summary>
 /// lay danh sach sinh vien vao file
 /// </summary>
 /// <param name="path">duong dan file</param>
 /// <param name="idStudent"></param>
 /// <returns></returns>
 public static List<QTHT> getQTHT(string path,string idStudent)
 {
     List<QTHT> list = new List<QTHT>();
     if (File.Exists(path))
     {
         var lines = File.ReadAllLines(path);
         foreach (var line in lines)
         {
             var qtht = QTHT.Parse(line);    
            if (qtht.IDStudent == idStudent)
            {
                 list.Add(qtht);
            }               
         }
         return list;
     }
     else
     {
         return null;
     }           
 }