Esempio n. 1
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();
        }
Esempio n. 2
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = StringTable.FilterHitbase;
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                DataBase dbImport = new DataBase();
                dbImport.Open(openFileDialog.FileName);

                MediumTableAdapter            cta = new MediumTableAdapter(dataBase);
                MediumDataSet.MediumDataTable cdt = cta.GetData();

                int count = listBoxMedium.Items.Count + 1;
                foreach (Medium Medium in dbImport.AllMediums)
                {
                    if (dataBase.GetIdByMedium(Medium.Name) < 0)
                    {
                        cdt.AddMediumRow(Medium.Name, count++);
                    }
                }

                cta.Update(cdt);

                dbImport.Close();

                FillList();
                UpdateWindowState();
            }
        }
Esempio n. 3
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();
        }
Esempio n. 4
0
        public void AddNew(string medium)
        {
            // Nicht vorhanden, also neues Medium anlegen
            MediumTableAdapter mta = new MediumTableAdapter(dataBase);

            MediumDataSet.MediumDataTable mdt = mta.GetData();
            mdt.AddMediumRow(medium, GetNextOrder());
            mta.Update(mdt);

            dataBase.UpdateMediums();
        }
Esempio n. 5
0
        /// <summary>
        /// Aktualisiert die Order aus der Liste in die Datenbank.
        /// </summary>
        private void SetOrderByList()
        {
            int index = 1;

            foreach (ListBoxItem item in listBoxMedium.Items)
            {
                MediumTableAdapter            mta = new MediumTableAdapter(dataBase);
                MediumDataSet.MediumDataTable dt  = mta.GetDataByName(item.Medium.Name);
                dt[0].Order = index;

                mta.Update(dt);

                index++;
            }
        }
Esempio n. 6
0
        private void FillList()
        {
            listBoxMedium.Items.Clear();

            MediumTableAdapter mta = new MediumTableAdapter(dataBase);

            MediumDataSet.MediumDataTable mdt = mta.GetData();
            if (Settings.Current.AutoSortMediums)
            {
                foreach (MediumDataSet.MediumRow medium in mdt.OrderBy(x => x.Name))
                {
                    listBoxMedium.Items.Add(new ListBoxItem(medium));
                }
            }
            else
            {
                foreach (MediumDataSet.MediumRow medium in mdt.OrderBy(x => x.Order))
                {
                    listBoxMedium.Items.Add(new ListBoxItem(medium));
                }
            }
        }