// Updates the current reminder time
        /// <summary>
        /// Updates the current reminder time
        /// </summary>
        private void UpdateReminderTime(object sender, EventArgs e)
        {
            DataBaseEventDbContext db = new DataBaseEventDbContext();
            var r = from d in db.DataBaseEvents1
                    where d.RemindTime.Year == Current_data.Year && d.RemindTime.Month == Current_data.Month && d.RemindTime.Day == Current_data.Day && d.RemindTime.Hour == Current_data.Hour && d.RemindTime.Minute == Current_data.Minute
                    select d;

            foreach (var item in r)
            {
                string      eventReminder = "Event " + item.Name.ToString() + " starts at " + item.StartTime.ToString();
                AlertWindow alertWindow   = new AlertWindow(eventReminder, "Reminder");
                alertWindow.ShowDialog();
            }
        }
Beispiel #2
0
        // The metod save information to the database
        /// <summary>
        /// The metod save information to the database
        /// </summary>
        /// <param name="sender"> Contains a reference to the object that triggered the event </param>
        /// <param name="e"> Contains state information and event data associated with a routed event  </param>
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            SolidColorBrush blackBrush = new SolidColorBrush(Colors.Black);

            blackBrush.Opacity = 0.9;
            string   input1 = EventStart.Text;
            string   input2 = EventStop.Text;
            TimeSpan time1;
            TimeSpan time2;

            if (TimeSpan.TryParse(input1, out time1) && TimeSpan.TryParse(input2, out time2))
            {
                if (TimeSpan.Compare(time1, time2) < 0 && this.EventName.Foreground.Opacity == blackBrush.Opacity && this.EventStart.Foreground.Opacity == blackBrush.Opacity && this.EventStop.Foreground.Opacity == blackBrush.Opacity && this.EventLocalization.Foreground.Opacity == blackBrush.Opacity)
                {
                    TimeSpan       ts        = new TimeSpan(RemindCombobox.SelectedIndex, 0, 0);
                    DateTime       from_date = new DateTime(EventDate.Year, EventDate.Month, EventDate.Day) + time1;
                    DataBaseEvent1 obj       = new DataBaseEvent1()
                    {
                        Name         = EventName.Text,
                        Localization = EventLocalization.Text,
                        Year         = EventDate.Year,
                        Month        = EventDate.Month,
                        Day          = EventDate.Day,
                        StartTime    = EventStart.Text,
                        StopTime     = EventStop.Text,
                        RemindTime   = from_date - ts,
                    };
                    DbEvent.SaveEvent(obj);
                    RestartWindow();
                    if (oneList != null)
                    {
                        oneList.UpdateGrid();
                    }
                    mainWindow.RefreshAllDayButtons();
                    mainWindow.ShowCurrentDay();
                    mainWindow.AddEventToStackPanel();
                }
                else
                {
                    AlertWindow alertWindow = new AlertWindow("Please, corect your information!", "Input Error");
                    alertWindow.ShowDialog();
                }
            }
            else
            {
                AlertWindow alertWindow = new AlertWindow("Please, corect your information!", "Input Error");
                alertWindow.ShowDialog();
            }
        }
        // The metod save change information to the database
        /// <summary>
        /// The metod save change information to the database
        /// </summary>
        /// <param name="sender"> Contains a reference to the object that triggered the event </param>
        /// <param name="e"> Contains state information and event data associated with a routed event  </param>
        private async void ButtonSave_Click(object sender, RoutedEventArgs e)
        {
            CurrentWeatherInfoModel currentWeather = await CurrentWeatherInfoProcessor.LoadCurrentWeather(EventLocalization.Text);

            if (currentWeather.Cod == "404")
            {
                AlertWindow alertWindow = new AlertWindow("No such city! Try Again!", "Input Error");
                alertWindow.ShowDialog();
            }
            else
            {
                DbLocalization.SaveLocalization(EventLocalization.Text);
                mainWindow.LoadCurrentCity();
                mainWindow.LoadCurrentWeather();
            }
        }
        // The metod save information to the database
        /// <summary>
        /// The metod save information to the database
        /// </summary>
        /// <param name="sender"> Contains a reference to the object that triggered the event </param>
        /// <param name="e"> Contains state information and event data associated with a routed event  </param>
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            SolidColorBrush blackBrush = new SolidColorBrush(Colors.Black);

            blackBrush.Opacity = 0.9;
            TimeSpan time1;
            TimeSpan time2;
            DateTime time3;

            if (TimeSpan.TryParse(EventStartAdd.Text, out time1) && TimeSpan.TryParse(EventStopAdd.Text, out time2) && DateTime.TryParse(EventYearAdd.Text + "/" + EventMonthAdd.Text + "/" + EventDayAdd.Text, out time3))
            {
                if (TimeSpan.Compare(time1, time2) < 0 && this.EventNameAdd.Foreground.Opacity == blackBrush.Opacity && this.EventLocalizationAdd.Foreground.Opacity == blackBrush.Opacity && this.EventStartAdd.Foreground.Opacity == blackBrush.Opacity && this.EventStopAdd.Foreground.Opacity == blackBrush.Opacity)
                {
                    TimeSpan       ts        = new TimeSpan(RemindComboboxAdd.SelectedIndex, 0, 0);
                    DateTime       from_date = new DateTime(int.Parse(EventYearAdd.Text), int.Parse(EventMonthAdd.Text), int.Parse(EventDayAdd.Text)) + time1;
                    DataBaseEvent1 obj       = new DataBaseEvent1()
                    {
                        Name         = EventNameAdd.Text,
                        Localization = EventLocalizationAdd.Text,
                        Year         = int.Parse(EventYearAdd.Text),
                        Month        = int.Parse(EventMonthAdd.Text),
                        Day          = int.Parse(EventDayAdd.Text),
                        StartTime    = EventStartAdd.Text,
                        StopTime     = EventStopAdd.Text,
                        RemindTime   = from_date - ts,
                    };
                    DbEvent.SaveEvent(obj);
                    RestartWindow();
                    UpdateGrid();
                    mainWindow.RefreshAllDayButtons();
                    mainWindow.ShowCurrentDay();
                    mainWindow.AddEventToStackPanel();
                }
                else
                {
                    AlertWindow alertWindow = new AlertWindow("Please, corect your information!", "Input Error");
                    alertWindow.ShowDialog();
                }
            }
            else
            {
                AlertWindow alertWindow = new AlertWindow("Please, corect your information!", "Input Error");
                alertWindow.ShowDialog();
            }
        }
        // The metod save change information to the database
        /// <summary>
        /// The metod save change information to the database.
        /// </summary>
        /// <param name="sender">Contains a reference to the object that triggered the event.</param>
        /// <param name="e">Contains state information and event data associated with a routed event.</param>
        private void ButtonSaveChange_Click(object sender, RoutedEventArgs e)
        {
            string   input1    = EventStartShow.Text;
            string   input2    = EventStopShow.Text;
            string   inputdate = EventYearShow.Text + "/" + EventMonthShow.Text + "/" + EventDayShow.Text;
            TimeSpan time1;
            TimeSpan time2;
            DateTime time3;

            if (TimeSpan.TryParse(input1, out time1) && TimeSpan.TryParse(input2, out time2) && DateTime.TryParse(inputdate, out time3))
            {
                if (TimeSpan.Compare(time1, time2) < 0)
                {
                    TimeSpan       ts        = new TimeSpan(RemindComboboxShow.SelectedIndex, 0, 0);
                    DateTime       from_date = new DateTime(int.Parse(EventYearShow.Text), int.Parse(EventMonthShow.Text), int.Parse(EventDayShow.Text));
                    DataBaseEvent1 obj       = new DataBaseEvent1();
                    if (obj != null)
                    {
                        obj.Name         = EventNameShow.Text;
                        obj.Localization = EventLocalizationShow.Text;
                        obj.Year         = int.Parse(EventYearShow.Text);
                        obj.Month        = int.Parse(EventMonthShow.Text);
                        obj.Day          = int.Parse(EventDayShow.Text);
                        obj.StartTime    = EventStartShow.Text;
                        obj.StopTime     = EventStopShow.Text;
                        obj.RemindTime   = from_date - ts;
                    }
                    DbEvent.SaveChangesEvent(obj, updatingEventID);
                    UpdateGrid();
                    mainWindow.RefreshAllDayButtons();
                    mainWindow.ShowCurrentDay();
                    mainWindow.AddEventToStackPanel();
                }
                else
                {
                    AlertWindow alertWindow = new AlertWindow("Please, corect your information!", "Input Error");
                    alertWindow.ShowDialog();
                }
            }
            else
            {
                AlertWindow alertWindow = new AlertWindow("Please, corect your information!", "Input Error");
                alertWindow.ShowDialog();
            }
        }
        // The metod save information to the database
        /// <summary>
        /// The metod save information to the database
        /// </summary>
        /// <param name="sender"> Contains a reference to the object that triggered the event </param>
        /// <param name="e"> Contains state information and event data associated with a routed event  </param>
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            SolidColorBrush blackBrush = new SolidColorBrush(Colors.Black);

            blackBrush.Opacity = 0.9;
            if (this.ToDoListNameShow.Foreground.Opacity == blackBrush.Opacity)
            {
                DataBaseToDoList1 todolist = new DataBaseToDoList1()
                {
                    Name = this.ToDoListNameShow.Text,
                    Done = false,
                };
                DbToDoList.SaveToDoList(todolist);
                RestartWindow();
                UpdateGrid();
            }
            else
            {
                AlertWindow alertWindow = new AlertWindow("Please, corect your information!", "Input Error");
                alertWindow.ShowDialog();
            }
        }