private void ButtonAddProjectStatus_Click(object sender, RoutedEventArgs e)
        {
            bool result = CreateProjectStatusInDb();

            //Display result
            if (result)
            {
                //Show Confirmation
                MessageBox.Show("Projektstatussen blev tilføjet", "Projektstatusser", MessageBoxButton.OK, MessageBoxImage.Information);

                //Reset Boxes
                ListBoxProjectStatuses.SelectedIndex = -1;
                ListBoxProjectStatuses.ItemsSource   = "";
                CBZ.RefreshIndexedList("ProjectStatuses");
                ListBoxProjectStatuses.ItemsSource = CBZ.IndexedCraftGroups;
                TextBoxProjectStatusSearch.Text    = "";
                TextBoxText.Text    = "";
                TextBoxNewText.Text = "";

                //Refresh Users list
                CBZ.RefreshList("ProjectStatuses");
                CBZ.TempProjectStatus = new ProjectStatus();
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Projektstatussen blev ikke tilføjet. Prøv igen.", "Projektstatusser", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 2
0
        private void ButtonExecute_Click(object sender, RoutedEventArgs e)
        {
            // Code that changes project status
            bool result = Bizz.UpdateInDb(Bizz.TempProject);

            if (result)
            {
                //Show Confirmation
                MessageBox.Show("Projekstatus blev ændret", "Ændr Projektstatus", MessageBoxButton.OK, MessageBoxImage.Information);

                //Update list of projects
                Bizz.RefreshList("Projects");
                Bizz.RefreshIndexedList("IndexedActiveProjects");
                Bizz.RefreshIndexedList("IndexedProjects");

                //Close right UserControl
                Bizz.UcRightActive = false;
                UcRight.Content    = new UserControl();
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Projektstatus blev ikke ændret. Prøv igen.", "Ændr Projektstatus", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        private void ButtonAddRegion_Click(object sender, RoutedEventArgs e)
        {
            bool result = CreateRegionInDb();

            //Display result
            if (result)
            {
                //Show Confirmation
                MessageBox.Show("Regionen blev tilføjet", "Regioner", MessageBoxButton.OK, MessageBoxImage.Information);

                //Reset Boxes
                ListBoxRegions.SelectedIndex = -1;
                ListBoxRegions.ItemsSource   = "";
                CBZ.RefreshIndexedList("Regtions");
                ListBoxRegions.ItemsSource = CBZ.IndexedJobDescriptions;
                TextBoxRegionSearch.Text   = "";
                TextBoxText.Text           = "";
                TextBoxZips.Text           = "";
                TextBoxNewText.Text        = "";
                TextBoxNewZips.Text        = "";

                //Refresh JobDescriptions list
                CBZ.RefreshList("JobDescriptions");
                CBZ.TempRegion = new Region();
                TempNewRegion  = new IndexedRegion();
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Regionen blev ikke tilføjet. Prøv igen.", "Regioner", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 4
0
        private void ButtonAddJobDescription_Click(object sender, RoutedEventArgs e)
        {
            bool result = CreateJobDescriptionInDb();

            //Display result
            if (result)
            {
                //Show Confirmation
                MessageBox.Show("Jobbeskrivelsen blev tilføjet", "Jobbeskrivelser", MessageBoxButton.OK, MessageBoxImage.Information);

                //Reset Boxes
                ListBoxJobDescriptions.SelectedIndex = -1;
                ListBoxJobDescriptions.ItemsSource   = "";
                CBZ.RefreshIndexedList("JobDescriptions");
                ListBoxJobDescriptions.ItemsSource = CBZ.IndexedJobDescriptions;
                TextBoxJobDescriptionSearch.Text   = "";
                TextBoxArea.Text                 = "";
                TextBoxOccupation.Text           = "";
                CheckBoxProcuration.IsChecked    = null;
                TextBoxNewArea.Text              = "";
                TextBoxNewOccupation.Text        = "";
                CheckBoxNewProcuration.IsChecked = null;

                //Refresh JobDescriptions list
                CBZ.RefreshList("JobDescriptions");
                CBZ.TempJobDescription = new JobDescription();
                TempNewJobDescription  = new IndexedJobDescription();
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Jobbeskrivelsen blev ikke tilføjet. Prøv igen.", "Jobbeskrivelser", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        private void ButtonAddCraftGroup_Click(object sender, RoutedEventArgs e)
        {
            bool result = CreateCraftGroupInDb();

            //Display result
            if (result)
            {
                //Show Confirmation
                MessageBox.Show("Faggruppen blev tilføjet", "Faggrupper", MessageBoxButton.OK, MessageBoxImage.Information);

                //Reset Boxes
                ListBoxCraftGroups.SelectedIndex = -1;
                ListBoxCraftGroups.ItemsSource   = "";
                CBZ.RefreshIndexedList("CraftGroups");
                ListBoxCraftGroups.ItemsSource    = CBZ.IndexedCraftGroups;
                TextBoxCraftGroupSearch.Text      = "";
                TextBoxDesignation.Text           = "";
                TextBoxDescription.Text           = "";
                ComboBoxCategory.SelectedIndex    = -1;
                ComboBoxCategory.ItemsSource      = "";
                TextBoxNewDesignation.Text        = "";
                TextBoxNewDescription.Text        = "";
                ComboBoxNewCategory.SelectedIndex = -1;
                ComboBoxNewCategory.ItemsSource   = "";

                //Refresh Users list
                CBZ.RefreshList("CraftGroups");
                CBZ.TempCraftGroup = new CraftGroup();
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Faggruppen blev ikke tilføjet. Prøv igen.", "Faggrupper", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 6
0
        private void ButtonCreateClose_Click(object sender, RoutedEventArgs e)
        {
            //Code that creates a new project
            if (Bizz.TempProject.EnterpriseList == false)
            {
                Bizz.TempProject.ToggleEnterpriseList();
                Bizz.UpdateInDb(Bizz.TempProject);
                Bizz.RefreshList("Projects");
                Bizz.RefreshIndexedList("IndexedActiveProjects");
                Bizz.RefreshIndexedList("IndexableProjects");
            }
            bool result = Bizz.CreateInDbReturnBool(Bizz.TempEnterprise);

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

                //Update EnterpriseList
                Bizz.RefreshList("EnterpriseList");
                Bizz.TempEnterprise = new Enterprise();

                //Close right UserControl
                Bizz.UcRightActive = false;
                UcRight.Content    = new UserControl();
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Entrepriselisten blev ikke oprettet. Prøv igen.", "Opret Projekt", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        private void ButtonEdit_Click(object sender, RoutedEventArgs e)
        {
            // Code that save changed CaseId to the project
            bool result = Bizz.UpdateInDb(Bizz.TempProject);

            if (result)
            {
                //Show Confirmation
                MessageBox.Show("Sagsnummer blev ændret", "Skift Sagsnummer", MessageBoxButton.OK, MessageBoxImage.Information);

                //Update list of projects
                Bizz.RefreshList("Projects");
                Bizz.RefreshIndexedList("IndexedActiveProjects");
                Bizz.RefreshIndexedList("IndexableProjects");

                //Close right UserControl
                Bizz.UcRightActive = false;
                UcRight.Content    = new UserControl();
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Sagsnummer blev ikke ændret. Prøv igen.", "Skift Sagsnummer", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        private void ButtonCreateClose_Click(object sender, RoutedEventArgs e)
        {
            //Code that creates a new project
            Project project = new Project(Convert.ToInt32(TextBoxCaseId.Text), TextBoxCaseName.Text, new Builder((Builder)ComboBoxBuilder.SelectedItem), new ProjectStatus((ProjectStatus)Bizz.GetEntity("ProjectStatus", "1")), new TenderForm((TenderForm)ComboBoxTenderForm.SelectedItem), new EnterpriseForm((EnterpriseForm)ComboBoxEnterpriseForm.SelectedItem), new User((User)ComboBoxExecutive.SelectedItem));
            bool    result  = Bizz.CreateInDbReturnBool(project);

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

                //Update list of projects
                Bizz.RefreshList("Projects");
                Bizz.RefreshIndexedList("IndexedActiveProjects");
                Bizz.RefreshIndexedList("IndexedProjects");

                //Close right UserControl
                Bizz.UcRightActive = false;
                UcRight.Content    = new UserControl();
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Projektet blev ikke oprettet. Prøv igen.", "Opret Projekt", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        private void ButtonCopy_Click(object sender, RoutedEventArgs e)
        {
            // Code that copies the current project into a new project
            Project project = new Project(Bizz.TempProject.CaseId, Bizz.TempProject.Name, Bizz.TempProject.Builder, new ProjectStatus((ProjectStatus)Bizz.GetEntity("ProjectStatus", "1")), Bizz.TempProject.TenderForm, Bizz.TempProject.EnterpriseForm, Bizz.TempProject.Executive);
            bool    result  = Bizz.CreateInDbReturnBool(Bizz.TempProject);

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

                //Update list of projects
                Bizz.RefreshList("Projects");
                Bizz.RefreshIndexedList("IndexedActiveProjects");
                Bizz.RefreshIndexedList("IndexableProjects");

                //Close right UserControl
                Bizz.UcRightActive = false;
                UcRight.Content    = new UserControl();
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Projektet blev ikke kopieret. Prøv igen.", "Kopier Projekt", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Ejemplo n.º 10
0
        private void ButtonErase_Click(object sender, RoutedEventArgs e)
        {
            if (CheckBoxEraseProject.IsChecked == true)
            {
                if (MessageBox.Show("Er du sikker på, at du vil slette projektet? Alle data vil gå tabt!", "Slet Projekt", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK)
                {
                    // Code that changes project status
                    bool result = Bizz.DeleteFromDb("Projects", Bizz.TempProject.Id.ToString());

                    if (result)
                    {
                        foreach (Enterprise enterprise in Bizz.EnterpriseList)
                        {
                            if (enterprise.Project.Id == Bizz.TempProject.CaseId)
                            {
                                foreach (SubEntrepeneur subEntrepeneur in Bizz.SubEntrepeneurs)
                                {
                                    if (subEntrepeneur.EnterpriseList.Id == enterprise.Id)
                                    {
                                        Bizz.DeleteFromDb("Requests", subEntrepeneur.Request.Id.ToString());
                                        Bizz.DeleteFromDb("IttLetters", subEntrepeneur.IttLetter.Id.ToString());
                                        Bizz.DeleteFromDb("Offers", subEntrepeneur.Offer.Id.ToString());
                                        Bizz.DeleteFromDb("SubEntrepeneurs", subEntrepeneur.Id.ToString());
                                    }
                                }
                                Bizz.DeleteFromDb("EnterpriseList", enterprise.Id.ToString());
                            }
                        }

                        //Show Confirmation
                        MessageBox.Show("Projektet blev slettet", "Slet Projekt", MessageBoxButton.OK, MessageBoxImage.Information);

                        //Update list of projects
                        Bizz.RefreshList("Projects");
                        Bizz.RefreshIndexedList("IndexedActiveProjects");
                        Bizz.RefreshIndexedList("IndexableProjects");

                        //Close right UserControl
                        Bizz.UcRightActive = false;
                        UcRight.Content    = new UserControl();
                    }
                    else
                    {
                        //Show error
                        MessageBox.Show("Databasen returnerede en fejl. Projektet blev ikke slettet. Prøv igen.", "Slet Projekt", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
            else
            {
                //Show error
                MessageBox.Show("Du har glemt at markere 'Godkend sletning af projekt'.", "Slet Projekt", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Method, that retrieves a list of filtered Entrepeneurs for ListBoxEntrepeneurs
        /// </summary>
        private void GetFilteredContacts()
        {
            CBZ.RefreshIndexedList("Contacts");
            this.FilteredContacts = new List <IndexedContact>();

            foreach (IndexedContact contact in CBZ.IndexedContacts)
            {
                if (contact.Entrepeneur == CBZ.TempEntrepeneur)
                {
                    this.FilteredContacts.Add(contact);
                }
            }
        }
        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);
            }
        }
Ejemplo n.º 13
0
        private void ListBoxEntrepeneurs_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ListBoxEntrepeneurs.SelectedItems.Count == 1)
            {
                CBZ.TempSubEntrepeneur.Entrepeneur = new Entrepeneur((IndexedEntrepeneur)ListBoxEntrepeneurs.SelectedItem);
                CBZ.RefreshIndexedList("Contacts");
                ComboBoxContact.ItemsSource   = "";
                ComboBoxContact.ItemsSource   = CBZ.IndexedContacts;
                ComboBoxContact.SelectedIndex = 0;

                //Set CBZ.UcMainEdited
                if (!CBZ.UcMainEdited)
                {
                    CBZ.UcMainEdited = true;
                }
            }
        }
Ejemplo n.º 14
0
        public UcUsersEdit(Bizz cbz, UserControl ucMain)
        {
            InitializeComponent();
            this.CBZ    = cbz;
            this.UcMain = ucMain;

            CBZ.RefreshIndexedList("JobDescriptions");
            CBZ.RefreshIndexedList("UserLevels");

            GetFilteredUsers();
            ListBoxUsers.ItemsSource = FilteredUsers;

            ComboBoxJobDescription.ItemsSource   = CBZ.IndexedJobDescriptions;
            ComboBoxJobDescription.SelectedIndex = -1;
            ComboBoxUserLevel.ItemsSource        = CBZ.IndexedUserLevels;
            ComboBoxJobDescription.SelectedIndex = -1;
        }
 public UcEntrepeneurCreate(Bizz cbz, UserControl ucMain)
 {
     InitializeComponent();
     this.CBZ            = cbz;
     this.UcMain         = ucMain;
     CBZ.TempEntrepeneur = new Entrepeneur();
     CBZ.RefreshIndexedList("CraftGroups");
     ComboBoxCraftGroup1.ItemsSource   = ComboBoxCraftGroup2.ItemsSource = ComboBoxCraftGroup3.ItemsSource = ComboBoxCraftGroup3.ItemsSource = CBZ.IndexedCraftGroups;
     ComboBoxCraftGroup1.SelectedIndex = ComboBoxCraftGroup2.SelectedIndex = ComboBoxCraftGroup3.SelectedIndex = ComboBoxCraftGroup3.SelectedIndex = 0;
 }
Ejemplo n.º 16
0
 public UcProjectsEdit(Bizz cbz, UserControl ucMain)
 {
     InitializeComponent();
     this.CBZ    = cbz;
     this.UcMain = ucMain;
     CBZ.RefreshIndexedList("Projects"); //Refreshes Indexed Projects list and all dependent lists
     ComboBoxCaseId.ItemsSource         = CBZ.IndexedActiveProjects;
     ComboBoxBuilder.ItemsSource        = CBZ.IndexedActiveBuilders;
     ComboBoxTenderForm.ItemsSource     = CBZ.IndexedTenderForms;
     ComboBoxEnterpriseForm.ItemsSource = CBZ.IndexedEnterpriseForms;
     ComboBoxExecutive.ItemsSource      = CBZ.IndexedActiveUsers;
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Method, that retrieves a list of filtered Users for ListBoxUsers
        /// </summary>
        private void GetFilteredUsers()
        {
            CBZ.RefreshIndexedList("Users");
            this.FilteredUsers = new List <IndexedUser>();

            foreach (IndexedUser user in CBZ.IndexedUsers)
            {
                if (user.Person.Name.Remove(3) == TextBoxUserSearch.Text.Remove(3))
                {
                    this.FilteredUsers.Add(user);
                }
            }
        }
Ejemplo n.º 18
0
        private void ButtonSave_Click(object sender, RoutedEventArgs e)
        {
            // Code that save changes to the project
            bool result = CBZ.UpdateInDb(CBZ.TempProject);

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

                //Update Projects lists
                CBZ.RefreshIndexedList("Projects"); //Refreshes Indexed Projects list and all dependent lists

                //Reset form
                ComboBoxCaseId.SelectedIndex = -1;
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Projektet blev ikke rettet. Prøv igen.", "Projekter", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Method, that retrieves a list of filtered Entrepeneurs for ListBoxEntrepeneurs
        /// </summary>
        private void GetFilteredEntrepeneurs()
        {
            CBZ.RefreshIndexedList("Entrepeneurs");
            this.FilteredEntrepeneurs = new List <IndexedEntrepeneur>();
            int length = TextBoxEntrepeneurSearch.Text.Length;

            foreach (IndexedEntrepeneur entrepeneur in CBZ.IndexedEntrepeneurs)
            {
                if (entrepeneur.Entity.Name.Remove(length) == TextBoxEntrepeneurSearch.Text || entrepeneur.Entity.Name.Remove(length + 4) == "A/S " + TextBoxEntrepeneurSearch.Text)
                {
                    this.FilteredEntrepeneurs.Add(entrepeneur);
                }
            }
        }
        private void ButtonSave_Click(object sender, RoutedEventArgs e)
        {
            // Code that save changed CaseId to the project
            bool result = CBZ.UpdateInDb(CBZ.TempProject);

            if (result)
            {
                //Show Confirmation
                MessageBox.Show("Sagsnummer blev ændret", "Projekter", MessageBoxButton.OK, MessageBoxImage.Information);

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

                //ResetForm
                ComboBoxCaseId.SelectedItem = -1;
                CBZ.UcMainEdited            = false;
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Sagsnummer blev ikke ændret. Prøv igen.", "Projekter", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Ejemplo n.º 21
0
        private void GetFilteredZipTowns()
        {
            CBZ.RefreshIndexedList("ZipTowns");
            this.FilteredZipTowns = new List <IndexedZipTown>();
            int length = TextBoxZipSearch.Text.Length;

            foreach (IndexedZipTown zipTown in CBZ.IndexedZipTowns)
            {
                if (zipTown.Zip.Remove(length) == TextBoxZipSearch.Text || zipTown.Town.Remove(length) == TextBoxZipSearch.Text)
                {
                    this.FilteredZipTowns.Add(zipTown);
                }
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Method, that retrieves a filtered Enterprise Form list
        /// </summary>
        private void GetFilteredEnterpriseForms()
        {
            CBZ.RefreshIndexedList("EnterpriseForms");
            this.FilteredEnterpriseForms = new List <IndexedEnterpriseForm>();
            int length = TextBoxEnterpriseFormSearch.Text.Length;

            foreach (IndexedEnterpriseForm form in CBZ.IndexedEnterpriseForms)
            {
                if (form.Text == TextBoxEnterpriseFormSearch.Text)
                {
                    this.FilteredEnterpriseForms.Add(form);
                }
            }
        }
        /// <summary>
        /// Method, that retrieves a list of filtered Entrepeneurs for ListBoxEntrepeneurs
        /// </summary>
        private void GetFilteredContacts()
        {
            CBZ.RefreshIndexedList("Contacts");
            this.FilteredContacts = new List <IndexedContact>();
            int length = TextBoxContactSearch.Text.Length;

            foreach (IndexedContact contact in CBZ.IndexedContacts)
            {
                if (contact.Person.Name.Remove(length) == TextBoxContactSearch.Text)
                {
                    this.FilteredContacts.Add(contact);
                }
            }
        }
Ejemplo n.º 24
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);
            }
        }
        public UcCraftGroups(Bizz cbz, UserControl ucMain)
        {
            InitializeComponent();
            this.CBZ    = cbz;
            this.UcMain = ucMain;

            CBZ.TempCraftGroup = new CraftGroup();

            GetFilteredCraftGroups();
            ListBoxCraftGroups.ItemsSource   = FilteredCraftGroups;
            ListBoxCraftGroups.SelectedIndex = -1;

            CBZ.RefreshIndexedList("Categories");
            ComboBoxCategory.ItemsSource   = CBZ.IndexedCategories;
            ComboBoxCategory.SelectedIndex = -1;
        }
Ejemplo n.º 26
0
        private void ButtonSave_Click(object sender, RoutedEventArgs e)
        {
            // Code that changes project status
            bool result = CBZ.UpdateInDb(CBZ.TempProject);

            if (result)
            {
                //Show Confirmation
                MessageBox.Show("Projekstatus blev ændret", "Ændr Projektstatus", MessageBoxButton.OK, MessageBoxImage.Information);

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

                CBZ.CloseUcMain(UcMain);
            }
            else
            {
                //Show error
                MessageBox.Show("Databasen returnerede en fejl. Projektstatus blev ikke ændret. Prøv igen.", "Ændr Projektstatus", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
        /// <summary>
        /// Method that creates a list of indexable Legal Entities
        /// </summary>
        /// <returns>List<IndexedLegalEntity></returns>
        private void GetIndexedEntrepeneurs()
        {
            CBZ.RefreshIndexedList("SubEntrepeneursFromProjectSubEntrepeneurs");

            IndexedSubEntrepeneurs.Clear();

            foreach (IndexedSubEntrepeneur subEntrepeneur in CBZ.IndexedSubEntrepeneurs)
            {
                if (CheckBoxShowSent.IsChecked == false)
                {
                    if (!subEntrepeneur.IttLetter.Sent)
                    {
                        IndexedSubEntrepeneurs.Add(subEntrepeneur);
                    }
                }
                else
                {
                    IndexedSubEntrepeneurs.Add(subEntrepeneur);
                }
            }

            ListBoxEntrepeneurs.ItemsSource = "";
            ListBoxEntrepeneurs.ItemsSource = IndexedSubEntrepeneurs;
        }
        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);
            }
        }
 /// <summary>
 /// Method, that refreshes content of a list in CBZ
 /// </summary>
 /// <param name="list">string</param>
 private void RefreshIndexedList(string list) => CBZ.RefreshIndexedList(list);
        private void ButtonDelete_Click(object sender, RoutedEventArgs e)
        {
            bool allSubEntrepeneursDeleted  = true;
            bool allRequestsDeleted         = true;
            bool allIttLettersDeleted       = true;
            bool allOffersDeleted           = true;
            bool allEnterprisesDeleted      = true;
            bool someSubEntrepeneursDeleted = false;
            bool someRequestsDeleted        = false;
            bool someIttLettersDeleted      = false;
            bool someOffersDeleted          = false;
            bool someEnterprisesDeleted     = false;
            bool result = false;

            if (CheckBoxEraseProject.IsChecked == true)
            {
                if (MessageBox.Show("Er du sikker på, at du vil slette projektet? Alle projektets data inkl. entrepriser & underentrepenører vil gå tabt!", "Projekter", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK)
                {
                    try
                    {
                        foreach (Enterprise enterprise in CBZ.Enterprises)
                        {
                            if (enterprise.Project.Id == CBZ.TempProject.Case)
                            {
                                foreach (SubEntrepeneur subEntrepeneur in CBZ.SubEntrepeneurs)
                                {
                                    if (subEntrepeneur.Enterprise.Id == enterprise.Id)
                                    {
                                        SubEntrepeneur sub = new SubEntrepeneur(subEntrepeneur);
                                        // Code that deletes SubEntrepeneur
                                        bool subEntrepeneurDeleted = CBZ.DeleteFromDb("SubEntrepeneurs", sub.Id.ToString());
                                        if (subEntrepeneurDeleted && !someSubEntrepeneursDeleted)
                                        {
                                            someSubEntrepeneursDeleted = true;

                                            // Code that deletes Request
                                            bool requestDeleted = CBZ.DeleteFromDb("Requests", sub.Request.Id.ToString());
                                            if (requestDeleted && !someRequestsDeleted)
                                            {
                                                someRequestsDeleted = true;
                                            }
                                            else if (!requestDeleted && allRequestsDeleted)
                                            {
                                                allRequestsDeleted = false;
                                            }

                                            // Code that deletes IttLetter
                                            bool ittLetterDeleted = CBZ.DeleteFromDb("IttLetters", sub.IttLetter.Id.ToString());
                                            if (ittLetterDeleted && !someIttLettersDeleted)
                                            {
                                                someIttLettersDeleted = true;
                                            }
                                            else if (!ittLetterDeleted && allIttLettersDeleted)
                                            {
                                                allIttLettersDeleted = false;
                                            }

                                            // Code that deletes Offer
                                            bool offerDeleted = CBZ.DeleteFromDb("Offers", sub.Offer.Id.ToString());
                                            if (offerDeleted && !someOffersDeleted)
                                            {
                                                someOffersDeleted = true;
                                            }
                                            else if (!offerDeleted && allOffersDeleted)
                                            {
                                                allOffersDeleted = false;
                                            }
                                        }
                                        else if (!someSubEntrepeneursDeleted && allSubEntrepeneursDeleted)
                                        {
                                            allSubEntrepeneursDeleted = false;
                                            allRequestsDeleted        = false;
                                            allIttLettersDeleted      = false;
                                            allOffersDeleted          = false;
                                        }
                                    }
                                }

                                // Code that deletes Enterprise
                                if (someSubEntrepeneursDeleted)
                                {
                                    bool enterpriseDeleted = CBZ.DeleteFromDb("Enterprises", enterprise.Id.ToString());
                                    if (enterpriseDeleted && !someEnterprisesDeleted)
                                    {
                                        someEnterprisesDeleted = true;
                                    }
                                    else if (!enterpriseDeleted && allEnterprisesDeleted)
                                    {
                                        allEnterprisesDeleted = false;
                                    }
                                }
                            }

                            if (someEnterprisesDeleted)
                            {
                                // Code that deletes Project
                                result = CBZ.DeleteFromDb("Projects", CBZ.TempProject.Id.ToString());
                                if (result)
                                {
                                    //Show results
                                    ShowDependencystatus(allSubEntrepeneursDeleted, allRequestsDeleted, allIttLettersDeleted, allOffersDeleted, allEnterprisesDeleted, someSubEntrepeneursDeleted, someRequestsDeleted, someIttLettersDeleted, someOffersDeleted, someEnterprisesDeleted);

                                    MessageBox.Show("Projektet blev slettet", "Projekter", MessageBoxButton.OK, MessageBoxImage.Information);
                                }
                                else
                                {
                                    //Show results
                                    ShowDependencystatus(allSubEntrepeneursDeleted, allRequestsDeleted, allIttLettersDeleted, allOffersDeleted, allEnterprisesDeleted, someSubEntrepeneursDeleted, someRequestsDeleted, someIttLettersDeleted, someOffersDeleted, someEnterprisesDeleted);

                                    MessageBox.Show("Projektet blev ikke slettet", "Projekter", MessageBoxButton.OK, MessageBoxImage.Error);
                                }
                            }

                            //Reset form
                            ComboBoxCaseId.SelectedIndex   = -1;
                            CheckBoxEraseProject.IsChecked = false;

                            //Update list of projects
                            CBZ.RefreshIndexedList("SubEntrepeneurs");
                        }
                    }
                    catch (Exception ex)
                    {
                        //Show results
                        ShowDependencystatus(allSubEntrepeneursDeleted, allRequestsDeleted, allIttLettersDeleted, allOffersDeleted, allEnterprisesDeleted, someSubEntrepeneursDeleted, someRequestsDeleted, someIttLettersDeleted, someOffersDeleted, someEnterprisesDeleted);

                        MessageBox.Show("Databasen returnerede en fejl. Projektet blev ikke slettet. Prøv igen.\n" + ex, "Projekter", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
            else
            {
                //Show error
                MessageBox.Show("Du har glemt at markere 'Godkend sletning af projekt'.", "Projekter", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }