private void QueryActive(string sql) { tempConnect.Open(); command = new SQLiteCommand(sql, tempConnect); command.ExecuteNonQuery(); tempConnect.Close(); calendar.TodayAlarmListRefresh(); calendar.RefreshAlarm(); Close(); }
// Impliment Method. public void AddMode(bool multiMod) { string[] tempDate = (dateTimePicker_start.Value.ToString("yyyy-M-d")).Split('-'); DataManage setData = new DataManage(dateYMD[0], dateYMD[1], dateYMD[2], numericUpDown_setHour.Value, numericUpDown_setMinute.Value, textBox_calendarText.Text, checkBox_checkAlarm.Checked); // overlap alarm check. string sql_str = new ListSqlQuery().sqlOverlapCheck(ListSqlQuery.CALENDAR_MODE, setData.YearMonthDay, setData.HourMinute); if (!OverlapCheck(sql_str, false)) { return; } // insert data. (normal) if (!multiMod) { sql_str = new ListSqlQuery().sqlInsertValues(ListSqlQuery.CALENDAR_MODE, setData.YearMonthDay, setData.HourMinute, setData.Text, setData.Active); QueryActive(sql_str, false); } // insert data. (multi) else { DateTime temp_nextday = new DateTime(dateTimePicker_start.Value.Ticks); TimeSpan temp = DateTime.Parse(dateTimePicker_end.Value.ToString("yyyy-M-d")) - DateTime.Parse(dateTimePicker_start.Value.ToString("yyyy-M-d")); int dayTemp = temp.Days; bool oncemessage = true; for (int count = 0; count <= dayTemp; count++, temp_nextday = temp_nextday.AddDays(1)) { tempDate = temp_nextday.ToString("yyyy-M-d").Split('-'); setData.YearMonthDay = new decimal[] { decimal.Parse(tempDate[0]), decimal.Parse(tempDate[1]), decimal.Parse(tempDate[2]) }; sql_str = new ListSqlQuery().sqlOverlapCheck(ListSqlQuery.CALENDAR_MODE, setData.YearMonthDay, setData.HourMinute); tempConnect.Open(); command = new SQLiteCommand(sql_str, tempConnect); SQLiteDataReader reader = command.ExecuteReader(); // data is already exist. if (reader.Read()) { reader.Close(); tempConnect.Close(); if (oncemessage) { MessageBox.Show("Existing data was maintained due to overlapping schedules."); } oncemessage = false; } // data is not already exist. else { reader.Close(); tempConnect.Close(); sql_str = new ListSqlQuery().sqlInsertValues(ListSqlQuery.CALENDAR_MODE, setData.YearMonthDay, setData.HourMinute, textBox_calendarText.Text, checkBox_checkAlarm.Checked); tempConnect.Open(); command = new SQLiteCommand(sql_str, tempConnect); command.ExecuteNonQuery(); tempConnect.Close(); } } calendar.ChangeCalendar(); calendar.CalendarListRefresh(); calendar.RefreshAlarm(); Close(); } }
public void RefreshCalendar() { calendar.ChangeCalendar(); calendar.CalendarListRefresh(); calendar.RefreshAlarm(); }