Esempio n. 1
0
        private void MnuRenameField_Click(object sender, EventArgs e)
        {
            try
            {
                NodeInfo nodeInfo  = _rClickNode.Tag as NodeInfo;
                string   fieldName = nodeInfo.Tag as string;

                NodeInfo parentNodeInfo = _rClickNode.Parent.Tag as NodeInfo;
                var      fileDb         = parentNodeInfo.Tag as FileDb;

                Utils.InputDlg dlg = new Utils.InputDlg("Rename Field", "Enter the new Field name", true, fieldName);

                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    this.Cursor = Cursors.WaitCursor;
                    this.Update();
                    fileDb.RenameField(fieldName, dlg.Value);
                    var    vs   = _rClickNode.Text.Split('[');
                    string text = string.Format("{0} [{1}", dlg.Value, vs[1]);
                    _rClickNode.Text = text;
                    this.Cursor      = Cursors.Default;
                }

                _rClickNode = null;
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        private void MnuSetEncryptionKey_Click(object sender, EventArgs e)
        {
            InputDlg dlg = new Utils.InputDlg("Enter Encryption Key", "Enter the Encryption Key for this database file", true);

            try
            {
                if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    if (_rClickNode != null)
                    {
                        NodeInfo nodeInfo = _rClickNode.Tag as NodeInfo;
                        _rClickNode = null;
                        var    fileDb = nodeInfo.Tag as FileDb;
                        string key    = dlg.TxtInput.Text.Trim();
                        if (string.IsNullOrEmpty(key))
                        {
                            throw new Exception("The encryption key cannot be empty");
                        }
                        fileDb.SetEncryptionKey(key);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }