private void executeQuery() { this.Cursor = Cursors.WaitCursor; string colName = GridViewCruIt.FocusedColumn.FieldName; string value = String.Empty; if (!string.IsNullOrWhiteSpace(GridViewCruIt.GetFocusedDisplayText())) { value = GridViewCruIt.GetFocusedDisplayText(); } if (!string.IsNullOrWhiteSpace(value)) { string query = String.Format("it.NAME like '{0}%'", GridViewCruIt.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "NAME")); var special = context.CRUIT.Where(query); if (!string.IsNullOrWhiteSpace(GridViewCruIt.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "CODE"))) { query = String.Format("it.{0} like '{1}%'", "CODE", GridViewCruIt.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "CODE")); special = special.Where(query); } int count = special.Count(); if (count > 0) { CruItBindingSource.DataSource = special; GridViewCruIt.ClearColumnsFilter(); } else { MessageBox.Show("No records in database."); GridViewCruIt.ClearColumnsFilter(); } } this.Cursor = Cursors.Default; }
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e) { GridViewCruIt.ClearColumnsFilter(); if (CruItBindingSource.Current == null) { //fake query in order to create a link between the database table and the binding source CruItBindingSource.DataSource = from opt in context.CRUIT where opt.CODE == "KJM9" select opt; CruItBindingSource.AddNew(); if (GridViewCruIt.FocusedRowHandle == GridControl.AutoFilterRowHandle) { GridViewCruIt.FocusedRowHandle = GridViewCruIt.RowCount - 1; } setValues(); //codeSearch.Focus(); setReadOnly(false); newRec = true; return; } ImageComboBoxEditCode.Focus(); //bindingNavigatorPositionItem.Focus(); //trigger field leave event GridViewCruIt.CloseEditor(); temp = newRec; if (checkForms()) { if (!temp) { context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, (CRUIT)CruItBindingSource.Current); } CruItBindingSource.AddNew(); if (GridViewCruIt.FocusedRowHandle == GridControl.AutoFilterRowHandle) { GridViewCruIt.FocusedRowHandle = GridViewCruIt.RowCount - 1; } setValues(); //codeSearch.Focus(); setReadOnly(false); newRec = true; } }