Esempio n. 1
0
        // database(today) current day calendar import.
        public void todayAlarmListRefresh()
        {
            dbConnect2.Open();
            listView_todayList.Items.Clear();

            dbCommand2 = new SQLiteCommand(QueryList.listviewTodayRefreshSQL(), dbConnect2);
            SQLiteDataReader reader = dbCommand2.ExecuteReader();

            while (reader.Read())
            {
                listView_todayList.Items.Add(new ListViewItem(new string[] {
                    ((int)reader["sethour"]).ToString("00") + " : " + ((int)reader["setminute"]).ToString("00"),
                    reader["text"].ToString()
                }));
            }

            reader.Close();
            dbConnect2.Close();

            button_today_modify.Enabled = false;
            button_today_delete.Enabled = false;
        }
        // today alarm check.
        public void todayAlarmChecked()
        {
            DateTime today     = new DateTime();
            DateTime current   = DateTime.Now;
            bool     findToday = false;

            try {
                sql = QueryList.listviewTodayRefreshSQL();
                dbconnect2.Open();
                dbcommand = new SQLiteCommand(sql, dbconnect2);
                reader    = dbcommand.ExecuteReader();

                // Today alarm confirm.
                while (reader.Read())
                {
                    today = new DateTime();

                    today = today.AddYears(current.Year - 1).AddMonths(current.Month - 1).AddDays(current.Day - 1).
                            AddHours((int)reader["sethour"]).AddMinutes((int)reader["setminute"]);

                    if (today <= current)
                    {
                        continue;
                    }
                    else if (today > current)
                    {
                        findToday = true;

                        if (today >= alarm)
                        {
                            break;
                        }
                        else if (today < alarm)
                        {
                            alarm      = today;
                            alarm_text = reader["text"].ToString();
                            break;
                        }
                    }
                }

                reader.Close();

                // Next day confirm.
                if (!findToday)
                {
                    reader = dbcommand.ExecuteReader();

                    if (reader.Read())
                    {
                        today = new DateTime();

                        today = today.AddYears(current.Year - 1).AddMonths(current.Month - 1).AddDays(current.Day).
                                AddHours((int)reader["sethour"]).AddMinutes((int)reader["setminute"]);

                        if (today <= current)
                        {
                        }
                        else if (today > current)
                        {
                            if (today >= alarm)
                            {
                            }
                            else if (today < alarm)
                            {
                                alarm      = today;
                                alarm_text = reader["text"].ToString();
                            }
                        }
                    }

                    reader.Close();
                }

                dbconnect2.Close();

                MessageBox.Show("alarm : " + alarm.Year + "." + alarm.Month + "." + alarm.Day + " " + alarm.Hour + ":" + alarm.Minute);
            } catch (Exception exc) { MessageBox.Show(exc.Message); }
        }