【delphi开源代码栏目提醒】:网学会员在delphi开源代码频道为大家收集整理了Cpxx.pas提供大家参考,希望对大家有所帮助!
unit Cpxx;
interface
uses
Windows, SysUtils, Variants, Classes, Controls, Forms, Dialogs, DB, Grids,
DBGrids, StdCtrls, ExtCtrls, dmXsgl, XSGLCommon, CpAdd, Basefrm;
type
TCpxxForm = class(TBaseForm)
procedure btAddClick(Sender: TObject);
procedure btDelClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent; AdmXSGL: TdmXsgl); overload;
end;
implementation
{$R *.dfm}
constructor TCpxxForm.Create(AOwner: TComponent; AdmXSGL: TdmXsgl);
begin
inherited Create(AOwner, AdmXSGL);
FdmXsgl := AdmXSGL;
with FdmXsgl, adotXSGLFields do
begin
Filtered := False;
Filter := 'GridName = ''Cpxx''';
Filtered := True;
InitDBGrid(adotXSGLFields, dbGrid);
end;
datasource.DataSet := FdmXsgl.adotCpxx;
end;
procedure TCpxxForm.btAddClick(Sender: TObject);
begin
inherited;
with TCpAddForm.Create(nil, FdmXSGL) do
try
ShowModal;
finally
Free;
end;
end;
procedure TCpxxForm.btDelClick(Sender: TObject);
begin
inherited;
if Application.MessageBox('是否删除此记录?', '确认', 1) = 1 then
begin
// 查询是否有订单使用了该产品,如有则不能删除
with FdmXsgl, adoqCommon do
try
Close;
Sql.Text := 'Select CPBM from DDMX where CPBM = ' +
QuotedStr(adotCpxx.FieldByName('CPBM').AsString);
Open;
if Recordcount > 0 then
Application.MessageBox('产品信息已被使用,不能删除!', '提示')
else
adotCpxx.Delete;
Close;
finally
Free;
end;
end;
end;
end.