Beispiel #1
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);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Handles the Click event of the btn_CritToPool 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_CritToPool_Click(object sender, EventArgs e)
        {
            try{
                if ((int)dataGridView_ProjCrits.SelectedRows[0].Index >= 0)
                {
                    DataGridViewRow row    = dataGridView_ProjCrits.SelectedRows[0];
                    int             CritId = (int)row.Cells["Criterion_Id"].Value;
                    int             index  = dataGridView_ProjCrits.CurrentCell.RowIndex;
                    ProjCrits.RemoveAt(index);
                    projCritCont.ChangeAllocationOfProjectCriterionsInDb(ProjectId, ProjCrits);
                    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();
                }
                else
                {
                    MessageBox.Show("Bitte erst eine Zeile auswählen");
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
            }
        }