Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
Bug Fixes, Improved Search Capabilities
Browse files Browse the repository at this point in the history
CHANGED - Updated Assembly version
ADDED - Ability to search in any field for record searches
CHANGED - Updated forms to correctly resize
CHANGED - Disabled maximize and minimize on Options form
  • Loading branch information
MarkoH17 committed Apr 7, 2020
1 parent 007d6ab commit 8e36661
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 59 deletions.
55 changes: 28 additions & 27 deletions DataWrangler/Forms/ManageRecordTypes.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 24 additions & 3 deletions DataWrangler/Forms/ManageRecords.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public partial class ManageRecords : MetroForm
private RecordType _recordTypeSel;
private IDataRetriever _retriever;
private int _rowIdxSel;
private bool _gridIsFiltered;

public ManageRecords(Dictionary<string, string> dbSettings, UserAccount user)
{
Expand Down Expand Up @@ -66,6 +67,12 @@ private void comboRecType_SelectedIndexChanged(object sender, EventArgs e)
comboField.Items.Add(comboBoxItem);
}

if(comboField.Items.Count > 0)
{
var comboBoxItem = new TextValueItem { Text = "(all fields)", Value = "*" };
comboField.Items.Add(comboBoxItem);
}

LoadRecordsByType(_recordTypeSel);
gridRecords.Enabled = true;
comboField.Enabled = true;
Expand Down Expand Up @@ -240,16 +247,30 @@ public void SwitchFormStyle()

private void txtFieldSearch_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Enter)
{
if (string.IsNullOrEmpty(comboField.SelectedItem.ToString()) ||
string.IsNullOrEmpty(txtFieldSearch.Text))
if (!_gridIsFiltered && comboField.SelectedItem != null && (string.IsNullOrEmpty(comboField.SelectedItem.ToString()) ||
string.IsNullOrEmpty(txtFieldSearch.Text)))
return;

if(_gridIsFiltered && string.IsNullOrEmpty(txtFieldSearch.Text))
{
comboField.SelectedIndex = -1;
txtFieldSearch.Text = "";
txtFieldSearch.Enabled = false;
LoadRecordsByType(_recordTypeSel);
_gridIsFiltered = false;
return;
}

var searchField = ((TextValueItem) comboField.SelectedItem).Value.ToString();
var searchValue = txtFieldSearch.Text;
var searchValueLen = txtFieldSearch.Text.Replace(" ", "").Length;

if (searchValueLen < 1) return;

LoadRecordsByType(_recordTypeSel, searchField, searchValue);
_gridIsFiltered = true;
}
}
}
Expand Down
Loading

0 comments on commit 8e36661

Please sign in to comment.