private IDirectAccessIterator<IdentificationUnit> _identificationUnitIterator; //Dieser iteriert im Gegensatz zu den anderen KLassen in Datamanagement nur auf dem TopLevel

        #endregion Fields

        #region Constructors

        internal IdentificationUnits(CollectionSpecimen cs)
        {
            if (cs != null)
            {
                this._collectionSpecimen = cs;
                _identificationUnitIterator = cs.IdentificationUnits;
                _identificationUnitIterator.Reset();
                this._currentIdentificationUnit = _identificationUnitIterator.First();
                if (this._currentIdentificationUnit != null)
                {
                    while (this._currentIdentificationUnit.RelatedUnitID != null)
                    {
                        try
                        {
                            this._currentIdentificationUnit = this.Next;
                        }
                        catch (DataFunctionsException)
                        {
                            this._currentIdentificationUnit = null;
                        }
                    }
                }
                //this._identificationUnitBrotherIterator = this._identificationUnitIterator;
            }
        }
 public SpecimenEditForm(CollectionSpecimen currentSpecimen)
     : this(true)
 {
     if (currentSpecimen != null)
     {
         this._specimen = currentSpecimen;
         //tabPage Specimen füllen und anzeigen
         Cursor.Current = Cursors.WaitCursor;
         this.fillSpecimenData();
         Cursor.Current = Cursors.Default;
     }
     else
         this.Close();
 }
예제 #3
0
        public void Remove(CollectionSpecimen collectionSpecimen)
        {
            if (collectionSpecimen != null)
            {
                try
                {
                    //// Remove Collection Specimen Attributs
                    //foreach (CollectionAgent agent in DataFunctions.Instance.RetrieveAgentForCollectionSpecimen((int)collectionSpecimen.CollectionSpecimenID))
                    //{
                    //    if (agent != null)
                    //    {
                    //        try
                    //        {
                    //            DataFunctions.Instance.Remove(agent);
                    //        }
                    //        catch (DataFunctionsException ex)
                    //        {
                    //            throw ex;
                    //        }
                    //    }
                    //}

                    // Remove all CollectionSpecimenImages assigned to CollectionSpecimen
                    IList<CollectionSpecimenImage> csImgList;
                    IRestriction restrict;
                    try
                    {
                        restrict = RestrictionFactory.Eq(typeof(CollectionSpecimenImage), "_CollectionSpecimenID", collectionSpecimen.CollectionSpecimenID);
                        csImgList = con.LoadList<CollectionSpecimenImage>(restrict);
                    }
                    catch (Exception)
                    {
                        throw new DataFunctionsException("List of assigned images couldn't be loaded.");
                    }

                    foreach (CollectionSpecimenImage csImgTemp in csImgList)
                    {
                        if (csImgTemp != null)
                        {
                            try
                            {
                                DataFunctions.Instance.Remove(csImgTemp);
                            }
                            catch (DataFunctionsException ex)
                            {
                                throw ex;
                            }
                        }
                    }

                    // Remove all IdentificationUnit assigned to CollectionSpecimen
                    //IList<IdentificationUnit> iuList;
                    //try
                    //{
                    //    restrict = RestrictionFactory.Eq(typeof(IdentificationUnit), "_CollectionSpecimenID", collectionSpecimen.CollectionSpecimenID);
                    //    iuList = con.LoadList<IdentificationUnit>(restrict);
                    //}
                    //catch (Exception)
                    //{
                    //    throw new DataFunctionsException("List of associated Identification Units couldn't be loaded.");
                    //}

                    //foreach (IdentificationUnit iuTemp in iuList)
                    //{
                    //    if (iuTemp != null)
                    //    {
                    //        try
                    //        {
                    //            DataFunctions.Instance.Remove(iuTemp);
                    //        }
                    //        catch (DataFunctionsException ex)
                    //        {
                    //            throw ex;
                    //        }
                    //    }
                    //}

                    //Remove all CollectionProjects assigned to CollectionSpecimen
                    //IList<CollectionProject> projList;
                    //try
                    //{
                    //    restrict = RestrictionFactory.Eq(typeof(CollectionProject), "_CollectionSpecimenID", collectionSpecimen.CollectionSpecimenID);
                    //    projList = con.LoadList<CollectionProject>(restrict);
                    //}
                    //catch (Exception)
                    //{
                    //    throw new DataFunctionsException("List of associated Identification Units couldn't be loaded.");
                    //}

                    //foreach (CollectionProject projTemp in projList)
                    //{
                    //    if (projTemp != null)
                    //    {
                    //        try
                    //        {
                    //            DataFunctions.Instance.Remove(projTemp);
                    //        }
                    //        catch (DataFunctionsException ex)
                    //        {
                    //            throw ex;
                    //        }
                    //    }
                    //}
                    try
                    {
                        con.Delete(collectionSpecimen);
                    }
                    catch (Exception)
                    {
                        throw new DataFunctionsException("Object (CollectionSpecimen) couldn't be removed.");
                    }

                    try
                    {
                        if (!this.HasNext)
                        {
                            if (this.HasPrevious)
                            {
                                this.Current = this.Previous;
                            }
                            else
                            {
                                this.Current = this.First;
                            }
                        }
                        else
                        {
                            this.Current = this.Next;
                        }
                    }
                    catch (DataFunctionsException ex)
                    {
                        throw ex;
                    }
                }
                catch (ConnectionCorruptedException ex)
                {
                    throw ex;
                }
            }
        }
예제 #4
0
        public CollectionSpecimen CreateSpecimen()
        {
            CollectionSpecimen cs = null;

            try
            {
                cs = SERIALIZER.CreateISerializableObject<CollectionSpecimen>();
                SERIALIZER.ConnectOneToMany(_parent, cs);
                cs.CollectionEventID = _parent.CollectionEventID;
                con.Save(cs);
            }
            catch (Exception)
            {
                throw new DataFunctionsException("New Specimen couldn't be created.");
            }

            try
            {
                if (UserProfiles.Instance.Current != null)
                {
                    try
                    {
                        CollectionAgent agent = SERIALIZER.CreateISerializableObject<CollectionAgent>();
                        SERIALIZER.ConnectOneToMany(cs, agent);
                        agent.CollectionSpecimenID = cs.CollectionSpecimenID;
                        agent.CollectorsName = UserProfiles.Instance.Current.CombinedNameCache;
                        if (UserProfiles.Instance.Current.AgentURI != null)
                        {
                            agent.CollectorsAgentURI = UserProfiles.Instance.Current.AgentURI;
                        }
                        con.Save(agent);
                    }
                    catch (Exception)
                    {
                        throw new DataFunctionsException("Associated Agent of new Specimen couldn't be created.");
                    }

                    try
                    {
                        CollectionProject csProject = SERIALIZER.CreateISerializableObject<CollectionProject>();
                        csProject.CollectionSpecimenID = cs.CollectionSpecimenID;
                        csProject.ProjectID = (int)UserProfiles.Instance.Current.ProjectID;
                        con.Save(csProject);
                    }
                    catch (Exception)
                    {
                        throw new DataFunctionsException("Associated Project of new Specimen couldn't be created.");
                    }
                }
            }
            catch (ConnectionCorruptedException)
            {
            }
            this._currentSpecimen = this._csIterator.Last();
            return cs;
        }
 public SpecimenVM(CollectionSpecimen spec)
     : base(spec)
 {
 }
        public int? RetrieveMaxDisplayOrderSpecimen(CollectionSpecimen cs)
        {
            int? max = 0;
            String where = "CollectionSpecimenID";
            String s = null;
            try
            {
                IList<String> t = con.selectWhatFromWhere<String>("MAX(DisplayOrder)", "IdentificationUnit", where, cs.CollectionSpecimenID.ToString());
                if (t.Count == 0)
                    return 0;
                s = t[0];

                max = Int32.Parse(s);
            }
            catch (Exception)
            {
                return -1;
            }
            return max;
        }
        public IdentificationUnitGeoAnalysis CreateIdentificationUnitGeoAnalysis(IdentificationUnit iu, CollectionSpecimen cs)
        {
            try
            {
                IdentificationUnitGeoAnalysis iuGeoAnalysis = SERIALIZER.CreateISerializableObject<IdentificationUnitGeoAnalysis>();
                SERIALIZER.ConnectOneToMany(iu, iuGeoAnalysis);
                iuGeoAnalysis.IdentificationUnitID = iu.IdentificationUnitID;
                iuGeoAnalysis.CollectionSpecimenID = cs.CollectionSpecimenID;

                try
                {
                    if (UserProfiles.Instance.Current != null)
                    {
                        iuGeoAnalysis.ResponsibleName = UserProfiles.Instance.Current.CombinedNameCache;
                        if (UserProfiles.Instance.Current.AgentURI != null)
                            iuGeoAnalysis.ResponsibleAgentURI = UserProfiles.Instance.Current.AgentURI;
                    }
                }
                catch (ConnectionCorruptedException)
                { }

                con.Save(iuGeoAnalysis);
                return iuGeoAnalysis;
            }
            catch (Exception)
            {
                throw new DataFunctionsException("New IdentificationUnit GeoAnalysis couldn't be created.");
            }
        }
        public NewIdentificationUnitDialog(CollectionSpecimen spec, IdentificationUnit parentUnit, IdentificationUnits ius)
            : this(spec, ius)
        {
            try
            {
                this.parent = parentUnit;
                if (this.parent != null)
                {
                    this.comboBoxTaxonomicGroup.SelectedItem = this._taxGroup = parent.TaxonomicGroup;

                    if (parent.LastIdentificationCache != null)
                    {
                        this.comboBoxIdentification.Items.Add(parent.LastIdentificationCache);
                        this.comboBoxIdentification.SelectedItem = this._lastIdentification = parent.LastIdentificationCache;
                        TaxonNames taxparent = DataFunctions.Instance.RetrieveTaxon(parent.LastIdentificationCache, parent.TaxonomicGroup);
                        if (taxparent != null)
                            tax = taxparent;
                        else
                            tax.TaxonNameCache = parent.LastIdentificationCache;
                        setSynonym(tax);
                    }
                }

                fillRelationList();

                this.comboBoxRelation.Enabled = true;

                short order = (short)DataFunctions.Instance.RetrieveMaxDisplayOrderCollectionSpecimenIdentificationUnit(spec);
                if (order > 0)
                    this.displayOrder = (short)(order + 1);
                else
                    this.displayOrder = 1;

                this.buttonOk.Enabled = this.setOkButton();
                this.buttonNewAnalysis.Enabled = this.setOkButton();
            }
            catch (ConnectionCorruptedException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                this.Close();
            }
        }
        public NewIdentificationUnitDialog(CollectionSpecimen spec, IdentificationUnits ius)
            : this(true)
        {
            if (ius != null && spec != null)
            {
                this.cs = spec;
                this._ius = ius;

                this.comboBoxTaxonomicGroup_TextChanged(null, null);

                this.parent = null;
                try
                {
                    tax = DataFunctions.Instance.CreateTaxonNames();
                    this.buttonOk.Enabled = false;
                    this.buttonNewAnalysis.Enabled = false;
                    this.comboBoxRelation.Enabled = false;
                    this.fillTaxonomicGroupList();
                    if (this.comboBoxTaxonomicGroup.Items.Count > 0)
                    {
                        this.comboBoxTaxonomicGroup.SelectedItem = this.comboBoxTaxonomicGroup.Items[0];
                    }

                    // Liste aller IdentificationUnits des aktuellen Specimen, um DiplayOrder zu finden
                    short order = (short)DataFunctions.Instance.RetrieveMaxDisplayOrderCollectionSpecimenIdentificationUnit(spec);
                    if (order > 0)
                        this.displayOrder = (short)(order + 1);
                    else
                        this.displayOrder = 1;
                }
                catch (ConnectionCorruptedException ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    this.Close();
                }
            }
            else
                this.Close();
        }
예제 #10
0
        /// <summary>
        /// Displays a specimen (does not check whether the passed on parameter is valid).
        /// </summary>
        /// <param name="specimen">The current specimen.</param>
        /// <returns></returns>
        /// 
        private void displaySpecimen(CollectionSpecimen spec)
        {
            if (spec != null)
            {
                Cursor.Current = Cursors.WaitCursor;
                this.treeViewFieldData.BeginUpdate();
                this.treeViewFieldData.SuspendLayout();
                TreeNode parent = treeViewFieldData.SelectedNode.Parent;
                TreeNode node = treeViewFieldData.SelectedNode;
                try
                {
                    treeViewFieldData.SelectedNode = null;
                    TreeNode specNode = new TreeNode();
                    IList<TreeNode> removeNodes = new List<TreeNode>();
                    int i = 0;
                    if (this._tvOperations.expandLvl <= ExpandLevel.Event)
                    {
                        removeNodes.Add(node);
                        i = node.Index;
                    }
                    else
                    {
                        foreach (TreeNode tn in parent.Nodes)
                        {
                            TreeViewNodeData td = tn.Tag as TreeViewNodeData;
                            if (td.NodeType == TreeViewNodeTypes.SpecimenNode)
                                removeNodes.Add(tn);
                            else
                                i++;
                        }
                    }

                    specNode = _tvOperations.displaySpecimen(spec);

                    foreach (TreeNode rem in removeNodes)
                    {
                        parent.Nodes.Remove(rem);
                    }
                    parent.Nodes.Insert(i, specNode);
                    this.treeViewFieldData.SelectedNode = specNode;
                    this._expandTrigger = false;
                    if (this._tvOperations.expandLvl <= ExpandLevel.Specimen)
                        specNode.ExpandAll();
                    else
                        specNode.Expand();
                    this._expandTrigger = true;
                    this._actualLvl = TreeViewNodeTypes.SpecimenNode;
                    this.enableDisableButtons(TreeViewNodeTypes.SpecimenNode);

                }
                catch (Exception ex)
                {
                    this.treeViewFieldData.SelectedNode = parent;
                    afterSelect(parent);
                    this.treeViewFieldData.EndUpdate();
                    this.treeViewFieldData.ResumeLayout();
                    this.treeViewFieldData.Refresh();
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show("DisplayError: " + ex.Message);
                    return;
                }
                this.treeViewFieldData.ResumeLayout();
                this.treeViewFieldData.EndUpdate();
                this.treeViewFieldData.Refresh();
                Cursor.Current = Cursors.Default;
            }
        }
 public TreeNode displayTopDownSpecimen(CollectionSpecimen spec)
 {
     TreeNode specimenNode = new TreeNode();
     if (spec != null)
     {
         parametrizeOnlySpecimenNode(spec, specimenNode);
         IDirectAccessIterator<IdentificationUnit> ius = spec.IdentificationUnits;
         if (ius.First() != null)
         {
             IdentificationUnit iu = ius.First();
             if (iu.RelatedUnit == null)
                 specimenNode.Nodes.Add(displayTopDownIdentificationUnit(iu));
             while (ius.HasNext())
             {
                 IdentificationUnit next = ius.Next();
                 if (next.RelatedUnit == null)
                     specimenNode.Nodes.Add(displayTopDownIdentificationUnit(next));
             }
         }
     }
     return specimenNode;
 }
        public TreeNode displaySpecimen(CollectionSpecimen spec)
        {
            TreeNode specNode = new TreeNode();

            if (spec != null)
            {
                if (expandLvl <= ExpandLevel.Specimen)
                {
                    specNode = displayTopDownSpecimen(spec);
                }
                else
                {
                    parametrizeOnlySpecimenNode(spec, specNode);
                    if (spec.IdentificationUnits.First() != null)
                    {
                        IdentificationUnit first = spec.IdentificationUnits.First();
                        if (first.RelatedUnit == null)
                        {
                            TreeNode iuNode = new TreeNode();
                            parametrizeIUNode(first, iuNode);
                            if (first.ChildUnits.First() != null)
                                iuNode.Nodes.Insert(0, new TreeNode());
                            specNode.Nodes.Add(iuNode);
                            while (spec.IdentificationUnits.HasNext())
                            {
                                IdentificationUnit next = spec.IdentificationUnits.Next();
                                if (next.RelatedUnit == null)
                                {
                                    TreeNode nextNode = new TreeNode();
                                    parametrizeIUNode(next, nextNode);
                                    if (next.ChildUnits.First() != null)
                                        nextNode.Nodes.Insert(0, new TreeNode());
                                    specNode.Nodes.Add(nextNode);
                                }
                            }
                        }
                    }
                }
            }
            return specNode;
        }
        public TreeNode displayBottomUpSpecimen(CollectionSpecimen specimen, TreeNode childNode)
        {
            TreeNode specNode = new TreeNode();
            TreeNode subRootNode = null;
            if (specimen != null)
            {
                parametrizeOnlySpecimenNode(specimen, specNode);
                if(childNode != null)
                    specNode.Nodes.Add(childNode);

                CollectionEvent ev = specimen.CollectionEvent;
                if (ev != null)
                {
                    subRootNode = displayBottomUpEvent(ev, specNode);
                    return subRootNode;
                }
            }
            return specNode;
        }
 public void parametrizeSpecimenNode(CollectionSpecimen spec, TreeNode specimenNode, List<ISerializableObject> list)
 {
     if (spec != null && specimenNode != null)
     {
         parametrizeOnlySpecimenNode(spec, specimenNode);
         foreach (ISerializableObject iso in list)
         {
             if (iso != null)
             {
                 if (iso.GetType().Equals(typeof(CollectionAgent)))
                 {
                     CollectionAgent agent = (CollectionAgent)iso;
                     if (agent.CollectionSpecimenID == spec.CollectionSpecimenID)
                     {
                         TreeNode agentNode = new TreeNode();
                         parameterizeCollectionAgentNode(agent, agentNode);
                         specimenNode.Nodes.Add(agentNode);
                     }
                 }
             }
         }
     }
 }
        //Agents werden nicht maehr angezeigt=>Abandoned
        public void parametrizeSpecimenNode(CollectionSpecimen spec, TreeNode specimenNode)
        {
            if (spec != null && specimenNode != null)
            {
                parametrizeOnlySpecimenNode(spec, specimenNode);

                IDirectAccessIterator<CollectionAgent> agents = spec.CollectionAgent;
                if (agents.First() != null)
                {
                    CollectionAgent agent = agents.First();
                    TreeNode agentNode = new TreeNode();
                    parameterizeCollectionAgentNode(agent, agentNode);
                    specimenNode.Nodes.Add(agentNode);
                    while (agents.HasNext())
                    {
                        CollectionAgent next = agents.Next();
                        agentNode = new TreeNode();
                        parameterizeCollectionAgentNode(agent, agentNode);
                        specimenNode.Nodes.Add(agentNode);
                    }
                }
            }
        }
 public void parametrizeOnlySpecimenNode(CollectionSpecimen spec, TreeNode specimenNode)
 {
     if (spec != null && specimenNode != null)
     {
         if (spec.AccessionNumber != null && !spec.AccessionNumber.Equals(String.Empty))
             specimenNode.Text = spec.AccessionNumber;
         if (specimenNode.Text == null || specimenNode.Text == String.Empty)
             specimenNode.Text = "        ";
         specimenNode.ImageIndex = (int)TreeViewIconIndex.Specimen;
         specimenNode.SelectedImageIndex = (int)TreeViewIconIndex.SpecimenRed;
         specimenNode.Tag = new TreeViewNodeData((int)spec.CollectionSpecimenID, TreeViewNodeTypes.SpecimenNode);
         if(this.expandLvl==ExpandLevel.Specimen)
             specimenNode.BackColor = System.Drawing.Color.BlanchedAlmond;
     }
 }