private void textBoxSearch_TextChanged(object sender, EventArgs e) { if (this.textBoxSearch.Text.Trim().Length >= 1) { try { // Ausgabe des Zeichens verhindern TaxonNames actual = DataFunctions.Instance.CreateTaxonNames(); actual.TaxonNameCache = this.textBoxSearch.Text;//Unterstützung von Arbeitsnamen actual.NameURI = String.Empty; String input = this.textBoxSearch.Text.Trim(); input += "%"; input = input.Replace(" ", "% "); input = input.Replace("'", "''"); this.comboBoxIdentification.Items.Clear(); comboBoxIdentification.Items.Insert(0, actual.TaxonNameCache); this.comboBoxIdentification.SelectedItem = actual.TaxonNameCache; IList<string> Ilist = DataFunctions.Instance.RetrieveTaxonCache(input, this.comboBoxTaxonomicGroup.Text);//Auswahl der TaxonomischenGruppe gewährleisten foreach (string item in Ilist) { if (item != null) { comboBoxIdentification.Items.Add(item); if (item.Equals(actual.TaxonNameCache))//prüfen,ob der Arbeitsname bereits eine korrekte Bezeichnung ist. Falls ja diesen durch das vollständige Objekt ersetzen { comboBoxIdentification.SelectedItem = item; } } } tax = actual; } catch (ConnectionCorruptedException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.comboBoxIdentification.Items.Clear(); } } setSynonym(tax); this.buttonOk.Enabled = this.setOkButton(); this.buttonNewAnalysis.Enabled = this.setOkButton(); }
private void comboBoxTaxonomicGroup_TextChanged(object sender, EventArgs e) { this.comboBoxUnitDescription.Items.Clear(); if (this.TaxonomicGroup != null) { if (this.TaxonomicGroup.Equals("plant")) { this.comboBoxUnitDescription.Items.Add("tree"); this.comboBoxUnitDescription.Items.Add("branch"); this.comboBoxUnitDescription.Items.Add("leaf"); this.comboBoxUnitDescription.Items.Add("gall"); this.pictureBoxIUImage.Image = this.imgList.Images[(int)IconIndex.leaf];//Wenn keine Description angegeben ist, wird eine Pflanze durch einen Baum symbolosiert. } else { int index; try { index = (int)Enum.Parse(typeof(IconIndex), this.TaxonomicGroup, true); } catch (Exception) { Cursor.Current = Cursors.Default; index = (int)IconIndex.unknown; } this.pictureBoxIUImage.Image = this.imgList.Images[index]; } } this.comboBoxIdentification.Items.Clear(); this.comboBoxIdentification.Text = String.Empty; this.tax = new TaxonNames(); setSynonym(tax); setOkButton(); if (this.TaxonomicGroup != null) this.comboBoxIdentification.Enabled = true; }
private void setSynonym(TaxonNames tax) { if (tax != null) { if (tax.Synonymy != null) { if (tax.Synonymy.Equals("Synonym")) { labelSynonym.Text = "Synonym"; labelSynonym.BackColor = Color.Red; } if (tax.Synonymy.Equals("Accepted")) { labelSynonym.Text = "Accepted"; labelSynonym.BackColor = Color.Green; } } else { labelSynonym.Text = "Working Name"; labelSynonym.BackColor = Color.White; } } }
private void comboBoxIdentification_TextChanged(object sender, EventArgs e) { if (comboBoxIdentification.Text != null) { try { TaxonNames taxon = null; taxon = DataFunctions.Instance.RetrieveTaxon(this.comboBoxIdentification.Text, this.comboBoxTaxonomicGroup.Text); if (taxon != null) tax = taxon; else { tax = new TaxonNames(); tax.TaxonNameCache = comboBoxIdentification.Text; tax.NameURI = String.Empty; } } catch (ConnectionCorruptedException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); tax = new TaxonNames(); } } else { tax = new TaxonNames(); } setSynonym(tax); this.buttonOk.Enabled = this.setOkButton(); this.buttonNewAnalysis.Enabled = this.setOkButton(); }
private void clearTextBoxes() { this.buttonOk.Enabled = false; this.buttonNewAnalysis.Enabled = false; if (this.comboBoxTaxonomicGroup.Items.Count > 0) { if (this._taxGroup.Equals(String.Empty)) this.comboBoxTaxonomicGroup.SelectedItem = this.comboBoxTaxonomicGroup.Items[0]; else this.comboBoxTaxonomicGroup.SelectedItem = this._taxGroup; } // Liste aller IdentificationUnits des aktuellen Specimen, um DiplayOrder zu finden try { int order = (int)DataFunctions.Instance.RetrieveMaxDisplayOrderCollectionSpecimenIdentificationUnit(this.cs); if (order > 0) this.displayOrder = (short)(order + 1); else this.displayOrder = 1; } catch (ConnectionCorruptedException) { this.displayOrder = 1; } this.textBoxSearch.Text = ""; if (!this._lastIdentification.Equals(String.Empty)) { this.comboBoxIdentification.Items.Add(this._lastIdentification); this.comboBoxIdentification.SelectedItem = this._lastIdentification; try { TaxonNames taxparent = DataFunctions.Instance.RetrieveTaxon(this._lastIdentification, this._taxGroup); if (taxparent != null) tax = taxparent; else tax.TaxonNameCache = this._lastIdentification; } catch (ConnectionCorruptedException) { tax.TaxonNameCache = this._lastIdentification; } setSynonym(tax); } this.panelTop.Focus(); this.Refresh(); }
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(); }
//Überträgt die Taxa einer taxonomischen Gruppe vom Repository in die mobile Datenbank. Um doppelte Einträge zu vermeidenm werden zunächst Einträge in der Mobilen Datenbank //gelöscht. public int updateTaxa(string[] sourceTables, string targetTable, DbConnection connRepository, SqlCeConnection connMobile) { //Neue Taxa holen List<TaxonNames> taxa = new List<TaxonNames>(); this.setProgressValue(0); int index = 0; StringBuilder sb = new StringBuilder(); foreach (String sourceTable in sourceTables) { connRepository.Open(); this.setActionInformation("Get TaxonNames from Source-Table: " + sourceTable); DbCommand com = connRepository.CreateCommand(); sb = new StringBuilder(); sb.Append("Select NameURI,TaxonNameCache,Synonymy,Family,\"Order\" From ").Append(sourceTable); com.CommandText = sb.ToString(); DbDataReader reader = null; try { reader = com.ExecuteReader(); } catch (Exception e) { this.setProgressInformation("Exception while updating TaxonNames from: " + sourceTable); connRepository.Close(); return -1; } while (reader.Read()) { TaxonNames taxon = new TaxonNames(); if (reader.IsDBNull(0) == false) taxon.NameURI = reader.GetString(0); else taxon.NameURI = String.Empty; if (reader.IsDBNull(1) == false) taxon.TaxonNameCache = reader.GetString(1); if (reader.IsDBNull(2) == false) taxon.Synonymy = reader.GetString(2); if (!reader.IsDBNull(3)) taxon.Family = reader.GetString(3); if (!reader.IsDBNull(4)) taxon.Order = reader.GetString(4); taxa.Add(taxon); index++; this.setProgressInformation(index + " items already read"); } connRepository.Close(); } this.setProgressValue(40); connRepository.Close(); connMobile.Open(); SqlCeTransaction trans = connMobile.BeginTransaction(); //Alte Taxa löschen this.setActionInformation("Delete old TaxonNames from Target-Table: " + targetTable); this.setProgressInformation(""); DbCommand commandMobile = connMobile.CreateCommand(); sb = new StringBuilder(); sb.Append("Delete From ").Append(targetTable); commandMobile.CommandText = sb.ToString(); commandMobile.ExecuteNonQuery(); this.setProgressValue(50); //Taxa eintragen this.setActionInformation("Save new TaxonNames in Target-Table: " + targetTable); index = 0; double part = ((double)50 / (double)taxa.Count); foreach (TaxonNames taxon in taxa) { sb = new StringBuilder(); //Alternativ mobileDBSerializer.Connector.Save(taxon) sb.Append("Insert INTO ").Append(targetTable).Append(" (NameURI,TaxonNameCache,Synonymy,Family,\"Order\") VALUES ("); sb.Append(SqlUtil.SqlConvert(taxon.NameURI)).Append(","); sb.Append(SqlUtil.SqlConvert(taxon.TaxonNameCache)).Append(",").Append(SqlUtil.SqlConvert(taxon.Synonymy)).Append(",").Append(SqlUtil.SqlConvert(taxon.Family)).Append(",").Append(SqlUtil.SqlConvert(taxon.Order)).Append(")"); DbCommand insert = connMobile.CreateCommand(); insert.CommandText = @sb.ToString(); insert.ExecuteNonQuery(); index++; // Set ProgressInformation this.setProgressInformation(index + " of " + taxa.Count + " items already saved"); int offset = Convert.ToInt32(index * part); this.setProgressValue(50 + offset); } trans.Commit(); connMobile.Close(); this.setActionInformation("Update TaxonNames"); return taxa.Count; }