private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     //get standard hours for that day
     getStandardHours(_staff_id, Convert.ToDateTime(dataGridView1.Rows[e.RowIndex].Cells[5].Value));
     if (e.ColumnIndex == dataGridView1.Columns["Full"].Index)
     {
         //6.40 hours - full Day
         dataGridView1.Rows[e.RowIndex].Cells[7].Value             = _standardHours;
         dataGridView1.Rows[e.RowIndex].Cells[6].Value             = "Full Day";
         dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightSeaGreen;
     }
     if (e.ColumnIndex == dataGridView1.Columns["Half"].Index)
     {//3.2
         dataGridView1.Rows[e.RowIndex].Cells[7].Value             = _standardHours / 2;
         dataGridView1.Rows[e.RowIndex].Cells[6].Value             = "Half Day";
         dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.MediumPurple;
     }
     if (e.ColumnIndex == dataGridView1.Columns["Shift"].Index)
     {//6.4
         dataGridView1.Rows[e.RowIndex].Cells[7].Value             = _standardHours;
         dataGridView1.Rows[e.RowIndex].Cells[6].Value             = "Shift";
         dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red;
     }
     if (e.ColumnIndex == dataGridView1.Columns["Manual"].Index)
     {
         //grab time from user input
         //open form
         frmManualHours mh = new frmManualHours();
         mh.ShowDialog();
         dataGridView1.Rows[e.RowIndex].Cells[7].Value             = mh._manualHours;
         dataGridView1.Rows[e.RowIndex].Cells[6].Value             = "Manual";
         dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightSeaGreen;
     }
 }
        private void dataGridViewSoftware_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int selectedrowindex = dgSelected.SelectedCells[0].RowIndex;

            DataGridViewRow selectedRow = dgSelected.Rows[selectedrowindex];

            int placementID = Convert.ToInt32(selectedRow.Cells["PlacementID"].Value);
            int staffID     = Convert.ToInt32(selectedRow.Cells["Staff Id"].Value);
            //for my department swap - ryucxd 27/11/19
            string PT   = Convert.ToString(selectedRow.Cells["placement type"].Value);
            double hour = Convert.ToDouble(selectedRow.Cells["Hours"].Value);

            //MessageBox.Show(_selectedDate.ToString());
            getStandardHours(staffID);


            //REMOVE BUTTON
            if (e.ColumnIndex == dgSelected.Columns["Remove"].Index)
            {
                SqlConnection conn = new SqlConnection(connectionStrings.ConnectionString);
                // the below code is only commented out because it would remove the user and we cant have that ^-^

                using (SqlCommand cmd = new SqlCommand("DELETE  FROM DBO.power_plan_staff where ID = @placementID", conn))
                {
                    cmd.Parameters.AddWithValue("@placementID", placementID);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                    checkExistingSelections();
                }

                //ask if the user wants to move this person to another location ---
                DialogResult result = MessageBox.Show("Would you like to move this user to another department?", "Move user?", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (result == DialogResult.Yes)
                {
                    //find out where they are heading
                    //form with combobox maybe?
                    frmMoveDept md = new frmMoveDept(staffID, _selectedDate, PT, hour);
                    md.ShowDialog();
                }
            }


            //MANUAL BUTTON
            if (e.ColumnIndex == dgSelected.Columns["Manual"].Index)
            {
                frmManualHours mh = new frmManualHours();
                mh.ShowDialog();


                SqlConnection conn = new SqlConnection(connectionStrings.ConnectionString);

                using (SqlCommand cmd = new SqlCommand("UPDATE dbo.power_plan_staff set placement_type = 'Manual' , hours = @hours where ID = @placementID", conn))
                {
                    cmd.Parameters.AddWithValue("placementID", placementID);
                    cmd.Parameters.AddWithValue("@hours", mh._manualHours);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                    checkExistingSelections();
                }
            }



            //FULL BUTTON
            if (e.ColumnIndex == dgSelected.Columns["Full"].Index)
            {
                SqlConnection conn = new SqlConnection(connectionStrings.ConnectionString);

                using (SqlCommand cmd = new SqlCommand("UPDATE dbo.power_plan_staff set placement_type = 'Full Day' , hours = @hours where ID = @placementID", conn))
                {
                    cmd.Parameters.AddWithValue("placementID", placementID);
                    cmd.Parameters.AddWithValue("@hours", _standardHours);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                    checkExistingSelections();
                }
            }

            //FULL BUTTON
            if (e.ColumnIndex == dgSelected.Columns["Shift"].Index)
            {
                SqlConnection conn = new SqlConnection(connectionStrings.ConnectionString);

                using (SqlCommand cmd = new SqlCommand("UPDATE dbo.power_plan_staff set placement_type = 'Shift' , hours = @hours where ID = @placementID", conn))
                {
                    cmd.Parameters.AddWithValue("placementID", placementID);
                    cmd.Parameters.AddWithValue("@hours", _standardHours);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                    checkExistingSelections();
                }
            }


            //Half BUTTON
            if (e.ColumnIndex == dgSelected.Columns["Half"].Index)
            {
                SqlConnection conn = new SqlConnection(connectionStrings.ConnectionString);

                using (SqlCommand cmd = new SqlCommand("UPDATE dbo.power_plan_staff set placement_type = 'Half Day' , hours = @hours where ID = @placementID", conn))
                {
                    cmd.Parameters.AddWithValue("placementID", placementID);
                    cmd.Parameters.AddWithValue("@hours", _standardHours / 2);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                    checkExistingSelections();
                }
            }

            //Note BUTTON
            if (e.ColumnIndex == dgSelected.Columns["Note"].Index)
            {
                PlacementNote pn = new PlacementNote(placementID);
                pn.ShowDialog();
                checkExistingSelections();
            }
        }