예제 #1
0
        public List <Desease> GetDesease()
        {
            List <Desease> deseaseList = new List <Desease>();

            foreach (DataRow row in Data.Rows)
            {
                string getDesease = row["chandoan"].ToString();
                int    dem        = 0;
                for (int i = 0; i < deseaseList.Count; i++)
                {
                    if (deseaseList[i].desease == getDesease)
                    {
                        deseaseList[i] = new Desease {
                            desease = deseaseList[i].desease, count = deseaseList[i].count + 1
                        };
                    }
                    else
                    {
                        dem++;
                    }
                }
                if (dem == deseaseList.Count)
                {
                    Desease newDesease = new Desease {
                        desease = getDesease, count = 1
                    };
                    deseaseList.Add(newDesease);
                }
            }
            return(deseaseList);
        }
예제 #2
0
        public List <Desease> GetSeasonalDesease()
        {
            List <Desease> chooseDesease = new List <Desease>();
            DateTime       now           = DateTime.Now;

            if (now.Month == 1 || now.Month == 2 || now.Month == 3)
            {
                string[] benh = new string[] { "Thủy đậu", "Sốt phát ban", "Viêm kết mạc" };
                for (int i = 0; i < 3; i++)
                {
                    Desease temp = new Desease();
                    temp.desease = benh[i];
                    chooseDesease.Add(temp);
                }
            }
            else if (now.Month == 4 || now.Month == 5 || now.Month == 6)
            {
                string[] benh = new string[] { "Tiêu chảy", "Sốt xuất huyết", "Viêm não Nhật Bản" };
                for (int i = 0; i < 3; i++)
                {
                    Desease temp = new Desease();
                    temp.desease = benh[i];
                    chooseDesease.Add(temp);
                }
            }
            else if (now.Month == 7 || now.Month == 8 || now.Month == 9)
            {
                string[] benh = new string[] { "Viêm phế quản", "Cảm cúm", "Đau mắt đỏ" };
                for (int i = 0; i < 3; i++)
                {
                    Desease temp = new Desease();
                    temp.desease = benh[i];
                    chooseDesease.Add(temp);
                }
            }
            else
            {
                string[] benh = new string[] { "Đau khớp", "Tay chân lạnh", "Hội chứng Norovirus" };
                for (int i = 0; i < 3; i++)
                {
                    Desease temp = new Desease();
                    temp.desease = benh[i];
                    chooseDesease.Add(temp);
                }
            }
            return(chooseDesease);
        }
예제 #3
0
 public List <Desease> GetDecreaseDesease()
 {
     using (SqlConnection connection = new SqlConnection(ConnectString.connectString))
     {
         SqlDataAdapter adapter = new SqlDataAdapter();
         DataTable      temp    = new DataTable();
         adapter.SelectCommand = new SqlCommand("select ngaykham, chuandoan from benhan", connection);
         adapter.Fill(temp);
         DataTable temp1 = new DataTable();
         temp1.Clear();
         temp1.Columns.Add("ngayKham");
         temp1.Columns.Add("chanDoan");
         DateTime dayAgo = DateTime.Now;
         dayAgo = dayAgo.AddDays(-3);
         foreach (DataRow row in temp.Rows)
         {
             string   time = row["ngaykham"].ToString();
             string[] date = time.Split(new[] { "/" }, StringSplitOptions.None);
             date[2] = date[2].Substring(0, 4);
             DateTime newdate = new DateTime(int.Parse(date[2]), int.Parse(date[0]), int.Parse(date[1]));
             TimeSpan diff    = newdate - dayAgo;
             if (diff.TotalDays >= 0)
             {
                 temp1.Rows.Add(row.ItemArray);
             }
         }
         List <Desease> deseaseList = new List <Desease>();
         foreach (DataRow row in temp1.Rows)
         {
             string getDesease = row["chandoan"].ToString();
             int    dem        = 0;
             for (int i = 0; i < deseaseList.Count; i++)
             {
                 if (deseaseList[i].desease == getDesease)
                 {
                     deseaseList[i] = new Desease {
                         desease = deseaseList[i].desease, count = deseaseList[i].count + 1
                     };
                 }
                 else
                 {
                     dem++;
                 }
             }
             if (dem == deseaseList.Count)
             {
                 Desease newDesease = new Desease {
                     desease = getDesease, count = 1
                 };
                 deseaseList.Add(newDesease);
             }
         }
         List <Desease> chooseDesease = new List <Desease>();
         for (int j = 0; j < 3; j++)
         {
             if (deseaseList.Count != 0)
             {
                 string tempDesease = deseaseList[0].desease;
                 int    tempCount   = deseaseList[0].count;
                 for (int i = 0; i < deseaseList.Count; i++)
                 {
                     if (deseaseList[i].count < tempCount)
                     {
                         tempDesease = deseaseList[i].desease;
                         tempCount   = deseaseList[i].count;
                     }
                 }
                 Desease choose = new Desease {
                     desease = tempDesease, count = tempCount
                 };
                 chooseDesease.Add(choose);
                 deseaseList.RemoveAll(e => e.desease == tempDesease);
             }
         }
         return(chooseDesease);
     }
 }