public static string CheckCancel(string auto_id)
        {
            string mes = string.Empty;
这里我想添加一个条件 这个条件也是要通过sql查询出来的,如果 IF_check = 1 则执行下面的update 
            string sql = " update check_hg_gj set IF_CANCEL = 1  where auto_id='" + auto_id + "'";
            try
            {
                ECI.PL.Query.ProcessSql(sql);
            }
            catch
            {
                mes = "操作失败!";
                return mes;
            }
如果  IF_check = 0 则执行
  {
                mes = "已经锁定不允许update!";
                return mes;
            }
            return mes;
        }

解决方案 »

  1.   

    感觉LZ说的很抽象,不是很懂LZ的意思。请LZ说具体点。
      

  2.   

    楼主要的大概是下的这个样子吧
    public static string CheckCancel(string auto_id)
      {
      string mes = string.Empty;
      _check = 从数据库查询出来地;
      if( _check  == 1)
      {
          string sql = " update check_hg_gj set IF_CANCEL = 1 where auto_id='" + auto_id + "'";
          try
          {
              ECI.PL.Query.ProcessSql(sql);
          }
          catch
          {
            mes = "操作失败!";        
          }      
      }
      else
      {
           mes = "已经锁定不允许update!";           
      } 
      return mes;
      }
      

  3.   

    将数据读出来再做判断就行如果不用什么特定消息则直接在sql语句里面带条件,然后判断更新的行数。(前提是没有其他触发器影响这个受影响行数的值) string sql = " update check_hg_gj set IF_CANCEL = 1 where auto_id='" + auto_id + "' and IF_check=1";
      

  4.   

    public static string CheckCancel(string auto_id)
      {
      string mes = string.Empty;
      string _check=check();//你写个查询方法,查询_check的值
      if(_check==1) 
      string sql = " update check_hg_gj set IF_CANCEL = 1 where auto_id='" + auto_id + "'";
      try
      {
      ECI.PL.Query.ProcessSql(sql);
      }
      catch
      {
      mes = "操作失败!";
      return mes;
      }
    if(_check == 0)
      {
      mes = "已经锁定不允许update!";
      return mes;
      }
      return mes;
      } 
    //查询方法如下
    public string check()
    {
     string sql="select _check from 表名";
     return "查询出来的值";
    }
    思路就是这样。