示例#1
0
        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            string pathFileXml = System.IO.Path.GetFullPath(Directory.GetCurrentDirectory() + @"\XMLFile1.xml");

            try
            {
                // here grid is cleared
                dataGrid.ItemsSource = null;
                dataGrid.Items.Clear();
                dataSet.Clear();

                // loading to grid data from .xml file
                dataSet.ReadXml(@pathFileXml);
                DataView dataView = new DataView(dataSet.Tables[0]);
                dataGrid.ItemsSource = dataView;

                // button is disabled after erase it added row
                cancel_button.IsEnabled = false;

                MessageBox.ShowInformation("Canceled Changes!");
            }
            catch (Exception ex)
            {
                MessageBox.ShowError(ex, "Cancel was't sucessful!");
            }
        }
        private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            saveButton.IsEnabled = false;

            try
            {
                if (dataChanged)
                {
                    SaveCurrentContent();
                    MessageBox.ShowInformation(String.Format("The schedule has been successfully saved!", titleTextBox.Text));
                }
            }
            catch (Exception)
            {
                try
                {
                    throw new Exception("Error occured, please try again!\nPlease check your events` dates.");
                }
                catch (Exception ex)
                {
                    MessageBox.ShowError(ex);
                }
            }


            ShowData();
            // saveButton.IsEnabled = true;
        }
            public void Execute(IJobExecutionContext context)
            {
                if (MainWindow.raisedEvent.Count > 0)
                {
                    EventNode savedDate    = MainWindow.raisedEvent.Dequeue();
                    DateTime  nowTime      = DateTime.Now;
                    string    remindString = String.Format("Alarm:\nLast reminding about Event: {0} is raising at the moment!)", savedDate.Title);
                    MessageBox.ShowInformation(remindString);
                    //MessageBox.ShowInformation(new Form() { TopMost = true }, "I'm still on top, YEAH");
                    //growlNotifications.AddNotification(new Notification { Title = "Your Health Reminder", ImageUrl = "pack://application:,,,/WPFGrowNotifications/Resources/notification-icon.png", Message = remindString });

                    SimpleDelegate d = new SimpleDelegate(TestMethod);
                    d(remindString);
                }
                //DoMoreWork();
            }
        private void CheckDates()
        {
            if (MainWindow.remindScheduler.scheduleStructure != null && MainWindow.remindScheduler.scheduleStructure.Count > 0)
            {
                DateTime nowTime      = DateTime.Now;
                DateTime plusHourTime = nowTime.AddMinutes(60);

                DateTime dayPlusMax = nowTime.AddMinutes(1470);
                DateTime dayPlusMin = nowTime.AddMinutes(1410);

                foreach (var savedDate in MainWindow.remindScheduler.scheduleStructure)
                {
                    if (savedDate.DatetimeEvent > nowTime && savedDate.DatetimeEvent < plusHourTime)
                    {
                        string remindString = String.Format("Notification:\nYour Event: {0} will raise in {1:mm} minutes", savedDate.Title, savedDate.DatetimeEvent - nowTime);
                        //MessageBox.Show(remindString);
                        MessageBox.ShowInformation(remindString);
                        StaticRemind.growlNotifications.AddNotification(new Notification {
                            Title = "Your Health Reminder", ImageUrl = "pack://application:,,,/WPFGrowNotifications/Resources/notification-icon.png", Message = remindString
                        });

                        MainWindow.raisedEvent.Enqueue(savedDate);
                    }

                    if (savedDate.DatetimeEvent > dayPlusMin && savedDate.DatetimeEvent < dayPlusMax)
                    {
                        string remindString = String.Format("Notification:\nYour Event: {0} will raise tomorrow ({1:dd/MM/yyyy})", savedDate.Title, dayPlusMax);
                        //MessageBox.ShowInformation(remindString);
                        StaticRemind.growlNotifications.AddNotification(new Notification {
                            Title = "Your Health Reminder", ImageUrl = "pack://application:,,,/WPFGrowNotifications/Resources/notification-icon.png", Message = remindString
                        });
                    }
                }

                foreach (var eventNod in MainWindow.raisedEvent)
                {
                    counterAlarms++;
                    int               transferMins = (int)(eventNod.DatetimeEvent - nowTime).Minutes;
                    IMyJob            myJob        = new MyJob();
                    JobDetailImpl     jobDetail    = new JobDetailImpl(counterAlarms.ToString(), null, myJob.GetType());
                    SimpleTriggerImpl trigger2     = new SimpleTriggerImpl("Trigger" + counterAlarms.ToString(), null, DateTime.Now.AddSeconds(transferMins * 60), null, 0, TimeSpan.Zero);
                    RaiseReminder(myJob, jobDetail, trigger2);
                }
            }
        }
 private void OpenAddToSchedule(object sender, RoutedEventArgs e)
 {
     try
     {
         DateTime eventDate = DateTime.Parse(dateTextBox.Text);
         MainWindow.mainScheduler.Add(new EventNode(eventDate, titleTextBox.Text, descriptionTextBox.Text));
         //MessageBox.Show("The event has been added successfully to the scheduler");
         MessageBox.ShowInformation(String.Format("The event {0} has been added successfully to the scheduler!", titleTextBox.Text));
         OpenSchedulePage(sender, e);
     }
     catch (Exception)
     {
         try
         {
             throw new Exception("The event can not be added to the scheduler.\nClick on details for more information.");
         }
         catch (Exception ex)
         {
             MessageBox.ShowError(ex);
         }
         //MessageBox.Show("The event can not be added to the scheduler due to invalid date format");
     }
 }
 private void ShowInfo_Click(object sender, RoutedEventArgs e)
 {
     MessageBox.ShowInformation("Hello World!");
 }
示例#7
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            // it is path to xml file
            string pathFileXml = System.IO.Path.GetFullPath(Directory.GetCurrentDirectory() + @"\XMLFile1.xml");

            // it is to check empty cell, after error with save
            ableToSave = true;

            try
            {
                foreach (DataRowView row in dataGrid.Items)
                {
                    if (row.Row.ItemArray[0].ToString() == "" || row.Row.ItemArray[0] == null)
                    {
                        ableToSave = false;
                        break;
                    }
                    else if (row.Row.ItemArray[1].ToString() == "" || row.Row.ItemArray[1] == null)
                    {
                        ableToSave = false;
                        break;
                    }
                    else if (row.Row.ItemArray[2].ToString() == "" || row.Row.ItemArray[2] == null)
                    {
                        ableToSave = false;
                        break;
                    }
                    else if (row.Row.ItemArray[3].ToString() == "" || row.Row.ItemArray[3] == null)
                    {
                        ableToSave = false;
                        break;
                    }
                    else if (row.Row.ItemArray[5].ToString() == "" || row.Row.ItemArray[5] == null)
                    {
                        ableToSave = false;
                        break;
                    }
                    else if (row.Row.ItemArray[6].ToString() == "" || row.Row.ItemArray[6] == null)
                    {
                        ableToSave = false;
                        break;
                    }
                    else if (row.Row.ItemArray[7].ToString() == "" || row.Row.ItemArray[7] == null)
                    {
                        ableToSave = false;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
            }


            try
            {
                if (ableToSave == true)
                {
                    // after press Save button, grid will be saved
                    dataSet.AcceptChanges();
                    dataSet.WriteXml(@pathFileXml);

                    MessageBox.ShowInformation("Grid is saved!", "Success of save!");
                }
                else
                {
                    MessageBox.ShowError("Grid has empty cell!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.ShowError(ex, "It was error with exception!");
            }
        }