Ejemplo n.º 1
0
 private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
 {
     GridViewSpecVal.ClearColumnsFilter();
     if (SpecialValueBindingSource.Current == null)
     {
         //fake query in order to create a link between the database table and the binding source
         SpecialValueBindingSource.DataSource = from opt in context.SpecialValue where opt.Code == "KJM9" select opt;
         SpecialValueBindingSource.AddNew();
         if (GridViewSpecVal.FocusedRowHandle == GridControl.AutoFilterRowHandle)
         {
             GridViewSpecVal.FocusedRowHandle = GridViewSpecVal.RowCount - 1;
         }
         ComboBoxEditType.Focus();
         setReadOnly(false);
         newRec = true;
         return;
     }
     ComboBoxEditType.Focus();
     //bindingNavigatorPositionItem.Focus();  //trigger field leave event
     GridViewSpecVal.CloseEditor();
     temp = newRec;
     if (checkForms())
     {
         if (!temp)
         {
             context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, (SpecialValue)SpecialValueBindingSource.Current);
         }
         SpecialValueBindingSource.AddNew();
         if (GridViewSpecVal.FocusedRowHandle == GridControl.AutoFilterRowHandle)
         {
             GridViewSpecVal.FocusedRowHandle = GridViewSpecVal.RowCount - 1;
         }
         ComboBoxEditType.Focus();
         setReadOnly(false);
         newRec = true;
     }
 }
Ejemplo n.º 2
0
        private void executeQuery()
        {
            this.Cursor = Cursors.WaitCursor;
            string colName = GridViewSpecVal.FocusedColumn.FieldName;
            string value   = String.Empty;

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


                if (!string.IsNullOrWhiteSpace(GridViewSpecVal.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "Name")))
                {
                    query   = String.Format("it.{0} like '{1}%'", "Name", GridViewSpecVal.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "Name"));
                    special = special.Where(query);
                }
                int count = special.Count();
                if (count > 0)
                {
                    SpecialValueBindingSource.DataSource = special;
                    GridViewSpecVal.SetRowCellValue(GridControl.AutoFilterRowHandle, colName, value);
                    GridViewSpecVal.FocusedRowHandle        = 0;
                    GridViewSpecVal.FocusedColumn.FieldName = colName;
                }
                else
                {
                    MessageBox.Show("No records in database.");
                    GridViewSpecVal.ClearColumnsFilter();
                }
            }
            this.Cursor = Cursors.Default;
        }