全不选

方法1:单击事件写法:

 

procedure TForm3.N9Click(Sender: TObject);

 begin
 with frmDataPool.qry需要做的事 do
 begin
 Close;
 SQL.Text :='UPDATE 需要做的事 SET 选中 = 0';
 ExecSQL;
 end;
     //防止程序假死
 // Application.ProcessMessages;
//  //刷新下显示
// with sAqry do
// begin
// Close;
// SQL.Text :='select * from ' + SBiao ;
// Open;
// end;
TInitializeDatabaseAdoSqlApi.accessAdoToSql(frmDataPool.qry需要做的事);
 end;

 

 

 

方法2:类写法:

unit UUnSelectAll;

interface
uses  FDataPool, Data.DB, Data.Win.ADODB, Vcl.Menus,  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls,
  Vcl.ExtCtrls, Vcl.DBCtrls, Vcl.Grids, Vcl.DBGrids, Clipbrd,
  Vcl.StdCtrls;
/// <summary>
/// 全选更新所有记录选中值为0
/// </summary>
type TUnSeleteAll=class
 public
 class procedure unSelectAllRecord (var sAqry:TADOQuery);
end;
implementation
uses 日常管理助手, UInitializeDatabaseAdoSqlApi;
 class procedure TUnSeleteAll.unSelectAllRecord(var sAqry:TADOQuery);
 var
 SBiao: string;
 begin
 SBiao:=copy(sAqry.name,4,length(sAqry.name)-3);
 with sAqry do
 begin
 Close;
 SQL.Text :='UPDATE ' + SBiao + ' SET 选中 = 0';
 ExecSQL;
 end;
     //防止程序假死
 Application.ProcessMessages;
//  //刷新下显示
// with sAqry do
// begin
// Close;
// SQL.Text :='select * from ' + SBiao ;
// Open;
// end;
TInitializeDatabaseAdoSqlApi.accessAdoToSql(sAqry);
 end;
end.

 

类引用:注意别忘记uses语句中添加引用类的单元名;(uses UUnSelectAll ;)

procedure TForm3.N9Click(Sender: TObject);
begin
TUnSeleteAll.unSelectAllRecord(frmDataPool.qry需要做的事);//全不选记录,更改选中列为0

end;

 

posted @ 2017-06-21 19:22  delphi学习交流吧  阅读(141)  评论(0编辑  收藏  举报