예제 #1
0
        private bool MySaveMedicineInStore(bool bIsRecheck = false)
        {
            var vm = this.DataContext as HISGUIMedicineVM;

            CommContracts.MedicineInStore MedicineInStore = new CommContracts.MedicineInStore();
            if (vm.CurrentUser != null)
            {
                MedicineInStore.OperateUserID = vm.CurrentUser.ID;
            }
            if (vm.CurrentStoreRoom != null)
            {
                MedicineInStore.ToStoreID = vm.CurrentStoreRoom.ID;
            }
            if ((CommContracts.Supplier) this.SupplierEdit.SelectedItem != null)
            {
                MedicineInStore.FromSupplierID = ((CommContracts.Supplier) this.SupplierEdit.SelectedItem).ID;
            }
            MedicineInStore.MedicineInStoreDetails = GetDetails();

            bool?result = vm?.SaveMedicineInStock(MedicineInStore, bIsRecheck);

            if (result.HasValue)
            {
                if (result.Value)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        public List <CommContracts.MedicineInStore> getAllMedicineInStore(int StoreID, CommContracts.
                                                                          InStoreEnum inStoreEnum,
                                                                          DateTime StartInStoreTime,
                                                                          DateTime EndInStoreTime,
                                                                          string InStoreNo = "")
        {
            List <CommContracts.MedicineInStore> list = new List <CommContracts.MedicineInStore>();

            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var query = from a in ctx.MedicineInStores
                            where a.ToStoreID == StoreID &&
                            a.InStoreEnum == (DAL.InStoreEnum)inStoreEnum &&
                            a.OperateTime > StartInStoreTime &&
                            a.OperateTime < EndInStoreTime &&
                            a.NO.StartsWith(InStoreNo)
                            orderby a.OperateTime descending
                            select a;

                foreach (DAL.MedicineInStore ass in query)
                {
                    var config = new MapperConfiguration(cfg =>
                    {
                        cfg.CreateMap <DAL.MedicineInStore, CommContracts.MedicineInStore>();
                    });
                    var mapper = config.CreateMapper();

                    CommContracts.MedicineInStore temp = mapper.Map <CommContracts.MedicineInStore>(ass);
                    list.Add(temp);
                }
            }
            return(list);
        }
예제 #3
0
        private void AddNewStockBtn_Click(object sender, RoutedEventArgs e)
        {
            var vm = this.DataContext as HISGUIMedicineVM;

            if (vm.IsMedicineOrMaterial)
            {
                var currentInStore = new CommContracts.MedicineInStore();
                vm.CurrentMedicineInStore = currentInStore;
                vm.IsInitViewEdit         = true;
                vm?.ShowMedicineInStoreDetail();
            }
            else
            {
                var currentInStore = new CommContracts.MaterialInStore();
                vm.CurrentMaterialInStore = currentInStore;
                vm.IsInitViewEdit         = true;
                vm?.ShowMaterialInStoreDetail();
            }
        }
예제 #4
0
        public bool SaveMedicineInStock(CommContracts.MedicineInStore medicineInStore)
        {
            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var config = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <CommContracts.MedicineInStore, DAL.MedicineInStore>().ForMember(x => x.MedicineInStoreDetails, opt => opt.Ignore())
                    .ForMember(x => x.FromSupplier, opt => opt.Ignore());
                });
                var mapper = config.CreateMapper();

                DAL.MedicineInStore temp = new DAL.MedicineInStore();
                temp = mapper.Map <DAL.MedicineInStore>(medicineInStore);

                var configDetail = new MapperConfiguration(ctr =>
                {
                    ctr.CreateMap <CommContracts.MedicineInStoreDetail, DAL.MedicineInStoreDetail>().ForMember(x => x.MedicineInStore, opt => opt.Ignore());
                });
                var mapperDetail = configDetail.CreateMapper();

                List <CommContracts.MedicineInStoreDetail> list1 = medicineInStore.MedicineInStoreDetails;
                List <DAL.MedicineInStoreDetail>           res   = mapperDetail.Map <List <DAL.MedicineInStoreDetail> >(list1);

                temp.MedicineInStoreDetails = res;
                ctx.MedicineInStores.Add(temp);
                try
                {
                    ctx.SaveChanges();
                }
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
                catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #5
0
        public CommContracts.MedicineInStore GetMedicineInStore(int Id)
        {
            CommContracts.MedicineInStore assay = new CommContracts.MedicineInStore();
            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var query = from t in ctx.MedicineInStores
                            where t.ID == Id
                            select t;
                var config = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <DAL.MedicineInStore, CommContracts.MedicineInStore>();
                });
                var mapper = config.CreateMapper();


                foreach (var tem in query)
                {
                    assay = mapper.Map <CommContracts.MedicineInStore>(tem);
                    break;
                }
            }
            return(assay);
        }
예제 #6
0
        public bool RecheckMedicineInStock(CommContracts.MedicineInStore medicineInStore)
        {
            using (DAL.HisContext db = new DAL.HisContext())
            {
                var tem = new DAL.MedicineInStore
                {
                    ID                = medicineInStore.ID,
                    ReCheckUserID     = medicineInStore.ReCheckUserID,
                    ReCheckStatusEnum = (DAL.ReCheckStatusEnum)medicineInStore.ReCheckStatusEnum
                };
                //将实体附加到对象管理器中
                db.MedicineInStores.Attach(tem);

                //获取到user的状态实体,可以修改其状态
                var setEntry = ((IObjectContextAdapter)db).ObjectContext.ObjectStateManager.GetObjectStateEntry(tem);
                //只修改实体的ReCheckUserID属性和ReCheckStatusEnum属性
                setEntry.SetModifiedProperty("ReCheckUserID");
                setEntry.SetModifiedProperty("ReCheckStatusEnum");

                db.SaveChanges();
            }

            return(true);
        }
예제 #7
0
 // 保存药品入库单
 public bool SaveMedicineInStock(CommContracts.MedicineInStore MedicineInStore, bool bIsAutoCheck = false)
 {
     CommClient.MedicineInStore myd = new CommClient.MedicineInStore();
     return(myd.SaveMedicineInStock(MedicineInStore));
 }
예제 #8
0
        public bool ReCheckMedicineInStore(CommContracts.MedicineInStore medicineInStore)
        {
            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                if (medicineInStore.ReCheckStatusEnum == CommContracts.ReCheckStatusEnum.已审核)
                {
                    return(false);
                }

                if (medicineInStore.MedicineInStoreDetails == null)
                {
                    return(false);
                }

                foreach (var tempDetail in medicineInStore.MedicineInStoreDetails)
                {
                    if (tempDetail == null)
                    {
                        continue;
                    }

                    var query = from s in ctx.StoreRoomMedicineNums
                                where s.Batch == tempDetail.Batch &&
                                s.MedicineID == tempDetail.MedicineID &&
                                s.StoreRoomID == medicineInStore.ToStoreID &&
                                s.StorePrice == tempDetail.StorePrice &&
                                s.SupplierID == medicineInStore.FromSupplierID &&
                                s.ExpirationDate == tempDetail.ExpirationDate
                                select s;


                    if (query.Count() == 0)
                    {
                        DAL.StoreRoomMedicineNum storeRoomMedicineNum = new DAL.StoreRoomMedicineNum();
                        storeRoomMedicineNum.Batch          = tempDetail.Batch;
                        storeRoomMedicineNum.SupplierID     = medicineInStore.FromSupplierID;
                        storeRoomMedicineNum.MedicineID     = tempDetail.MedicineID;
                        storeRoomMedicineNum.StoreRoomID    = medicineInStore.ToStoreID;
                        storeRoomMedicineNum.Num            = tempDetail.Num;
                        storeRoomMedicineNum.StorePrice     = tempDetail.StorePrice;
                        storeRoomMedicineNum.ExpirationDate = tempDetail.ExpirationDate;
                        ctx.StoreRoomMedicineNums.Add(storeRoomMedicineNum);
                    }
                    else
                    {
                        var temp = query.First();
                        temp.Num += tempDetail.Num;
                    }
                }

                try
                {
                    ctx.SaveChanges();
                }
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
                catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
                {
                    return(false);
                }
            }
            return(true);
        }