📄 scgdzc.~pas
字号:
unit scgdzc;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Grids, DBGrids, Buttons, StdCtrls, DB;
type
TForm10 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Label1: TLabel;
ComboBox1: TComboBox;
SpeedButton1: TSpeedButton;
DBGrid1: TDBGrid;
Panel3: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
DataSource1: TDataSource;
procedure BitBtn2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form10: TForm10;
czbh: String;
implementation
uses Dataz;
{$R *.dfm}
procedure TForm10.BitBtn2Click(Sender: TObject);
begin
ComboBox1.Text := '';
DataSource1.DataSet := Nil;
BitBtn1.Enabled := False;
end;
procedure TForm10.FormShow(Sender: TObject);
begin
ComboBox1.Clear;
with Daz.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select distinct 固定资产名称 From 固定资产信息表');
Open;
end;
if Daz.ADOQuery1.RecordCount >0 then
begin
while Not Daz.ADOQuery1.Eof do
begin
ComboBox1.Items.Add(Daz.ADOQuery1.FieldByName('固定资产名称').Value);
Daz.ADOQuery1.Next;
end;
end;
BitBtn2.OnClick(Sender);
end;
procedure TForm10.SpeedButton1Click(Sender: TObject);
begin
if Trim(ComboBox1.Text)<>'' then
begin
with Daz.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 固定资产信息表 where 固定资产名称 = :a');
Parameters.ParamByName('a').Value := Trim(ComboBox1.Text);
Open;
end;
if Daz.ADOQuery2.RecordCount>0 then
begin
DataSource1.DataSet := Daz.ADOQuery2;
BitBtn1.Enabled := True;
czbh := Daz.ADOQuery2.FieldByName('固定资产编号').Value;
end
else
begin
DataSource1.DataSet := Nil;
BitBtn1.Enabled := False;
end;
end;
end;
procedure TForm10.BitBtn1Click(Sender: TObject);
begin
if Application.MessageBox('确实要删除固定资产信息吗?','提示',MB_YesNo)= ID_Yes then
begin
Try
Daz.ADOConnection1.BeginTrans;
with Daz.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('delete 固定资产减少表 where 固定资产编号 = :a');
Parameters.ParamByName('a').Value := Trim(czbh);
ExecSQL;
end;
with Daz.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('delete 固定资产信息表 where 固定资产编号 = :a');
Parameters.ParamByName('a').Value := Trim(czbh);
ExecSQL;
end;
Daz.ADOConnection1.CommitTrans;
self.OnShow(Sender);
Application.MessageBox('操作成功。','提示',64);
Except
Daz.ADOConnection1.RollbackTrans;
Application.MessageBox('操作失败。','提示',64);
end;
end;
end;
procedure TForm10.DBGrid1CellClick(Column: TColumn);
begin
if Daz.ADOQuery2.Active = True then
if Daz.ADOQuery2.RecordCount >0 then
czbh := Daz.ADOQuery2.FieldByName('固定资产编号').Value;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -