Exemple #1
0
        private void executeQuery()
        {
            this.Cursor = Cursors.WaitCursor;
            string colName = GridViewCarOff.FocusedColumn.FieldName;
            string value   = String.Empty;

            if (!string.IsNullOrWhiteSpace(GridViewCarOff.GetFocusedDisplayText()))
            {
                value = GridViewCarOff.GetFocusedDisplayText();
            }
            if (!string.IsNullOrWhiteSpace(value))
            {
                string query   = String.Format("it.NAME like '{0}%'", GridViewCarOff.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "NAME"));
                var    special = context.CAROFF.Where(query);

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