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; }
public void setEmsOrDrugList(XapDataList <EmsOrDrug> list) { lock (this) { IMaterialStockService stoctService = XapServiceMgr.find <IMaterialStockService>(); List <GetStockReqDTO> reqDtos = new List <GetStockReqDTO>(); if (emsOrDrugList == null) { emsOrDrugList = new XapDataList <EmsOrDrug>(); } for (int i = 0; i < list.Count; i++) { if (list[i].Fg_mm == true) { GetStockReqDTO reqDTO = new GetStockReqDTO(); reqDTO.Id_mm = list[i].Id_mm; reqDTO.Id_dep = list[i].Id_dep_wh; reqDTO.Req_unit_id = list[i].Id_unit_sale; reqDtos.Add(reqDTO); } } if (reqDtos.Count > 0) { MaterialStockDTO[] stockdto = null; try { stockdto = stoctService.getMaterialStocks(reqDtos.ToArray()); } catch (Exception ex) { ex.Publish(); //this.ShowInfo(ex.Message); } if (stockdto == null) { return; } for (int i = list.Count - 1; i >= 0; i--) { MaterialStockDTO materialDo = stockdto.FirstOrDefault(p => p.Id_mm == list[i].Id_mm); if (materialDo != null) { FDouble mmcount = materialDo.Quan_stock; int? mmStatus = materialDo.Mmstatus; //药房无此药的移除 if (mmStatus != null && mmStatus == (int)MaterialStatus.NORELATION) { list.RemoveAt(i); } else { list[i].Fact_count = mmcount; list[i].Price = materialDo.Price_act; list[i].Mmstatus = materialDo.Mmstatus; EmsOrDrug ems = emsOrDrugList.FirstOrDefault(p => p.Id_mm == list[i].Id_mm); if (ems != null) { emsOrDrugList.Remove(ems); } emsOrDrugList.Add(list[i]); } } } List <EmsOrDrug> sortList = null; try { sortList = emsOrDrugList.OrderByDescending(p => p.Fact_count).OrderBy(p => p.Mmstatus).ToList(); } catch //(Exception e) { // e.Message; } if (emsOrDrugList == null) { emsOrDrugList = new XapDataList <EmsOrDrug>(); } else { emsOrDrugList.Clear(); } sortList.ForEach(p => emsOrDrugList.Add(p)); } } }