示例#1
0
        private void UxCalculateHoursWorked_Click(object sender, EventArgs e)
        {
            int month = 1;

            switch (uxSelectMonthComboBox.SelectedItem.ToString())
            {
            case "March":
                month = 3;
                break;

            case "April":
                month = 4;
                break;
            }
            DateTime date = new DateTime(Int32.Parse(uxSelectYearComboBox.SelectedItem.ToString()), month, 1);

            repo3 = new SqlTimeEntryRepository(connectionString);
            uxdataGridView.Columns.Clear();
            uxdataGridView.Columns.Add("EmployeeName", "Employee Name");
            uxdataGridView.Columns.Add("HoursWorked", "Hours Worked");

            var employees = repo3.RetrieveHoursWorked(date);

            foreach (var employee in employees)
            {
                uxdataGridView.Rows.Add(employee.EmployeeName,
                                        employee.HoursWorked);
            }
        }