📄 kccxgl.~pas
字号:
unit kccxgl;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Grids, DBGrids, Buttons, DB;
type
TForm16 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Label1: TLabel;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
SpeedButton1: TSpeedButton;
DBGrid1: TDBGrid;
Panel3: TPanel;
CheckBox1: TCheckBox;
Label4: TLabel;
Label2: TLabel;
Label3: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn8: TBitBtn;
DataSource1: TDataSource;
Shape3: TShape;
Label5: TLabel;
Label6: TLabel;
Shape1: TShape;
procedure ComboBox1Change(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure ComboBox1KeyPress(Sender: TObject; var Key: Char);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormShow(Sender: TObject);
procedure ComboBox2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure DBGrid1CellClick(Column: TColumn);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form16: TForm16;
implementation
uses datamodal;
{$R *.dfm}
procedure TForm16.ComboBox1Change(Sender: TObject);
begin
if Trim(ComboBox1.Text)<> ''then
begin
ComboBox2.Clear;
with Data.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select distinct');
SQL.Add(Trim(ComboBox1.Text));
SQL.Add('From 库存表');
Open;
end;
while Not Data.ADOQuery1.Eof do
begin
ComboBox2.Items.Add(Data.ADOQuery1.Fields[0].value);
Data.ADOQuery1.Next;
end;
end;
end;
procedure TForm16.SpeedButton1Click(Sender: TObject);
begin
if (Trim(ComboBox2.Text) <>'')and(Trim(ComboBox1.Text)<>'')then
begin
CheckBox1.Checked := False;
with Data.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('select * From 库存表 where ');
SQL.Add(Trim(ComboBox1.Text));
SQL.Add('=');
SQL.Add(':a');
Parameters.ParamByName('a').Value := Trim(ComboBox2.Text);
Open;
end;
if Data.ADOQuery2.RecordCount >0 then
begin
DataSource1.DataSet := Data.ADOQuery2;
label5.Caption := IntToStr(Data.ADOQuery2.FieldByName('库存数量').Value);
label6.Caption := FloatToStr(Data.ADOQuery2.FieldByName('库存金额').Value);
end;
end;
end;
procedure TForm16.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked = True then
begin
with Data.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add(' select * from 库存表');
Open;
end;
DataSource1.DataSet := Data.ADOQuery2;
label5.Caption := IntToStr(Data.ADOQuery2.FieldByName('库存数量').Value);
label6.Caption := FloatToStr(Data.ADOQuery2.FieldByName('库存金额').Value);
end;
end;
procedure TForm16.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
key := #0;
end;
procedure TForm16.BitBtn2Click(Sender: TObject);
begin
if Not Data.ADOQuery2.Eof then
Data.ADOQuery2.Next;
label5.Caption := IntToStr(Data.ADOQuery2.FieldByName('库存数量').Value);
label6.Caption := FloatToStr(Data.ADOQuery2.FieldByName('库存金额').Value);
end;
procedure TForm16.BitBtn1Click(Sender: TObject);
begin
if Not Data.ADOQuery2.Bof then
Data.ADOQuery2.Prior;
label5.Caption := IntToStr(Data.ADOQuery2.FieldByName('库存数量').Value);
label6.Caption := FloatToStr(Data.ADOQuery2.FieldByName('库存金额').Value);
end;
procedure TForm16.BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
TBitBtn(Sender).Font.Color := clRed;
end;
procedure TForm16.BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
TBitBtn(Sender).Font.Color := clBlue;
end;
procedure TForm16.FormShow(Sender: TObject);
begin
ComboBox1.Text := '';
ComboBox2.Clear;
DataSource1.DataSet := nil;
Label5.Caption := '';
Label6.Caption := '';
CheckBox1.Checked := False;
end;
procedure TForm16.ComboBox2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
SpeedButton1.OnClick(Sender);
end;
procedure TForm16.ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Trim(ComboBox1.Text)<>'' then
if Key = VK_Right then
ComboBox2.SetFocus;
end;
procedure TForm16.DBGrid1CellClick(Column: TColumn);
begin
if Data.ADOQuery2.Active = True then
if Data.ADOQuery2.RecordCount>0 then
begin
Label5.Caption := IntToStr(Data.ADOQuery2.FieldByName('库存数量').Value);
Label6.Caption := FloatToStr(Data.ADOQuery2.FieldByName('库存金额').Value);
End;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -