Пример #1
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listBoxMedium.SelectedItem == null)
            {
                return;
            }

            ListBoxItem item = (ListBoxItem)listBoxMedium.SelectedItem;

            FormName formName = new FormName();

            formName.Text      = StringTable.EditMedium;
            formName.NameValue = item.Medium.Name;
            if (formName.ShowDialog(this) == DialogResult.OK)
            {
                MediumTableAdapter            mta = new MediumTableAdapter(dataBase);
                MediumDataSet.MediumDataTable mdt = mta.GetDataById(item.Medium.MediumID);
                mdt[0].Name = formName.NameValue;
                mta.Update(mdt);

                listBoxMedium.Items[listBoxMedium.SelectedIndex] = new ListBoxItem(mdt[0]);
            }

            UpdateWindowState();
        }
Пример #2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            FormName formName = new FormName();

            formName.Text          = StringTable.AddNewMedium;
            formName.NameValue     = "";
            formName.AllowEmpty    = false;
            formName.ValidateName += delegate(object sender1, ValidateNameEventArgs e1)
            {
                if (dataBase.AllMediums.Names.Contains(e1.Name) && e1.Name != e1.OriginalName)
                {
                    MessageBox.Show(string.Format(StringTable.MediumAlreadyExists, e1.Name), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    e1.Cancel = true;
                }
            };
            if (formName.ShowDialog(this) == DialogResult.OK)
            {
                MediumTableAdapter            cta = new MediumTableAdapter(dataBase);
                MediumDataSet.MediumDataTable cdt = cta.GetData();
                cdt.AddMediumRow(formName.NameValue, listBoxMedium.Items.Count + 1);
                cta.Update(cdt);

                FillList();
            }

            UpdateWindowState();
        }
Пример #3
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();
        }