private void pictureBoxNewEventSeries_Click(object sender, EventArgs e) { //Ruft den Dialog auf und wechselt direkt zur neuen Eventseries EventSeriesDialog dlg = null; try { dlg = new EventSeriesDialog(null); if (dlg == null) return; } catch (ContextCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Context Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } // Dialog zentrieren dlg.Location = new Point((this.Size.Width) / 2 - (dlg.Size.Width) / 2, this.Location.Y); if (dlg.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; try { EventSeriess.Instance.Find(dlg.EventSeries.SeriesID); this.displayEventSeries(dlg.EventSeries); this.labelPosition.Text = EventSeriess.Instance.Position; this.enableDisableButtons(TreeViewNodeTypes.EventSeriesNode); this._actualLvl = TreeViewNodeTypes.EventSeriesNode; this.enableDisableToolbarButtons(_actualLvl); } catch (ConnectionCorruptedException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.pictureBoxHome_Click(null, null); return; } Cursor.Current = Cursors.Default; } else { this.treeViewFieldData.SelectedNode = null; } }
private void pictureBoxEdit_Click(object sender, EventArgs e) { if (this.treeViewFieldData.SelectedNode == null) { return; } //this.saveEventProperties(); TreeNode node = this.treeViewFieldData.SelectedNode; TreeViewNodeData data = node.Tag as TreeViewNodeData; if (data == null) { MessageBox.Show("Node information not found!"); return; } try { switch (data.NodeType) { case TreeViewNodeTypes.EventSeriesNode: // eventSeries node CollectionEventSeries ceSeries = null; if (data.ID != null) { EventSeriess.Instance.Find((int)data.ID); ceSeries = EventSeriess.Instance.Current; } if (ceSeries == null) { MessageBox.Show("You can't edit the NoEvent-Series!"); return; } EventSeriesDialog dlg = new EventSeriesDialog(ceSeries); // Dialog zentrieren dlg.Location = new Point((this.Size.Width) / 2 - (dlg.Size.Width) / 2, this.Location.Y); if (dlg.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; try { DataFunctions.Instance.Update(dlg.EventSeries); this._tvOperations.parametrizeEventSeriesNode(ceSeries, node);//Komplett neu Zeichnen? } catch (DataFunctionsException ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Changed data couldn't be saved. (" + ex.Message + ")", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } this.treeViewFieldData.SelectedNode = node; this.treeViewFieldData.Refresh(); Cursor.Current = Cursors.Default; this.treeViewFieldData.Focus(); } return; case TreeViewNodeTypes.EventNode: // event node // Show CollectionEventForm if (this._events.Current != null) { if (data.ID != this._events.Current.CollectionEventID) { MessageBox.Show("Display Error!"); pictureBoxHome_Click(null, null); return; } } CollectionEventForm ceDetails = new CollectionEventForm(this._events.Current); if (ceDetails.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; this._tvOperations.parametrizeOnlyEventNode(this._events.Current, node); this.treeViewFieldData.SelectedNode = node; this.treeViewFieldData.Refresh(); Cursor.Current = Cursors.Default; this.treeViewFieldData.Focus(); } return; case TreeViewNodeTypes.SpecimenNode: // specimen node // Show CollectionSpecimenForm if (this._specimen.Current != null) { if (data.ID != this._specimen.Current.CollectionSpecimenID) { MessageBox.Show("DisplayError!"); pictureBoxHome_Click(null, null); return; } } SpecimenEditForm csDetails = new SpecimenEditForm(this._specimen.Current); if (csDetails.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; this._tvOperations.parametrizeOnlySpecimenNode(this._specimen.Current, node); this.treeViewFieldData.SelectedNode = node; this.treeViewFieldData.Refresh(); Cursor.Current = Cursors.Default; this.treeViewFieldData.Focus(); } return; case TreeViewNodeTypes.IdentificationUnitNode: // IdentificationUnit node IdentificationUnit iu = DataFunctions.Instance.RetrieveIdentificationUnit((int)data.ID); if (iu == null) { MessageBox.Show("Selected Identification Unit couldn't be retrieved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (this._iu.Current != null) { if (this.findIUTopLevelID(iu) != this._iu.Current.IdentificationUnitID) { MessageBox.Show("DisplayError!"); pictureBoxHome_Click(null, null); return; } } // Show IdentificationUnitForm IdentificationUnitForm iuDetails = new IdentificationUnitForm(iu); if (iuDetails.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; this._tvOperations.parametrizeOnlyIUNode(iu, node); this.treeViewFieldData.SelectedNode = node; this.treeViewFieldData.Refresh(); Cursor.Current = Cursors.Default; this.treeViewFieldData.Focus(); } return; case TreeViewNodeTypes.AnalysisNode: IdentificationUnitAnalysis iua = DataFunctions.Instance.RetrieveIdentificationUnitAnalysis(data.CollectionSpecimenID, data.IdentificationUnitID, data.AnalysisID, data.AnalysisNumber); if (iua == null) { MessageBox.Show("Selected Identification Unit Analysis couldn't be retrieved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } // Show IdentificationUnitAnalysisForm IdentificationUnitAnalysisForm iuaDetails = new IdentificationUnitAnalysisForm(iua); if (iuaDetails.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; this._tvOperations.parametrizeIUANode(iua, node); this.treeViewFieldData.SelectedNode = node; this.treeViewFieldData.Refresh(); Cursor.Current = Cursors.Default; this.treeViewFieldData.Focus(); } return; case TreeViewNodeTypes.GeographyNode: MessageBox.Show("Details for IdentificationUnitGeoanlyses cannot be displayed. Use \"Show Map\" in the Context Menu to Edit"); return; case TreeViewNodeTypes.LocalisationNode: // localisation node // Show EventLocalisationForm with Details CollectionEventLocalisation ceLoc = DataFunctions.Instance.RetrieveCollectionEventLocalisation((int)data.ID, this._events.Current.CollectionEventID); if (ceLoc == null) { MessageBox.Show("Selected Localisation couldn't be retrieved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } LocalisationDetailForm eventLocForm = new LocalisationDetailForm(ceLoc); if (eventLocForm.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; this._tvOperations.parameterizeCollectionEventLocalisationNode(eventLocForm._ceLoc, this.treeViewFieldData.SelectedNode); this.treeViewFieldData.SelectedNode = node; this.treeViewFieldData.Refresh(); Cursor.Current = Cursors.Default; this.treeViewFieldData.Focus(); } return; case TreeViewNodeTypes.SitePropertyNode: // localisation node // Show EventPropertyForm with Details CollectionEventProperty ceProp = DataFunctions.Instance.RetrieveCollectionEventProperty((int)data.ID, this._events.Current.CollectionEventID); if (ceProp == null) { MessageBox.Show("Selected Event Property couldn't be retrieved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } EventPropertyForm eventPropForm = new EventPropertyForm(ceProp); if (eventPropForm.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; this._tvOperations.parameterizeCollectionEventPropertyNode(eventPropForm._ceProp, node); this.treeViewFieldData.SelectedNode = node; this.treeViewFieldData.Refresh(); Cursor.Current = Cursors.Default; this.treeViewFieldData.Focus(); } return; case TreeViewNodeTypes.AgentNode: // localisation node // Show AgentNode Details CollectionAgent agent = DataFunctions.Instance.RetrieveCollectionAgent(data.CollectorsName, data.CollectionSpecimenID); if (agent == null) { MessageBox.Show("Selected Agent couldn't be retrieved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } AgentForm agentForm = new AgentForm(agent); if (agentForm.ShowDialog() == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; this._tvOperations.parameterizeCollectionAgentNode(agentForm._agent, this.treeViewFieldData.SelectedNode); this.treeViewFieldData.SelectedNode = node; this.treeViewFieldData.Refresh(); Cursor.Current = Cursors.Default; this.treeViewFieldData.Focus(); } this.treeViewFieldData.Focus(); return; default: Cursor.Current = Cursors.Default; MessageBox.Show("There is no DetailForm for " + data.NodeType.ToString() + "!"); return; } } catch (ConnectionCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } catch (ContextCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Context Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); pictureBoxHome_Click(null, null); return; } }