Beispiel #1
0
        private void PopulateReport()
        {
            using (var ctx = new TimeTrackerContext())
            {
                var query = from t in ctx.TrackDetails
                            where t.Start >= ReportCalendar.SelectionRange.Start && t.End <= ReportCalendar.SelectionRange.End &&
                            (ProjectTB.Text.Trim() == "" || t.Project.Contains(ProjectTB.Text.Trim()))
                            select t;

                List <TrackReportItem> list = new List <TrackReportItem>();

                double minutes = 0;
                foreach (var item in query)
                {
                    TrackReportItem tri = new TrackReportItem()
                    {
                        End     = item.End,
                        Minutes = (int)(item.End.Subtract(item.Start).TotalMinutes),
                        Project = item.Project,
                        Start   = item.Start,
                        Task    = item.Task
                    };
                    list.Add(tri);
                    minutes += item.End.Subtract(item.Start).TotalMinutes;
                }
                ReportGridView.DataSource = list;

                for (int i = 0, j = 0; i <= minutes; i += 60, j++)
                {
                    TotalHoursLabel.Text = string.Format("{0}:{1}", j, (int)(minutes - i));
                }
            }
        }
Beispiel #2
0
 private AutoCompleteStringCollection GetProjectList()
 {
     using (var ctx = new TimeTrackerContext())
     {
         AutoCompleteStringCollection col = new AutoCompleteStringCollection();
         col.AddRange(ctx.TrackDetails.Select <TrackDetail, string>(x => x.Project).Distinct <string>().ToArray <string>());
         return(col);
     }
 }
Beispiel #3
0
 private void SaveTime()
 {
     if (CurrentTD != null)
     {
         using (var ctx = new TimeTrackerContext())
         {
             var item = ctx.TrackDetails.FirstOrDefault(t => t.ID == CurrentTD.ID);
             item.End     = DateTime.Now;
             item.Project = CurrentTD.Project;
             item.Task    = CurrentTD.Task;
             ctx.SaveChanges();
         }
     }
 }
Beispiel #4
0
 private void StartBT_Click(object sender, EventArgs e)
 {
     IsTracking = true;
     if (CurrentTD == null)
     {
         CurrentTD = new TrackDetail()
         {
             Project = ProjectTB.Text.Trim(), Start = DateTime.Now, End = DateTime.Now, Task = TaskTB.Text.Trim()
         };
         using (var ctx = new TimeTrackerContext())
         {
             ctx.TrackDetails.Add(CurrentTD);
             ctx.SaveChanges();
         }
     }
 }