private Records.GridRecord GetRecordFromGrid(DataGridViewCellCollection cells) { var newRecord = new Records.GridRecord(); newRecord.category = cells[0].Value.ToString(); newRecord.leftHandHold = cells[1].Value.ToString(); newRecord.rightHandHold = cells[2].Value.ToString(); newRecord.name = cells[3].Value.ToString(); newRecord.record = cells[4].Value.ToString(); newRecord.units = cells[5].Value.ToString(); newRecord.description = cells[6].Value != null ? cells[6].Value.ToString() : ""; return(newRecord); }
private void addBtn_Click(object sender, EventArgs e) { cancelBtn.Enabled = true; addingRow = true; ClearRecordsTable(); SetGridEditMode(true); var newRecord = new Records.GridRecord(); newRecord.leftHandHold = leftHand_Combo.SelectedItem.ToString(); newRecord.rightHandHold = rightHand_Combo.SelectedItem.ToString(); AddToRecordsTable(newRecord); }
private void AddToRecordsTable(Records.GridRecord record) { recordsGrid.Rows.Add(); var cells = recordsGrid.Rows[recordsGrid.Rows.Count - 1].Cells; cells[0].Value = record.category; cells[1].Value = record.leftHandHold; cells[2].Value = record.rightHandHold; cells[3].Value = record.name; cells[4].Value = record.record; cells[5].Value = record.units; cells[6].Value = record.description; recordsGrid.ClearSelection(); }
private bool RecordContains(Records.GridRecord record, string search) { search = search.ToLower(); if (record.ToString().ToLower().Contains(search)) { return(true); } // Add specific searching var columns = record.GetAllColumns(); var searchTerms = search.Split(','); var valid = false; foreach (var x in searchTerms) { var split = x.Split('='); if (split.Length != 2) { continue; } var index = Array.IndexOf(columns.Select((y) => { return(y.ToLower()); }).ToArray(), ClimbingRecords.Records.RemoveWhitespace(split[0])); if (index != -1) { valid = record.GetColumnValueByIndex(index).ToLower().Contains(split[1].Trim()); if (!valid) { return(false); } } } return(valid); }