コード例 #1
0
        private void BtnUpdate_Click(object sender, EventArgs e)
        {
            if (this.dgvContent.SelectedRows.Count == 0)
            {
                return;
            }
            var id = int.Parse(this.dgvContent.CurrentRow.Cells["clID"].Value.ToString());

            using (var context = new MyBookDB())
            {
                var currentcontent = context.DiaryContent.FirstOrDefault(t => t.ID == id);
                if (currentcontent == null)
                {
                    UI_DiaryContent ui = new UI_DiaryContent();
                    ui.user  = user;
                    ui.IsNew = true;
                    ui.ShowDialog();
                    ui.Dispose();
                }
                else
                {
                    UI_DiaryContent ui = new UI_DiaryContent();
                    ui.user         = user;
                    ui.IsNew        = false;
                    ui.DiaryContent = currentcontent;
                    ui.ShowDialog();
                    ui.Dispose();
                }
            }
            Search();
        }
コード例 #2
0
        private void BtnNew_Click(object sender, EventArgs e)
        {
            UI_DiaryContent ui = new UI_DiaryContent();

            ui.user  = user;
            ui.IsNew = true;
            ui.ShowDialog();
            ui.Dispose();
            Search();
        }