コード例 #1
0
ファイル: RecipeRuleChecker.cs プロジェクト: xuanximoming/key
        private void CheckItemAmount(decimal productSerialNo, string itemCode, decimal amount, ItemUnit unit, ItemUnit dosageUnit, ItemUnit wardUnit)
        {
            m_Filter = String.Format(CultureInfo.CurrentCulture, ConstSqlSentences.FormatRecipeRuleItemAmountFilter
                                     , WarrantCode, productSerialNo, itemCode);
            DataRow[] matchRows = m_ItemLimited.Select(m_Filter);
            if ((matchRows != null) && (matchRows.Length > 0))
            {
                ItemUnit usedUnit;
                decimal  warningAmount = Convert.ToDecimal(matchRows[0][ConstSchemaNames.RecipeRuleColWarningLine]);
                decimal  maxAmount     = Convert.ToDecimal(matchRows[0][ConstSchemaNames.RecipeRuleColControlLine]);
                decimal  baseWarningAmount;
                decimal  baseMaxAmount;
                if (Convert.ToInt16(matchRows[0][ConstSchemaNames.RecipeRuleColUnitKind]) == (int)DruggeryUnitKind.Ward) // 使用住院单位
                {
                    usedUnit = wardUnit;
                }
                else
                {
                    usedUnit = dosageUnit;
                }

                baseWarningAmount = usedUnit.Convert2BaseUnit(warningAmount);
                baseMaxAmount     = usedUnit.Convert2BaseUnit(maxAmount);

                decimal trueAmount = unit.Convert2BaseUnit(amount);

                if (trueAmount > baseMaxAmount)
                {
                    throw new DataCheckException(String.Format(ConstMessages.FormatMoreThanControlLine, maxAmount, usedUnit.Name), ConstNames.Amount, 1);
                }
                else if (trueAmount > baseWarningAmount)
                {
                    throw new DataCheckException(String.Format(ConstMessages.FormatMoreThanWarningLine, warningAmount, usedUnit.Name), ConstNames.Amount, 0);
                }
            }
        }