void PopupForm_KeyUp(object sender, KeyEventArgs e)
        {
            bool gotMatch = false;
            PopupSearchLookUpEditForm popupForm = sender as PopupSearchLookUpEditForm;

            if (e.KeyData == Keys.Enter)
            {
                string searchText = popupForm.Properties.View.FindFilterText;
                if (!string.IsNullOrEmpty(searchText))
                {
                    GridView view = popupForm.OwnerEdit.Properties.View;
                    //If there is a match is on the ValueMember (Code) column, that should take precedence
                    //This needs to be case insensitive, but there is no case insensitive lookup, so we have to iterate the rows
                    //int row = view.LocateByValue(popupForm.OwnerEdit.Properties.ValueMember, searchText);
                    for (int row = 0; row < view.DataRowCount; row++)
                    {
                        CodeName codeName = (CodeName)view.GetRow(row);
                        if (codeName.Code.Equals(searchText.Trim('"'), StringComparison.OrdinalIgnoreCase))
                        {
                            view.FocusedRowHandle = row;
                            gotMatch = true;
                            break;
                        }
                    }
                    if (!gotMatch)
                    {
                        view.FocusedRowHandle = 0;
                    }
                    popupForm.OwnerEdit.ClosePopup();
                }
            }
        }
        void LoadLookups()
        {
            CodeName loadBlank = new CodeName(string.Empty);

            _productLookups = new Dictionary <String, List <CodeName> >();

            List <CodeName> lookup;

            //EF will try to execute the entire projection on the sql side, which knows nothing about string.format so it will
            //error. Putting AsEnumerable beforehand will tell EF to execute sql side up to there and return results, then the
            //rest will be EF client side

            lookup = new List <CodeName>();
            lookup.AddRange(_context.HOTEL
                            .OrderBy(t => t.CODE)
                            .Select(t => new CodeName()
            {
                Code = t.CODE, Name = t.NAME
            }));
            _productLookups.Add("HTL", lookup);

            lookup = new List <CodeName>();
            lookup.AddRange(_context.WAYPOINT
                            .OrderBy(t => t.CODE)
                            .Select(t => new CodeName()
            {
                Code = t.CODE, Name = t.DESC
            }));
            _productLookups.Add("WAY", lookup);

            lookup = new List <CodeName>();
            lookup.AddRange(_context.COMP
                            .OrderBy(t => t.CODE)
                            .Select(t => new CodeName()
            {
                Code = t.CODE, Name = t.NAME
            }));
            _productLookups.Add("OPT", lookup);

            lookup = new List <CodeName>();
            lookup.AddRange(_context.PACK
                            .OrderBy(t => t.CODE)
                            .Select(t => new CodeName()
            {
                Code = t.CODE, Name = t.NAME
            }));
            _productLookups.Add("PKG", lookup);

            //Set up a merged grouping for the master type and code and sort by position
            //Set up a merged grouping for the key fields and sort by day and line
            GridViewLookup.SortInfo.ClearAndAddRange(
                new[] { new GridMergedColumnSortInfo(new[] { colProduct_Type, colProduct_Code },
                                                     new[] { ColumnSortOrder.Ascending, ColumnSortOrder.Ascending }),
                        new GridColumnSortInfo(colPosition, ColumnSortOrder.Ascending) }, 1);

            BindingSource.DataSource = _context.RelatedProduct;
        }
Exemple #3
0
        private void LoadLookups()
        {
            CodeName loadBlank = new CodeName(string.Empty);

            _productLookups = new Dictionary <String, List <CodeName> >();

            List <CodeName> lookup;

            //EF will try to execute the entire projection on the sql side, which knows nothing about string.format so it will
            //error. Putting AsEnumerable beforehand will tell EF to execute sql side up to there and return results, then the
            //rest will be EF client side

            lookup = new List <CodeName>();
            lookup.AddRange(_context.HOTEL
                            .OrderBy(t => t.CODE)
                            .Select(t => new CodeName()
            {
                Code = t.CODE, Name = t.NAME
            }));
            _productLookups.Add("HTL", lookup);

            lookup = new List <CodeName>();
            lookup.AddRange(_context.COMP
                            .OrderBy(t => t.CODE)
                            .Select(t => new CodeName()
            {
                Code = t.CODE, Name = t.NAME
            }));
            _productLookups.Add("OPT", lookup);

            lookup = new List <CodeName>();
            lookup.AddRange(_context.PACK
                            .OrderBy(t => t.CODE)
                            .Select(t => new CodeName()
            {
                Code = t.CODE, Name = t.NAME
            }));
            _productLookups.Add("PKG", lookup);

            lookup = new List <CodeName>();
            lookup.AddRange(_context.AGY
                            .OrderBy(t => t.NO)
                            .Select(t => new CodeName()
            {
                Code = t.NO, Name = t.NAME
            }));
            SearchLookupEditAgency.Properties.DataSource = lookup;

            lookup = new List <CodeName>();
            lookup.AddRange(_context.ROOMCOD
                            .OrderBy(t => t.CODE)
                            .Select(t => new CodeName()
            {
                Code = t.CODE, Name = t.DESC
            }));
            SearchLookupEditCategory.Properties.DataSource = lookup;
        }