public static int GetCount() { int count = 0; List <InsureInfo> all = InsureInfo.GetAll(); foreach (InsureInfo insureInfo in all) { if (insureInfo.ExpireDate < DateTime.Now) { count += 1; } } return(count); }
public static List <InsureInfo> GetAll() { new DatabaseConnector(); MySqlConnection dbCon = DatabaseConnector.GetConnection(); List <InsureInfo> all = new List <InsureInfo>(); String query = "select * from insure"; MySqlCommand cmd = new MySqlCommand(query, dbCon); dbCon.Open(); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { DateTime date = reader.GetDateTime(2); InsureInfo info = new InsureInfo((int)reader["ID"], reader["Provider"].ToString(), date, reader["itemid"].ToString(), (int)reader["worth"]); all.Add(info); } dbCon.Close(); return(all); }
public static List <Notification> GetAll() { List <Notification> all = new List <Notification>(); List <InsureInfo> allinfo = InsureInfo.GetAll(); foreach (InsureInfo insureInfo in allinfo) { if (insureInfo.ExpireDate < DateTime.Now) { String title = insureInfo.Provider + " to be updated"; String content = "Expires on " + insureInfo.ExpireDate.ToString() + ". Be advised and update soon"; String timeStamp = String.Format("{0}:0{1}", DateTime.Now.Hour.ToString(), DateTime.Now.Minute.ToString()); Notification temp = new Notification(title, content, timeStamp); all.Add(temp); } } return(all); }