private void BtnNext_Click(object sender, EventArgs e) { if (this.currentStep == 0) { if (this.ListGridColumns.SelectedIndex < 0) { MessageBox.Show("Please select a column from the list on which the search query will run", Constants.msgAttention, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } int k = ComboDataType.FindStringExact(dgvToBeSearchedMeta.GetColumnValueTypeAt(this.ListGridColumns.SelectedIndex)); if (k != ComboDataType.SelectedIndex) { ComboDataType.SelectedIndex = k; ComboSearchCondition.Items.Clear(); StaticFunctions.PopulateOperatorComboBox(ComboSearchCondition, ComboDataType.Text); } ActivePanel(1); } else if (this.currentStep == 1) { if (this.ComboDataType.Text == "") { MessageBox.Show("Please choose the data type of the column", Constants.msgAttention, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (this.ComboSearchCondition.Text == "") { MessageBox.Show("Please choose the search column condition", Constants.msgAttention, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } ActivePanel(2); } else if (this.currentStep == 2) { ActivePanel(0); // this is the last step, move the collected results to searchgrid string conj = this.radioBtnAnd.Text; if (this.radioBtnNot.Checked == true) { conj = radioBtnNot.Text; } else if (this.radioBtnOr.Checked == true) { conj = radioBtnOr.Text; } this.searchForm.BuildandAddSearchRow(conj, this.ListGridColumns.SelectedItem.ToString(), ListGridColumns.SelectedIndex, ComboDataType.Text, ComboSearchCondition.Text, TxtSearchVal1.Text, TxtSearchVal2.Text, this.ComboDataType.Text == Constants.ValueType_Bool ? 1 : 0); this.searchForm.UpdateQueryText(); // update the query text of the searchForm this.queryMeta.ResetValues(); if (ListGridColumns.SelectedIndex > -1) { queryMeta.colName = ListGridColumns.SelectedItem.ToString(); } this.TxtSearchQuery.Text = queryMeta.ToQueryText(); } this.currentStep++; if (this.currentStep == 3) { this.currentStep = 0; BtnBack.Enabled = false; } else { BtnBack.Enabled = true; } }
private void ReadGridColumns() { // reads the column names of the datagridview this.CleanColumnInfo(); if (this.dgv == null || dgv.ColumnCount == 0) { return; } string s = ""; int u = 0; // will count only visible columns for (int k = 0; k < this.dgv.ColumnCount; k++) { if (this.dgv.Columns[k].Visible) { u++; if (this.FirstVisibleColumnIndex == -1) { this.FirstVisibleColumnIndex = k; } Array.Resize(ref col_indices, u); col_indices[u - 1] = k; Array.Resize(ref col_names, u); col_names[u - 1] = this.dgv.Columns[k].Name; Array.Resize(ref col_headerTexts, u); col_headerTexts[u - 1] = (this.dgv.Columns[k].HeaderText == "") ? this.dgv.Columns[k].Name : this.dgv.Columns[k].HeaderText; Array.Resize(ref col_valueTypes, u); s = this.dgv.Columns[k].ValueType.Name.ToLower(); if (StaticFunctions.IsSubstring(s, Constants.types_Bool)) { col_valueTypes[u - 1] = Constants.ValueType_Bool; } else if (StaticFunctions.IsSubstring(s, Constants.types_DateTime)) { col_valueTypes[u - 1] = Constants.ValueType_Date; } else if (StaticFunctions.IsSubstring(s, Constants.types_Numeric)) { col_valueTypes[u - 1] = Constants.ValueType_Numeric; } else { col_valueTypes[u - 1] = Constants.ValueType_String; } } } // setting the property values ColumnValueTypeLength = this.col_valueTypes.Length; ColumnHeaderTextLength = this.col_headerTexts.Length; ColumnNameLength = this.col_names.Length; ColumnIndexLength = this.col_indices.Length; }