Exemple #1
0
        public void GetRecords_1(List <string> actualFields)
        {
            this.isReadStopEvent = false;
            int i;

            while (this.reader.Read() && this.isReadStopEvent == false)
            {
                //callback(this.reader);
                var t = new ShipmentGoods();
                var y = this.reader.FieldCount;

                object a = reader.GetValue(0);
                object b = reader.GetValue(1);
                object c = reader.GetValue(2);
                object d = reader.GetValue(3);
                object v = reader.GetValue(2);

                //ShipmentGoods shipment = new ShipmentGoods();
                //i = 0;
                //foreach (string actualField in actualFields)
                //{
                //    shipment[actualField] = reader[i].ToString();
                //    i++;
                //}
                //shipment["Qty"] = int.Parse(reader[i].ToString());
                //shipment["Price"] = decimal.Parse(reader[i + 1].ToString());
                //listData.Add(shipment);
            }
            this.isReadStopEvent = false;
        }
Exemple #2
0
        public List <ShipmentGoods> groupData()
        {
            List <ShipmentGoods> goodsVm = new List <ShipmentGoods>();

            var res = db.ShipmentGoods.GroupBy(g => g.date).ToList();

            foreach (var group in res)
            {
                var dateVm = new ShipmentGoods()
                {
                    date  = group.Key.Value,
                    qty   = group.Sum(g => g.qty).Value,
                    price = group.Sum(g => g.price).Value,
                };

                goodsVm.Add(dateVm);
            }

            return(goodsVm);
        }
Exemple #3
0
        public List <ShipmentGoods> SelectData(Dictionary <int, string> groupFields)
        {
            List <ShipmentGoods> goodsVm = new List <ShipmentGoods>();

            if (groupFields.Count > 0)
            {
                //List<IGrouping<string, ShipmentGoods>> res = new List<IGrouping<string, ShipmentGoods>>();
                //List<IGrouping<DateTime?, ShipmentGoods>> resData = new List<IGrouping<DateTime?, ShipmentGoods>>();
                foreach (var f in groupFields)
                {
                    if (f.Key == (int)filds.date)
                    {
                        var resData = db.ShipmentGoods.GroupBy(g => g.date).ToList();
                        foreach (var groupDate in resData)
                        {
                            var dateVm = new ShipmentGoods()
                            {
                                date  = groupDate.Key.Value,
                                qty   = groupDate.Sum(g => g.qty).Value,
                                price = groupDate.Sum(g => g.price).Value,
                            };
                            goodsVm.Add(dateVm);
                        }
                    }

                    if (f.Key == (int)filds.organization)
                    {
                        var res1 = db.ShipmentGoods.GroupBy(g => g.organization).ToList();
                        foreach (var group in res1)
                        {
                            var groupVm = new ShipmentGoods()
                            {
                                organization = group.Key,
                                qty          = group.Sum(g => g.qty).Value,
                                price        = group.Sum(g => g.price).Value,
                            };
                            goodsVm.Add(groupVm);
                        }
                    }
                    if (f.Key == (int)filds.cityName)
                    {
                        var res1 = db.ShipmentGoods.GroupBy(g => g.cityName).ToList();
                        foreach (var group in res1)
                        {
                            var groupVm = new ShipmentGoods()
                            {
                                cityName = group.Key,
                                qty      = group.Sum(g => g.qty).Value,
                                price    = group.Sum(g => g.price).Value,
                            };
                            goodsVm.Add(groupVm);
                        }
                    }
                    if (f.Key == (int)filds.managerName)
                    {
                        var res1 = db.ShipmentGoods.GroupBy(g => g.managerName).ToList();
                        foreach (var group in res1)
                        {
                            var groupVm = new ShipmentGoods()
                            {
                                countryName = group.Key,
                                qty         = group.Sum(g => g.qty).Value,
                                price       = group.Sum(g => g.price).Value,
                            };
                            goodsVm.Add(groupVm);
                        }
                    }
                    if (f.Key == (int)filds.countryName)
                    {
                        var res1 = db.ShipmentGoods.GroupBy(g => g.countryName).ToList();
                        foreach (var group in res1)
                        {
                            var groupVm = new ShipmentGoods()
                            {
                                managerName = group.Key,
                                qty         = group.Sum(g => g.qty).Value,
                                price       = group.Sum(g => g.price).Value,
                            };
                            goodsVm.Add(groupVm);
                        }
                    }
                }

                var t = goodsVm;
            }
            else
            {
                var res = GetGoods();

                goodsVm = res;
            }

            return(goodsVm);
        }