Exemplo n.º 1
0
        private void InfoButton_Click(object sender, EventArgs e)
        {
            answersPanel.Controls.Clear();
            Termin termin = db.GetTermin((int)terminView.Rows[terminView.SelectedCells[0].RowIndex].Cells["id"].Value);

            foreach (Definition def in termin.Definitions)
            {
                TerminControl tc = new TerminControl
                {
                    Relator            = termin.Relator,
                    Descriptor         = termin.Descriptor,
                    Definition         = def.Content,
                    Ascriptors         = termin.Ascriptors,
                    definitionId       = def.ID,
                    DefinitionLocation = new int[] { def.StartLine, def.StartChar, def.EndLine, def.EndChar },
                    DescriptorLocation = new int[] { termin.StartLine, termin.StartChar, termin.EndLine, termin.EndChar },
                    Relations          = termin.Relations,
                    Links = def.Links
                };
                tc.Click += new EventHandler(ItemClick);
                answersPanel.Controls.Add(tc);
            }
            ItemClick(answersPanel.Controls[0], null);
            bool reg = CurrentSession.CurrentUser != null;

            ChangeButton.Enabled           = reg && (CheckedItem != null);
            addRelationButton.Enabled      = reg && (CheckedItem != null);
            AddSynonymButton.Enabled       = reg && (CheckedItem != null);
            addLinkButton.Enabled          = reg && (CheckedItem != null);
            deleteDefinitionButton.Enabled = reg && (CheckedItem != null);
        }
Exemplo n.º 2
0
        private void ChangeButton_Click_1(object sender, EventArgs e)
        {
            DescriptorForm df = new DescriptorForm();
            Termin         t  = new Termin()
            {
                Descriptor = CheckedItem.Descriptor,
                StartLine  = CheckedItem.DescriptorLocation[0],
                StartChar  = CheckedItem.DescriptorLocation[1],
                EndLine    = CheckedItem.DescriptorLocation[2],
                EndChar    = CheckedItem.DescriptorLocation[3]
            };

            df.Termin = t;
            Definition d = new Definition()
            {
                ID        = CheckedItem.definitionId,
                Content   = CheckedItem.Definition,
                StartLine = CheckedItem.DefinitionLocation[0],
                StartChar = CheckedItem.DefinitionLocation[1],
                EndLine   = CheckedItem.DefinitionLocation[2],
                EndChar   = CheckedItem.DefinitionLocation[3]
            };

            df.id         = CheckedItem.definitionId;
            df.Definition = d;
            df.Show();
            answersPanel.Controls.Clear();
            ShowTermins(searchBox.Text);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Получение термина по идентификатору
        /// </summary>
        /// <param name="descriptor_id"></param>
        /// <returns></returns>
        public Termin GetTermin(int descriptor_id)
        {
            Termin termin = new Termin();

            using (SqlConnection sqlConnection = new SqlConnection(con))
            {
                SqlCommand cmd = sqlConnection.CreateCommand();

                sqlConnection.Open();
                cmd.Parameters.AddWithValue("@descriptor_id", descriptor_id);
                cmd.CommandText = "select descriptor_content, relator, start_line, start_char, end_line, end_char from descriptors " +
                                  "where id=@descriptor_id";
                SqlDataReader reader = cmd.ExecuteReader();
                {
                    if (reader.Read())
                    {
                        termin.Descriptor = reader["descriptor_content"].ToString().Trim();
                        termin.Relator    = reader["relator"].ToString().Trim();
                        termin.StartLine  = (int)reader["start_line"];
                        termin.StartChar  = (int)reader["start_char"];
                        termin.EndLine    = (int)reader["end_line"];
                        termin.EndChar    = (int)reader["end_char"];
                    }
                }
                reader.Close();
                cmd.CommandText = "select ID, definition_content, start_line, start_char, end_line, end_char from definitions " +
                                  "where descriptor_id = @descriptor_id";
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Definition def = new Definition
                    {
                        ID        = (int)reader["id"],
                        Content   = reader["definition_content"].ToString().Trim(),
                        StartLine = (int)reader["start_line"],
                        StartChar = (int)reader["start_char"],
                        EndLine   = (int)reader["end_line"],
                        EndChar   = (int)reader["end_char"]
                    };
                    termin.Definitions.Add(def);
                }
                reader.Close();

                foreach (Definition def in termin.Definitions)
                {
                    def.Links = GetLinks(def.ID, sqlConnection);
                }

                cmd.CommandText = "select ascriptor_content from ascriptors " +
                                  "where descriptor_id = @descriptor_id";
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    termin.Ascriptors.Add(reader["ascriptor_content"].ToString());
                }
                reader.Close();

                cmd.CommandText = "select t.ID, type_name, Descriptor2_ID, Descriptor_content " +
                                  "from Relation_types t, Relations r, Descriptors d " +
                                  "where r.Relation_type_ID = t.ID and Descriptor1_ID = @descriptor_id " +
                                  "and d.id = Descriptor2_ID; ";
                reader = cmd.ExecuteReader();

                RelationsList rl = new RelationsList();
                while (reader.Read())
                {
                    Termin related = new Termin();
                    related.ID         = (int)reader["descriptor2_id"];
                    related.Descriptor = reader["descriptor_content"].ToString();
                    rl.AddRelation(new Relation((int)reader["ID"], reader["type_name"].ToString()), related);
                }
                termin.Relations = rl;
                reader.Close();



                sqlConnection.Close();
            }
            return(termin);
        }