Example #1
0
        private void Save(DlgSave dlg)
        {
            Mitglied mitglied;

            if (!dlg.TryGetData(out mitglied))
            {
                return;
            }

            dlg.Close();

            int id;

            try
            {
                Queries.Save(mitglied, out id);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            Read(id);
        }
Example #2
0
        private void CreateMenu()
        {
            MenuStrip strip = new MenuStrip();

            strip.Font = new Font("Microsoft Sans Serif", 9.75F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));

            ToolStripMenuItem itemSelect = new ToolStripMenuItem("&Neu Abfragen");
            ToolStripMenuItem itemInsert = new ToolStripMenuItem("&Anlegen");
            ToolStripMenuItem itemUpdate = new ToolStripMenuItem("&Bearbeiten");
            ToolStripMenuItem itemDelete = new ToolStripMenuItem("&Löschen");
            ToolStripMenuItem itemClose  = new ToolStripMenuItem("&Schliessen");

            itemClose.Alignment = ToolStripItemAlignment.Right;

            strip.Items.Add(new ToolStripSeparator());
            strip.Items.Add(itemSelect);
            strip.Items.Add(new ToolStripSeparator());
            strip.Items.Add(itemInsert);
            strip.Items.Add(itemUpdate);
            strip.Items.Add(itemDelete);
            strip.Items.Add(new ToolStripSeparator());

            ToolStripSeparator sep1 = new ToolStripSeparator();

            sep1.Alignment = ToolStripItemAlignment.Right;
            strip.Items.Add(sep1);

            strip.Items.Add(itemClose);

            ToolStripSeparator sep2 = new ToolStripSeparator();

            sep2.Alignment = ToolStripItemAlignment.Right;
            strip.Items.Add(sep2);

            itemSelect.Click += (s, e) =>
            {
                if (mAsyncTask.IsBusy)
                {
                    return;
                }

                Mitglied mg = mBindingSource.Current as Mitglied;
                int      id = mg == null ? 0 : mg.Id;
                Read(id);
            };

            itemInsert.Click += (s, e) =>
            {
                if (mAsyncTask.IsBusy)
                {
                    return;
                }

                DlgSave dlg = new DlgSave();
                dlg.SetHeaderText("M i t g l i e d  A n l e g e n");
                dlg.SetData(null);
                dlg.Save = Save;
                dlg.ShowDialog();
            };

            itemUpdate.Click += (s, e) =>
            {
                if (mAsyncTask.IsBusy)
                {
                    return;
                }

                Mitglied mitglied = mBindingSource.Current as Mitglied;

                if (mitglied == null)
                {
                    string msg = "Es wurde kein Mitglied ausgewählt";
                    MessageBox.Show(msg, "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                DlgSave dlg = new DlgSave();
                dlg.SetHeaderText("M i t g l i e d  B e a r b e i t e n");
                dlg.SetData(mitglied);
                dlg.Save = Save;
                dlg.ShowDialog();
            };

            itemDelete.Click += (s, e) =>
            {
                if (mAsyncTask.IsBusy)
                {
                    return;
                }

                Mitglied mitglied = mBindingSource.Current as Mitglied;

                if (mitglied == null)
                {
                    string msg = "Es wurde kein Mitglied ausgewählt";
                    MessageBox.Show(msg, "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                Delete(mitglied);
            };

            itemClose.Click += (s, e) =>
            {
                Close();
            };

            this.Controls.Add(strip);
        }