1. 程式人生 > >修改優先級(類寫法)

修改優先級(類寫法)

ssm ecs span strong windows nec 優先級 引用 orm

定義類:

unit UUpdateYouXianJi;

interface
uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Data.DB, Data.Win.ADODB,
  Vcl.ExtCtrls, Vcl.DBCtrls, Vcl.Grids, Vcl.DBGrids, Clipbrd, Vcl.Menus,
  Vcl.StdCtrls, DBGridEhGrouping, ToolCtrlsEh, DBGridEhToolCtrls, DynVarsEh,
  EhLibVCL, GridsEh, DBAxisGridsEh, DBGridEh,EhLibADO,DBGridEhImpExp;
/// <summary> /// 右擊批量修改優先級 /// </summary> type TUpdateYouXianJi = class public class procedure updateyouxianjiselected(const SValue: string; var SAdq: TADOQuery); end; implementation uses FDataPool, 日常管理助手; class procedure TUpdateYouXianJi.updateyouxianjiselected(const SValue: string; var SAdq: TADOQuery);
var SAdoq:TADOQuery; SBiao: string; begin try SAdoq:=TADOQuery.Create(nil); SAdoq.Connection:=frmDataPool.ADOConnection1; SBiao:=copy(SAdq.name,4,length(SAdq.name)-3); with SAdoq do begin SQL.Text:=UPDATE +SBiao+ SET 優先級 = +SValue.QuotedString+ WHERE 選中 = true; ExecSQL; end; //防止程序假死 Application.ProcessMessages;
//刷新紀錄 SAdq.Requery(); finally SAdoq.Free; end; end; end.

類實現應用:

註意添加引用類的單元名UUpdateYouXianJi

procedure TForm3.N29Click(Sender: TObject);
begin
  //批量更新優先級為高
  TUpdateYouXianJi.updateyouxianjiselected(,frmDataPool.qry需要做的事);
end;


procedure TForm3.N30Click(Sender: TObject);
begin
//批量修改為普通
TUpdateYouXianJi.updateyouxianjiselected(普通,frmDataPool.qry需要做的事);
end;
procedure TForm3.N31Click(Sender: TObject);
begin
//批量修改為低
TUpdateYouXianJi.updateyouxianjiselected(,frmDataPool.qry需要做的事);
end;

修改優先級(類寫法)