Esempio n. 1
0
        private void btnAddTimesheet_Click(object sender, EventArgs e)
        {
            if (lst != null && lstboxEmployees.SelectedItem != null)
            {
                foreach (Employee obj in lst)
                {
                    if (obj == lstboxEmployees.SelectedItem)
                    {
                        try
                        {
                            int       empid      = obj.EmpId;
                            DateTime  dateWorked = dtpWorkedDate.Value;
                            double    hours      = double.Parse(txtHours.Text);
                            Timesheet tim        = new Timesheet();
                            tim.EmpId    = empid;
                            tim.WorkDate = dateWorked;
                            tim.Hours    = hours;

                            TimesheetManager manager = new TimesheetManager();
                            ResultEnum       result  = manager.AddTimesheet(tim);
                            switch (result)
                            {
                            case ResultEnum.SUCCESS:
                                MessageBox.Show("New TimeSheet Added");
                                break;

                            case ResultEnum.FAIL:
                                MessageBox.Show("Error, Something went wrong");
                                break;
                            }
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Please Enter Hours");
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Please Select an employee!");
            }
        }