| | |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!单张条码数量必须大于0"; |
| | | objJsonResult.Message = "保存失败!条码张数必须大于0"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | // 计算需要生成的条码数量 |
| | | int fullBarcodeCount = (int)(HQty / HPieceQty); // 完整箱数 |
| | | decimal remainder = HQty % HPieceQty; // 余数 |
| | | // 固定生成指定张数的条码 |
| | | int barcodeCount = (int)HPieceQty; // HPieceQty 作为条码张数 |
| | | |
| | | int barcodeCount = fullBarcodeCount; |
| | | if (remainder > 0) |
| | | { |
| | | barcodeCount += 1; // 有余数时增加一张条码 |
| | | } |
| | | // 计算每张条码的平均数量 |
| | | decimal baseQty = Math.Floor(HQty / HPieceQty); |
| | | decimal remainder = HQty % HPieceQty; |
| | | |
| | | // 查询原始单据信息 |
| | | ds = oCN.RunProcReturn("select * from Sc_StationOutBillMain where HInterID='" + HInterID + "'", "Sc_StationOutBillMain"); |
| | |
| | | for (int i = 0; i < barcodeCount; i++) |
| | | { |
| | | // 计算当前条码的数量 |
| | | decimal currentQty; |
| | | if (i < fullBarcodeCount) |
| | | decimal currentQty = baseQty; |
| | | if (i < remainder) // 如果有余数,前N张条码各加1 |
| | | { |
| | | // 前 fullBarcodeCount 张条码,每张数量为 HPieceQty |
| | | currentQty = HPieceQty; |
| | | } |
| | | else |
| | | { |
| | | // 最后一张条码,数量为余数 |
| | | currentQty = remainder; |
| | | currentQty += 1; |
| | | } |
| | | |
| | | // 生成条码号(可以在原始条码号后面加序号) |
| | | // 生成条码号 |
| | | string barcodeNumber = row["HBillNO"].ToString() + (barcodeCount > 1 ? "-" + (i + 1).ToString() : ""); |
| | | |
| | | string sql = "insert into Gy_BarCodeBill (HInterID, HEntryID, HBarCode, HBarCodeType, HBarCodeSubType, HMaterID, HUnitID, HQty, HBatchNo, HSupID, HGroupID, HMaker, HMakeDate, " + |