public override void EditObject() { DataGridViewRow dgvRow = base.getSelectedDataRow(); if (dgvRow != null) { int editId = (int)dgvRow.Cells["Id"].Value; NoteTemplate note = new NoteTemplate(editId); NoteTemplateForm frm = new NoteTemplateForm(note); DialogResult result = frm.ShowDialog(); AppFuncs.dialogCloseResult(frm.GetType().Name, result); if (result == DialogResult.OK) { bool dbResult = DBContext.UpdateEntity(note); if (dbResult) { this.LoadDataToGrid(); base.selectGridRowById(editId); MessageBox.Show("Шаблон службової оновлен", "Оновлення шаблону службової", MessageBoxButtons.OK, MessageBoxIcon.Information); } AppFuncs.saveToDBResult(dbResult); } base.EditObject(); } }
public override void CreateNewObject() { NoteTemplateForm frm = new NoteTemplateForm(null); DialogResult result = frm.ShowDialog(); AppFuncs.dialogCloseResult(frm.GetType().Name, result); if ((result == DialogResult.OK) && (frm.NoteTemplate != null)) { bool dbResult = DBContext.InsertEntity(frm.NoteTemplate); if (dbResult) { this.LoadDataToGrid(); base.selectGridRowById(frm.NoteTemplate.Id); MessageBox.Show("Створена нова службова за № " + frm.NoteTemplate.Id.ToString(), "Строверення службової", MessageBoxButtons.OK, MessageBoxIcon.Information); } AppFuncs.saveToDBResult(dbResult); } frm.Dispose(); base.CreateNewObject(); }