Beispiel #1
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listBoxCategories.SelectedItem == null)
            {
                return;
            }

            ListBoxItem item = (ListBoxItem)listBoxCategories.SelectedItem;

            FormName formName = new FormName();

            formName.Text      = StringTable.EditCategory;
            formName.NameValue = item.Category.Name;
            if (formName.ShowDialog(this) == DialogResult.OK)
            {
                int oldId = dataBase.GetIdByCategory(item.Category.Name);

                CategoryTableAdapter cta = new CategoryTableAdapter(dataBase);
                CategoryDataSet.CategoryDataTable cdt = cta.GetDataById(item.Category.CategoryID);
                cdt[0].Name = formName.NameValue;
                cta.Update(cdt);

                listBoxCategories.Items[listBoxCategories.SelectedIndex] = new ListBoxItem(cdt[0]);

                UpdateSoundfiles(oldId, item.Category.Name, formName.NameValue, false);
            }

            UpdateWindowState();
        }
Beispiel #2
0
        /// <summary>
        /// Aktualisiert die Order aus der Liste in die Datenbank.
        /// </summary>
        private void SetOrderByList()
        {
            int index = 1;

            foreach (ListBoxItem item in listBoxCategories.Items)
            {
                CategoryTableAdapter cta             = new CategoryTableAdapter(dataBase);
                CategoryDataSet.CategoryDataTable dt = cta.GetDataById(item.Category.CategoryID);
                dt[0].Order = index;

                cta.Update(dt);

                index++;
            }
        }