C# 按地址传值

项目中在上传Excel数据时,有一个Currency栏位会到Currency表中Check用户输入的是否正确,这时发现一个问题:如果用户输入的是小写的usd,到Currency表中Check时可以通过,但是保存到自己的表中如果是小写的话就会有问题。所以下面的方法参数加了ref

/// <summary>
        /// 检查Currency Code是否存在
        /// </summary>
        /// <param name="inputString">需要Check的字符</param>
        /// <returns></returns>
        public static bool CheckCurrency(ref string inputString)
        {
            CurrencyEntity entityCurrency = new CurrencyEntity();
            entityCurrency.QueryMode = true;
            entityCurrency.CurrencyCode += inputString;
            entityCurrency.EffectiveFrom += SystemParameter.DefaultNowDate;
            entityCurrency.EffectiveFrom.Operator = BenQ.Public.QData.Foundation.SQLOperator.LessThanEqual;
            entityCurrency.EffectiveTo += SystemParameter.DefaultNowDate;
            entityCurrency.EffectiveTo.Operator = BenQ.Public.QData.Foundation.SQLOperator.MoreThanEqual;
            DataTable currencyTable = entityCurrency.Query().Tables[0];
            if (currencyTable.Rows.Count > 0)
            {
                inputString = currencyTable.Rows[0][entityCurrency.CurrencyCode.PhysicalFieldName.ToString()].ToString();
                return true;
            }
            else
            {
                return false;
            }
        }

调用:
 if (!CommonFunction.CheckCurrency(ref currency))
                    {
                        m_DetailTable.Rows[i][
"ErrorMessage"= "Currecny is invalid";
                        result 
= false;
                    }

posted on 2007-07-04 15:25  Sammy  阅读(503)  评论(0编辑  收藏  举报

导航