// EVENT. private void Button_today_OK_Click(object sender, EventArgs e) { int length; string sql; length = Encoding.Default.GetBytes(textBox_today_text.Text).Length; if (!(length <= 20 && length > 0)) { MessageBox.Show("Invalid input.\nPlease select the correct date."); return; } try { sql = QueryList.overlapCheckSQL_Today(nUD_t_hour.Value, nUD_t_minute.Value); if (!overlapCheck(sql)) { MessageBox.Show("Duplicate alarm time."); return; } // insert sql = QueryList.insertSQL_today(nUD_t_hour.Value, nUD_t_minute.Value, textBox_today_text.Text); queryActive(sql); } catch (Exception exc) { MessageBox.Show("Error : " + exc.Message); if (dbConnect.State.ToString() == "Open") { dbConnect.Close(); } } }