示例#1
0
        private void btnFindByEmail_Click(object sender, EventArgs e)
        {
            if (new EmailAddressAttribute().IsValid(txtEmailAdd.Text) == false)
            {
                MessageBox.Show("Please enter a valid email");
                return;
            }
            else
            {
                string email;
                int    totalHours = 0;
                email = txtEmailAdd.Text;

                //create EmpHoursService object
                EmpHrsService service = new EmpHrsService();

                //call method
                Result <List <EmpHrs> > res = new Result <List <EmpHrs> >();
                res = service.FindEmpbyEmail(email);
                if (res.Status == ResultEnum.Success && res.Data.Count() != 0)
                {
                    foreach (EmpHrs ehrs in res.Data)
                    {
                        totalHours += ehrs.Hours;
                    }
                }
                else
                {
                    MessageBox.Show("Oops! Error");
                }

                dgvEmployees.DataSource = res.Data;
                lblEmpTotalHrs.Text     = "Total Hours worked by this Employee: " + totalHours.ToString() + " hours.";
            }
        }
示例#2
0
        //click event to add hours
        private void btnAddHours_Click(object sender, EventArgs e)
        {
            EmpHrs empHrs = new EmpHrs();

            try
            {
                empHrs.EmpID    = int.Parse(txtEmpID.Text);
                empHrs.WorkDate = txtDate.Text;
                empHrs.Hours    = int.Parse(txtHours.Text);
                MessageBox.Show("Employee Hours added successfully!");
            }
            catch (Exception)
            {
                MessageBox.Show("Please enter valid inputs");
            }


            //create EmpHoursService object
            EmpHrsService service = new EmpHrsService();

            service.AddEmpHours(empHrs);
        }
示例#3
0
        //click event to show total hours of employee
        private void btnShowHrs_Click(object sender, EventArgs e)
        {
            int id;
            int totalHours = 0;

            try
            {
                id = int.Parse(txtEmpID.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Enter a valid ID");
                return;
            }

            //    //create EmpHoursService object
            EmpHrsService service = new EmpHrsService();

            //call method
            Result <List <EmpHrs> > res = new Result <List <EmpHrs> >();

            res = service.EmpHoursbyID(id);
            if (res.Status == ResultEnum.Success && res.Data.Count() != 0)
            {
                foreach (EmpHrs ehrs in res.Data)
                {
                    totalHours += ehrs.Hours;
                }
            }
            else
            {
                MessageBox.Show("Error!");
            }

            dgvEmployees.DataSource = res.Data;
            lblEmpTotalHrs.Text     = "Total Hours worked by Employee ID " + id + " : " + totalHours.ToString();
        }