예제 #1
0
 private void ButtonSave_Click(object sender, EventArgs e)
 {
     try
     {
         var setting         = SettingService.GetSettings();
         var restMinutes     = (int)(StaticAssets.Duration.TotalMinutes * setting.RestTimeInMinutes / 60);
         var stopDateTimeNow = StaticAssets.StopDateTime <= DateTime.MinValue
             ? DateTime.Now.AddMinutes(restMinutes)
             : StaticAssets.StopDateTime.AddMinutes(restMinutes);
         TimeService.Save(new TimeModel
         {
             ProjectId     = int.Parse(_projectId),
             Duration      = StaticAssets.Duration.Add(new TimeSpan(0, 0, restMinutes, 0)),
             StopDateTime  = stopDateTimeNow,
             StartDateTime = StaticAssets.StartDateTime,
             Description   = textBoxDescription.Text.Trim()
         });
         ShowSuccessMessage("Time saved successfully");
         StaticAssets.Duration = new TimeSpan(0, 0, 0, 0, 0);
         DraftService.Clear();
         Close();
     }
     catch (Exception exception)
     {
         ShowErrorMessage(exception.Message);
     }
 }
예제 #2
0
 private void ButtonReset_Click(object sender, EventArgs e)
 {
     DisableDeactivateOperation = true;
     if (MessageBox.Show(this, @"Are you sure to reset timer?", @"Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
     {
         return;
     }
     StaticAssets.Duration      = new TimeSpan(0, 0, 0, 0);
     labelDuration.Text         = "00:00:00";
     toolStripMenuItemTime.Text = "00:00:00";
     labelStartFrom.Text        = "";
     if (_isTimerStarted)
     {
         StaticAssets.StartDateTime = DateTime.Now;
         labelStartFrom.Text        = StaticAssets.StartDateTime.ToStandardString();
     }
     DraftService.Clear();
 }