private void DisplayPanelNoMailSelected()
        {
            archivedInfoPanel.Visible = false;
            archivePanel.Visible = false;

            _showingPanel = MailFormPanel.NoMailSelected;
        }
        private void DisplayPanelForComposeMail()
        {
            var currentMailItemInfo = GetCurrentMailItemInfo();

            archivedInfoPanel.Visible = false;
            archivePanel.Visible = false;
            composePanel.Visible = true;
            composePanel.Dock = DockStyle.Fill;

            _showingPanel = MailFormPanel.Compose;
        }
        private void DisplayPanelForUnarchivedMail()
        {
            try
            {
                var currentMailItemInfo = GetCurrentMailItemInfo();

                archivedInfoPanel.Visible = false;
                archivePanel.Visible = true;
                archivePanel.Dock = DockStyle.Fill;

                _showingPanel = MailFormPanel.UnarchivedMail;

                if (currentMailItemInfo != null)
                {
                    Enabled = true;

                    if (currentMailItemInfo.IsInboxItem)
                    {
                        receivedRadioButton.Checked = true;
                    }
                    else
                    {
                        sentRadioButton.Checked = true;
                    }

                    archivePanelCompanyContactTaskPicker1.GuessCompanyAndContact(currentMailItemInfo);
                }
                else
                {
                    Enabled = false;
                }
            }
            catch (Exception archiveExzception)
            {
                var m = string.Format("Fejl ved forsøg på vising af arkiver panel: {0}", archiveExzception.Message);

                log.Error(m, archiveExzception);

                MessageBox.Show(m, "Ukendt fejl ved vis arkiver panel", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void DisplayPanelForArchivedMail(Outlook.MailItem currentMailItem)
        {
            try
            {
                archivePanel.Visible = false;
                archivedInfoPanel.Visible = true;
                archivedInfoPanel.Dock = DockStyle.Fill;

                _showingPanel = MailFormPanel.ArhivedMail;

                var docGuid = GetDocumentID(currentMailItem);

                using (var dc = new iorunEntities())
                {
                    var doc = dc.Document.SingleOrDefault(d => d.DOC_GUID == docGuid);

                    if (doc != null)
                    {
                        var company = dc.Kunder.Where(c => c.Kunde_GUID == doc.DOC_CompanyGUID).ToList().Single();
                        var contact = doc.DOC_ContactGUID != null ? dc.Contact.Where(c => c.Contact_GUID == doc.DOC_ContactGUID).ToList().Single() : null;
                        var task = doc.DOC_TaskGUID != null ? dc.Tasks.Where(t => t.Task_GUID == doc.DOC_TaskGUID).ToList().Single() : null;
                        var archivedBy = doc.DOC_CreatedByGUID != null ? dc.Bruger.Where(b => b.Bruger_GUID == doc.DOC_CreatedByGUID).ToList().Single() : null;

                        archivedCompanyTexttBox.Text = company.Kunde_Navn_1;
                        archivedContactTextBox.Text = contact != null ? contact.Contact_Name : "(None selected)";
                        archivedTaskTextBox.Text = task != null ? task.Task_Caption : "(None selected)";
                        archivedByTextBox.Text = archivedBy != null ? archivedBy.Bruger_Navn : "(Unknown)";
                        archivedWhenTextBox.Text = doc.DOC_CreatedDate.ToString("g");
                    }
                    else
                    {
                        archivedCompanyTexttBox.Text = "(Dokument ikke fundet i database)";
                        archivedContactTextBox.Text = "(Dokument ikke fundet i database)";
                        archivedTaskTextBox.Text = "(Dokument ikke fundet i database)";
                        archivedByTextBox.Text = "(Dokument ikke fundet i database)";
                        archivedWhenTextBox.Text = "(Dokument ikke fundet i database)";
                    }
                }
            }
            catch (Exception archiveExzception)
            {
                var m = string.Format("Fejl ved forsøg på vising af arkivering info: {0}", archiveExzception.Message);

                log.Error(m, archiveExzception);

                MessageBox.Show(m, "Ukendt fejl ved vis arkivering info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }