--将当前库存记录insert医废转移单中 --declare @Warehouse nvarchar(100); declare @Warehouse_JJRID nvarchar(100); declare @Warehouse_JJRName nvarchar(100); declare @ZYGS_ID Nvarchar(100);--转运公司ID declare @ZYGS_Name NVarchar(100); declare @ZYGS_JSRID Nvarchar(100); declare @ZDR_ID Nvarchar(20); declare @ZDR_Name Nvarchar(20); --select @Warehouse={&WarehouseID};--'仓库ID' select @Warehouse_JJRID={&Warehouse_JJRID};--'仓库保管的ID' select @Warehouse_JJRName={&Warehouse_JJRName};--'仓库保管姓名' select @ZYGS_ID={&ZYGS_ID};--处置公司ID --select @ZYGS_Name={&ZYGS_Name};--处置公司名称 select @ZYGS_JSRID={&ZYGS_JSRID};--处置公司处置人ID select @ZDR_ID={&ZDR_ID};--制单人ID select @ZDR_Name={&ZDR_Name};--制单人姓名 declare @error int; select @error=0; BEGIN TRANSACTION --get符合条件的库存记录 insert into MedicalWastesDelivery ( MWC_ID, MWC_Code,--医疗袋标识码BagID 18位 MWD_ThisBarcode, MWC_Date, WT_Code, WT_Name, MWD_ZYBMCode,--转运公司ID MWD_ZYBMName,--转运公司名称 MWD_ZYBMJSR,--转运接收人 MWD_weight, emp_ID,--制单人ID MWD_ZDR,--制单人name WWH_Code, MWD_JJR, MWD_JJRName, MWD_CKdate --出库操作时间 ) select (replace(newid(), '-', '')), b.MWC_Code,--'医疗袋标识码BagID 18位', MWS_ThisBarcode, getdate(), a.WT_Code, a.WT_Name, @ZYGS_ID, @ZYGS_Name, @ZYGS_JSRID, weight, @ZDR_ID, @ZDR_Name, a.WWH_CODE, @Warehouse_JJRID, @Warehouse_JJRName, getdate() from MedicalWastesStock a left join MedicalWastesCollection b on a.MWS_ThisBarcode=b.MWC_Barcode where isnull(a.MWS_CKDate,0)=0 and ({&Warehouse}); select @error =@error + @@error; update MedicalWastesStock set MWS_CKDate=getdate() -- 仓库出库日期; where ({&Warehouse1}) and --选择的没有出库的库存记录 isnull(MWS_CKDate,0)=0; select @error =@error + @@error; if @error <>0 begin ROLLBACK TRANSACTION; Return; end else begin COMMIT TRANSACTION; end;