コード例 #1
0
        /// <summary>
        /// Updates all percentage layer weightings for one project.
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// Erstellt von Joshua Frey, am 04.01.2016
        private void UpdateAllPercentageLayerWeightings(int projectId)
        {
            // calculate all weightings for the base layer
            List <ProjectCriterion> baseProjectCriterions = GetBaseProjectCriterions(projectId);

            CalculatePercentageLayerWeighting(ref baseProjectCriterions);

            // write calculated weightings back to db
            UpdateAllProjectCriterionDataSets(projectId, baseProjectCriterions);

            // calculate all weightings for all child project criterions

            List <ProjectCriterion> allProjectCriterions = GetAllProjectCriterionsForOneProject(projectId);

            foreach (ProjectCriterion projCrit in allProjectCriterions)
            {
                List <ProjectCriterion> eventualChildrenOfCurrentProjCriterion = GetChildCriterionsByParentId(projectId, projCrit.Criterion_Id);
                if (eventualChildrenOfCurrentProjCriterion.Count > 0)
                {
                    CalculatePercentageLayerWeighting(ref eventualChildrenOfCurrentProjCriterion);
                    foreach (ProjectCriterion childProjCrit in eventualChildrenOfCurrentProjCriterion)
                    {
                        ProjectCriterion projCritToChangeInCompleteList = allProjectCriterions.Single(
                            projCritToChange => projCritToChange.Criterion_Id == childProjCrit.Criterion_Id);
                        projCritToChangeInCompleteList.Weighting_Percentage_Layer = childProjCrit.Weighting_Percentage_Layer;
                    }
                }
            }
            UpdateAllProjectCriterionDataSets(projectId, allProjectCriterions);
        }
コード例 #2
0
        /// <summary>
        /// Gets the project criterion by ids.
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// <param name="criterionId">The criterion identifier.</param>
        /// <returns>
        /// An instance of 'ProjectCriterion'
        /// </returns>
        /// Erstellt von Joshua Frey, am 18.12.2015
        public ProjectCriterion GetProjectCriterionByIds(int projectId, int criterionId)
        {
            ProjectCriterion resultProjectCriterion = base.DataContext.ProjectCriterion.SingleOrDefault(projectCriterion => projectCriterion.Criterion_Id == criterionId &&
                                                                                                        projectCriterion.Project_Id == projectId);

            return(resultProjectCriterion);
        }
コード例 #3
0
        /// <summary>
        /// Gets the layer depth for single project criterion.
        /// </summary>
        /// <returns></returns>
        /// Erstellt von Joshua Frey, am 28.01.2016
        private int GetLayerDepthForSingleProjectCriterion(ProjectCriterion involvedProjCriterion, List <ProjectCriterion> allProjectCriterionsForThisProject)
        {
            bool hasParent    = false;
            int  layerCounter = 1;

            // traverse all parent criterion and count them in layerCounter
            do
            {
                // check if involvedProjCriterion has a parent
                if (involvedProjCriterion.Parent_Criterion_Id != null && involvedProjCriterion.Parent_Criterion_Id.Value != 0)
                {
                    int parentCritId = involvedProjCriterion.Parent_Criterion_Id.Value;
                    hasParent = true;
                    // for each parent inkrement counter
                    layerCounter++;
                    // parent is new involvedProjCriterion now
                    involvedProjCriterion = allProjectCriterionsForThisProject.Single(projCrit => projCrit.Criterion_Id == parentCritId);
                }
                else
                {
                    hasParent = false;
                }
            } while (hasParent);
            return(layerCounter);
        }
コード例 #4
0
        /// <summary>
        /// Inserts the project criterion into database.
        /// </summary>
        /// <param name="newProjectCriterion">The new project criterion.</param>
        /// <returns>
        /// bool if insertion was sucessfully
        /// </returns>
        /// Erstellt von Joshua Frey, am 22.12.2015
        /// <exception cref="NWATException">
        /// </exception>
        private bool InsertProjectCriterionIntoDb(ProjectCriterion newProjectCriterion, bool isImported)
        {
            bool success;

            try
            {
                success = InsertProjectCriterionDataSet(newProjectCriterion, isImported);
            }
            catch (Exception e)
            {
                throw (e);
            }
            if (success)
            {
                int projectId = newProjectCriterion.Project_Id;

                if (!isImported)
                {
                    UpdateLayerDepthForSingleProjectCriterion(projectId, newProjectCriterion.Criterion_Id);
                    UpdateAllPercentageLayerWeightings(projectId);
                    UpdateAllPercentageProjectWeightings(projectId);
                }
            }
            return(success);
        }
コード例 #5
0
        /// <summary>
        /// Updates the percentage project weighting for one criterion.
        /// </summary>
        /// <param name="projectCrit">The project crit.</param>
        /// Erstellt von Joshua Frey, am 20.01.2016
        private double UpdatePercentageProjectWeightingForOneCriterion(ProjectCriterion projectCrit)
        {
            int projectId   = projectCrit.Project_Id;
            int criterionId = projectCrit.Criterion_Id;

            double percentageProjectWeightingValue       = 1;
            List <ProjectCriterion> allProjectCriterions = GetAllProjectCriterionsForOneProject(projectId);
            ProjectCriterion        involvedProjCriterion;

            involvedProjCriterion = allProjectCriterions.Single(projCrit => projCrit.Criterion_Id == criterionId);

            bool hasParent = false;

            // traverse all parent criterions and multiply their layer weightings
            do
            {
                // multiplies weightingvalue by percentageLayerWeighting of current involved proj crit
                percentageProjectWeightingValue *= involvedProjCriterion.Weighting_Percentage_Layer.Value;
                if (involvedProjCriterion.Parent_Criterion_Id != null && involvedProjCriterion.Parent_Criterion_Id.Value != 0)
                {
                    int parentCritId = involvedProjCriterion.Parent_Criterion_Id.Value;
                    hasParent             = true;
                    involvedProjCriterion = allProjectCriterions.Single(projCrit => projCrit.Criterion_Id == parentCritId);
                }
                else
                {
                    hasParent = false;
                }
            } while (hasParent);

            return(Math.Round(percentageProjectWeightingValue, 6, MidpointRounding.ToEven));
        }
コード例 #6
0
        /// <summary>
        /// Allocates the new project criterion.
        /// </summary>
        /// <param name="projCritToAllocate">The proj crit to allocate.</param>
        /// <param name="index">The index.</param>
        /// Erstellt von Veit Berg, am 27.01.16
        public void AllocateNewProjectCriterion(ProjectCriterion projCritToAllocate, int index)
        {
            try{
                ProjCrits.Add(projCritToAllocate);
                projCritCont.ChangeAllocationOfProjectCriterionsInDb(ProjectId, ProjCrits);
                //          AllCrits.Remove((Criterion)projCritToAllocate);
                //foreach (ProjectCriterion projCrit in ProjCrits)
                //{
                //    Criterion allocatedCrit = AllCrits.Single(crit => crit.Criterion_Id == projCrit.Criterion_Id);
                //    AllCrits.Remove(allocatedCrit);
                //}


                using (CriterionController critCont = new CriterionController())
                {
                    AllCrits = critCont.GetAllCriterionsFromDb();

                    if (ProjCrits.Count != 0)
                    {
                        foreach (ProjectCriterion projCrit in ProjCrits)
                        {
                            Criterion allocatedCrit = AllCrits.Single(crit => crit.Criterion_Id == projCrit.Criterion_Id);
                            AllCrits.Remove(allocatedCrit);
                        }
                    }
                }

                using (ProjectCriterionController proCriCont = new ProjectCriterionController())
                {
                    ProjCrits = proCriCont.GetAllProjectCriterionsForOneProject(ProjectId);
                }
                using (CriterionController critCont = new CriterionController())
                {
                    AllCrits = critCont.GetAllCriterionsFromDb();

                    if (ProjCrits.Count != 0)
                    {
                        foreach (ProjectCriterion projCrit in ProjCrits)
                        {
                            Criterion allocatedCrit = AllCrits.Single(crit => crit.Criterion_Id == projCrit.Criterion_Id);
                            AllCrits.Remove(allocatedCrit);
                        }
                    }
                }
                dataGridView_CritAvail.DataSource = null;
                dataGridView_CritAvail.DataSource = AllCrits;

                refreshGridL();
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
            }
        }
コード例 #7
0
        /// <summary>
        /// Deletes the project criterion data set.
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// <param name="criterionId">The criterion identifier.</param>
        /// <returns></returns>
        /// Erstellt von Joshua Frey, am 12.01.2016
        private bool DeleteProjectCriterionDataSet(int projectId, int criterionId)
        {
            ProjectCriterion delProjCrit = (from projCrit in base.DataContext.ProjectCriterion
                                            where projCrit.Project_Id == projectId &&
                                            projCrit.Criterion_Id == criterionId
                                            select projCrit).FirstOrDefault();

            base.DataContext.ProjectCriterion.DeleteOnSubmit(delProjCrit);
            base.DataContext.SubmitChanges();

            return(GetProjectCriterionByIds(projectId, criterionId) == null);
        }
コード例 #8
0
        //// Erstellt von Weloko Tchokoua
        //public void CalculatePercentageProjectWeighting(ref List<ProjectCriterion> resultProjectCriterions)
        //{
        //    int projectId = 0;
        //   //List<ProjectCriterion> allProjectCriterions = GetAllProjectCriterionsForOneProject(projectId);
        //    List<ProjectCriterion> papa = GetBaseProjectCriterions(projectId);
        //    List<ProjectCriterion> basecrit = GetBaseProjectCriterions(projectId);
        //    float sumweightinglayeronecrit = 0;
        //    float sumweigthinglayerseconddepth =0;
        //    float parentprojectweightinglayer =0;
        //    //double parentprojectfirstlayer = 0;

        //    foreach (ProjectCriterion all in resultProjectCriterions)
        //        foreach (ProjectCriterion parent in papa)
        //        {
        //            List<ProjectCriterion> childcrit = GetChildCriterionsByParentId(projectId, parent.Criterion_Id);

        //            foreach (ProjectCriterion son in childcrit)
        //            {

        //                if (parent.Criterion_Id == son.Parent_Criterion_Id)
        //                {
        //                    UpdateAllPercentageLayerWeightings(projectId);
        //                    UpdateLayerDepthForProjectCriterion(projectId, all.Criterion_Id);
        //                    int maxlayer = int.MaxValue;
        //                    maxlayer = Math.Max(all.Layer_Depth, maxlayer) + 1;
        //                    for (all.Layer_Depth = 1; all.Layer_Depth <= maxlayer; all.Layer_Depth--)
        //                    {

        //                        sumweightinglayeronecrit += (float)son.Weighting_Percentage_Layer.Value;
        //                        parentprojectweightinglayer = sumweightinglayeronecrit * (float)parent.Weighting_Percentage_Layer.Value;

        //                        parent.Weighting_Percentage_Project = parentprojectweightinglayer;
        //                        foreach (ProjectCriterion papaohneparent in basecrit)
        //                        {
        //                            while (son.Layer_Depth == 2)
        //                            {
        //                                sumweigthinglayerseconddepth += (float)son.Weighting_Percentage_Project;
        //                                papaohneparent.Weighting_Percentage_Project = sumweigthinglayerseconddepth;
        //                            }


        //                        }


        //                    }
        //                }

        //            }



        //        }


        //}

        /// <summary>
        /// Checks if parent exists in project as project criterion.
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// <param name="parentCritId">The parent crit identifier.</param>
        /// <returns>
        /// bool which says if given parent is a projectCriterion
        /// </returns>
        /// Erstellt von Joshua Frey, am 22.12.2015
        private bool CheckIfParentExistsInProjectAsProjectCriterion(int projectId, int parentCritId)
        {
            ProjectCriterion resultProjectCriterion = base.DataContext.ProjectCriterion.FirstOrDefault(projectCriterion => projectCriterion.Project_Id == projectId && projectCriterion.Criterion_Id == parentCritId);

            if (resultProjectCriterion == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #9
0
        //// Esrstellt von Weloko Tchokoua
        //public void UpdateAllPercentageProjectWeightings(int projectId)
        //{
        //    // calculate all weightings for the base layer

        //    List<ProjectCriterion> baseProjectCriterions = GetBaseProjectCriterions(projectId);
        //    CalculatePercentageProjectWeighting(ref baseProjectCriterions);

        //    // write calculated weightings back to db

        //    foreach (ProjectCriterion baseProjCrit in baseProjectCriterions)
        //    {
        //        UpdateProjectCriterionDataSet(baseProjCrit);
        //    }

        //    // calculate all weightings for all child project criterions

        //    List<ProjectCriterion> allProjectCriterions = GetAllProjectCriterionsForOneProject(projectId);

        //    foreach (ProjectCriterion projCrit in allProjectCriterions)
        //    {
        //        List<ProjectCriterion> eventualChildrenOfCurrentProjCriterion = GetChildCriterionsByParentId(projectId, projCrit.Criterion_Id);
        //        if (eventualChildrenOfCurrentProjCriterion.Count > 0)
        //        {
        //            CalculatePercentageProjectWeighting(ref eventualChildrenOfCurrentProjCriterion);
        //            foreach (ProjectCriterion childProjCrit in eventualChildrenOfCurrentProjCriterion)
        //            {
        //                UpdateProjectCriterionDataSet(childProjCrit);
        //            }
        //        }
        //    }

        //}



        /// <summary>
        /// Checks if same project criterions.
        /// </summary>
        /// <param name="projCritOne">The proj crit one.</param>
        /// <param name="projCritTwo">The proj crit two.</param>
        /// <returns></returns>
        /// Erstellt von Joshua Frey, am 12.01.2016
        private static bool checkIfSameProjectCriterions(ProjectCriterion projCritOne, ProjectCriterion projCritTwo)
        {
            bool sameParentCritId               = projCritOne.Parent_Criterion_Id == projCritTwo.Parent_Criterion_Id;
            bool sameLayerDepth                 = projCritOne.Layer_Depth == projCritTwo.Layer_Depth;
            bool sameCardinalWeighting          = projCritOne.Weighting_Cardinal == projCritTwo.Weighting_Cardinal;
            bool samePercentageLayerWeighting   = projCritOne.Weighting_Percentage_Layer == projCritTwo.Weighting_Percentage_Layer;
            bool samePercentageProjectWeighting = projCritOne.Weighting_Percentage_Project == projCritTwo.Weighting_Percentage_Project;

            return(sameCardinalWeighting &&
                   sameLayerDepth &&
                   sameParentCritId &&
                   samePercentageLayerWeighting &&
                   samePercentageProjectWeighting);
        }
コード例 #10
0
        private static string MessageUserDecisionOfDeallocatingAllChildCriterions(ProjectCriterion projCrit, List <ProjectCriterion> eventualChildCriterions)
        {
            string critName = projCrit.Criterion.Name;
            // user is asked if he wants to deallocate the subordinated criterions
            string decisionMessage = @"Dem Kriterium " + critName + " sind noch folgende Kriterien untergeordnet: \n";

            foreach (ProjectCriterion childProjCrit in eventualChildCriterions)
            {
                decisionMessage += childProjCrit.Criterion.Name + "\n";
            }
            decisionMessage += "Wenn Sie das Kriterium dem Projekt entziehen, werden auch alle untergeordneten Kriterien dem Projekt entzogen\n" +
                               "Des Weiteren werden alle Erfüllungseinträge mit den betroffenen Kriterien für dieses Projekt entfernt.\n" +
                               "Möchten Sie das Kriterium " + critName + " und dessen Unterkriterien vom Projekt entkoppeln?";
            return(decisionMessage);
        }
コード例 #11
0
        /// <summary>
        /// Calculates the layer depth of the Criterion and updates it in Database;
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// <param name="projCritId">The proj crit identifier.</param>
        /// Erstellt von Joshua Frey, am 12.01.2016
        private void UpdateLayerDepthForSingleProjectCriterion(int projectId, int projCritId)
        {
            // base criterions are on layer one. So the lowest layer a criterion can exist in, is 1

            List <ProjectCriterion> allProjectCriterions = GetAllProjectCriterionsForOneProject(projectId);
            ProjectCriterion        involvedProjCriterion;

            involvedProjCriterion = allProjectCriterions.Single(projCrit => projCrit.Criterion_Id == projCritId);

            int layerCounter = GetLayerDepthForSingleProjectCriterion(involvedProjCriterion, allProjectCriterions);

            ProjectCriterion projCritToUpdate = allProjectCriterions.Single(projCrit => projCrit.Criterion_Id == projCritId);

            projCritToUpdate.Layer_Depth = layerCounter;
            UpdateProjectCriterionDataSet(projCritToUpdate);
        }
コード例 #12
0
 /// <summary>
 /// Handles the Click event of the btn_cancle control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 /// Erstellt von Veit Berg, am 27.01.16
 private void btn_cancle_Click(object sender, EventArgs e)
 {
     try{
         ProjectCriterion projCritToAllocate = new ProjectCriterion()
         {
             Project_Id   = ProjectId,
             Criterion_Id = CriterionIdToAllocate
         };
         ParentView.AllocateNewProjectCriterion(projCritToAllocate, CriterionIdDeleteFromList);
         this.Close();
     }
     catch (Exception x)
     {
         MessageBox.Show(x.Message);
     }
 }
コード例 #13
0
        /// <summary>
        /// Gets the old project criterions which were deallocated in a new list. This list contains all project criterions
        /// which have to be deleted in the db table
        /// </summary>
        /// <param name="listFromDb">The list from database.</param>
        /// <param name="newProjectCriterionList">The new project criterion list.</param>
        /// <returns>
        /// A list that contains all project criterions
        /// which have to be deleted in the db table
        /// </returns>
        /// Erstellt von Joshua Frey, am 28.12.2015
        private List <ProjectCriterion> GetOldProjectCriterionsWhichWereDeallocated(List <ProjectCriterion> listFromDb,
                                                                                    List <ProjectCriterion> newProjectCriterionList)
        {
            List <ProjectCriterion> resultProjCritList = new List <ProjectCriterion>();

            foreach (ProjectCriterion projCritFromDb in listFromDb)
            {
                ProjectCriterion projCritExistingInBothList = newProjectCriterionList.SingleOrDefault(newProjCrit =>
                                                                                                      newProjCrit.Criterion_Id == projCritFromDb.Criterion_Id);
                if (projCritExistingInBothList == null)
                {
                    resultProjCritList.Add(projCritFromDb);
                }
            }
            return(resultProjCritList);
        }
コード例 #14
0
        /// <summary>
        /// Gets the new project criterions which were allocated in a new list. This list contains all project criterions
        /// which have to be inserted into the db table
        /// </summary>
        /// <param name="listFromDb">The list from database.</param>
        /// <param name="newProjectCriterionList">The new project criterion list.</param>
        /// <returns>
        /// A list that contains all project criterions
        /// which have to be inserted in the db table
        /// </returns>
        /// Erstellt von Joshua Frey, am 28.12.2015
        private List <ProjectCriterion> GetNewProjectCriterionsWhichWereAllocated(List <ProjectCriterion> listFromDb,
                                                                                  List <ProjectCriterion> newProjectCriterionList)
        {
            List <ProjectCriterion> resultProjCritList = new List <ProjectCriterion>();

            foreach (ProjectCriterion newAllocatedCrit in newProjectCriterionList)
            {
                ProjectCriterion projCritExistingInBothLists = listFromDb.SingleOrDefault(allocatedCritInDb =>
                                                                                          allocatedCritInDb.Criterion_Id == newAllocatedCrit.Criterion_Id);
                if (projCritExistingInBothLists == null)
                {
                    resultProjCritList.Add(newAllocatedCrit);
                }
            }

            return(resultProjCritList);
        }
コード例 #15
0
        /// <summary>
        /// Allocates the criterion.
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// <param name="projCrit">The proj crit.</param>
        /// <returns>
        /// bool if insertions in projectCriterion table and fulfillment table were successful
        /// </returns>
        /// Erstellt von Joshua Frey, am 04.01.2016
        /// <exception cref="NWATException"></exception>
        private bool AllocateCriterion(int projectId, ProjectCriterion projCrit)
        {
            bool insertionProjectCritionSuccessful = true;
            bool insertionFulfillmentSuccessful    = true;

            int projCritId = projCrit.Criterion_Id;

            if (projCritId != 0 && projCrit.Project_Id != 0)
            {
                insertionProjectCritionSuccessful = InsertProjectCriterionIntoDb(projCrit);

                // get all project products for insertion to fulfillment table
                List <ProjectProduct> allProjectProducts;
                using (ProjectProductController projProdCont = new ProjectProductController())
                {
                    allProjectProducts = projProdCont.GetAllProjectProductsForOneProject(projectId);
                }

                // insert criterions into fulfillment table for each product
                using (FulfillmentController fulfillContr = new FulfillmentController())
                {
                    foreach (ProjectProduct projProd in allProjectProducts)
                    {
                        int productId = projProd.Product_Id;

                        // new fulfillment which will be inserted into fulfillment table.
                        // default values for Fulfilled and Comment (false and null)
                        Fulfillment newFulfillment = new Fulfillment()
                        {
                            Project_Id   = projectId,
                            Product_Id   = productId,
                            Criterion_Id = projCritId,
                            Fulfilled    = false,
                            Comment      = null
                        };

                        if (!fulfillContr.InsertFullfillmentInDb(newFulfillment))
                        {
                            insertionFulfillmentSuccessful = false;
                            throw (new NWATException(CommonMethods.MessageInsertionToFulFillmentTableFailed(productId, projCritId)));
                        }
                    }
                }
            }
            return(insertionFulfillmentSuccessful && insertionProjectCritionSuccessful);
        }
コード例 #16
0
        /// <summary>
        /// Updates the project criterion in database.
        /// </summary>
        /// <param name="alteredProjectCriterion">The altered project criterion.</param>
        /// <returns></returns>
        /// Erstellt von Joshua Frey, am 12.01.2016
        /// <exception cref="NWATException"></exception>
        public bool UpdateProjectCriterionInDb(ProjectCriterion alteredProjectCriterion)
        {
            bool updateSuccess;

            updateSuccess = UpdateProjectCriterionDataSet(alteredProjectCriterion);
            if (!updateSuccess)
            {
                throw new NWATException(MessageUpdateProjectCriterionFailed(alteredProjectCriterion.Criterion.Name));
            }

            int projectId = alteredProjectCriterion.Project_Id;

            UpdateLayerDepthForSingleProjectCriterion(projectId, alteredProjectCriterion.Criterion_Id);
            UpdateAllPercentageLayerWeightings(projectId);
            UpdateAllPercentageProjectWeightings(projectId);

            return(updateSuccess);
        }
コード例 #17
0
 /// <summary>
 /// Handles the Click event of the btn_zuordnen control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 /// Erstellt von Veit Berg, am 27.01.16
 private void btn_zuordnen_Click(object sender, EventArgs e)
 {
     try{
         Criterion        selectedParentCiterion = (Criterion)comboBox_CritName.SelectedItem;
         ProjectCriterion projCritToAllocate     = new ProjectCriterion()
         {
             Project_Id          = ProjectId,
             Criterion_Id        = CriterionIdToAllocate,
             Parent_Criterion_Id = selectedParentCiterion.Criterion_Id
         };
         ParentView.AllocateNewProjectCriterion(projCritToAllocate, CriterionIdDeleteFromList);
         this.Close();
     }
     catch (Exception x)
     {
         MessageBox.Show(x.Message);
     }
 }
コード例 #18
0
        /// <summary>
        /// Gets the project criterion by line from import file.
        /// </summary>
        /// <param name="projectCriterionImportLine">The project criterion import line.</param>
        /// <returns></returns>
        /// Erstellt von Joshua Frey, am 20.01.2016
        /// <exception cref="NWATException"></exception>
        private ProjectCriterion GetProjectCriterionByLineFromImportFile(string projectCriterionImportLine)
        {
            ProjectCriterion importProjectCriterion;
            // Project_Id|Criterion_Id|Layer_Depth|Parent_Criterion_Id|Weighting_Cardinal|Weighting_Percentage_Layer|Weigthing_Percentage_Project
            var lineAsArray = projectCriterionImportLine.Split(this._delimiter);

            int projectId;
            int criterionId;
            int layerDepth;

            System.Nullable <int> parentCritId;
            int cardinalWeighting;

            System.Nullable <double> percentageLayerWeighting;
            System.Nullable <double> percentageProjectWeighting;
            try
            {
                projectId                  = Convert.ToInt32(lineAsArray[0]);
                criterionId                = Convert.ToInt32(lineAsArray[1]);
                layerDepth                 = Convert.ToInt32(lineAsArray[2]);
                parentCritId               = CommonMethods.GetNullableIntValueFromString(lineAsArray[3]);
                cardinalWeighting          = Convert.ToInt32(lineAsArray[4]);
                percentageLayerWeighting   = CommonMethods.GetNullableDoubleValueFromString(lineAsArray[5]);
                percentageProjectWeighting = CommonMethods.GetNullableDoubleValueFromString(lineAsArray[6]);
            }
            catch (FormatException formatException)
            {
                throw new NWATException(String.Format("{0}\n\n{1}",
                                                      formatException,
                                                      MessageWrongDatatypeInExportedLine("Product", projectCriterionImportLine, "int|int|int|int|int|double (mit Kommata)|double (mit Kommata)")));
            }

            importProjectCriterion = new ProjectCriterion()
            {
                Project_Id                   = projectId,
                Criterion_Id                 = criterionId,
                Layer_Depth                  = layerDepth,
                Parent_Criterion_Id          = parentCritId,
                Weighting_Cardinal           = cardinalWeighting,
                Weighting_Percentage_Layer   = percentageLayerWeighting,
                Weighting_Percentage_Project = percentageProjectWeighting
            };
            return(importProjectCriterion);
        }
コード例 #19
0
        /// <summary>
        /// Handles the Click event of the btn_ProjCritStruSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        /// Erstellt von Veit Berg, am 27.01.16
        private void btn_ProjCritStruSave_Click(object sender, EventArgs e)
        {
            try
            {
                int i = 0;

                List <ProjectCriterion> changedProjectCriterions = new List <ProjectCriterion>();
                foreach (DataGridViewRow row in dataGridView_CritStruUpd.Rows)
                {
                    ProjectCriterion fromList = ProjCrits[i];
                    i++;
                    if (row.Cells["Parent_Criterion_Id"].Value == null)
                    {
                        fromList.Parent_Criterion_Id = null;
                        //projCritCont.UpdateProjectCriterionInDb(fromList);
                    }
                    else
                    {
                        bool projCritExists = projCritCont.CheckIfProjectCriterionAlreadyExists(ProjectId, (int)row.Cells["Parent_Criterion_Id"].Value);
                        if (projCritExists == false)
                        {
                            MessageBox.Show("Das eingetragene Parentkriterium des Kriteriums mit der ID: " + (int)row.Cells["Criterion_Id"].Value + " existiert nicht.\n" +
                                            "Es wurden keine Daten in der Datenbank gespeichert.");
                            // Ausstiegspunkt, da keine inkonsistenten Daten gespeichert werden sollen.
                            return;
                        }
                        else
                        {
                            fromList.Parent_Criterion_Id = (int)row.Cells["Parent_Criterion_Id"].Value;
                            //  projCritCont.UpdateProjectCriterionInDb(fromList);
                        }
                    }
                    changedProjectCriterions.Add(fromList);
                }

                projCritCont.UpdateAllProjectCriterions(this.ProjectId, changedProjectCriterions);
                refreshGrid();
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
            }
        }
コード例 #20
0
        /// <summary>
        /// Updates the project criterion data set.
        /// </summary>
        /// <param name="alteredProjectCriterion">The altered project criterion.</param>
        /// <returns></returns>
        /// Erstellt von Joshua Frey, am 12.01.2016
        private bool UpdateProjectCriterionDataSet(ProjectCriterion alteredProjectCriterion)
        {
            int projectId   = alteredProjectCriterion.Project_Id;
            int criterionId = alteredProjectCriterion.Criterion_Id;
            ProjectCriterion resultProjectCriterion = base.DataContext.ProjectCriterion.SingleOrDefault(projectCriterion => projectCriterion.Criterion_Id == criterionId &&
                                                                                                        projectCriterion.Project_Id == projectId);

            resultProjectCriterion.Parent_Criterion_Id          = alteredProjectCriterion.Parent_Criterion_Id;
            resultProjectCriterion.Weighting_Cardinal           = alteredProjectCriterion.Weighting_Cardinal;
            resultProjectCriterion.Layer_Depth                  = alteredProjectCriterion.Layer_Depth;
            resultProjectCriterion.Weighting_Percentage_Layer   = alteredProjectCriterion.Weighting_Percentage_Layer;
            resultProjectCriterion.Weighting_Percentage_Project = alteredProjectCriterion.Weighting_Percentage_Project;
            base.DataContext.SubmitChanges();

            ProjectCriterion changedProjCritFromDb = GetProjectCriterionByIds(alteredProjectCriterion.Project_Id, alteredProjectCriterion.Criterion_Id);

            bool successfulUpdate = checkIfSameProjectCriterions(alteredProjectCriterion, changedProjCritFromDb);

            return(successfulUpdate);
        }
コード例 #21
0
 /// <summary>
 /// Handles the Click event of the btn_ProjCritBalaSave control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 /// Erstellt von Veit Berg, am 27.01.16
 private void btn_ProjCritBalaSave_Click(object sender, EventArgs e)
 {
     try{
         int i = 0;
         List <ProjectCriterion> changedProjectCriterions = new List <ProjectCriterion>();
         foreach (DataGridViewRow row in dataGridView_ProjCritBalance.Rows)
         {
             int critID = (int)row.Cells["Weighting_Cardinal"].Value;
             ProjectCriterion fromList = ProjCrits[i];
             i++;
             fromList.Weighting_Cardinal = (int)row.Cells["Weighting_Cardinal"].Value; //wc vorher 3
             changedProjectCriterions.Add(fromList);
         }
         this.projCritCont.UpdateAllProjectCriterions(ProjectId, changedProjectCriterions);
         refreshGrid();
     }
     catch (Exception x)
     {
         MessageBox.Show(x.Message);
     }
 }
コード例 #22
0
 /// <summary>
 /// Handles the Click event of the btn_SameBalance control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 /// Erstellt von Veit Berg, am 27.01.16
 private void btn_SameBalance_Click(object sender, EventArgs e)
 {
     try{
         foreach (DataGridViewRow row in dataGridView_ProjCritBalance.Rows)
         {
             row.Cells["Weighting_Cardinal"].Value = 1;
         }
         int i = 0;
         foreach (DataGridViewRow row in dataGridView_ProjCritBalance.Rows)
         {
             int critID = (int)row.Cells["Weighting_Cardinal"].Value;
             ProjectCriterion fromList = ProjCrits[i];
             i++;
             fromList.Weighting_Cardinal = (int)row.Cells["Weighting_Cardinal"].Value;
             projCritCont.UpdateProjectCriterionInDb(fromList);
         }
         refreshGrid();
     }
     catch (Exception x)
     {
         MessageBox.Show(x.Message);
     }
 }
コード例 #23
0
        /// <summary>
        /// Inserts the project criterion data set into Db
        /// </summary>
        /// <param name="newProjectCriterion">The new project criterion.</param>
        /// <returns></returns>
        /// Erstellt von Joshua Frey, am 12.01.2016
        /// <exception cref="NWATException">
        /// </exception>
        private bool InsertProjectCriterionDataSet(ProjectCriterion newProjectCriterion, bool isImported)
        {
            if (newProjectCriterion != null)
            {
                int projectId   = newProjectCriterion.Project_Id;
                int criterionId = newProjectCriterion.Criterion_Id;

                if (!isImported)
                {
                    // set equal weighting when inserting a new project criterion
                    newProjectCriterion.Weighting_Cardinal = 1;
                    // set default layer depth to 1
                    newProjectCriterion.Layer_Depth = 1;
                }
                // if == null then this project criterion does not exist yet and it can be inserted into db
                if (!CheckIfProjectCriterionAlreadyExists(projectId, criterionId))
                {
                    base.DataContext.ProjectCriterion.InsertOnSubmit(newProjectCriterion);
                    base.DataContext.SubmitChanges();
                }

                // project criterion already exists --> throw exception
                else
                {
                    ProjectCriterion alreadyExistingProjectCriterion = this.GetProjectCriterionByIds(projectId, criterionId);
                    string           projectName   = alreadyExistingProjectCriterion.Project.Name;
                    string           criterionName = alreadyExistingProjectCriterion.Criterion.Name;
                    throw (new NWATException((MessageProjectCriterionAlreadyExists(projectName, criterionName))));
                }
                return(checkIfSameProjectCriterions(newProjectCriterion, this.GetProjectCriterionByIds(projectId, criterionId)));
            }
            else
            {
                throw (new NWATException(MessageProjectCriterionCouldNotBeSavedEmptyObject()));
            }
        }
コード例 #24
0
        /// <summary>
        /// Gets the highest layer number in project.
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// <returns></returns>
        /// Erstellt von Joshua Frey, am 20.01.2016
        public int GetHighestLayerNumberInProject(int projectId)
        {
            ProjectCriterion projCritWithHighestLayerNum = base.DataContext.ProjectCriterion.OrderByDescending(projCrit => projCrit.Layer_Depth).FirstOrDefault();

            return(projCritWithHighestLayerNum.Layer_Depth);
        }
コード例 #25
0
 private bool InsertProjectCriterionIntoDb(ProjectCriterion newProjectCriterion)
 {
     return(InsertProjectCriterionIntoDb(newProjectCriterion, false));
 }
コード例 #26
0
        /// <summary>
        /// Deallocates the criterion and all child criterions from project. This includes the entries in the fulfillment table
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// <param name="projCrit">The proj crit.</param>
        /// <returns></returns>
        /// Erstellt von Joshua Frey, am 04.01.2016
        public bool DeallocateCriterionAndAllChildCriterions(int projectId, ProjectCriterion projCrit, bool forceDeallocationOfChildren)
        {
            int projectCriterionId = projCrit.Criterion_Id;
            // checks if criterion has any children criterion (is a parent criterion)
            List <ProjectCriterion> eventualChildCriterions = GetChildCriterionsByParentId(projectId, projectCriterionId);
            bool deletionPermitted = true;

            if (eventualChildCriterions.Count > 0)
            {
                string       decisionMessage = MessageUserDecisionOfDeallocatingAllChildCriterions(projCrit, eventualChildCriterions);
                const string caption         = "Kriterienentkopplung";

                // only ask user if children should be deallocated when forceDeallocationOfChildre = false
                if (!forceDeallocationOfChildren)
                {
                    var result = MessageBox.Show(decisionMessage, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (result == DialogResult.No)
                    {
                        deletionPermitted = false;
                    }
                }

                if (deletionPermitted)
                {
                    foreach (ProjectCriterion childProjCrit in eventualChildCriterions)
                    {
                        deletionPermitted = DeallocateCriterionAndAllChildCriterions(projectId, childProjCrit, forceDeallocationOfChildren);
                    }
                }
            }
            string projCritName = projCrit.Criterion.Name;

            if (deletionPermitted)
            {
                // delete all fulfillment entries which point to this project criterion
                bool fulfillmentDeletionSuccessfull;
                using (FulfillmentController fulfillmentContr = new FulfillmentController())
                {
                    fulfillmentDeletionSuccessfull = fulfillmentContr.DeleteAllFulfillmentsForOneCriterionInOneProject(projectId, projCrit.Criterion_Id);
                }

                if (fulfillmentDeletionSuccessfull && DeleteProjectCriterionFromDb(projectId, projectCriterionId))
                {
                    if (!forceDeallocationOfChildren)
                    {
                        MessageBox.Show("Das Kriterium " + projCritName + " wurde erfolgreich vom Projekt entkoppelt.");
                    }

                    return(true);
                }
                else
                {
                    MessageBox.Show("Bei dem Löschvorgang ist ein Fehler aufgetreten.");
                    return(false);
                }
            }
            else
            {
                MessageBox.Show("Löschen von " + projCritName + " konnte nicht durchgeführt werden, weil ein Löschvorgang vom Benutzer abgelehnt wurde.");
                return(false);
            }
        }
コード例 #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnalysisResultCrit"/> class.
 /// </summary>
 /// <param name="projCrit">The proj crit.</param>
 /// Erstellt von Joshua Frey, am 20.01.2016
 public AnalysisResultCrit(ProjectCriterion projCrit)
 {
     this.ProjCrit       = projCrit;
     this.IsReCalculated = false;
     this.ResultValue    = this.ProjCrit.Weighting_Percentage_Project.Value;
 }
コード例 #28
0
        /// <summary>
        /// Checks if project criterion already exists.
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// <param name="criterionId">The criterion identifier.</param>
        /// <returns></returns>
        /// Erstellt von Joshua Frey, am 20.01.2016
        public bool CheckIfProjectCriterionAlreadyExists(int projectId, int criterionId)
        {
            ProjectCriterion existingProjCrit = GetProjectCriterionByIds(projectId, criterionId);

            return(existingProjCrit != null);
        }
コード例 #29
0
 /// <summary>
 /// Deallocates the criterion and all child criterions from project. This includes the entries in the fulfillment table
 /// User will be asked, if children should be deallocated
 /// </summary>
 /// <param name="projectId">The project identifier.</param>
 /// <param name="projCrit">The proj crit.</param>
 /// <returns></returns>
 /// Erstellt von Joshua Frey, am 13.01.2016
 public bool DeallocateCriterionAndAllChildCriterions(int projectId, ProjectCriterion projCrit)
 {
     return(DeallocateCriterionAndAllChildCriterions(projectId, projCrit, false));
 }
コード例 #30
0
 /// <summary>
 /// Imports the project criterion.
 /// </summary>
 /// <param name="importProjectCriterion">The import project criterion.</param>
 /// <returns></returns>
 /// Erstellt von Joshua Frey, am 20.01.2016
 public bool ImportProjectCriterion(ProjectCriterion importProjectCriterion)
 {
     return(InsertProjectCriterionIntoDb(importProjectCriterion, true));
 }