Guest User

Untitled

a guest
Feb 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. public void Run_OnClick()
  2. {
  3. StartActionTimer();
  4. }
  5.  
  6. public void Stop_OnClick()
  7. {
  8. StopActionTimer();
  9. }
  10.  
  11. public bool StartActionTimer()
  12. {
  13. if (Action.StartTimer())
  14. {
  15. LetsGo.Tag = DateTime.Now;
  16. SRETimer.Enabled = true;
  17. Stop.Enabled = true;
  18. Start.Enabled = false;
  19. }
  20. else if (Action.CheckRMSActionStatus() == ActionStatus.Running)
  21. {
  22. MessageBox.Show("You have an action running. You must stop this action to continue.")
  23. ActionStop stop = new ActionStop(Action.CurrentAction.ActionID);
  24. if (stop.ShowDialog() == DialogResult.OK && stop.CurrentData.Save())
  25. {
  26. return StartActionTimer();
  27. }
  28. }
  29. return Stop.Enabled;
  30. }
  31.  
  32. public void StopActionTimer()
  33. {
  34. Action.StopTimer();
  35. SRETimer.Enabled = false;
  36. lblTime.Visible = false;
  37. lblTime.Tag = null;
  38. Stop.Enabled = false;
  39. Start.Enabled = true;
  40. }
  41.  
  42.  
  43. public void DoAdd()
  44. {
  45. if (Action.CheckDBActionStatus() == ActionStatus.Timer || StartActionTimer())
  46. {
  47. //continue with the add stuff
  48. }
  49. }
  50.  
  51. public void DoEdit()
  52. {
  53. if (Action.CheckDBActionStatus() == ActionStatus.Timer || StartActionTimer())
  54. {
  55. //continue with the edit stuff
  56. }
  57. }
  58.  
  59. public void DoSave()
  60. {
  61. UpdateData();
  62.  
  63. currentProject.Validate();
  64. if (txtActionSummary.Trim().Length == 0)
  65. {
  66. currentProject.ErrorList.Add(new Error("ActionSummary", "You need this"));
  67. }
  68. if (txtActionNotes.Trim().Length == 0)
  69. {
  70. currentProject.ErrorList.Add(new Error("ActionNotes", "You need this"));
  71. }
  72.  
  73. if (currentProject.ErrorList.Count > 0)
  74. {
  75. SetErrors(currentProject.ErrorList);
  76. }
  77. else
  78. {
  79. if(currentProject.Save())
  80. {
  81. Action action = new Action();
  82. action.ProjectID = currentProject.ProjectID;
  83. action.MenuID = currentProject.MenuID;
  84. action.Description = txtActionNotes.Text;
  85. action.Summary = txtActionSummary.Text;
  86. action.StartTime = DateTime.Now;
  87. if (lblTime.Tag != null && lblTime.Tag is DateTime)
  88. {
  89. action.StartTime = (DateTime)lblTime.Tag;
  90. }
  91. action.StopTime = DateTime.Now;
  92. if (!action.Validate() || !action.Save())
  93. {
  94. MessageBox.Show("Error saving action");
  95. }
  96. }
  97. else
  98. {
  99. MessageBox.Show("Error saving project")
  100. }
  101. StopActionTimer();
  102. }
  103. }
Add Comment
Please, Sign In to add comment