Beispiel #1
0
        public IActionResult DrugNormalEdit(vwCHIS_Code_Drug_Main drugOutpatient)
        {
            var model = _drugSvr.DrugNormalEdit(drugOutpatient);

            ViewBag.BackLink     = "/Pharmacy/DurgIncome?drugId=" + model.DrugId;
            ViewBag.BackLinkName = "入库该药品";
            return(View("Success"));
        }
Beispiel #2
0
        /// <summary>
        /// 药品一般编辑调整
        /// </summary>
        /// <param name="drugOutpatient"></param>
        /// <returns></returns>
        public CHIS_Code_Drug_Main DrugNormalEdit(vwCHIS_Code_Drug_Main drugOutpatient)
        {
            var main  = _db.CHIS_Code_Drug_Main.Find(drugOutpatient.DrugId);
            var model = _db.CHIS_Code_Drug_Outpatient.FirstOrDefault(m => m.DrugId == drugOutpatient.DrugId);

            main.Trademark          = drugOutpatient.Trademark;
            main.ManufacturerOrigin = drugOutpatient.ManufacturerOrigin;
            main.OriginPlace        = drugOutpatient.OriginPlace;
            //别名
            if (main.Alias != drugOutpatient.Alias)
            {
                main.Alias       = drugOutpatient.Alias;
                main.AliasSCode  = main.AliasPyCode = Ass.Data.Chinese2Spell.GetFstLettersLower(drugOutpatient.Alias);
                main.AliasQPCode = Ass.Data.Chinese2Spell.ConvertLower(drugOutpatient.Alias);
            }

            main.DefDrugGivenTakeTypeId  = drugOutpatient.DefDrugGivenTakeTypeId;
            main.DefDrugGivenTimeTypeId  = drugOutpatient.DefDrugGivenTimeTypeId;
            main.DefDrugGivenWhereTypeId = drugOutpatient.DefDrugGivenWhereTypeId;
            //获取供应商拼音
            main.ManufacturerOriginPinYin = getManufacturerOriginPinYin(main.ManufacturerOrigin, main.Trademark);



            bool bmod = (model.UnitBigId != drugOutpatient.UnitSmallId) ||
                        (model.UnitSmallId != drugOutpatient.UnitSmallId) ||
                        (model.OutpatientConvertRate != drugOutpatient.OutpatientConvertRate) ||
                        (model.DosageContent != drugOutpatient.DosageContent);

            model.UnitSmallId           = drugOutpatient.UnitSmallId;
            model.UnitBigId             = drugOutpatient.UnitBigId;
            model.DosageUnitId          = drugOutpatient.DosageUnitId;
            model.DosageContent         = drugOutpatient.DosageContent;
            model.OutpatientConvertRate = drugOutpatient.OutpatientConvertRate.Value;
            model.DefDosage             = drugOutpatient.DefDosage;

            _db.SaveChanges();

            //删除库存
            if (bmod)
            {
                var finds = _db.CHIS_DrugStock_Monitor.Where(m => m.DrugId == drugOutpatient.DrugId);
                _db.CHIS_DrugStock_Monitor.RemoveRange(finds);
                _db.SaveChanges();
            }
            return(main);
        }
Beispiel #3
0
        //修改药品监控表数据
        internal CHIS_DrugStock_Monitor ChangeDrugMonitor(int drugId, int stationId, int num, int inUnitId, out int stockNumPre, out int stockNum, vwCHIS_Code_Drug_Main drug = null)
        {
            stockNumPre = 0;
            if (drug == null)
            {
                drug = _db.vwCHIS_Code_Drug_Main.AsNoTracking().FirstOrDefault(m => m.DrugId == drugId);
            }
            var find = _db.CHIS_DrugStock_Monitor.AsNoTracking().FirstOrDefault(m => m.StationId == stationId && m.DrugId == drugId);

            if (find == null)
            {
                find = _db.CHIS_DrugStock_Monitor.Add(new CHIS_DrugStock_Monitor
                {
                    DrugStockMonitorId = $"{stationId}.{drugId}",
                    DrugId             = drugId,
                    DrugStockNum       = inUnitId == drug.UnitBigId && inUnitId != drug.UnitSmallId ? (int)(num * drug.OutpatientConvertRate) : num,
                    StationId          = stationId,
                    StockUnitId        = drug.UnitSmallId.Value,
                    StockSalePrice     = 0,
                    StockDrugIsEnable  = true,
                    StockLineNum       = 100
                }).Entity;
                _db.SaveChanges();
                stockNum = find.DrugStockNum;
                return(null);
            }
            else
            {
                stockNumPre = find.DrugStockNum;
                if (find.StockUnitId == inUnitId)
                {
                    find.DrugStockNum += num;
                }
                else if (find.StockUnitId == drug.UnitSmallId && inUnitId == drug.UnitBigId)
                {
                    find.DrugStockNum += (int)(num * drug.OutpatientConvertRate);
                }
                stockNum = find.DrugStockNum;
                return(find);
            }
        }