private void btnAddNewField_Click(object sender, EventArgs e)
        {
            //if (ID < 1) {
            //    if (DialogResult.Yes == MessageBox.Show(this, "You must save the permission before adding restrictions to it.\nDo you want to save it now?", "Save Permission?", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) {
            //        save(false);
            //    } else {
            //        return;
            //    }
            //}

            var f = new frmSearchEngineIndexField();

            f.IndexName = IndexName;
            f.FieldName = null;
            f.DataTable = _dsIndex.Tables["index_field"];

            MainFormPopupNewItemForm(f);
        }
        private void showFieldProperties()
        {
            if (lvFields.SelectedItems.Count == 1)
            {
                var f = new frmSearchEngineIndexField();
                f.IndexName = this.IndexName;
                f.FieldName = ("" + lvFields.SelectedItems[0].Tag);
                f.DataTable = _dsIndex.Tables["index_field"];
                if (DialogResult.OK == MainFormPopupForm(f, this, false))
                {
                    // copy to view and behind-the-scenes datatable here!

                    var offset       = lvFields.SelectedIndices[0];
                    var dtIndexField = stripNotInIndex(_dsIndex.Tables["index_field"], IndexName);
                    var drField      = dtIndexField.Rows[offset];
                    var lvi          = lvFields.Items[offset];

                    drField["field_name"]        = lvi.SubItems[0].Text = f.txtName.Text;
                    drField["foreign_key_table"] = f.txtForeignKeyTable.Text;
                    drField["foreign_key_field"] = f.txtForeignKeyField.Text;
                    drField["format"]            = f.txtFormat.Text;      // 4
                    drField["calculation"]       = f.txtCalculation.Text; // 3
                    drField["true_value"]        = f.txtTrueValue.Text;   //6

                    // primary key flag
                    if (f.chkPrimaryKey.Checked)
                    {
                        drField["is_primary_key"] = "TRUE";
                    }
                    else
                    {
                        drField["is_primary_key"] = "FALSE";
                    }

                    // stored in index flag
                    if (f.chkStoredInIndex.Checked)
                    {
                        drField["is_stored_in_index"] = "TRUE";
                        lvi.SubItems[1].Text          = "Y";
                    }
                    else
                    {
                        drField["is_stored_in_index"] = "FALSE";
                        lvi.SubItems[1].Text          = "N";
                    }

                    // searchable flag
                    if (f.chkSearchable.Checked)
                    {
                        drField["is_searchable"] = "TRUE";
                        lvi.SubItems[2].Text     = "Y";
                    }
                    else
                    {
                        drField["is_searchable"] = "FALSE";
                        lvi.SubItems[2].Text     = "N";
                    }

                    // boolean flag
                    if (f.chkIsBoolean.Checked)
                    {
                        drField["is_boolean"] = "TRUE";
                        lvi.SubItems[5].Text  = "Y";
                    }
                    else
                    {
                        drField["is_boolean"] = "FALSE";
                        lvi.SubItems[5].Text  = "N";
                    }
                    MarkDirty();
                    syncGUI();
                }
            }
        }