Ejemplo n.º 1
0
        private void titleLabel_LinkClick(object sender, EventArgs e)
        {
            using (var db = new SetTitleDbContext())
            {
                Console.WriteLine("Clicked titleLabel");
                LinkLabel linkLabel  = sender as LinkLabel;
                int       setTitleId = (int)linkLabel.Tag;
                Console.WriteLine($"setTitleId = {setTitleId}");

                var setTitle_data = from setTitle in db.SetTitles
                                    where setTitle.SetTitleId == setTitleId
                                    orderby setTitle.SetTitleId
                                    select setTitle;
                var startupProg_data = from startupProg in db.StartupProgs
                                       where startupProg.SetTitleId == setTitleId
                                       orderby startupProg.StartupProgId
                                       select startupProg;
                addEditForm  addEditForm  = new addEditForm(setTitle_data, startupProg_data);
                DialogResult dialogResult = addEditForm.ShowDialog();
                if (dialogResult == DialogResult.OK)
                {
                    FormReload();
                }
            }
        }
Ejemplo n.º 2
0
        //メニューバーの項目がクリックされた場合
        private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            const string ADD        = "add";
            const string BULKDELETE = "bulkdelete";

            var item = e.ClickedItem as ToolStripButton;

            switch (item.Tag)
            {
            //追加ボタン
            case ADD:
                Console.WriteLine("Clicked addButton in InitForm.");
                addEditForm addeditform = new addEditForm();
                if (addeditform.ShowDialog() == DialogResult.OK)
                {
                    FormReload();
                }
                break;

            //一括削除ボタン
            case BULKDELETE:
                DialogResult result = MessageBox.Show("すべて削除しますか?", "一括削除", MessageBoxButtons.YesNo);
                if (result != DialogResult.Yes)
                {
                    break;
                }
                using (var db = new SetTitleDbContext())
                {
                    Console.WriteLine("all delete");
                    var datas = from setTitle in db.SetTitles
                                select setTitle;
                    foreach (var data in datas)
                    {
                        db.Remove(data);
                    }
                    db.SaveChanges();
                }
                FormReload();
                break;
            }
        }