Ejemplo n.º 1
0
        public SearchString(string str)
        {
            str             = str ?? string.Empty;
            str             = str.Trim();
            _OriginalString = str.Trim();
            TextSearch      = _OriginalString;
            var splitted = str.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            Filters
                = splitted
                  .Select(t => t.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries))
                  .Where(kv => kv.Length == 2)
                  .Select(kv => new KeyValuePair <string, string>(kv[0].ToLowerInvariant(), kv[1]))
                  .ToDictionary(o => o.Key, o => o.Value);

            foreach (var filter in splitted)
            {
                if (filter.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Length == 2)
                {
                    TextSearch = TextSearch.Replace(filter, string.Empty);
                }
            }
            TextSearch = TextSearch.Trim();
        }
Ejemplo n.º 2
0
        void DataCommand(object parameter)
        {
            String que = "SELECT * FROM " + SelectedTableName.Name;


            if (SelectedAttribute.Name.Length > 0 && TextSearch.Length > 0)
            {
                que += " WHERE " + SelectedAttribute.Name + " LIKE \'%" + TextSearch.Replace(",", ".") + "%\' ";
            }

            DatabaseModel DataModel = new DatabaseModel();

            try
            {
                if (SelectedTableName.Name == "Bron")
                {
                    IEnumerable <Bron> Table      = DataModel.Query <Bron>(sql_query: que);
                    ShowData           DataWindow = new ShowData(Table, 1);
                    DataWindow.Show();
                }
                else if (SelectedTableName.Name == "Amunicja")
                {
                    IEnumerable <Amunicja> Table = DataModel.Query <Amunicja>(sql_query: que);
                    ShowData DataWindow          = new ShowData(Table, 2);
                    DataWindow.Show();
                }
                else if (SelectedTableName.Name == "Hurtowe")
                {
                    IEnumerable <Hurtowe> Table = DataModel.Query <Hurtowe>(sql_query: que);
                    ShowData DataWindow         = new ShowData(Table, 3);
                    DataWindow.Show();
                }
                else if (SelectedTableName.Name == "Detaliczne")
                {
                    IEnumerable <Detaliczne> Table = DataModel.Query <Detaliczne>(sql_query: que);
                    ShowData DataWindow            = new ShowData(Table, 4);
                    DataWindow.Show();
                }
                else if (SelectedTableName.Name == "Dostawa")
                {
                    IEnumerable <Dostawa> Table = DataModel.Query <Dostawa>(sql_query: que);
                    ShowData DataWindow         = new ShowData(Table, 5);
                    DataWindow.Show();
                }
                else if (SelectedTableName.Name == "Kategoria")
                {
                    IEnumerable <Kategoria> Table = DataModel.Query <Kategoria>(sql_query: que);
                    ShowData DataWindow           = new ShowData(Table, 6);
                    DataWindow.Show();
                }
                else if (SelectedTableName.Name == "Material")
                {
                    IEnumerable <Material> Table = DataModel.Query <Material>(sql_query: que);
                    ShowData DataWindow          = new ShowData(Table, 7);
                    DataWindow.Show();
                }
                else if (SelectedTableName.Name == "Pracownik")
                {
                    IEnumerable <Pracownik> Table = DataModel.Query <Pracownik>(sql_query: que);
                    ShowData DataWindow           = new ShowData(Table, 8);
                    DataWindow.Show();
                }
                else if (SelectedTableName.Name == "Produkcja")
                {
                    IEnumerable <Produkcja> Table = DataModel.Query <Produkcja>(sql_query: que);
                    ShowData DataWindow           = new ShowData(Table, 9);
                    DataWindow.Show();
                }
                else if (SelectedTableName.Name == "Zamowienie")
                {
                    IEnumerable <Zamowienie> Table = DataModel.Query <Zamowienie>(sql_query: que);
                    ShowData DataWindow            = new ShowData(Table, 10);
                    DataWindow.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }