Ejemplo n.º 1
0
        private void TSB_AddTag_Click(object sender, EventArgs e)
        {
            AddTag addTag = new AddTag();

            addTag.settings = Settings;
            if (addTag.ShowDialog() == DialogResult.OK)
            {
                LoadPictureTags();
                PictureTags buf;
                if (G_I_listView.SelectedItems.Count > 0)
                {
                    buf = new PictureTags {
                        IdTags = addTag.S_Tags, URL = G_I_listView.SelectedItems[0].Text
                    };
                }
                else
                {
                    buf = new PictureTags {
                        IdTags = addTag.S_Tags, URL = G_I_TreeView.SelectedNode.FullPath
                    };
                }
                PictureTags.Add(buf);
                string query = "insert into PictureTags (URL,IdTag) values(@URL,@IdTag)";
                connection.Open();
                SqlCommand cmd = new SqlCommand(query, connection);
                cmd.Parameters.Add("@URL", SqlDbType.NVarChar, 50).Value   = buf.URL;;
                cmd.Parameters.Add("@IdTag", SqlDbType.NVarChar, 50).Value = buf.IdTags;
                cmd.ExecuteNonQuery();
                MessageBox.Show("Тег успешно добавлен");
                connection.Close();
            }
        }
Ejemplo n.º 2
0
        private void LoadPictureTags()
        {
            LoadTags();
            string query = "select * from PictureTags";

            connection.Open();
            SqlCommand    cmd    = new SqlCommand(query, connection);
            SqlDataReader reader = cmd.ExecuteReader();

            PictureTags.Clear();
            while (reader.Read())
            {
                PictureTags c = new PictureTags()
                {
                    Id     = (int)reader["Id"],
                    IdTags = (int)reader["IdTag"],
                    URL    = (string)reader["URL"]
                };
                PictureTags.Add(c);
            }
            connection.Close();
        }