Exemplo n.º 1
0
        public void CreatePage()
        {
            if (Request.Cookies["pagesize"] != null)
            {
                PageSize = int.Parse(Request.Cookies["pagesize"]);
            }

            IQueryable <Data.Tables.Technical> query;

            if (!ShowDeleted)
            {
                query = _db.Technical.AsNoTracking().AsQueryable();
            }
            else
            {
                query = _db.Technical.AsNoTracking().IgnoreQueryFilters().AsQueryable();
            }

            char separator = ',';

            string[] filterOptions =
            {
                "Prawda",
                "Fałsz",
            };
            kanbanFilter = new SelectList(filterOptions);

            if (Filter_Rodzina != null)
            {
                var options = Filter_Rodzina.Split(separator).Select(c => c.Trim());
                foreach (var option in options)
                {
                    query = query.Where(c => c.Rodzina.Contains(option));
                }
            }
            if (Filter_Wiazka != null)
            {
                var options = Filter_Wiazka.Split(separator).Select(c => c.Trim());
                foreach (var option in options)
                {
                    query = query.Where(c => c.Wiazka.Contains(option));
                }
            }
            if (Filter_KodWiazki != null)
            {
                var options = Filter_KodWiazki.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.KodWiazki));
            }
            if (Filter_PrzewodCiety != null)
            {
                var options = Filter_PrzewodCiety.Split(separator).Select(c => c.Replace("PLC", "").Trim());
                foreach (var option in options)
                {
                    query = query.Where(c => c.PrzewodCiety.Contains(option));
                }
            }
            if (Filter_BIN != null)
            {
                var options = Filter_BIN.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.BIN));
            }
            if (Filter_LiteraRodziny != null)
            {
                var options = Filter_LiteraRodziny.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.LiterRodziny));
            }
            if (Filter_Uwagi != null)
            {
                var options = Filter_Uwagi.Split(separator).Select(c => c.Trim());
                foreach (var option in options)
                {
                    query = query.Where(c => c.Uwagi.Contains(option));
                }
            }
            if (Filter_IlePrzedowow != null)
            {
                var options = Filter_IlePrzedowow.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.IlePrzewodow));
            }
            if (Filter_Kanban != null)
            {
                if (Filter_Kanban == "Prawda")
                {
                    query = query.Where(c => c.KanBan == true);
                }
                else if (Filter_Kanban == "Fałsz")
                {
                    query = query.Where(c => c.KanBan == false);
                }
            }

            string[] sortings =
            {
                "Rodzina",
                "Wiązka",
                "Litera rodziny",
                "Kod wiązki",
                "Przew. Cięty",
                "BIN"
            };
            availableSortings = new SelectList(sortings);

            if (SortColumn != null)
            {
                switch (SortColumn)
                {
                case "Rodzina":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.Rodzina);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.Rodzina);
                    }
                    break;

                case "Wiązka":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.Wiazka);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.Wiazka);
                    }
                    break;

                case "Litera rodziny":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.LiterRodziny);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.LiterRodziny);
                    }
                    break;

                case "Kod wiązki":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.KodWiazki);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.KodWiazki);
                    }
                    break;

                case "Przew. Cięty":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.PrzewodCiety);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.PrzewodCiety);
                    }
                    break;

                case "BIN":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.BIN);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.BIN);
                    }
                    break;
                }
            }

            Data = PaginatedList <Data.Tables.Technical> .CreateAsync(query, CurrentPage, PageSize).Result;
        }
Exemplo n.º 2
0
        public async Task OnGetAsync()
        {
            if (Request.Cookies["pagesize"] != null)
            {
                PageSize = int.Parse(Request.Cookies["pagesize"]);
            }

            string[] filterOptions =
            {
                "Prawda",
                "Fałsz",
            };
            completeFilter = new SelectList(filterOptions);
            declaredFilter = new SelectList(filterOptions);

            var  query     = _db.VTMagazyn.AsNoTracking().Include(c => c.Technical).AsNoTracking().AsQueryable();
            char separator = ',';

            if (Filter_LiteraRodziny != null)
            {
                var options = Filter_LiteraRodziny.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.Technical.LiterRodziny));
            }
            if (Filter_KodWiazki != null)
            {
                var options = Filter_KodWiazki.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.Technical.KodWiazki));
            }
            if (Filter_NumerKompletu != null)
            {
                var options = Filter_NumerKompletu.Split(separator).Select(c => int.Parse(c.Trim()));
                query = query.Where(c => options.Contains(c.NumerKompletu));
            }
            if (Filter_SztukiZeskanowane != null)
            {
                var options = Filter_SztukiZeskanowane.Split(separator).Select(c => int.Parse(c.Trim()));
                query = query.Where(c => options.Contains(c.SztukiZeskanowane));
            }
            if (Filter_Wiazka != null)
            {
                var options = Filter_Wiazka.Split(separator).Select(c => c.Trim());
                foreach (var option in options)
                {
                    query = query.Where(c => c.Wiazka.Contains(option));
                }
            }
            if (Filter_KodCiety != null)
            {
                var options = Filter_KodCiety.Split(separator).Select(c => c.Trim());
                foreach (var option in options)
                {
                    query = query.Where(c => c.KodCiety.Contains(option));
                }
            }
            if (Filter_Pracownik != null)
            {
                var options = Filter_Pracownik.Split(separator).Select(c => c.Trim());
                foreach (var option in options)
                {
                    query = query.Where(c => c.Pracownik.Contains(option));
                }
            }
            if (Filter_DokDostawy != null)
            {
                var options = Filter_DokDostawy.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.DokDostawy));
            }
            if (Filter_DokDostawyDopis != null)
            {
                var options = Filter_DokDostawy.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.DostawaDopis));
            }

            if (Filter_DataUtworzeniaFrom != DateTime.MinValue && Filter_DataUtworzeniaTo != DateTime.MinValue)
            {
                query = query.Where(c => c.DataUtworzenia.Date >= Filter_DataUtworzeniaFrom.Date && c.DataUtworzenia.Date <= Filter_DataUtworzeniaTo.Date);
            }
            else if (Filter_DataUtworzeniaFrom != DateTime.MinValue)
            {
                query = query.Where(c => c.DataUtworzenia.Date == Filter_DataUtworzeniaFrom);
            }

            if (Filter_DataDostawyFrom != DateTime.MinValue && Filter_DataDostawyTo != DateTime.MinValue)
            {
                query = query.Where(c => c.DataDostawy.Date >= Filter_DataDostawyFrom.Date && c.DataDostawy.Date <= Filter_DataDostawyTo.Date);
            }
            else if (Filter_DataDostawyFrom != DateTime.MinValue)
            {
                query = query.Where(c => c.DataDostawy.Date == Filter_DataDostawyFrom);
            }

            if (Filter_DataDopisuFrom != DateTime.MinValue && Filter_DataDopisuTo != DateTime.MinValue)
            {
                query = query.Where(c => c.DataDopisu != null && ((DateTime)c.DataDopisu).Date >= Filter_DataDopisuFrom && ((DateTime)c.DataDopisu).Date <= Filter_DataDopisuTo);
            }
            else if (Filter_DataDopisuFrom != DateTime.MinValue)
            {
                query = query.Where(c => c.DataDopisu != null && ((DateTime)c.DataDopisu).Date == Filter_DataDopisuFrom);
            }

            if (Filter_Uwagi != null)
            {
                var options = Filter_Uwagi.Split(separator).Select(c => c.Trim());
                foreach (var option in options)
                {
                    query = query.Where(c => c.Uwagi.Contains(option));
                }
            }
            if (Filter_Komplet != null)
            {
                if (Filter_Komplet == "Prawda")
                {
                    query = query.Where(c => c.Komplet == true);
                }
                else if (Filter_Komplet == "Fałsz")
                {
                    query = query.Where(c => c.Komplet == false);
                }
            }
            if (Filter_Deklaracja != null)
            {
                if (Filter_Deklaracja == "Prawda")
                {
                    query = query.Where(c => c.Deklarowany == true);
                }
                else if (Filter_Deklaracja == "Fałsz")
                {
                    query = query.Where(c => c.Deklarowany == false);
                }
            }

            string[] sortings =
            {
                "Sztuki Zeskanowane",
                "Pracownik",
                "Dok. Dostawy",
                "Data Utworzenia",
                "Data Dostawy",
                "Data Dopisu",
                "Deklarowany",
                "Uwagi"
            };



            availableSortings = new SelectList(sortings);

            if (SortColumn != null)
            {
                switch (SortColumn)
                {
                case "Sztuki Zeskanowane":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.SztukiZeskanowane);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.SztukiZeskanowane);
                    }
                    break;

                case "Pracownik":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.Pracownik);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.Pracownik);
                    }
                    break;

                case "Dok. Dostawy":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.DokDostawy);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.DokDostawy);
                    }
                    break;

                case "Data Utworzenia":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.DataUtworzenia);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.DataUtworzenia);
                    }
                    break;

                case "Data Dostawy":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.DataDostawy);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.DataDostawy);
                    }
                    break;

                case "Data Dopisu":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.DataDopisu);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.DataDopisu);
                    }
                    break;

                case "Deklarowany":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.Deklarowany);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.Deklarowany);
                    }
                    break;

                case "Uwagi":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.Uwagi);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.Uwagi);
                    }
                    break;
                }
            }
            int count = query.Count();

            Data = await PaginatedList <Data.Tables.VTMagazyn> .CreateAsync(query, CurrentPage, PageSize);

            return;
        }
Exemplo n.º 3
0
        public async Task OnGetAsync()
        {
            if (Request.Cookies["pagesize"] != null)
            {
                PageSize = int.Parse(Request.Cookies["pagesize"]);
            }

            var  query     = _db.Dostawa.IgnoreQueryFilters().Include(c => c.Technical).AsNoTracking().AsQueryable();
            char separator = ',';

            if (Filter_Kod != null)
            {
                var options = Filter_Kod.Split(separator).Select(c => c.Replace("PLC", "").Trim());
                query = query.Where(c => options.Contains(c.Kod.Replace("PLC", "")));
            }
            if (Filter_Wiazka != null)
            {
                var options = Filter_Wiazka.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.Technical.Wiazka));
            }
            if (Filter_LiteraRodziny != null)
            {
                var options = Filter_LiteraRodziny.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.Technical.LiterRodziny));
            }
            if (Filter_KodWiazki != null)
            {
                var options = Filter_KodWiazki.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.Technical.KodWiazki));
            }
            if (Filter_Ilosc != null)
            {
                query = query.Where(c => c.Ilosc == Filter_Ilosc);
            }
            if (Filter_DataFrom != DateTime.MinValue && Filter_DataTo != DateTime.MinValue)
            {
                query = query.Where(c => c.Data.Date >= Filter_DataFrom.Date && c.Data.Date <= Filter_DataTo.Date);
            }
            else if (Filter_DataFrom != DateTime.MinValue)
            {
                query = query.Where(c => c.Data.Date == Filter_DataFrom.Date);
            }
            if (Filter_DateCreated != DateTime.MinValue)
            {
                query = query.Where(c => c.DataUtworzenia.Date == Filter_DateCreated.Date);
            }
            if (Filter_Uwagi != null)
            {
                var options = Filter_Uwagi.Split(separator).Select(c => c.Trim());
                query = query.Where(c => options.Contains(c.Uwagi));
            }

            string[] sortings =
            {
                "Kod",
                "Ilość",
                "Data",
                "Data utworzenia"
            };
            availableSortings = new SelectList(sortings);

            if (SortColumn != null)
            {
                switch (SortColumn)
                {
                case "Kod":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.Kod);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.Kod);
                    }
                    break;

                case "Ilość":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.Ilosc);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.Ilosc);
                    }
                    break;

                case "Data":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.Data);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.Data);
                    }
                    break;

                case "Data utworzenia":
                    if (OrderDescent)
                    {
                        query = query.OrderByDescending(c => c.DataUtworzenia);
                    }
                    else
                    {
                        query = query.OrderBy(c => c.DataUtworzenia);
                    }
                    break;
                }
            }

            Data = await PaginatedList <Data.Tables.Dostawa> .CreateAsync(query, CurrentPage, PageSize);

            return;
        }