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 IdentificationUnitVM(IdentificationUnit iu)
     : base(iu)
 {
 }
        private bool saveIU()
        {
            Cursor.Current = Cursors.WaitCursor;
            IdentificationUnit iu=null;
            try
            {
                if (this.parent == null)
                    iu = this._ius.CreateTopLevelIdentificationUnit(Identification);
                else
                    iu = this._ius.CreateIdentificationUnit(Identification);
            }
            catch (DataFunctionsException ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(ex.Message + " Identification and Identification Unit couldn't be saved.", "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                return false;
            }

            if (iu != null)
            {
                this.current = iu;
                this._lastIdentification = iu.LastIdentificationCache;
                iu.TaxonomicGroup = this._taxGroup = TaxonomicGroup;

                // Create Identification for new IU
                try
                {
                    DataFunctions.Instance.CreateIdentificationWithCheck(iu);
                }
                catch (Exception ex)
                {
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show(ex.Message + " Identification and Identification Unit couldn't be saved.", "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    try
                    {
                        if (this.parent == null)
                        {
                            this._ius.RemoveTopLevelIU();
                        }
                        else
                            this._ius.Remove(iu);
                    }
                    catch (DataFunctionsException) { }

                    return false;
                }

                if (UnitDescription != null && !UnitDescription.Equals(String.Empty))
                    iu.UnitDescription = UnitDescription;

                if (Family != null && !Family.Equals(String.Empty))
                    iu.FamilyCache = Family;

                if (Order != null && !Order.Equals(String.Empty))
                    iu.OrderCache = Order;

                if (UnitIdentifier != null && !UnitIdentifier.Equals(String.Empty))
                    iu.UnitIdentifier = UnitIdentifier;

                iu.CollectionSpecimenID = cs.CollectionSpecimenID;

                iu.DisplayOrder = DisplayOrder;

                if (this.parent != null)//hat einen parent
                {
                    iu.RelatedUnitID = parent.IdentificationUnitID;
                    iu.RelationType = Relation;
                }
                try
                {
                    DataFunctions.Instance.Update(iu);
                }
                catch (Exception ex)
                {
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show("Identification Unit Data couldn't be saved. (" + ex.Message + ")", "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    return false;
                }

                if (UserProfiles.Instance.Current.DefaultIUGeographyAnalysis == true)
                {
                    try
                    {
                        // Create new IUGeographyAnalysis automatically
                        if (this.InvokeRequired)
                        {
                            newGeoAnalysisDelegate geoDelegate = new newGeoAnalysisDelegate(newGeoAnalysis);
                            this.Invoke(geoDelegate, iu);
                        }
                        else
                        {
                            this.newGeoAnalysis(iu);
                        }
                    }
                    catch (DataFunctionsException ex)
                    {
                        Cursor.Current = Cursors.Default;
                        MessageBox.Show("Associated GeoAnalysis with IU couldn't be automatically created. (" + ex.Message + ")", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }
                }
            }
            Cursor.Current = Cursors.Default;
            return true;
        }
        private void newGeoAnalysis(IdentificationUnit iu)
        {
            if (iu != null)
            {
                IdentificationUnitGeoAnalysis iuGeoAnalysis = null;

                try
                {
                    if (UserProfiles.Instance.Current != null && (bool)UserProfiles.Instance.Current.DefaultIUGeographyAnalysis)
                    {
                        try
                        {
                            iuGeoAnalysis = DataFunctions.Instance.CreateIdentificationUnitGeoAnalysis(iu, iu.CollectionSpecimen);
                        }
                        catch (DataFunctionsException ex)
                        {
                            throw ex;
                        }

                        if (StaticGPS.isOpened())
                        {
                            if (StaticGPS.position != null)
                            {
                                try
                                {
                                    float latitude = float.Parse(StaticGPS.position.Latitude.ToString());
                                    float longitude = float.Parse(StaticGPS.position.Longitude.ToString());
                                    float altitude = float.Parse(StaticGPS.position.SeaLevelAltitude.ToString());
                                    iuGeoAnalysis.setGeography(48.2, 11.8, 230.12);
                                }
                                catch (Exception)
                                {
                                    Cursor.Current = Cursors.Default;
                                    throw new DataFunctionsException("GPS-Data couldn`t be read. Data will be set to default values.");
                                }
                            }
                        }
                        try
                        {
                            if (UserProfiles.Instance.Current != null)
                            {
                                iuGeoAnalysis.ResponsibleName = UserProfiles.Instance.Current.CombinedNameCache;
                                iuGeoAnalysis.ResponsibleAgentURI = UserProfiles.Instance.Current.AgentURI;
                            }
                        }
                        catch (ConnectionCorruptedException) { }

                        try
                        {
                            DataFunctions.Instance.Update(iuGeoAnalysis);
                        }
                        catch (DataFunctionsException ex)
                        {
                            Cursor.Current = Cursors.Default;
                            DataFunctions.Instance.Remove(iuGeoAnalysis);
                            throw ex;
                        }
                    }
                }
                catch (ConnectionCorruptedException ex)
                {
                    throw new DataFunctionsException(ex.Message);
                }
            }
        }
        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 bool FindTopLevelIU(int id)
        {
            try
            {
                IRestriction r1 = RestrictionFactory.Eq(typeof(IdentificationUnit), "_IdentificationUnitID", id);
                IRestriction r2 = RestrictionFactory.Eq(typeof(IdentificationUnit), "_RelatedUnitID", null);
                IRestriction restrict = RestrictionFactory.And().Add(r1).Add(r2);
                this._currentIdentificationUnit = con.Load<IdentificationUnit>(restrict);

                if (this._currentIdentificationUnit == null)
                {
                    return false;
                }
                else
                {
                    this._identificationUnitIterator.SetIteratorTo(this._currentIdentificationUnit);
                    return true;
                }
            }
            catch (Exception)
            {
                return false;
            }
        }
        public IList<IdentificationUnitGeoAnalysis> RetrieveIdentificationUnitGeoAnalysisForIdentificationUnit(IdentificationUnit iu)
        {
            IList<IdentificationUnitGeoAnalysis> iuGeoAnalysisList;

            try
            {
                IRestriction restrict = RestrictionFactory.Eq(typeof(IdentificationUnitGeoAnalysis), "_IdentificationUnitID", iu.IdentificationUnitID);
                iuGeoAnalysisList = con.LoadList<IdentificationUnitGeoAnalysis>(restrict);
            }
            catch (Exception)
            {
                iuGeoAnalysisList = new List<IdentificationUnitGeoAnalysis>();
            }

            return iuGeoAnalysisList;
        }
        public void CreateIdentificationWithCheck(IdentificationUnit iu)
        {
            try
            {
                Identification ident = SERIALIZER.CreateISerializableObject<Identification>();
                SERIALIZER.ConnectOneToMany(iu, ident);
                ident.CollectionSpecimenID = iu.CollectionSpecimenID;
                ident.IdentificationUnitID = iu.IdentificationUnitID;

                if (iu.LastIdentificationCache != null)
                {
                    ident.TaxonomicName = iu.LastIdentificationCache;
                }
                ident.IdentificationCategory = "determination";

                try
                {
                    // Current User as responsible agent
                    if (UserProfiles.Instance.Current != null)
                    {
                        ident.ResponsibleName = UserProfiles.Instance.Current.CombinedNameCache;

                        if (UserProfiles.Instance.Current.AgentURI != null)
                            ident.ResponsibleAgentURI = UserProfiles.Instance.Current.AgentURI;
                    }
                }
                catch (ConnectionCorruptedException)
                { }

                short sequence = 0;
                IList<Identification> identList = RetrieveIdentificationsForIU(iu.IdentificationUnitID);

                foreach (Identification item in identList)
                {
                    if (item != null)
                    {
                        if (item.IdentificationSequence > sequence)
                            sequence = (short)item.IdentificationSequence;
                    }
                }

                ident.IdentificationSequence = ++sequence;
                con.Save(ident);
            }
            catch (Exception)
            {
                throw new DataFunctionsException("New Identification couldn't be created");
            }
        }
 public TreeNode displayTopDownIdentificationUnit(IdentificationUnit iUnit)
 {
     TreeNode iuNode = new TreeNode();
     if (iUnit != null)
     {
         parametrizeIUNode(iUnit, iuNode);
         if (iUnit.ChildUnits.First() != null)
         {
             iuNode.Nodes.Add(displayTopDownIdentificationUnit(iUnit.ChildUnits.First()));
             while (iUnit.ChildUnits.HasNext())
             {
                 IdentificationUnit next = iUnit.ChildUnits.Next();
                 iuNode.Nodes.Add(displayTopDownIdentificationUnit(next));
             }
         }
     }
     return iuNode;
 }
        public TreeNode displayIdentificationUnit(IdentificationUnit iu)
        {
            TreeNode iuNode = new TreeNode();
            if(iu != null)
                iuNode = displayTopDownIdentificationUnit(iu);

            return iuNode;
        }
        public TreeNode displayBottomUpIdentificationUnit(IdentificationUnit iu, TreeNode childNode)
        {
            TreeNode iuNode = new TreeNode();
            TreeNode subRootNode = null;
            if (iu != null)
            {
                parametrizeIUNode(iu, iuNode);
                IdentificationUnit parent = iu.RelatedUnit;

                if(childNode != null)
                    iuNode.Nodes.Add(childNode);

                if (parent != null)
                {
                    subRootNode = displayBottomUpIdentificationUnit(parent, iuNode);
                }
                else
                {
                    CollectionSpecimen spec = iu.CollectionSpecimen;
                    subRootNode = displayBottomUpSpecimen(spec, iuNode);
                }
                if (subRootNode != null)
                {
                    return subRootNode;
                }
            }
            return iuNode;
        }
        public void parametrizeOnlyIUNode(IdentificationUnit iu, TreeNode iuNode)
        {
            if (iu != null && iuNode != null)
            {
                StringBuilder sb = new StringBuilder();
                if (iu.UnitIdentifier != null)
                {
                    sb.Append("(");
                    sb.Append(iu.UnitIdentifier);
                    sb.Append(") ");
                }
                if (iu.UnitDescription != null)
                    sb.Append(iu.UnitDescription).Append(", ");
                if (iu.LastIdentificationCache != null)
                    sb.Append(iu.LastIdentificationCache);
                iuNode.Text = sb.ToString();

                iuNode.Tag = new TreeViewNodeData((int)iu.IdentificationUnitID, TreeViewNodeTypes.IdentificationUnitNode);
                iuNode.ImageIndex = 0;
                iuNode.SelectedImageIndex = 0;

                if (iu.TaxonomicGroup != null)
                {
                    switch (iu.TaxonomicGroup.ToLower())
                    {
                        case "plant":
                            if (iu.UnitDescription != null)
                            {
                                switch (iu.UnitDescription.ToLower())
                                {
                                    case "tree":
                                        iuNode.ImageIndex = (int)TreeViewIconIndex.Tree;
                                        iuNode.SelectedImageIndex = (int)TreeViewIconIndex.Tree;
                                        break;
                                    case "branch":
                                        iuNode.ImageIndex = (int)TreeViewIconIndex.Branch;
                                        iuNode.SelectedImageIndex = (int)TreeViewIconIndex.Branch;
                                        break;
                                    case "leaf":
                                        iuNode.ImageIndex = (int)TreeViewIconIndex.Plant;
                                        iuNode.SelectedImageIndex = (int)TreeViewIconIndex.Plant;
                                        break;
                                    case "gall":
                                        iuNode.ImageIndex = (int)TreeViewIconIndex.Other;
                                        iuNode.SelectedImageIndex = (int)TreeViewIconIndex.Other;
                                        break;
                                    default:
                                        iuNode.ImageIndex = (int)TreeViewIconIndex.Plant;
                                        iuNode.SelectedImageIndex = (int)TreeViewIconIndex.Plant;
                                        break;
                                }
                            }
                            else
                            {
                                iuNode.ImageIndex = (int)TreeViewIconIndex.Plant;
                                iuNode.SelectedImageIndex = (int)TreeViewIconIndex.Plant;
                            }
                            break;
                        default:
                            int index;
                            try
                            {
                                index = (int)Enum.Parse(typeof(TreeViewIconIndex), iu.TaxonomicGroup.ToLower(), true);
                            }
                            catch (Exception)
                            {
                                index = (int)TreeViewIconIndex.Unknown;
                            }
                            iuNode.ImageIndex = index;
                            iuNode.SelectedImageIndex = index;
                            break;
                    }
                }
                if(this.expandLvl==ExpandLevel.IdentificationUnit&&iu.RelatedUnit==null)
                    iuNode.BackColor = System.Drawing.Color.BlanchedAlmond;
            }
        }
 public void parametrizeIUNode(IdentificationUnit iu, TreeNode iuNode)
 {
     if (iu != null && iuNode != null)
     {
         parametrizeOnlyIUNode(iu, iuNode);
         IdentificationUnitGeoAnalysis iugae = iu.IdentificationUnitGeoAnalysis.First();
         Identification id = iu.Identifications.First();
         IdentificationUnit firstBorn = iu.ChildUnits.First();
         IdentificationUnitAnalysis iuana = iu.IdentificationUnitAnalysis.First();
          if (iu.IdentificationUnitGeoAnalysis.First() != null)
         {
             IdentificationUnitGeoAnalysis iuga = iu.IdentificationUnitGeoAnalysis.First();
             TreeNode iugaNode = new TreeNode();
             parameterizeIUGeoANode(iuga, iugaNode);
             iuNode.Nodes.Add(iugaNode);
             while (iu.IdentificationUnitGeoAnalysis.HasNext())
             {
                 iuga = iu.IdentificationUnitGeoAnalysis.Next();
                 iugaNode = new TreeNode();
                 this.parameterizeIUGeoANode(iuga, iugaNode);
                 iuNode.Nodes.Add(iugaNode);
             }
         }
         IdentificationUnitAnalysis ana = iu.IdentificationUnitAnalysis.First();
         if (iu.IdentificationUnitAnalysis.First() != null)
         {
             IdentificationUnitAnalysis iua = iu.IdentificationUnitAnalysis.First();
             TreeNode iuaNode = new TreeNode();
             parametrizeIUANode(iua, iuaNode);
             iuNode.Nodes.Add(iuaNode);
             while (iu.IdentificationUnitAnalysis.HasNext())
             {
                 iua = iu.IdentificationUnitAnalysis.Next();
                 iuaNode = new TreeNode();
                 parametrizeIUANode(iua, iuaNode);
                 iuNode.Nodes.Add(iuaNode);
             }
         }
     }
 }
        public void Remove(IdentificationUnit identificationUnit)
        {
            if (identificationUnit != null)
            {
                //IU-Children und Analysen werden durch Cascade gelöscht.

                //// Remove all IdentificationUnitAnalysis assigned to IdentificationUnit
                //IList<IdentificationUnitAnalysis> iuaList;
                //IRestriction restrict = RestrictionFactory.Eq(typeof(IdentificationUnitAnalysis), "_IdentificationUnitID", identificationUnit.IdentificationUnitID);
                //iuaList = con.LoadList<IdentificationUnitAnalysis>(restrict);
                //foreach (IdentificationUnitAnalysis iuaTemp in iuaList)
                //{
                //    DataFunctions.Instance.Remove(iuaTemp);
                //}
                //// Remove all IdentificationUnitGeoAnalysis assigned to IdentificationUnit
                //IList<IdentificationUnitGeoAnalysis> iuGeoAnalysisList;
                //restrict = RestrictionFactory.Eq(typeof(IdentificationUnitGeoAnalysis), "_IdentificationUnitID", identificationUnit.IdentificationUnitID);
                //iuGeoAnalysisList = con.LoadList<IdentificationUnitGeoAnalysis>(restrict);
                //foreach (IdentificationUnitGeoAnalysis iuGeoAnalysisTemp in iuGeoAnalysisList)
                //{
                //    DataFunctions.Instance.Remove(iuGeoAnalysisTemp);
                //}
                try
                {
                    con.Delete(identificationUnit);
                }
                catch (Exception)
                {
                    throw new DataFunctionsException("Identification Unit ("+identificationUnit.IdentificationUnitID+") couldn't be removed.");
                }
            }
        }
        public IdentificationUnitAnalysis CreateIdentificationUnitAnalysis(IdentificationUnit iu, int analysisId, String value, DateTime analysisDate)
        {
            try
            {
                IdentificationUnitAnalysis iua = SERIALIZER.CreateISerializableObject<IdentificationUnitAnalysis>();

                SERIALIZER.ConnectOneToMany(iu, iua);

                iua.AnalysisID = analysisId;
                iua.AnalysisNumber = DateTime.Now.ToString();
                iua.AnalysisResult = value;
                iua.AnalysisDate = analysisDate.ToShortDateString();
                iua.IdentificationUnitID = iu.IdentificationUnitID;
                iua.CollectionSpecimenID = iu.CollectionSpecimenID;
                //Das Datum der Analyse wird gespeichert
                iua.AnalysisDate = System.DateTime.Now.ToShortDateString();

                // Current User as responsible agent
                try
                {
                    if (UserProfiles.Instance.Current != null)
                    {
                        iua.ResponsibleName = UserProfiles.Instance.Current.CombinedNameCache;

                        if (UserProfiles.Instance.Current.AgentURI != null)
                            iua.ResponsibleAgentURI = UserProfiles.Instance.Current.AgentURI;
                    }
                }
                catch (ConnectionCorruptedException)
                { }

                con.Save(iua);
                return iua;
            }
            catch (Exception)
            {
                throw new DataFunctionsException("New IdentificationUnitAnalysis couldn't be created.");
            }
        }
Пример #16
0
        private int findIUTopLevelID(IdentificationUnit iu)
        {
            if (iu == null)
                return -1;

            if (iu.RelatedUnit == null)
                return iu.IdentificationUnitID;

            while (iu.RelatedUnit != null)
            {
                iu = iu.RelatedUnit;
            }
            return iu.IdentificationUnitID;
        }
        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.");
            }
        }
Пример #18
0
        private void displayIdentificationUnit(IdentificationUnit iu)
        {
            if (iu != null)
            {
                TreeNode parent = treeViewFieldData.SelectedNode.Parent;
                TreeNode node = treeViewFieldData.SelectedNode;
                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    this.treeViewFieldData.BeginUpdate();
                    this.treeViewFieldData.SuspendLayout();
                    treeViewFieldData.SelectedNode = null;
                    TreeNode iuNode = new TreeNode();
                    treeViewFieldData.SelectedNode = null;
                    IList<TreeNode> removeNodes = new List<TreeNode>();
                    int i = 0;
                    if (this._tvOperations.expandLvl <= ExpandLevel.Specimen)
                    {
                        removeNodes.Add(node);
                        i = node.Index;
                    }
                    else
                    {
                        foreach (TreeNode tn in parent.Nodes)
                        {
                            TreeViewNodeData td = tn.Tag as TreeViewNodeData;
                            if (td.NodeType == TreeViewNodeTypes.IdentificationUnitNode)
                                removeNodes.Add(tn);
                            else
                                i++;
                        }
                    }

                    iuNode = _tvOperations.displayIdentificationUnit(iu);
                    foreach (TreeNode rem in removeNodes)
                    {
                        parent.Nodes.Remove(rem);
                    }
                    parent.Nodes.Insert(i, iuNode);
                    this.treeViewFieldData.SelectedNode = iuNode;
                    this._expandTrigger = false;
                    iuNode.ExpandAll();
                    this._expandTrigger = true;
                    this._actualLvl = TreeViewNodeTypes.IdentificationUnitNode;
                    this.enableDisableButtons(TreeViewNodeTypes.IdentificationUnitNode);
                    this.treeViewFieldData.Refresh();
                }
                catch (Exception ex)
                {
                    this.treeViewFieldData.SelectedNode = null;
                    this.treeViewFieldData.ResumeLayout();
                    this.treeViewFieldData.EndUpdate();
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show("DisplayError: " + ex.Message);
                    return;
                }

                this.treeViewFieldData.ResumeLayout();
                this.treeViewFieldData.EndUpdate();
                this.treeViewFieldData.Refresh();
                Cursor.Current = Cursors.Default;
            }
        }
 public IEnumerable<IdentificationUnitAnalysis> RetrieveIdentificationUnitAnalysisForIdentificationUnit(IdentificationUnit iu)
 {
     if (iu != null)
         return iu.IdentificationUnitAnalysis;
     else
         return new List<IdentificationUnitAnalysis>();
 }
        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();
        }
        public IdentificationUnitForm(IdentificationUnit currentIU)
            : this(true)
        {
            if (currentIU != null)
            {
                this._iu = currentIU;

                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    this.fillIUData();
                    this._oldIdentificationCache = currentIU.LastIdentificationCache;
                    Cursor.Current = Cursors.Default;
                }
                catch (ConnectionCorruptedException ex)
                {
                    Cursor.Current = Cursors.Default;
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    this.Close();
                }
            }
        }
 public IdentificationUnit CreateTopLevelIdentificationUnit(String lastIdentificationCache)
 {
     try
     {
         IdentificationUnit iu = SERIALIZER.CreateISerializableObject<IdentificationUnit>();
         iu.CollectionSpecimenID = this._collectionSpecimen.CollectionSpecimenID;
         iu.LastIdentificationCache = lastIdentificationCache;
         SERIALIZER.ConnectOneToMany(this._collectionSpecimen, iu);
         SERIALIZER.Connector.Save(iu);
         this._currentIdentificationUnit = this._identificationUnitIterator.Last();
         return iu;
     }
     catch (Exception)
     {
         throw new DataFunctionsException("New TopLevel Identification Unit couldn't be created");
     }
 }