示例#1
0
 static public USER[] CreateListUser(string pathUser = "", string pathID = "") // Trả về danh sách các USER có List các ToDo
 {
     try
     {
         string userPath = Path.Combine(pathUser, "user.txt");
         string idPath;
         if (!File.Exists(userPath))
         {
             return(null);
         }
         USER[] a;
         using (StreamReader users = new StreamReader(userPath))
         {
             a = new USER[int.Parse(users.ReadLine())];
             int    length_a = a.Length, count = -1;
             string user;
             while ((user = users.ReadLine()) != null)
             {
                 string[] user_element = user.Split(' ');
                 count++;
                 a[count] = new USER(user_element[1], user_element[2], int.Parse(user_element[0]));
                 idPath   = Path.Combine(pathID, a[count].getID().ToString());
                 if (!File.Exists(idPath))
                 {
                     MessageBox.Show($"Dữ liệu của ID {a[count].getID()} không tồn tại!", "Lỗi hệ thống", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     CreateFileID(pathID, a[count].getID().ToString());
                 }
                 using (StreamReader ids = new StreamReader(idPath))
                 {
                     string id;
                     id = ids.ReadLine();
                     int    capacity_id = int.Parse(id);
                     bool   On          = false;
                     bool   checkbox    = false;
                     string content     = "";
                     for (int i = 0; i < capacity_id; i++)
                     {
                         id = ids.ReadLine();
                         if (id == "<")
                         {
                             On       = true;
                             content  = "";
                             id       = ids.ReadLine();
                             checkbox = Convert.ToBoolean(id);
                             continue;
                         }
                         else if (id == ">")
                         {
                             On = false;
                             a[count].tdlUser.AddContent(content, checkbox);
                             continue;
                         }
                         if (On)
                         {
                             content += id;
                         }
                     }
                 }
             }
         }
         return(a);
     }
     catch (Exception a)
     {
         MessageBox.Show(a.Message);
         return(null);
     }
 }
示例#2
0
 public void EditContent(ref USER admin, int pos, string content, bool checkbox)
 {
     admin.EditContent(pos, content, checkbox);
 }
示例#3
0
 public void DeleteAllContent(ref USER admin)
 {
     admin.DeleteALlContent();
 }
示例#4
0
 public void AddContent(ref USER admin, string content, bool checkbox)
 {
     admin.AddContent(content, checkbox);
 }
示例#5
0
 public void DeleteContent(ref USER admin, int pos)
 {
     admin.DeleteContent(pos);
 }