public MmForm(XapDataList <EmsOrDrug> list) : this() { mm = new MmRefView(list); mm.DoubleClickEvent += new EventHandler(mm_DoubleClickEvent); this.Panel = mm; }
public MmForm(XapDataList <EmsOrDrug> list, EmsDrugItemDO drugItemDO) : this() { IMaterialStockService stoctService = XapServiceMgr.find <IMaterialStockService>(); GetStockReqDTO[] reqDtos = new GetStockReqDTO[list.Count]; for (int i = 0; i < list.Count; i++) { GetStockReqDTO reqDTO = new GetStockReqDTO(); reqDTO.Id_mm = list[i].Id_mm; reqDTO.Id_dep = ""; reqDTO.Req_unit_id = list[i].Id_unit_sale; reqDtos[i] = reqDTO; } MaterialStockDTO[] stockdto = stoctService.getMaterialStocks(reqDtos); for (int i = list.Count - 1; i >= 0; i--) { MaterialStockDTO materialDo = stockdto.FirstOrDefault(p => p.Id_mm == list[i].Id_mm); if (materialDo != null) { double mmcount = (double)materialDo.Quan_stock; if (mmcount <= 0) { list.RemoveAt(i); } else { list[i].Fact_count = Math.Round(mmcount); list[i].Price = materialDo.Price_act; } } } IEnumerable <EmsOrDrug> query = null; query = from items in list orderby items.Fact_count descending select items; int flag = 0; foreach (var item in query) { list[flag] = item; flag++; //Console.WriteLine(item.Id+":"+item.Name); } mm = new MmRefView(list); mm.DoubleClickEvent += new EventHandler(mm_DoubleClickEvent); this.Panel = mm; }