修改类别 (类实现)两种方法
Posted delphi学习交流吧
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了修改类别 (类实现)两种方法相关的知识,希望对你有一定的参考价值。
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.
以上是关于修改类别 (类实现)两种方法的主要内容,如果未能解决你的问题,请参考以下文章
《java精品毕设》基于javaweb宠物领养平台管理系统(源码+毕设论文+sql):主要实现:个人中心,信息修改,填写领养信息,交流论坛,新闻,寄养信息,公告,宠物领养信息,我的寄养信息等(代码片段