コード例 #1
0
ファイル: AppNotes.cs プロジェクト: dmitriyChernov89/FlyDoc
        public override void CreateNewObject()
        {
            if (base.AllowEdit == false)
            {
                base.notAllowEditAction(); return;
            }

            NewNote      frm    = new NewNote(null);
            DialogResult result = frm.ShowDialog();

            AppFuncs.dialogCloseResult(frm.GetType().Name, result);
            if ((result == DialogResult.OK) && (frm.Note != null))
            {
                bool dbResult = DBContext.InsertNotes(frm.Note);
                if (dbResult)
                {
                    this.LoadDataToGrid();
                    base.selectGridRowById(frm.Note.Id);
                    MessageBox.Show("Створена нова службова за № " + frm.Note.Id.ToString(), "Строверення службової", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                AppFuncs.saveToDBResult(dbResult);
            }
            frm.Dispose();

            base.CreateNewObject();
        }
コード例 #2
0
ファイル: AppNotes.cs プロジェクト: dmitriyChernov89/FlyDoc
        public override void EditObject()
        {
            if (base.AllowEdit == false)
            {
                base.notAllowEditAction();
                return;
            }

            DataGridViewRow dgvRow = base.getSelectedDataRow();

            if (dgvRow != null)
            {
                int  editId = (int)dgvRow.Cells["Id"].Value;
                Note note   = new Note(editId);

                NewNote      frm    = new NewNote(note);
                DialogResult result = frm.ShowDialog();
                AppFuncs.dialogCloseResult(frm.GetType().Name, result);
                if (result == DialogResult.OK)
                {
                    bool dbResult = DBContext.UpdateNotes(note);
                    if (dbResult)
                    {
                        this.LoadDataToGrid();
                        base.selectGridRowById(editId);
                        MessageBox.Show("Службова оновлена", "Оновлення службової", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    AppFuncs.saveToDBResult(dbResult);
                }
                base.EditObject();
            }
        }