Пример #1
0
        private void lstEmp_SelectedIndexChanged(object sender, EventArgs e)
        {
            EmpHour empH = (EmpHour)lstEmp.SelectedItem;

            txtEmpId.Text = empH.EmpID.ToString();

            EmpHourManager           ehM      = new EmpHourManager();
            Result <List <EmpHour> > resultEH = ehM.GetEmpWorkByEmpId(empH.EmpID);

            switch (resultEH.Status)
            {
            case ResultsEnum.SUCCESS:
                cmbWorkDate.DataSource    = resultEH.List;
                cmbWorkDate.DisplayMember = "WorkDate";
                cmbWorkDate.ValueMember   = "EmpHourID";
                break;

            case ResultsEnum.FAIL:
                MessageBox.Show("Fail to get the work list");
                break;
            }
        }
Пример #2
0
        private void lstEmp_SelectedIndexChanged(object sender, EventArgs e)
        {
            Employee emp = (Employee)lstEmp.SelectedItem;

            lblEmpId.Text = "Employee ID: " + emp.EmpID;

            EmpHourManager           ehM      = new EmpHourManager();
            Result <List <EmpHour> > resultEH = ehM.GetEmpWorkByEmpId(emp.EmpID);

            double totalHour = 0;

            switch (resultEH.Status)
            {
            case ResultsEnum.SUCCESS:
                lstWorkDate.DataSource    = lstWorkHour.DataSource = resultEH.List;
                lstWorkDate.DisplayMember = "WorkDate";
                lstWorkDate.ValueMember   = "EmpId";
                lstWorkHour.DisplayMember = "Hour";
                lstWorkHour.ValueMember   = "Hour";

                List <EmpHour> .Enumerator eList = resultEH.List.GetEnumerator();
                while (eList.MoveNext())
                {
                    EmpHour empH1 = eList.Current;
                    if (empH1.EmpID == emp.EmpID)
                    {
                        totalHour += empH1.Hour;
                    }
                }

                break;

            case ResultsEnum.FAIL:
                MessageBox.Show("Fail to get the work list");
                break;
            }

            lblTotalHours.Text = "Total working hours:\n" + totalHour;
        }