C# Winform用户自定义公式配置工具界面
作者:C/S框架网|www.cscode.ne  发布日期:2019-10-18 21:20:11
  C# Winform用户自定义公式配置工具界面


公式配置界面:

贴图图片-微信截图_20191018211044


公式项目表结构:


贴图图片-微信截图_20191018211721


C# Code:


/// <summary>
/// SQL测试表达式
/// </summary>
/// <param name="expression"></param>
/// <returns></returns>
public object Calculate(string expression)
{
   try
   {
      string SQL = "SELECT (" + expression + ") AS Result";
      CommandHelper cmd = _Database.CreateCommand(SQL);
      return ConvertEx.ToFloat(_Database.ExecuteScalar(SQL));
   }
   catch
   {
      return DBNull.Value;
   }
}

/// <summary>
/// SQL测试表达式
/// </summary>
/// <param name="expression">表达式</param>
/// <param name="result"></param>
/// <returns></returns>
public bool TestFormula(string expression, out float result)
{
   result = 0;
   try
   {
      string SQL = "SELECT (" + expression + ") AS Result";
      CommandHelper cmd = _Database.CreateCommand(SQL);
      result = ConvertEx.ToFloat(_Database.ExecuteScalar(SQL));
      return true;
   }
   catch
   {
      return false;
   }
}

//来源:C/S框架网(www.csframework.com) QQ:23404761




VIP下载源码:


点击下载附件 (VIP会员下载) 点击下载附件 (如下载失败,请邮件通知我们寄回给您,或QQ:23404761留言.)
上一篇 下一篇