public void LoadListView(DateTime dt) { jobs = new Jobs(Jobs.ContactView.CurrentLinker, dt); lvJobs.Items.Clear(); rtbJobNotes.Clear(); rtbLink1.Clear(); rtbLink2.Clear(); rtbLink1.BackColor = rtbLink2.BackColor = Color.White; btnLink.Enabled = false; btnLink.Text = "Link the Jobs"; //foreach (Job j in jobs.Where(h => h.JobDate == dt.Date || ((h.JobDate.AddDays(-1) == dt.Date || h.JobDate.AddDays(1) == dt.Date) && h.HasLinkedJob)).OrderBy(s => s.ClientSurname)) foreach (Job j in jobs.OrderBy(s => s.JobDate).OrderBy(s => s.PickUpTime)) { Job job = new Job(j.JobID); ListViewItem lv = lvJobs.Items.Add(job.JobID.ToString()); //ListViewItem lv = lvJobs.Groups[job.HasLinkedJob ? 0 : 1].Items.Add(job.JobID.ToString()); lvJobs.Groups[job.HasLinkedJob ? 0 : 1].Items.Add(lv); lvJobs.ShowItemToolTips = true; lv.ToolTipText = job.JobID.ToString(); lv.SubItems.Add(job.ClientName); lv.SubItems.Add(job.joblegs[0].PickUpAddressLine1 + " " + job.ClientPostCode); lv.SubItems.Add(job.joblegs[0].AppointmentTime == null ? "not set" : job.joblegs[0].AppointmentTime.ToShortTimeString()); lv.SubItems.Add(job.joblegs[0].DropName); lv.SubItems.Add(job.joblegs[0].DropAddressLine1 + " " + job.joblegs[0].DropPostCode); lv.SubItems.Add(job.JobDate.ToShortDateString()); lv.UseItemStyleForSubItems = false; lv.SubItems[0].BackColor = job.HasLinkedJob ? System.Drawing.Color.LightBlue : lv.BackColor; lv.SubItems[1].BackColor = job.HasLinkedJob ? System.Drawing.Color.LightBlue : lv.BackColor; lv.SubItems[2].BackColor = job.HasLinkedJob ? System.Drawing.Color.LightBlue : lv.BackColor; lv.SubItems[3].BackColor = job.HasLinkedJob ? System.Drawing.Color.LightBlue : lv.BackColor; lv.SubItems[4].BackColor = job.HasLinkedJob ? System.Drawing.Color.LightBlue : lv.BackColor; lv.SubItems[5].BackColor = job.HasLinkedJob ? System.Drawing.Color.LightBlue : lv.BackColor; lv.SubItems[6].BackColor = job.HasLinkedJob ? System.Drawing.Color.LightCoral : lv.BackColor; } }
private void LoadTreeView() { string drivername; jobs = new Jobs(radAll.Checked ? Jobs.ContactView.NonCurrent : Jobs.ContactView.ExpiredNoDriver); tvJobs.Nodes.Clear(); if (radByDate.Checked) { foreach (Job job in jobs.OrderByDescending(s => s.JobDate)) { DateTime dt; drivername = job.DriverName == null || job.DriverName.Replace(" ", "") == string.Empty ? "n/a" : job.DriverName; dt = job.JobDate; if (tvJobs.Nodes.Find(job.JobDate.ToShortDateString(), false).Count <TreeNode>() == 0) { TreeNode topnode = tvJobs.Nodes.Add(job.JobDate.ToShortDateString(), job.JobDate.ToShortDateString()); topnode.SelectedImageIndex = topnode.ImageIndex = 11; } //job.LoadJobContacts(); //TreeNode node = tvJobs.Nodes[job.JobDate.ToShortDateString()].Nodes.Add(job.JobID.ToString(), job.ClientName + Environment.NewLine + "-" + job.PendingStatus); TreeNode node = tvJobs.Nodes[job.JobDate.ToShortDateString()].Nodes.Add(job.JobID.ToString(), "Client=" + job.ClientName + ", Driver = " + drivername); node.ImageIndex = job.StatusID == 18 ? 12 : job.StatusID == 50 ? 14 : 13; node.Nodes.Add(" "); } } if (radByDriver.Checked) { foreach (Job job in jobs.OrderBy(s => s.DriverName)) { drivername = job.DriverName; if (drivername == null || drivername == string.Empty || drivername == " ") { continue; } if (tvJobs.Nodes.Find(drivername, false).Count <TreeNode>() == 0) { tvJobs.Nodes.Add(drivername, drivername); } //job.LoadJobContacts(); //TreeNode node = tvJobs.Nodes[job.JobDate.ToShortDateString()].Nodes.Add(job.JobID.ToString(), job.ClientName + Environment.NewLine + "-" + job.PendingStatus); TreeNode node = tvJobs.Nodes[drivername].Nodes.Add(job.JobID.ToString(), job.JobDate.ToShortDateString() + ", Client=" + job.ClientName); node.ImageIndex = job.StatusID == 18 ? 12 : 13; node.ToolTipText = job.StatusID == 18 ? "Cancelled Job" : "Expired Job"; node.Nodes.Add(" "); } } if (radByClient.Checked) { foreach (Job job in jobs.OrderBy(s => s.ClientName)) { String clientName; drivername = job.DriverName; clientName = job.ClientName; if (tvJobs.Nodes.Find(clientName, false).Count <TreeNode>() == 0) { tvJobs.Nodes.Add(clientName, clientName); } TreeNode node = tvJobs.Nodes[clientName].Nodes.Add(job.JobID.ToString(), job.JobDate.ToShortDateString() + ", Driver = " + drivername); node.ImageIndex = job.StatusID == 18 ? 12 : 13; node.ToolTipText = job.StatusID == 18 ? "Cancelled Job" : "Expired Job"; node.Nodes.Add(" "); } } }