Esempio n. 1
0
        /// <summary>
        /// fills the listview with appointment data with compared month & year
        /// </summary>
        /// <param name="compareMonth"></param>
        /// <param name="compareYear"></param>
        private void FillInAppointmentData(int compareMonth, int compareYear)
        {
            int currentMonth = compareMonth;
            int currentYear  = compareYear;

            var appointments = _controller.GetAppointments(currentMonth, currentYear);

            listView1.Columns.Clear();
            listView1.Items.Clear();
            listView1.Columns.Add("Antal i alt", 80);

            listView1.Items.Add(appointments.Count.ToString());

            foreach (var a in appointments)
            {
                string type = StatisticsViewController.GetAppointmentType(a);


                if (!ListViewContainsHeader(type))
                {
                    var column = listView1.Columns.Add(type, type, 120);
                    ListViewItem.ListViewSubItem value = new ListViewItem.ListViewSubItem();
                    listView1.Items[0].SubItems.Add(value);
                    List <APTDETAILS> appointmentsWithTag = new List <APTDETAILS>();
                    value.Tag  = appointmentsWithTag;
                    column.Tag = value;
                }

                var matchingColumn = listView1.Columns[type];
                if (matchingColumn.Text.Equals(type))
                {
                    var subItem = (ListViewItem.ListViewSubItem)matchingColumn.Tag;
                    var value   = (List <APTDETAILS>)subItem.Tag;
                    value.Add(a);
                }

                filterListBox.Items.Clear();
            }



            for (int i = 1; i < listView1.Columns.Count; i++)
            {
                ColumnHeader c       = listView1.Columns[i];
                var          subItem = (ListViewItem.ListViewSubItem)c.Tag;
                var          value   = (List <APTDETAILS>)subItem.Tag;
                subItem.Text = value.Count.ToString();
            }
        }
        private void PopulateLastAndFutureAppointments()
        {
            if (cprBox.Text.Equals(""))
            {
                return;
            }
            customerAppLabel.Enabled   = true;
            showPreviousButton.Enabled = true;

            lastFutureAppointmentsListView.Items.Clear();

            var customer            = _controller.FindCustomerWithCpr(cprBox.Text);
            var twoLastAppointments = _controller.GetPastAppointments(customer);
            var futureAppointments  = _controller.GetFutureAppointments(customer);

            var forrigeItem = lastFutureAppointmentsListView.Items.Add("Forrige");

            forrigeItem.Font = new Font(forrigeItem.Font, FontStyle.Bold | FontStyle.Underline);

            foreach (var appointment in twoLastAppointments)
            {
                var appointmentItem = lastFutureAppointmentsListView.Items.Add(appointment.APD_DATE.ToString());
                var type            = StatisticsViewController.GetAppointmentType(appointment);
                appointmentItem.SubItems.Add(type);
                var description = Encoding.Default.GetString(appointment.APD_DESCRIPTION);
                appointmentItem.SubItems.Add(description);
            }

            var fremtidigeItem = lastFutureAppointmentsListView.Items.Add("Fremtidige");

            fremtidigeItem.Font = new Font(fremtidigeItem.Font, FontStyle.Bold | FontStyle.Underline);
            foreach (var appointment in futureAppointments)
            {
                var appointmentItem = lastFutureAppointmentsListView.Items.Add(appointment.APD_DATE.ToString());
                var type            = StatisticsViewController.GetAppointmentType(appointment);
                appointmentItem.SubItems.Add(type);
                var description = Encoding.Default.GetString(appointment.APD_DESCRIPTION);
                appointmentItem.SubItems.Add(description);
            }
        }