Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. string firma = "";
  2. private void radButton1_Click(object sender, EventArgs e)
  3. {
  4. try
  5. {
  6. for (int i = 0; i < radGridView4.Rows.Count; i++)
  7. {
  8. DateTime executionTime = Convert.ToDateTime(radGridView4.Rows[i].Cells[10].Value.ToString());
  9. ScheduleAction(action, executionTime);
  10. }
  11. }
  12. catch (Exception ex)
  13. {
  14. Console.WriteLine(ex);
  15. }
  16. }
  17.  
  18. public async void ScheduleAction(Action action, DateTime ExecutionTime)
  19. {
  20. try
  21. {
  22. if (DateTime.Now < ExecutionTime)//ExecutionTime only create an alarm for rows that are later than now
  23. {
  24. await Task.Delay((int)ExecutionTime.Subtract(DateTime.Now).TotalMilliseconds);
  25.  
  26. action();
  27. }
  28. }
  29. catch (Exception ex)
  30. {
  31. Console.WriteLine(ex);
  32. }
  33. }
  34.  
  35. public void action()
  36. {
  37. RadDesktopAlert Alert;
  38. for (int i = 0; i < radGridView4.Rows.Count; i++)
  39. {
  40. DateTime executionTime = Convert.ToDateTime(radGridView4.Rows[i].Cells[10].Value.ToString());
  41.  
  42. if (DateTime.Now.Date == executionTime.Date && DateTime.Now.Hour == executionTime.Hour && DateTime.Now.Minute == executionTime.Minute)
  43. {
  44. Alert = new RadDesktopAlert();
  45.  
  46. firma = radGridView4.Rows[i].Cells[2].Value.ToString();
  47.  
  48. Alert.CaptionText = "Telefonmøde";
  49. Alert.ContentText = firma;
  50. Alert.Show();
  51.  
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement