Exemplo n.º 1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            currentTime = DateTime.Now.ToString("HH:mm:ss");
            label1.Text = currentTime;
            TimeSpan fiveMinutes    = new TimeSpan(0, 5, 0);
            DateTime fiveMinutesAgo = DateTime.Now.Subtract(fiveMinutes);

            //Check whether the current time is in the list, if so then check that last time it was checked was longer than 5 minutes ago.
            //This is to stop us having loads of windows pop up at one time.
            if (reminderTimes.ContainsKey(currentTime) && ((DateTime.Compare(reminderTimes[currentTime], fiveMinutesAgo)) < 0) &&
                DateTime.Now.DayOfWeek != DayOfWeek.Saturday && DateTime.Now.DayOfWeek != DayOfWeek.Sunday)
            {
                reminderTimes[currentTime] = DateTime.Now;
                if (enableTimesheetReminder.Checked)
                {
                    TimesheetEntry timesheetEntry = new TimesheetEntry();
                    timesheetEntry.Show();
                }
            }

            if (enableMovements.Checked && DateTime.Now.ToString("dddd") == Properties.Settings.Default.movementDay && Properties.Settings.Default.movementTime == currentTime &&
                ((DateTime.Compare(lastTimeMovementsReminded, fiveMinutesAgo)) < 0))
            {
                MovementEntry movementEntry = new MovementEntry(Properties.Settings.Default.movementCurrentWeek);
                movementEntry.Show();
                lastTimeMovementsReminded = DateTime.Now;
            }


            if (Properties.Settings.Default.movementsAutofill)
            {
                DateTime lastSaturday = DateTime.Now.AddDays(-1);
                while (lastSaturday.DayOfWeek != DayOfWeek.Saturday)
                {
                    lastSaturday = lastSaturday.AddDays(-1);
                }

                //This is to make sure we only attempt to fill in movements once per hour.
                TimeSpan oneHour    = new TimeSpan(1, 0, 0);
                DateTime oneHourAgo = DateTime.Now.Subtract(oneHour);

                if (((DateTime.Compare(lastTimeMovementsFilled, lastSaturday) < 0)) && (DateTime.Compare(lastTimeMovementsFillAttempted, oneHourAgo) < 0))
                {
                    lastTimeMovementsFillAttempted     = DateTime.Now;
                    webBrowser1.ScriptErrorsSuppressed = true;
                    webBrowser1.Navigate(new Uri("http://intranet.cougarautomation.net/Cats/Movements/MyMovements.aspx"));
                }
            }
        }
Exemplo n.º 2
0
        private void movementsNextWeek_Click(object sender, EventArgs e)
        {
            MovementEntry movementEntry = new MovementEntry(false);

            movementEntry.Show();
        }
Exemplo n.º 3
0
        private void movementsThisWeek_Click(object sender, EventArgs e)
        {
            MovementEntry movementEntry = new MovementEntry(true);

            movementEntry.Show();
        }