static public MaterielOutEarningsOrderDetails getInctance() { if (m_instance == null) { m_instance = new MaterielOutEarningsOrderDetails(); } return(m_instance); }
private bool updateMaterielData(string billNumber) { bool isRet = true; SortedDictionary <int, MaterielOutEarningsOrderDetailsTable> dataList = MaterielOutEarningsOrderDetails.getInctance().getMaterielOutEarningsInfoFromBillNumber(billNumber); if (!m_isRedBill) { // 首先检查物料库存余额是否大于本次出库单交易额,如果小于,则提示用户,但是审核失败 foreach (KeyValuePair <int, MaterielOutEarningsOrderDetailsTable> index in dataList) { MaterielOutEarningsOrderDetailsTable record = index.Value; InitMaterielTable materielRecord = new InitMaterielTable(); materielRecord.materielID = record.materielID; materielRecord.value = record.value; InitMaterielTable materielStorageData = InitMateriel.getInctance().getMaterielInfoFromMaterielID(record.materielID); if (materielStorageData.value < materielRecord.value) { isRet = false; MessageBoxExtend.messageWarning("物料:[" + materielRecord.materielID + "]库存数量小于当前交易数量,单据审核失败"); break; } } } if (isRet) { foreach (KeyValuePair <int, MaterielOutEarningsOrderDetailsTable> index in dataList) { MaterielOutEarningsOrderDetailsTable record = index.Value; //InitMaterielTable materielRecord = new InitMaterielTable(); //materielRecord.materielID = record.materielID; //materielRecord.value = (int)record.value; //// 交易后库存数量等于当前仓库库存数减去本次交易数 //InitMaterielTable materielStorageData = InitMateriel.getInctance().getMaterielInfoFromMaterielID(record.materielID); //if (m_isRedBill) //{ // // 如果是销售退货,库存数量应该增加 // materielRecord.value = materielStorageData.value + materielRecord.value; //} //else //{ // materielRecord.value = materielStorageData.value - materielRecord.value; //} //InitMateriel.getInctance().materielOutStorage(materielRecord.materielID, materielRecord.value); #region 更新库存汇总表(INIT_STORAGE_STOCK) // 交易完毕后库存数量 double tradingStocksValue = record.value; // 交易后库存数量等于当前仓库库存数减去本次交易数 InitMaterielTable materielStorageData = InitMateriel.getInctance().getMaterielInfoFromMaterielID(record.materielID); if (m_isRedBill) { // 如果是销售退货,库存数量应该增加 tradingStocksValue = materielStorageData.value + tradingStocksValue; } else { tradingStocksValue = materielStorageData.value - tradingStocksValue; } InitMateriel.getInctance().materielOutStorage(record.materielID, tradingStocksValue); #endregion #region 更新存货明细账表(STORAGE_STOCK_DETAIL) 2012-1-16 00:56 StorageStockDetailTable storageStockDetailRecord = new StorageStockDetailTable(); storageStockDetailRecord.materielID = record.materielID; storageStockDetailRecord.tradingDate = DateTime.Now.ToString("yyyyMMdd"); storageStockDetailRecord.billNumber = billNumber; storageStockDetailRecord.thingsType = "盘盈毁损"; storageStockDetailRecord.isIn = 0; // 本次交易数量和单价 if (m_isRedBill) { storageStockDetailRecord.value = record.value * -1; } else { storageStockDetailRecord.value = record.value; } storageStockDetailRecord.price = record.price; // 交易完毕后数量和单价 storageStockDetailRecord.storageValue = tradingStocksValue; storageStockDetailRecord.storagePrice = materielStorageData.price; StorageStockDetail.getInctance().insert(storageStockDetailRecord); #endregion } } return(isRet); }