7
Answers

date time comparasion

ta mu

ta mu

10y
1.1k
1
this is code which i am using for reminder option. but it only works when  pc remain running how to convert that code if i restart my computer
it starts working agin.

 public DateTime mytime;
        private void timer1_Tick(object sender, EventArgs e)
        {
           
            if (mytime.CompareTo(DateTime.Now) < 0)
            {

                this.Show();

            }
        }
       
          private void button1_Click(object sender, EventArgs e)
        {
            mytime = monthCalendar1.SelectionStart.AddHours(dateTimePicker1.Value.Hour).AddMinutes(dateTimePicker1.Value.Minute).AddSeconds(dateTimePicker1.Value.Second);
           if (textBox1.Text!="")
            {
              
              

                SqlCommand cmd = new SqlCommand("INSERT INTO reminder (message,date,time) VALUES ('" + textBox1.Text + "','" + monthCalendar1.SelectionStart + "','" + dateTimePicker1.Value + "')", my);

                cmd.ExecuteNonQuery();
               this.Hide();


            }
            else
            {



                MessageBox.Show("Enter A Messag");

            }

Answers (7)