Пример #1
0
        private void executeQuery()
        {
            this.Cursor = Cursors.WaitCursor;
            string colName = GridViewUsers.FocusedColumn.FieldName;
            string value   = String.Empty;

            //if (!string.IsNullOrWhiteSpace(GridViewUsers.GetFocusedDisplayText()))
            value = GridViewUsers.GetFocusedDisplayText();
            //if (!string.IsNullOrWhiteSpace(value))
            //{
            string query   = String.Format("it.UserID like '{0}%'", GridViewUsers.GetRowCellDisplayText(GridControl.AutoFilterRowHandle, "UserID"));
            var    results = context.ExtranetUser.Where(query);

            int count = results.Count();

            if (count > 0)
            {
                UsersBindingSource.DataSource = results;
                GridViewUsers.SetRowCellValue(GridControl.AutoFilterRowHandle, colName, value);
                GridViewUsers.FocusedRowHandle        = 0;
                GridViewUsers.FocusedColumn.FieldName = colName;
            }
            else
            {
                XtraMessageBox.Show("No records in database.");
                GridViewUsers.ClearColumnsFilter();
            }
            //}
            this.Cursor = Cursors.Default;
        }
Пример #2
0
        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
            if (modified || newRec)
            {
                DialogResult select = DevExpress.XtraEditors.XtraMessageBox.Show("Do you want to confirm these changes?", Text, MessageBoxButtons.YesNoCancel);
                if (select == DialogResult.Cancel)
                {
                    return;
                }
                if (select == DialogResult.Yes)
                {
                    if (!SaveRecord())
                    {
                        return;
                    }
                }
                if (select == DialogResult.No)
                {
                    if (newRec)
                    {
                        RemoveRecord();
                    }
                    else
                    {
                        RefreshRecord();
                    }
                }
            }

            GridViewUsers.ClearColumnsFilter();
            if (UsersBindingSource.Current == null)
            {
                //fake query in order to create a link between the database table and the binding source
                UsersBindingSource.DataSource = from opt in context.ExtranetUser where opt.UserID == "KJM9" select opt;
            }
            CheckEditAgent.Focus();
            GridViewUsers.CloseEditor();
            newRec         = true;
            ignoreLeaveRow = true;       //so that when the grid row changes it doesn't try to save again
            UsersBindingSource.AddNew();
            if (GridViewUsers.FocusedRowHandle == GridControl.AutoFilterRowHandle)
            {
                GridViewUsers.FocusedRowHandle = GridViewUsers.RowCount - 1;
            }
            CheckEditAgent.Focus();
            setReadOnly(false);
            ignoreLeaveRow = false;
        }