Esempio n. 1
0
        /// <summary>
        /// Method that load the list view with the staff shifts data.
        /// </summary>
        /// <param name="staffID"></param>
        private void AddShiftToListView(string staffID)
        {
            Logger.Instance.Log("StaffUserControlUserControl:AddShiftToListView() -> Adding shifts to the list view.");


            string date = dateTimePicker1.Text;

            DataSet dsStaffAvail = DBConnection.getDBConnectionInstance().getDataSet(Constants.SelectShiftQuery(date));

            //get the table to be displayed from the data set
            DataTable dtStaffAvail = dsStaffAvail.Tables[0];

            //find out how many shifts a member of staff has in that specific day
            int shiftAmount = DBConnection.getDBConnectionInstance().GetIntValue(Constants.Countshifts(date));

            Console.WriteLine("Shift Amount=" + shiftAmount);

            //debug
            Console.WriteLine("Passed Value:" + staffID);
            for (int i = 0; i < shiftAmount; i++)
            {
                Console.WriteLine("Value from the datatable:" + (dtStaffAvail.Rows[i]["Staff ID"].ToString()));
                if ((dtStaffAvail.Rows[i]["Staff ID"].ToString()) == staffID)
                {
                    //change the subitems value to change the staff member

                    string value = (dtStaffAvail.Rows[i]["From"].ToString());
                    Console.WriteLine("Row value=" + value);
                    int staffInt = Convert.ToInt32(staffID);

                    switch (value)
                    {
                    case "08:00:00":
                        listView1.Items[0].SubItems[staffInt].Text      = "Working";
                        listView1.Items[0].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "09:00:00":
                        listView1.Items[1].SubItems[staffInt].Text      = "Working";
                        listView1.Items[1].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "10:00:00":
                        listView1.Items[2].SubItems[staffInt].Text      = "Working";
                        listView1.Items[2].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "11:00:00":
                        listView1.Items[3].SubItems[staffInt].Text      = "Working";
                        listView1.Items[3].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "12:00:00":
                        listView1.Items[4].SubItems[staffInt].Text      = "Working";
                        listView1.Items[4].SubItems[staffInt].ForeColor = Color.Green;
                        break;

                    case "13:00:00":
                        listView1.Items[5].SubItems[staffInt].Text      = "Working";
                        listView1.Items[5].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "14:00:00":
                        listView1.Items[6].SubItems[staffInt].Text      = "Working";
                        listView1.Items[6].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "15:00:00":
                        listView1.Items[7].SubItems[staffInt].Text      = "Working";
                        listView1.Items[7].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "16:00:00":
                        listView1.Items[8].SubItems[staffInt].Text      = "Working";
                        listView1.Items[8].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "17:00:00":
                        listView1.Items[9].SubItems[staffInt].Text      = "Working";
                        listView1.Items[9].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "18:00:00":
                        listView1.Items[10].SubItems[staffInt].Text      = "Working";
                        listView1.Items[10].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "19:00:00":
                        listView1.Items[11].SubItems[staffInt].Text      = "Working";
                        listView1.Items[11].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "20:00:00":
                        listView1.Items[12].SubItems[staffInt].Text      = "Working";
                        listView1.Items[12].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "21:00:00":
                        listView1.Items[13].SubItems[staffInt].Text      = "Working";
                        listView1.Items[13].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "22:00:00":
                        listView1.Items[14].SubItems[staffInt].Text      = "Working";
                        listView1.Items[14].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "23:00:00":
                        listView1.Items[15].SubItems[staffInt].Text      = "Working";
                        listView1.Items[15].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    default:
                        Console.WriteLine("No time found");
                        break;
                    }
                }
            }
        }