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