⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uadoset.~pas

📁 这是一个啤酒行业的软件
💻 ~PAS
📖 第 1 页 / 共 5 页
字号:
              for i:=0 to  _FParamList.count-1 do
              begin
                  ///if Fields[i+1].DataType=ftString then
                  ///begin
                     Parameters[i].value:=_FParamList[i];
                  ///end;   
              end;
           end
           else
           begin
              showmessage('parameter error');
              exit;
           end;

           prepared;
           open;
           if Recordcount<>0 then
           begin
              result:=fields[0].AsInteger;
           end
           else
              result:=0;

       end;
    Finally
       _FQuery.Close;
    end;
end;
{
  功能:
  参数:
  用法:
}
Function TuAdoSet.getRecordCount(_Sql:string;paramValues:TStringList):integer;
      Function getSqlString:string;
      var
         _selectPos:integer;
         _fromPos:integer;
         _newSql:string;
      begin
        if _Sql<>'' then
        begin
           _selectPos:=pos('select',trim(_Sql));
           _fromPos:=pos('from',trim(_Sql));
           _newSql:=copy(trim(_Sql),_selectPos,6)+'  Count(*)  '+copy(trim(_Sql),_fromPos,length(trim(_Sql))-9);
           result:=_newSql;
        end
        else
        begin
           result:='';
        end;
      end;
var
    i:integer;
begin
    
    try
       with _FQuery  do
       begin
           if _FDbType=1 then
           begin
              ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID='+trim(_FLoginID)+';Initial Catalog='+_FdbName+';Data Source='+trim(_FserverName)+'';
           end;
           if _FDbType=2 then
           begin
              ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+_FDbName+';Persist Security Info=False';
           end;
           Close;
           Sql.Clear;
           //Sql.Text:=trim(_Sql);
           ///showmessage(getsqlstring);
           if getSqlString='' then
           begin
              showmessage('sql语句错误...');
              exit;
           end;
           Sql.Text:=getSqlString;
           if _str.getSubStringCount(':',getSqlString)<>paramValues.Count then
           begin
              showmessage('参数的个数不匹配...');
              exit;
           end;
           if paramValues=nil then
           begin
              exit;
           end;
           if paramValues.Count<>0 then
           begin
              for i:=0 to  paramValues.count-1 do
              begin
                  ///if Fields[i+1].DataType=ftString then
                  ///begin
                     Parameters[i].value:=paramValues[i];
                  ///end;   
              end;
           end
           else
           begin
           end;

           prepared;
           open;
           if Recordcount<>0 then
           begin
              result:=fields[0].AsInteger;
           end
           else
              result:=0;

       end;
    Finally
       _FQuery.Close;
    end;
end;
{
  功能:
  参数:
  用法:
}
Function TuAdoset.getRecordCount(_TableName:string):integer;
begin
    try
       with _FQuery do
       begin
           if _FDbType=1 then
           begin
              ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID='+trim(_FLoginID)+';Initial Catalog='+_FdbName+';Data Source='+trim(_FserverName)+'';
           end;
           if _FDbType=2 then
           begin
              ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+_FDbName+';Persist Security Info=False';
           end;
           Close;
           Sql.Clear;
           Sql.Text:='select count(*) as _count From  '+trim(_TableName)+'';
           prepared;
           open;
           if Recordcount<>0 then
           begin
              result:=fields[0].AsInteger;
           end
           else
              result:=0;

       end;
    Finally
       _FQuery.Close;
    end;
end;
{
  功能:
  参数:
  用法:
}
Function TuAdoSet.isRecordExist:boolean;
begin
      if getRecordCount>0 then
      begin
         result:=true;
      end
      else
      begin
         result:=false;
      end;
end;
{
  功能:
  参数:
  用法:
}
Function TuAdoSet.isRecordExist(_Sql:string;paramValues:TStringList):boolean;
begin
      if getRecordCount(_Sql,paramValues)>0 then
      begin
         result:=true;
      end
      else
      begin
         result:=false;
      end;
end;
{
  功能:
  参数:
  用法:
}
procedure TuAdoSet.FillControl(_ctrl:TControl;_Sql:string;paramValues:TStringList;FieldName:string);
var
   i:integer;
begin
   if (_ctrl is TCombobox) then
   begin
       Tcombobox(_ctrl).Clear;
       try
           with _FQuery do
           begin
               if _FDbType=1 then
               begin
                  ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID='+trim(_FLoginID)+';Initial Catalog='+_FdbName+';Data Source='+trim(_FserverName)+'';
               end;
               if _FDbType=2 then
               begin
                  ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+_FDbName+';Persist Security Info=False';
               end;
               Close;
               Sql.Clear;
               if _Sql='' then
               begin
                 showmessage('sql语句错误...');
                 exit;
               end;
               Sql.Text:=trim(_Sql);
               if _str.getSubStringCount(':',_Sql)<>paramValues.Count then
               begin
                  showmessage('参数的个数不匹配...');
                  exit;
               end;
               if paramValues=nil then
               begin
                  exit;
               end;
               if paramValues.Count<>0 then
               begin
                  for i:=0 to  paramValues.count-1 do
                  begin
                      Parameters[i].value:=paramValues[i];
                  end;
               end
               else
               begin
               end;

               prepared;
               open;
               if Recordcount<>0 then
               begin
                  while not eof do
                  begin
                      TCombobox(_ctrl).Items.Add(FieldByName(FieldName).AsString);
                      next;
                  end;///while
               end;//if


           end;//with
       Finally
          _FQuery.Close;
       end;
   end;////if(ctrl is Tcombobox)
   if (_ctrl is TListbox) then
   begin
       TListbox(_ctrl).Clear;
       try
           with _FQuery do
           begin
               if _FDbType=1 then
               begin
                  ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID='+trim(_FLoginID)+';Initial Catalog='+_FdbName+';Data Source='+trim(_FserverName)+'';
               end;
               if _FDbType=2 then
               begin
                  ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+_FDbName+';Persist Security Info=False';
               end;
               Close;
               Sql.Clear;
               if _Sql='' then
               begin
                  showmessage('sql语句错误...');
                  exit;
               end;
               Sql.Text:=trim(_Sql);
               if _str.getSubStringCount(':',_Sql)<>paramValues.Count then
               begin
                  showmessage('参数的个数不匹配...');
                  exit;
               end;
               if paramValues=nil then
               begin
                  exit;
               end;
               if paramValues.Count<>0 then
               begin
                  for i:=0 to  paramValues.count-1 do
                  begin
                      Parameters[i].value:=paramValues[i];
                  end;
               end
               else
               begin
               end;

               prepared;
               open;
               if Recordcount<>0 then
               begin
                  while not eof do
                  begin
                      TListbox(_ctrl).Items.Add(FieldByName(FieldName).AsString);
                      next;
                  end;///while
               end;//if


           end;//with
       Finally
          _FQuery.Close;
       end;

   end;////if(ctrl is TListbox)
end;
{
  功能:
  参数:
  用法:
}
procedure TuAdoSet.FillControl(_ctrl:TControl;FieldName:string);
var
    i,j:integer;
begin
   if (_ctrl is TCombobox) then
   begin
       Tcombobox(_ctrl).Clear;
       try
           with _FQuery do
           begin
               if _FDbType=1 then
               begin
                  ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID='+trim(_FLoginID)+';Initial Catalog='+_FdbName+';Data Source='+trim(_FserverName)+'';
               end;
               if _FDbType=2 then
               begin
                  ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+_FDbName+';Persist Security Info=False';
               end;
               Close;
               Sql.Clear;
               if _FSqlString='' then
               begin
                 showmessage('sql语句错误...');
                 exit;
               end;
               Sql.Text:=trim(_FSqlString);
               if _str.getSubStringCount(':',_FSqlString)<>_FParamList.Count then
               begin
                  showmessage('参数的个数不匹配...');
                  exit;
               end;
               if _FParamList=nil then
               begin
                  exit;
               end;
               if _FParamList.Count<>0 then
               begin
                  for i:=0 to  _FParamList.count-1 do
                  begin
                      Parameters[i].value:=_FParamList[i];
                  end;
               end
               else
               begin
               end;

               prepared;
               open;
               if Recordcount<>0 then
               begin
                  while not eof do
                  begin
                      TCombobox(_ctrl).Items.Add(FieldByName(FieldName).AsString);
                      next;
                  end;///while
               end;//if


           end;//with
       Finally
          _FQuery.Close;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -