예제 #1
0
 //method to add Employee Hours
 public void AddEmpHours(EmpHrs empDailyHrs)
 {
     //create EmpHrs object
     try
     {
         EmpHrsDAO dao = new EmpHrsDAO();
         dao.AddEmpHrs(empDailyHrs);
     }
     catch
     {
         // Ask Shanty
     }
 }
예제 #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
        //method to add employee hours to database
        public void AddEmpHrs(EmpHrs empDailyHrs)
        {
            //create connection object
            SqlConnection conn = new SqlConnection();

            conn.ConnectionString = @"Data Source=USER-HP\SQLEXPRESS1;Initial Catalog=ETSDB;Integrated Security=True";
            conn.Open();


            //create command object
            SqlCommand cmd = new SqlCommand("sp_EmpHours_Insert", conn);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@empID", empDailyHrs.EmpID));
            cmd.Parameters.Add(new SqlParameter("@workDate", empDailyHrs.WorkDate));
            cmd.Parameters.Add(new SqlParameter("@hrs", empDailyHrs.Hours));

            //execute command
            cmd.ExecuteNonQuery();

            //handle result
            conn.Close();
        }
예제 #4
0
        //method to get an employee's days worked and hours
        public List <EmpHrs> EmpTotalHrs(int empID)
        {
            List <EmpHrs> listHrs = new List <EmpHrs>();
            //create connection object
            SqlConnection conn = new SqlConnection();

            conn.ConnectionString = @"Data Source=USER-HP\SQLEXPRESS1;Initial Catalog=ETSDB;Integrated Security=True";
            conn.Open();


            //create command object
            SqlCommand cmd = new SqlCommand("sp_EmpHours_WorkDateHrs", conn);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@empID", empID));


            //4.Execute the command - select
            SqlDataReader reader = cmd.ExecuteReader();

            //5.Handle the results
            while (reader.Read())
            {
                EmpHrs eh = new EmpHrs();
                eh.EmpID    = empID;
                eh.Hours    = Convert.ToInt32(reader["Hours"]);
                eh.WorkDate = Convert.ToString(reader["WorkDate"]);
                eh.FName    = Convert.ToString(reader["FirstName"]);
                eh.LName    = Convert.ToString(reader["LastName"]);
                listHrs.Add(eh);
            }

            //handle result
            conn.Close();

            return(listHrs);
        }