-
Notifications
You must be signed in to change notification settings - Fork 0
/
Log.cs
101 lines (85 loc) · 2.82 KB
/
Log.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
namespace ClockIn
{
public partial class Log : Form
{
public Log(DataAccess dataAccess)
{
InitializeComponent();
this.DataAccess = dataAccess;
this.DataAccess.FillDataSet();
FillLog();
}
private DataAccess DataAccess { get; set; }
private void FillLog()
{
if (rbtSummary.Checked == true)
{
FillLogSummary();
}
else
{
DataTable dt = DataAccess.DataSet.Tables["ClockEvents"];
int i = 0;
foreach (DataRow dr in dt.Rows)
{
if (i < 17)
{
String type = dr["EventType"].ToString();
Debug.WriteLine("Attempting to parse date: " + dr["DT_Created"].ToString() + " for event " + dr["EventID"].ToString());
DateTime created = DateTime.Parse(dr["DT_Created"].ToString());
ClockEvent thisEvent = new ClockEvent(type, created);
lbxLog.Items.Add(thisEvent.ToString());
i++;
}
else
{
break;
}
}
}
}//FillLog()
private void FillLogSummary()
{
int startIndex = -1, endIndex = -1;
DateTime startTime, endTime;
int i = 0;
foreach (DataRow dr in DataAccess.DataSet.Tables["ClockEvents"].Rows)
{
if (dr["EventType"].ToString() == "In")
{
startIndex = i;
startTime = DateTime.Parse(dr["DT_Created"].ToString());
}
else if (dr["EventType"].ToString() == "Out")
{
endIndex = i;
endTime = DateTime.Parse(dr["DT_Created"].ToString());
}
if (startIndex > 0 && endIndex > 0)
{
}
}
}
public void RefreshLog()
{
DataAccess.FillDataSet();
FillLog();
}
}
}
//look through clockevents table. Every time there's a clock out and a clock in, create a string representing the time between them.
/*
* 1. Go through ClockEvents, 1 event at a time
* 2. record what type of event was encountered by assigning a value to the index var
* 3. check to see if you have both a start and an end. If so, make an entry
*/