/// Method, that creates a User in Db
        /// </summary>
        /// <returns>bool</returns>
        private bool CreateUserInDb()
        {
            bool result = false;

            //Create ContactInfo in Db
            bool contactInfoExist = CreateContactInfo();

            //Create Person in Db
            bool personExist = false;

            if (contactInfoExist)
            {
                personExist = CreatePersonInDb();
            }

            //Create User in Db
            int userId = 0;

            if (personExist)
            {
                userId = CBZ.CreateInDb(CBZ.TempUser);
            }

            //Check result
            if (userId >= 1)
            {
                result = true;
            }

            return(result);
        }
        /// <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;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void ButtonCreate_Click(object sender, RoutedEventArgs e)
        {
            //Code that creates a new project
            bool result = false;
            int  id     = CBZ.CreateInDb(CBZ.TempZipTown);

            if (id >= 1)
            {
                result = true;
            }

            if (result)
            {
                //Show Confirmation
                MessageBox.Show("Postnummeret blev oprettet", "Opret Postnummer", MessageBoxButton.OK, MessageBoxImage.Information);

                //Update lists and fields
                CBZ.TempZipTown = new ZipTown();
                CBZ.RefreshList("ZipTowns");

                //Close right UserControl
                CBZ.UcMainEdited = false;
                UcMain.Content   = new UserControl();
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Postnummeret blev ikke oprettet. Prøv igen.", "Opret Postnummer", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Exemplo n.º 4
0
        private void ButtonChoose_Click(object sender, RoutedEventArgs e)
        {
            bool result = false;

            if (ListBoxEntrepeneurs.SelectedItems.Count == 0)
            {
                //Show Confirmation
                MessageBox.Show("Du har ikke valgt nogen underentrepenører.", "Vælg Underentrepenør", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else if (ListBoxEntrepeneurs.SelectedItems.Count == 1)
            {
                int id = 0;

                //Code that adds IttLetter, Offer and Request to Bizz.TempSubEntrepeneur
                CreateIttLetter();
                CreateOffer();
                CreateRequest();

                //Code that adds a SubEntrepeneur to Enterprise List
                id = CBZ.CreateInDb(CBZ.TempSubEntrepeneur);
                if (id >= 1)
                {
                    result = true;
                }
            }
            else
            {
                result = AddMultipleSubentrepeneurs();
            }
            if (result)
            {
                //Show Confirmation
                MessageBox.Show("Underentrepenøren/-ne blev føjet til Entrepriselisten. Ved flere underentrepenører, er der ikke valgt kontaktperson. Ret dette under 'Rediger Underentrepenør'", "Vælg Underentrepenør", MessageBoxButton.OK, MessageBoxImage.Information);

                //Reset Boxes
                ComboBoxCaseId.SelectedIndex      = -1;
                TextBoxName.Text                  = "";
                ListBoxEntrepeneurs.SelectedIndex = -1;
                ListBoxEntrepeneurs.ItemsSource   = "";
                ComboBoxContact.SelectedIndex     = -1;
                ComboBoxContact.ItemsSource       = "";


                //Update SubEntrepeneurs List
                CBZ.RefreshList("SubEntrepeneurs");
                CBZ.UcMainEdited = false;
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Underentrepenøren blev ikke føjet til Entrepriselisten. Prøv igen.", "Rediger Projekt", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        private void ButtonCopy_Click(object sender, RoutedEventArgs e)
        {
            bool result = false;
            // Code that copies the current project into a new project
            Project project = new Project(CBZ.TempProject.Case, CBZ.TempProject.Builder, new ProjectStatus((ProjectStatus)CBZ.GetProjectStatus(1)), CBZ.TempProject.TenderForm, CBZ.TempProject.EnterpriseForm, CBZ.TempProject.Executive, CBZ.TempProject.Details, CBZ.TempProject.EnterpriseList, CBZ.TempProject.Copy);

            int id = CBZ.CreateInDb(project);

            if (id >= 1)
            {
                result = true;
            }

            if (result)
            {
                //Show Confirmation
                MessageBox.Show("Projektet blev kopieret", "Projekter", MessageBoxButton.OK, MessageBoxImage.Information);

                //Update list of projects
                CBZ.RefreshIndexedList("Projects");

                //Close right UserControl
                CBZ.UcMainEdited = false;
                UcMain.Content   = new UserControl();
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Projektet blev ikke kopieret. Prøv igen.", "Projekter", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        /// <summary>
        /// Method, that creates an Address in Db
        /// </summary>
        /// <returns>bool</returns>
        private bool CreateAddressInDb()
        {
            bool result = false;

            try
            {
                int addressId = CBZ.CreateInDb(CBZ.TempEntrepeneur.Entity.Address);
                CBZ.TempEntrepeneur.Entity.Address.SetId(addressId);
                result = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Addressen blev ikke gemt\n" + ex, "Entrepenører", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return(result);
        }
        private void ButtonAddBullet_Click(object sender, RoutedEventArgs e)
        {
            if (ComboBoxParagrafs.SelectedIndex < 0)
            {
                MessageBox.Show("Der er ikke valgt en overskrift. Punktet kan ikke knyttes til overskriften", "Projekter", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (ComboBoxParagrafs.SelectedIndex >= 1 && TextBoxNewBullet.Text == "")
            {
                MessageBox.Show("Der er ikke indtastet et punkt. Punktet kan ikke tilføjes til overskriften", "Projekter", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                int       dbAnswer  = 0;
                Exception exception = new Exception();
                CBZ.TempBullet = new Bullet(CBZ.TempParagraf, TextBoxNewBullet.Text);
                try
                {
                    dbAnswer = CBZ.CreateInDb(CBZ.TempBullet);
                }
                catch (Exception ex)
                {
                    exception = ex;
                }

                if (dbAnswer < 1)
                {
                    MessageBox.Show("Databasen meldte en fejl. Punktet blev ikke tilføjet til afsnittet\n" + exception, "", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    RefreshIndexedBullets();
                    ListBoxBullets.SelectedIndex = -1;
                    ListBoxBullets.ItemsSource   = "";
                    ListBoxBullets.ItemsSource   = CBZ.IndexedBullets;
                    TextBoxNewBullet.Text        = "";

                    SetUcMainEdited();
                }
            }
        }
        public bool CreateRegionInDb()
        {
            bool result = false;

            int regionId = CBZ.CreateInDb(TempNewRegion);

            if (regionId >= 1)
            {
                result = true;
            }

            return(result);
        }
        /// <summary>
        /// Method, that creates a Project Status in Db
        /// </summary>
        /// <returns>bool</returns>
        private bool CreateProjectStatusInDb()
        {
            bool result = false;

            int projectStatusId = CBZ.CreateInDb(TempNewProjectStatus);

            if (projectStatusId >= 1)
            {
                result = true;
            }

            return(result);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Method, that creates an Enterprise Form in Db
        /// </summary>
        /// <returns>bool</returns>
        private bool CreateEnterpriseFormInDb()
        {
            bool result = false;

            int formId = CBZ.CreateInDb(TempNewEnterpriseForm);

            if (formId >= 1)
            {
                result = true;
            }

            return(result);
        }
Exemplo n.º 11
0
        private bool CreateJobDescriptionInDb()
        {
            bool result = false;

            int jobDescriptionId = CBZ.CreateInDb(TempNewJobDescription);

            if (jobDescriptionId >= 1)
            {
                result = true;
            }

            return(result);
        }
        /// <summary>
        /// Method, that creates a CraftGroup in Db
        /// </summary>
        /// <returns>bool</returns>
        private bool CreateCraftGroupInDb()
        {
            bool result = false;

            int craftGroupId = CBZ.CreateInDb(TempNewCraftGroup);

            if (craftGroupId >= 1)
            {
                result = true;
            }

            return(result);
        }
Exemplo n.º 13
0
        private void ButtonCreate_Click(object sender, RoutedEventArgs e)
        {
            //Code that creates a new project
            if (CBZ.TempProject.EnterpriseList == false)
            {
                CBZ.TempProject.ToggleEnterpriseList();
                CBZ.UpdateInDb(CBZ.TempProject);
                CBZ.RefreshIndexedList("Projects");
            }

            bool result = false;
            int  id     = CBZ.CreateInDb(CBZ.TempEnterprise);

            if (id >= 1)
            {
                result = true;
            }

            if (result)
            {
                //Show Confirmation
                MessageBox.Show("Entrepriselisten blev oprettet", "Entrepriser", MessageBoxButton.OK, MessageBoxImage.Information);

                //Reset Boxes
                TextBoxCaseName.Text              = "";
                TextBoxName.Text                  = "";
                TextBoxElaboration.Text           = "";
                TextBoxOfferList.Text             = "";
                ComboBoxCraftGroup1.SelectedIndex = 0;
                ComboBoxCraftGroup2.SelectedIndex = 0;
                ComboBoxCraftGroup3.SelectedIndex = 0;
                ComboBoxCraftGroup4.SelectedIndex = 0;

                //Update Enterprise list
                CBZ.RefreshList("Enterprises");
                CBZ.TempEnterprise.Name        = "";
                CBZ.TempEnterprise.Elaboration = "";
                CBZ.TempEnterprise.OfferList   = "";
                CBZ.TempEnterprise.CraftGroup1 = new CraftGroup((CraftGroup)CBZ.GetCraftGroup(0));
                CBZ.TempEnterprise.CraftGroup2 = new CraftGroup((CraftGroup)CBZ.GetCraftGroup(0));
                CBZ.TempEnterprise.CraftGroup3 = new CraftGroup((CraftGroup)CBZ.GetCraftGroup(0));
                CBZ.TempEnterprise.CraftGroup4 = new CraftGroup((CraftGroup)CBZ.GetCraftGroup(0));
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Entrepriselisten blev ikke oprettet. Prøv igen.", "Entrepriser", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        private void ButtonCreate_Click(object sender, RoutedEventArgs e)
        {
            bool result = false;

            //Code that creates a new project
            if (newCaseIdCorrect)
            {
                int id = CBZ.CreateInDb(CBZ.TempProject);
                if (id >= 1)
                {
                    result = true;
                }
            }

            if (result)
            {
                //Show Confirmation
                MessageBox.Show("Projektet blev oprettet", "Projekter", MessageBoxButton.OK, MessageBoxImage.Information);

                //Reset form
                TextBoxCaseId.Text                   = "";
                TextBoxCaseName.Text                 = "";
                ComboBoxBuilder.SelectedIndex        = -1;
                ComboBoxTenderForm.SelectedIndex     = -1;
                ComboBoxEnterpriseForm.SelectedIndex = -1;
                ComboBoxExecutive.SelectedIndex      = -1;

                //Update list of projects
                CBZ.RefreshIndexedList("Projects");
            }
            else
            {
                //Show error
                MessageBox.Show("Projektet blev ikke oprettet. Check alle oplysninger og prøv igen.", "Projekter", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        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);
            }
        }