コード例 #1
0
        public List <PPSC_Inventory_Weekly> GetSerialNumberFiltered(string limitData, string[] customer, string[] model, string[] serialnumber, string[] plant, string [] product, string paramsModel = null, string paramsSerialNumber = null)
        {
            var InventoryFiltered = _ctx.Inventory_Weekly.Where(item => true);

            var ListData = new List <PPSC_Inventory_Weekly>();

            InventoryFiltered = LogicFilterQuery(InventoryFiltered, customer, model, serialnumber, plant, product, paramsModel, paramsSerialNumber);
            var getdata = (from item in InventoryFiltered
                           group item by item.Serial_Number into sn
                           select new
            {
                serialNumber = sn.FirstOrDefault().Serial_Number
            });

            foreach (var item in getdata)
            {
                var data = new PPSC_Inventory_Weekly();
                data.Serial_Number = item.serialNumber;
                ListData.Add(data);
            }
            if (!String.IsNullOrWhiteSpace(limitData))
            {
                return(ListData.Take(Convert.ToInt32(limitData)).ToList());
            }
            else
            {
                return(ListData.ToList());
            }
            //}
            //else
            //{
            //    InventoryFiltered = InventoryFiltered.Take(0);
            //    foreach (var item in InventoryFiltered)
            //    {
            //        var data = new PPSC_Inventory_Weekly();
            //        data.Serial_Number = item.Serial_Number;
            //        ListData.Add(data);
            //    }
            //    return ListData;
            //}
        }
コード例 #2
0
        public List <PPSC_Inventory_Weekly> GetProductOverview(string filter, string customer = null, string model = null, string product = null, string plant = null, string serialnumber = null)
        {
            var getData = _ctx.Inventory_Weekly.Where(item => item.Product.Contains(filter));

            //var getData = _ctx.Inventory_Weekly.Where(item =>true);
            if (!String.IsNullOrWhiteSpace(customer))
            {
                getData.Where(item => customer.Contains(item.Customer_Name));
            }
            if (!String.IsNullOrWhiteSpace(model))
            {
                getData.Where(item => model.Contains(item.Model));
            }
            if (!String.IsNullOrWhiteSpace(product))
            {
                getData.Where(item => product.Contains(item.Product));
            }
            if (!String.IsNullOrWhiteSpace(plant))
            {
                getData.Where(item => plant.Contains(item.Plant));
            }
            if (!String.IsNullOrWhiteSpace(serialnumber))
            {
                getData.Where(item => serialnumber.Contains(item.Serial_Number));
            }
            var listData = getData.GroupBy(g => g.Product)
                           .Select(select => new
            {
                Product = select.FirstOrDefault().Product
            }).Take(100).OrderBy(odb => odb.Product).ToList();
            var listitem = new List <PPSC_Inventory_Weekly>();

            foreach (var item in listData)
            {
                var data = new PPSC_Inventory_Weekly();
                data.Product = item.Product;
                listitem.Add(data);
            }
            return(listitem);
        }