public void AddDrugStockOut2(DrugOutEntity data, float used) { IRepository db = new RepositoryFactory().BaseRepository().BeginTrans(); try { var drug = (from q in db.IQueryable <DrugEntity>() where q.Id == data.DrugId select q).FirstOrDefault(); var all = drug.Used + used; var ss = (int)(all / float.Parse(drug.Spec)); drug.DrugNum -= ss; drug.Used = all - int.Parse(drug.Spec) * ss; data.Surplus = (decimal)(drug.DrugNum * int.Parse(drug.Spec) - drug.Used); db.Update(drug); db.Insert(data); db.Commit(); } catch (Exception) { db.Rollback(); throw; } }
/// <summary> /// 药品取用 /// /// </summary> /// <param name="Id"></param> /// <param name="entity"></param> public void SaveDrugOutNew(string Id, DrugOutEntity entity) { try { //更新出库信息 (该id取的出库信息id) DrugStockOutEntity drug = dsoservice.GetEntity(entity.DrugId); drug.Total = drug.Total - entity.OutNum; dsoservice.SaveDrugStockOut(drug.Id, drug); //保存取用记录 entity.Id = Guid.NewGuid().ToString(); entity.DrugUnit = drug.DrugUnit; entity.DrugName = drug.DrugName; entity.DrugLevel = drug.DrugLevelName + "(" + drug.DrugLevel + ")"; entity.Surplus = drug.Total; entity.OutNum = entity.OutNum; drugOut.SaveDrugOut(Id, entity); } catch (Exception) { throw; } }
public void AddDrugStockOut2(DrugOutEntity data, float used) { service.AddDrugStockOut2(data, used); }