コード例 #1
0
        private void AccountTable_KeyDown(object sender, KeyEventArgs e)
        {
            //delete account
            if (e.KeyCode == Keys.Delete && this.AccountTable.CurrentRow != null)
            {
                //delete selected account
                this.DeleteAccountToolStripMenuItem.PerformClick();
                ////get id from selected cell or row in datagridview row
                //int id = (int)this.AccountTable.CurrentRow.Cells[0].Value.ToString().ToInteger();
                //this._Database.DeleteAccount(id);
                //this.AccountTable.Rows.Remove(this.AccountTable.CurrentRow);
            }

            //edit account
            if (e.KeyCode == Keys.Enter && this.AccountTable.CurrentRow != null)
            {
                if (this.AccountTable.CurrentRow != null)
                {
                    //get id from selected cell or row in datagridview row
                    int id = (int)this.AccountTable.CurrentRow.Cells[0].Value.ToString().ToInteger();
                    using (Form form = new AccountForm(id, this._Database, this._MasterPassword))
                    {
                        form.ShowDialog(this);
                        this._Database.LoadAccount(ref this.AccountTable);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// add new account into database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddAccountToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this._Database == null)
            {
                return;
            }

            //add new account
            using (Form form = new AccountForm(this._Database, this._MasterPassword))
            {
                form.ShowDialog(this);
                this._Database.LoadAccount(ref this.AccountTable);
            }
        }
コード例 #3
0
        private void EditToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.AccountTable.CurrentRow == null)
            {
                return;
            }

            int id = (int)this.AccountTable.CurrentRow.Cells[0].Value.ToString().ToInteger();

            using (Form form = new AccountForm(id, this._Database, this._MasterPassword))
            {
                form.ShowDialog(this);
                this._Database.LoadAccount(ref this.AccountTable);
            }
        }
コード例 #4
0
        private void AccountTable_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex < 0)
            {
                return;
            }

            int id = int.Parse(this.AccountTable.Rows[e.RowIndex].Cells[0].Value.ToString());

            using (Form form = new AccountForm(id, this._Database, this._MasterPassword))
            {
                form.ShowDialog(this);
                this._Database.LoadAccount(ref this.AccountTable);
            }
        }