/// <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;
}
}
/// 检查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;
}
{
m_DetailTable.Rows[i]["ErrorMessage"] = "Currecny is invalid";
result = false;
}