Ejemplo n.º 1
0
        void LoadRequests()
        {
            lstRequests.Items.Clear();
            List <ServiceRequest> requests = new ServiceRequestController().Read();
            Client client;
            List <RequestAgent> handlers;
            string           technicianNames;
            IndividualClient ind;
            BusinessClient   bus;
            ListViewItem     lst;

            foreach (ServiceRequest i in requests)
            {
                if (i.Status == "Open" || i.Status == "Resolved")
                {
                    client          = i.Client;
                    handlers        = i.Handlers;
                    technicianNames = "";

                    foreach (Agent j in handlers)
                    {
                        if (j.EmployeeType == "Technician")
                        {
                            technicianNames += j.Name + ", ";
                        }
                    }

                    technicianNames = genLogic.TruncList(technicianNames);

                    lst = new ListViewItem(
                        new string[]
                    {
                        i.Description, i.DateCreated.ToShortDateString(), i.JobStarted.ToString(),
                        i.DateResolved.ToString(), i.Call.TimeStarted.ToLongTimeString(), i.Call.TimeEnded.ToLongTimeString(), technicianNames
                    });

                    if (client is IndividualClient)
                    {
                        ind = (IndividualClient)client;
                        lst.SubItems.Add(ind.Name);
                    }
                    else if (client is BusinessClient)
                    {
                        bus = (BusinessClient)client;
                        lst.SubItems.Add(bus.Name);
                    }

                    lst.SubItems.Add(i.Status);

                    lst.Tag = i;

                    lstRequests.Items.Add(lst);
                }
            }
        }