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

📄 uadoset.pas

📁 这是delphi7.0开发的人力资源培训考核软件
💻 PAS
📖 第 1 页 / 共 3 页
字号:
            sql.Text:=strSql;
            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;
            ExeCSql;
        end;//with
     Finally
        AdoQuery.Close;
     end;
end;////
/////做数据表进行更新操作//////////////////////////////////
procedure UpdateRecord(AdoQuery:TAdoQuery;strSql:string;paramValues:TStringList);
var
    i:integer;
begin
    with AdoQuery do
    begin
        try
            ConnectionString:=ConnectToDatabase(2);
            close;
            sql.clear;
            sql.Text:=strSql;
            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;
            ExeCSql;
        Finally
            AdoQuery.Close;
        end;
    end;//with
end;////
/////惊醒存盘///////////////////////////////////////////
procedure SaveRecord(AdoQuery:TAdoQuery;strSql:string;paramValues:TStringList);
var
   i:integer;
begin
    with AdoQuery do
    begin
        try
           ConnectionString:=ConnectToDatabase(2);
           close;
           sql.clear;
           sql.Text:=strSql;
           for i:=0 to  paramValues.count-1 do
           begin
               Parameters[i].value:=paramValues[i];
           end;
           prepared;
           ExeCSql;
        Finally
           AdoQuery.Close;
        end;
    end;//with
end;///
/////将数据绑顶到控件////////////////////////////////////
procedure BindToGrid1(AdoQuery:TAdoQuery;strSql:string;Ctrl:TControl);
var
    i:integer;
    j:integer;
    ListItem:TListItem;
begin
   try
    with Adoquery  do
    begin
         ConnectionString:=ConnectToDatabase(2);
         try
            close;
         except
            ON E:exception do
            begin
               exit;
            end;
         end;
         sql.clear;
         ///strSql:='SELECT * FROM    '+TableName+'   WHERE  '+FieldName+'=:'+FieldName;
         Sql.Text:=strSql;
         prepared;
         Open;

         if RecordCount<>0 then
         begin
          ///1./////将数据绑定到控件EasyGrid////////
             if (ctrl is TEasyGrid) then
             begin
                //////清空表格中的数据////////////////
                for j:=2 to TEasyGrid(ctrl).RowCount-2 do
                begin
                    for i:=1 to TEasyGrid(ctrl).ColCount-1 do
                    begin
                        TEasyGrid(ctrl).Cells[i,j].ForeText:='';
                    end;///i
                end;///j
                ///////////////////////////////////////
               first;
               //////////////////////////////////////
               TEasyGrid(ctrl).ColCount:=FieldList.Count+1;
               TEasyGrid(ctrl).RowCount:=Recordcount+2;
               j:=1;
               while (not eof) and (j<=Recordcount)  do
               begin
                   for i:=0 to FieldList.Count-1 do
                   begin
                       TEasyGrid(ctrl).Cells[i+1,j+1].ForeText:=FieldByName(FieldDefList[i].Name).asstring;
                   end;
                   next;
                   inc(j);
                end;///while
                TEasyGrid(ctrl).Refresh;
              end;///if (ctrl is)结束
           ///2.将数据绑定到控件stringGrid///////////////////////////////////
             if (ctrl is TStringGrid) then
             begin
                //////清空表格中的数据////////////////
                for j:=1 to TStringGrid(ctrl).RowCount-2 do
                begin
                    for i:=1 to TStringGrid(ctrl).ColCount-1 do
                    begin
                        TStringGrid(ctrl).Cells[i,j]:='';
                    end;///i
                end;///j
                ///////////////////////////////////////
               first;
               //////////////////////////////////////
               TStringGrid(ctrl).ColCount:=FieldList.Count+1;
               TStringGrid(ctrl).RowCount:=Recordcount+2;
               j:=1;
               while (not eof) and (j<=Recordcount)  do
               begin
                   for i:=0 to FieldList.Count-1 do
                   begin
                       TStringGrid(ctrl).Cells[i+1,j]:=FieldByName(FieldDefList[i].Name).asstring;
                   end;
                   next;
                   inc(j);
                end;///while
                ///TEasyGrid(ctrl).Refresh;
              end;///if 结束
           ////2.结束//////////////////////////////////////////////////////////////
           ////3.将数据绑定到控件ListView///////////////////////////////////////////
              if (ctrl is TListView) then
              begin
                 TListView(ctrl).Clear;
                 //FieldIndex:=0;
                 first;
                 while not eof  do
                 begin
                    listitem:=TlistView(ctrl).Items.Add;
                    for i:=0 to FieldList.Count-2 do
                    begin
                        //listitem.Caption:=FieldValues[FieldDefList[0].Name];
                        if not  FieldbyName(FieldDefList[i+1].Name).IsNull then
                        begin
                           listitem.SubItems.Add(FieldValues[FieldDefList[i+1].Name]);
                        end;
                    end;//for
                    next;
                    end;///while
              end;///if(ctrl is Listview)结束///
           ////3.结束///////////////////////////////////////////////////////////////
           end;////if
      end; //with
    Finally
       AdoQuery.Close;
    end;
end;/////
////将符合条件的记录显示记录集///////////////////////////
procedure BindToGrid(AdoQuery:TAdoQuery;strSql:string;paramValues:TStringList;Ctrl:TControl);
var
    i:integer;
    j:integer;
    ListItem:TListItem;
begin
    try
      with Adoquery  do
      begin
         ConnectionString:=ConnectToDatabase(2);
         try
            close;
         except
            ON E:exception do
            begin
               exit;
            end;
         end;
         sql.clear;
         ///strSql:='SELECT * FROM    '+TableName+'   WHERE  '+FieldName+'=:'+FieldName;
         Sql.Text:=strSql;
         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
          ///1./////将数据绑定到控件EasyGrid////////
             if (ctrl is TEasyGrid) then
             begin
                //////清空表格中的数据////////////////
                for j:=2 to TEasyGrid(ctrl).RowCount-2 do
                begin
                    for i:=1 to TEasyGrid(ctrl).ColCount-1 do
                    begin
                        TEasyGrid(ctrl).Cells[i,j].ForeText:='';
                    end;///i
                end;///j

                ///////////////////////////////////////
               first;
               //////////////////////////////////////
               TEasyGrid(ctrl).ColCount:=FieldList.Count+1;
               TEasyGrid(ctrl).RowCount:=Recordcount+3;
               j:=1;
               while (not eof) and (j<=Recordcount)  do
               begin
                    ////showmessage('asas');
                   for i:=0 to FieldList.Count-1 do
                   begin
                       ////showmessage(FieldByName(FieldDefList[i].Name).asstring);
                       TEasyGrid(ctrl).Cells[i+1,j+1].ForeText:=trim(FieldByName(FieldDefList[i].Name).asstring);
                   end;
                   next;
                   inc(j);
                end;///while
                TEasyGrid(ctrl).Refresh;
              end;///if (ctrl is)结束
           ///2.将数据绑定到控件stringGrid///////////////////////////////////
             if (ctrl is TStringGrid) then
             begin
                //////清空表格中的数据////////////////
                for j:=1 to TStringGrid(ctrl).RowCount-2 do
                begin
                    for i:=1 to TStringGrid(ctrl).ColCount-1 do
                    begin
                        TStringGrid(ctrl).Cells[i,j]:='';
                    end;///i
                end;///j
                ///////////////////////////////////////
               first;
               //////////////////////////////////////
               TStringGrid(ctrl).ColCount:=FieldList.Count+1;
               TStringGrid(ctrl).RowCount:=Recordcount+2;
               j:=1;
               while (not eof) and (j<=Recordcount)  do
               begin
                   for i:=0 to FieldList.Count-1 do
                   begin
                       TStringGrid(ctrl).Cells[i+1,j]:=FieldByName(FieldDefList[i].Name).asstring;
                   end;
                   next;
                   inc(j);
                end;///while
                ///TEasyGrid(ctrl).Refresh;
              end;///if 结束
           ////2.结束//////////////////////////////////////////////////////////////
           ////3.将数据绑定到控件ListView///////////////////////////////////////////
              if (ctrl is TListView) then
              begin
                 TListView(ctrl).Clear;
                 //FieldIndex:=0;
                 first;
                 while not eof  do
                 begin
                    listitem:=TlistView(ctrl).Items.Add;
                    for i:=0 to FieldList.Count-2 do
                    begin
                        //listitem.Caption:=FieldValues[FieldDefList[0].Name];
                        if not  FieldbyName(FieldDefList[i+1].Name).IsNull then
                        begin
                           listitem.SubItems.Add(FieldValues[FieldDefList[i+1].Name]);
                        end;
                    end;//for
                    next;
                    end;///while
              end;///if(ctrl is Listview)结束///
           ////3.结束///////////////////////////////////////////////////////////////
           end;////if
        end; //with
     Finally
        AdoQuery.Close;
     end;
end;////
//////得到某一字段值/////////////////////////////////
Function getFieldValue(AdoQuery:TAdoQuery;strSql:string;paramValues:TStringList;FieldName:string):variant;
var
   i:integer;
begin
    ///FieldName:=TStringList.Create;
    try
       with Adoquery  do
       begin
           ConnectionString:=ConnectToDatabase(2);
           try
              close;
           except
              ON E:exception do
              begin
                 exit;
              end;
           end;
           sql.clear;
           ///strSql:='SELECT * FROM    '+TableName+'   WHERE  '+FieldName+'=:'+FieldName;
           Sql.Text:=strSql;
           if paramValues.Count<>0 then
           begin
              for i:=0 to  paramValues.count-1 do
              begin
                  Parameters[i].value:=paramValues[i];
              end;
           end
           else

⌨️ 快捷键说明

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