ta mu

ta mu

  • NA
  • 201
  • 78.8k

date time comparasion

Sep 11 2013 4:46 AM
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)