public List <CommContracts.MaterialOutStore> getAllMaterialOutStore(int StoreID, CommContracts. OutStoreEnum outStoreEnum, DateTime StartInStoreTime, DateTime EndInStoreTime, string OutStoreNo = "") { List <CommContracts.MaterialOutStore> list = new List <CommContracts.MaterialOutStore>(); using (DAL.HisContext ctx = new DAL.HisContext()) { var query = from a in ctx.MaterialOutStores where a.ToStoreID == StoreID && a.OutStoreEnum == (DAL.OutStoreEnum)outStoreEnum && a.OperateTime > StartInStoreTime && a.OperateTime < EndInStoreTime && a.NO.StartsWith(OutStoreNo) orderby a.OperateTime descending select a; foreach (DAL.MaterialOutStore ass in query) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <DAL.MaterialOutStore, CommContracts.MaterialOutStore>(); }); var mapper = config.CreateMapper(); CommContracts.MaterialOutStore temp = mapper.Map <CommContracts.MaterialOutStore>(ass); list.Add(temp); } } return(list); }
private bool MySaveMaterialOutStore(bool bIsRecheck = false) { var vm = this.DataContext as HISGUIMedicineVM; CommContracts.MaterialOutStore materialOutStore = new CommContracts.MaterialOutStore(); if (vm.CurrentUser != null) { materialOutStore.OperateUserID = vm.CurrentUser.ID; } if (vm.CurrentStoreRoom != null) { materialOutStore.ToStoreID = vm.CurrentStoreRoom.ID; } materialOutStore.MaterialOutStoreDetails = GetDetails(); bool?result = vm?.SaveMaterialOutStock(materialOutStore, bIsRecheck); if (result.HasValue) { if (result.Value) { return(true); } } return(false); }
public bool RecheckMaterialOutStore(CommContracts.MaterialOutStore MaterialOutStore) { using (DAL.HisContext ctx = new DAL.HisContext()) { if (MaterialOutStore.ReCheckStatusEnum == CommContracts.ReCheckStatusEnum.已审核) { return(false); } if (MaterialOutStore.MaterialOutStoreDetails == null) { return(false); } foreach (var tempDetail in MaterialOutStore.MaterialOutStoreDetails) { if (tempDetail == null) { continue; } var query = from s in ctx.StoreRoomMaterialNums where s.ID == tempDetail.StoreRoomMaterialNumID && s.StoreRoomID == MaterialOutStore.ToStoreID && s.StorePrice == tempDetail.StorePrice select s; if (query.Count() == 1) { var temp = query.First(); if (temp.Num >= tempDetail.Num) { temp.Num -= tempDetail.Num; } else { return(false); } } else { return(false); } } try { ctx.SaveChanges(); } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { return(false); } } return(true); }
// 保存物资出库单 public bool SaveMaterialOutStock(CommContracts.MaterialOutStore materialOutStore, bool bIsAutoCheck = false) { CommClient.MaterialOutStore myd = new CommClient.MaterialOutStore(); if (myd.SaveMaterialOutStock(materialOutStore)) { return(true); } return(false); }
private void AddNewOutStockBtn_Click(object sender, RoutedEventArgs e) { var vm = this.DataContext as HISGUIMedicineVM; if (vm.IsMedicineOrMaterial) { var currentOutStore = new CommContracts.MedicineOutStore(); vm.CurrentMedicineOutStore = currentOutStore; vm.IsInitViewEdit = true; vm?.ShowMedicineOutStoreDetail(); } else { var currentOutStore = new CommContracts.MaterialOutStore(); vm.CurrentMaterialOutStore = currentOutStore; vm.IsInitViewEdit = true; vm?.ShowMaterialOutStoreDetail(); } }
public bool SaveMaterialOutStock(CommContracts.MaterialOutStore MaterialOutStore) { using (DAL.HisContext ctx = new DAL.HisContext()) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <CommContracts.MaterialOutStore, DAL.MaterialOutStore>().ForMember(x => x.MaterialOutStoreDetails, opt => opt.Ignore()); }); var mapper = config.CreateMapper(); DAL.MaterialOutStore temp = new DAL.MaterialOutStore(); temp = mapper.Map <DAL.MaterialOutStore>(MaterialOutStore); var configDetail = new MapperConfiguration(ctr => { ctr.CreateMap <CommContracts.MaterialOutStoreDetail, DAL.MaterialOutStoreDetail>().ForMember(x => x.MaterialOutStore, opt => opt.Ignore()); }); var mapperDetail = configDetail.CreateMapper(); List <CommContracts.MaterialOutStoreDetail> list1 = MaterialOutStore.MaterialOutStoreDetails; List <DAL.MaterialOutStoreDetail> res = mapperDetail.Map <List <DAL.MaterialOutStoreDetail> >(list1); temp.MaterialOutStoreDetails = res; ctx.MaterialOutStores.Add(temp); try { ctx.SaveChanges(); } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { return(false); } } return(true); }
public bool RecheckMaterialOutStock(CommContracts.MaterialOutStore MaterialOutStore) { using (DAL.HisContext db = new DAL.HisContext()) { var tem = new DAL.MaterialOutStore { ID = MaterialOutStore.ID, ReCheckUserID = MaterialOutStore.ReCheckUserID, ReCheckStatusEnum = (DAL.ReCheckStatusEnum)MaterialOutStore.ReCheckStatusEnum }; //将实体附加到对象管理器中 db.MaterialOutStores.Attach(tem); //获取到user的状态实体,可以修改其状态 var setEntry = ((IObjectContextAdapter)db).ObjectContext.ObjectStateManager.GetObjectStateEntry(tem); //只修改实体的ReCheckUserID属性和ReCheckStatusEnum属性 setEntry.SetModifiedProperty("ReCheckUserID"); setEntry.SetModifiedProperty("ReCheckStatusEnum"); db.SaveChanges(); } return(true); }