/// <summary>
        /// Method, that adds multiple Receivers to Db
        /// </summary>
        /// <returns></returns>
        private void AddReceivers()
        {
            result = false;
            ProjectReceivers.Clear();
            ProjectShippings.Clear();

            foreach (var item in ListBoxEntrepeneurs.SelectedItems)
            {
                IndexedSubEntrepeneur subEntrepeneur = new IndexedSubEntrepeneur((IndexedSubEntrepeneur)item);
                FillReceiver(subEntrepeneur);

                //Code that ads a enterprise to Enterprise List
                int tempResult = CBZ.CreateInDb(CBZ.TempReceiver);

                //Code, that checks result
                if (!result)
                {
                    if (tempResult < 1)
                    {
                        ProjectReceivers.Add(CBZ.TempReceiver);

                        //CBZ.TempShipping = new Shipping(subEntrepeneur, CBZ.TempReceiver, CBZ.TempLetterData, @"PDF_Documents\", macAddress);
                        CBZ.TempShipping.SetId(CBZ.CreateInDb(CBZ.TempShipping));
                        ProjectShippings.Add(CBZ.TempShipping);

                        if (!result)
                        {
                            result = true;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Method, that adds data to an ITT-letter receiver
        /// </summary>
        /// <param name="entrepeneur">IndexedSubEntrepeneur</param>
        private void FillReceiver(IndexedSubEntrepeneur entrepeneur)
        {
            string cvr         = entrepeneur.Entrepeneur.Entity.Cvr;
            string companyName = entrepeneur.Entrepeneur.Entity.Name;
            string attention   = @"Att. " + entrepeneur.Contact.Person.Name;
            string street      = entrepeneur.Entrepeneur.Entity.Address.Street;
            string place       = entrepeneur.Entrepeneur.Entity.Address.Place;
            string zipTown     = entrepeneur.Entrepeneur.Entity.Address.ZipTown.ToString();
            string email       = entrepeneur.Contact.Person.ContactInfo.Email;

            CBZ.TempReceiver = new Receiver(cvr, companyName, attention, street, zipTown, email, place);
        }
        /// <summary>
        /// Method, that creates a Shipping
        /// </summary>
        /// <param name="project">Project</param>
        /// <param name="receiver">Receiver</param>
        /// <param name="subEntrepeneur">SubEntrepeneur</param>
        /// <param name="letterData">PdfData</param>
        private void CreateShipping(Project project, Receiver receiver, IndexedSubEntrepeneur subEntrepeneur)
        {
            // CBZ.TempShipping = new Shipping(subEntrepeneur, receiver, new LetterData(), @"PDF_Documents\", macAddress);

            try
            {
                int id = CBZ.CreateInDb(CBZ.TempShipping);
                CBZ.TempShipping.SetId(id);
                CBZ.TempShipping.PersonalIttLetterPdfPath = @"PDF_Documents\";
                CBZ.UpdateInDb(CBZ.TempShipping);
                CBZ.ProjectLists.Shippings.Add(CBZ.TempShipping);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Databasen returnerede en fejl. Forsendelsen blev ikke opdateret.\n" + ex, "Udbudsbreve", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        /// <summary>
        /// Method, that load add an index to S
        /// </summary>
        /// <returns></returns>
        private List <IndexedSubEntrepeneur> GetIndexedSubEntrepeneurs()
        {
            List <IndexedSubEntrepeneur> result = new List <IndexedSubEntrepeneur>();
            int i = 0;

            foreach (SubEntrepeneur entrepeneur in CBZ.SubEntrepeneurs)
            {
                foreach (int id in EnterpriseIds)
                {
                    if (entrepeneur.Enterprise.Id == id)
                    {
                        IndexedSubEntrepeneur temp = new IndexedSubEntrepeneur(i, entrepeneur);
                        result.Add(temp);
                    }
                    i++;
                }
            }
            return(result);
        }
        private void ButtonSend_Click(object sender, RoutedEventArgs e)
        {
            result = false;
            bool receivers = CheckReceiversExist();
            bool details   = Convert.ToBoolean(CheckBoxDetails.IsChecked);

            if (details)
            {
                switch (receivers)
                {
                case false:
                    //Show Confirmation
                    MessageBox.Show("Du har ikke valgt nogen modtagere. Der blev ikke føjet modtagere til modtagerlisten.", "Forespørgsler", MessageBoxButton.OK, MessageBoxImage.Information);
                    break;

                case true:
                    result = true;
                    break;
                }

                if (result)
                {
                    //Code to Send Requests
                    try
                    {
                        //Make som code, that sends emails
                        foreach (object item in ListBoxSubEntrepeneurs.SelectedItems)
                        {
                            IndexedSubEntrepeneur subEntrepeneur = new IndexedSubEntrepeneur((IndexedSubEntrepeneur)item);
                            CBZ.TempShipping.SubEntrepeneur = subEntrepeneur;
                            CBZ.TempShipping.Receiver       = new Receiver(CBZ.TempShipping.SubEntrepeneur.Entrepeneur.Entity.Cvr, CBZ.TempShipping.SubEntrepeneur.Entrepeneur.Entity.Name, @"Att. " + CBZ.TempShipping.SubEntrepeneur.Contact.Person.Name, CBZ.TempShipping.SubEntrepeneur.Entrepeneur.Entity.Address.Street, CBZ.TempShipping.SubEntrepeneur.Entrepeneur.Entity.Address.ZipTown.ToString(), CBZ.TempShipping.SubEntrepeneur.Contact.Person.ContactInfo.Email, CBZ.TempShipping.SubEntrepeneur.Entrepeneur.Entity.Address.Place);
                            CBZ.TempShipping.RequestPdfPath = PdfCreator.GenerateRequestPdf(CBZ, CBZ.TempShipping);
                            string[] fileNames = new string[] { CBZ.TempShipping.RequestPdfPath };
                            Email    email     = new Email(CBZ, "Forespørgsel om underentreprise på " + CBZ.TempShipping.Receiver.Name, CBZ.TempShipping.Receiver.Email, CBZ.TempShipping.SubEntrepeneur.Enterprise.Project.Executive.Person.ContactInfo.Email, "Dette er en prøve", fileNames);
                            CBZ.TempShipping.SubEntrepeneur.Request.Status   = new RequestStatus((RequestStatus)CBZ.GetRequestStatus(1));
                            CBZ.TempShipping.SubEntrepeneur.Request.SentDate = DateTime.Now;
                            CBZ.CreateInDb(CBZ.TempShipping);
                            //CBZ.UpdateInDb(subEntrepeneur.Request);
                            //CBZ.UpdateInDb(subEntrepeneur);
                        }
                        MessageBox.Show("Forespørgslen/-erne blev sendt.", "Forespørgsler", MessageBoxButton.OK, MessageBoxImage.Information);

                        //Reset Boxes
                        ComboBoxCaseId.SelectedIndex         = -1;
                        ListBoxSubEntrepeneurs.SelectedIndex = -1;
                        ListBoxSubEntrepeneurs.ItemsSource   = "";
                        TextBoxName.Text          = "";
                        CheckBoxDetails.IsChecked = false;
                        CBZ.RefreshList("SubEntrepeneurs");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Forespørgslen/-erne blev ikke sendt.\n" + ex.ToString(), "Forespørgsler", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                else
                {
                    //Show error
                    MessageBox.Show("Modtageren/-erne blev ikke føjet til modtagerlisten. Prøv igen.", "Forespørgsler", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            else
            {
                //Show error
                MessageBox.Show("Projektet mangler detaljer. Tilføj disse under 'Rediger Projekt' og prøv igen.", "Forespørgsler", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }