码迷,mamicode.com
首页 > 其他好文 > 详细

修改类别 (类实现)两种方法

时间:2017-06-23 18:27:17      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:final   .class   winapi   int   nts   variant   dbgrideh   log   public   

unit UUpdateLeiBie;

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, Vcl.Buttons;

type TUpdateLeiBie=class
  public
  class procedure updateselectedleibie(var combox:TComboBox; SAdq:TADOQuery);
  class procedure updateselectedleibierequery(var SAdq:TADOQuery);
end;

implementation
/// <summary>
/// 通过打开窗口combobox下拉选择修改
/// </summary>

uses FDataPool, Uleibie;
class procedure TUpdateLeiBie.updateselectedleibie(var combox:TComboBox; SAdq:TADOQuery);
var
MyAdoq:TADOQuery;
LeiBie,SBiao: string;
begin
  MyAdoq := TADOQuery.Create(nil);
  SBiao:=copy(SAdq.name,4,length(SAdq.name)-3);
  try
    MyAdoq.Connection := frmDataPool.ADOConnection1;
    LeiBie:=combox.text;
    with MyAdoq do
    begin
      Close;
      SQL.Text := UPDATE +SBiao+ SET 类别 =+ LeiBie.QuotedString+where 选中 = true;
      ExecSQL;
    end;
    //防止程序假死
    Application.ProcessMessages;

    //刷新纪录
  SAdq.Requery;

  finally
    MyAdoq.Free;
  end;

end;

/// <summary>
/// 通过requery窗口询问写法类实现
/// </summary>
class procedure TUpdateLeiBie.updateselectedleibierequery(var SAdq: TADOQuery);
var
 LeiBie,SBiao: string;
 SAdoq:TADOQuery;
begin
 SAdoq:=TADOQuery.Create(nil);
 SAdoq.Connection:=frmDataPool.ADOConnection1;
 SBiao:=copy(SAdq.name,4,length(SAdq.name)-3);
 try
  //或许比例数值
  if not InputQuery(修改类别, 请输入类别, LeiBie) then
  begin
    ShowMessage(请输入类别);
    Exit;
  end;
  with SAdoq do
  begin
    Close;
    SQL.Text:=UPDATE +SBiao+ SET 类别 =+LeiBie.QuotedString+WHERE 选中 = true;
    ExecSQL;
  end;
  //防止程序假死
  Application.ProcessMessages;
  //刷新纪录显示
  SAdq.Requery();
 finally
  SAdoq.Free;
 end;
end;
end.

 

修改类别 (类实现)两种方法

标签:final   .class   winapi   int   nts   variant   dbgrideh   log   public   

原文地址:http://www.cnblogs.com/ddxxxb/p/7071032.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!