?? yhzhgl.pas
字號:
unit yhzhgl;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Buttons, ImgList, ToolWin, ComCtrls, StdCtrls, Grids;
type
TForm10 = class(TForm)
Panel1: TPanel;
StringGrid1: TStringGrid;
Panel2: TPanel;
Label1: TLabel;
Label3: TLabel;
ComboBox1: TComboBox;
Label2: TLabel;
Label4: TLabel;
Edit3: TEdit;
Panel3: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
Label6: TLabel;
Shape3: TShape;
Label7: TLabel;
Shape1: TShape;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Edit3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ComboBox1Change(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure Clear;
procedure Edit3KeyPress(Sender: TObject; var Key: Char);
procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form10: TForm10;
Yhzh : array[0..10]of String;
nsr: String;//記錄納稅人
implementation
uses data2;
{$R *.dfm}
procedure TForm10.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[0,0]:= ' 往來單位';
StringGrid1.Cells[1,0]:= ' 開戶銀行';
StringGrid1.Cells[2,0]:= ' 銀行賬號';
StringGrid1.Cells[3,0]:= ' 存款金額';
StringGrid1.Cells[4,0]:= ' 納 稅 人';
end;
procedure TForm10.FormShow(Sender: TObject);
begin
with Datam.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 客戶基礎(chǔ)信息表');
Open;
end;
While Not Datam.ADOQuery1.Eof do
begin
ComboBox1.Items.Add(Datam.ADOQuery1.FieldByName('客戶全稱').AsString);
Datam.ADOQuery1.Next;
end;
ComboBox1.SetFocus;
end;
procedure TForm10.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
BitBtn1.Font.Color := clBlue;
BitBtn2.Font.Color := clBlue;
BitBtn3.Font.Color := clBlue;
end;
procedure TForm10.Edit3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Trim(Edit3.Text)<>'')and(key = VK_RETurn) then
BitBtn1.SetFocus;
end;
procedure TForm10.ComboBox1Change(Sender: TObject);
begin
with Datam.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 客戶基礎(chǔ)信息表 where 客戶全稱 = :a');
Parameters.ParamByName('a').Value := Trim(ComboBox1.Text);
Open;
end;
label6.Caption := Trim(Datam.ADOQuery1.FieldByName('開戶銀行').Value);
label7.Caption := Trim(Datam.ADOQuery1.FieldByName('銀行賬號').Value);
nsr := Trim(Datam.ADOQuery1.FieldByName('納稅人').Value);
Edit3.Clear;
Edit3.SetFocus;
end;
procedure TForm10.BitBtn1Click(Sender: TObject);
var
m: integer;
begin
for m := 1 to StringGrid1.RowCount -2 do
if Trim(ComboBox1.Text) = Trim(StringGrid1.Cells[0,m]) then
Exit;
if (Trim(ComboBox1.Text)<>'')and(Trim(label6.Caption)<>'')and(Trim(label7.Caption)<>'')
and(Trim(Edit3.Text)<>'')and(Trim(nsr)<>'')then
begin
with Datam.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('Select * from 銀行賬戶管理表 where 往來單位 = :a');
Parameters.ParamByName('a').Value := ComboBox1.Text;
Open;
end;
if Datam.ADOQuery1.RecordCount <1 then
begin
StringGrid1.Cells[0,StringGrid1.RowCount -1]:= ComboBox1.Text;
StringGrid1.Cells[1,StringGrid1.RowCount -1]:= label6.Caption;
StringGrid1.Cells[2,StringGrid1.RowCount -1]:= label7.Caption;
StringGrid1.Cells[3,StringGrid1.RowCount -1]:= Edit3.Text;
StringGrid1.Cells[4,StringGrid1.RowCount -1]:= nsr;
StringGrid1.RowCount := StringGrid1.RowCount +1 ;
BitBtn2.Enabled := True;
end
else
Application.MessageBox('該單位在銀行賬戶表中已經(jīng)存在。','提示',0+64);
end
else
Application.MessageBox('項目不能為空。','提示',0+64);
end;
procedure TForm10.BitBtn2Click(Sender: TObject);
var
a,b: integer;
begin
try
For a := 1 to StringGrid1.RowCount -2 do
begin
With Datam.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('insert 銀行賬戶管理表 values (:a ,:b ,:c ,:d ,:e)');
For b := 0 to StringGrid1.ColCount -1 do
Yhzh[b]:= StringGrid1.Cells[b,a];
Parameters.ParamByName('a').Value := Trim(Yhzh[0]);
Parameters.ParamByName('b').Value:= Trim(Yhzh[1]);
Parameters.ParamByName('c').Value:= Trim(Yhzh[2]);
Parameters.ParamByName('d').Value := StrToFloat(Trim(Yhzh[3]));
Parameters.ParamByName('e').Value := Trim(Yhzh[4]);
ExecSQL;
end;
end;
Application.MessageBox('數(shù)據(jù)已經(jīng)成功插入表中','提示',0+64);
Clear;
StringGrid1.RowCount := 2;
BitBtn2.Enabled := False;
Except
Application.MessageBox('系統(tǒng)出錯','提示',0+64);
Close;
end;
end;
procedure TForm10.Clear;
var
a,b: integer;
begin
For a := 1 to StringGrid1.RowCount -1 do
For b := 0 to StringGrid1.ColCount -1 do
StringGrid1.Cells[b,a]:= '';
end;
procedure TForm10.Edit3KeyPress(Sender: TObject; var Key: Char);
var
m: Boolean;
begin
m := (key <#8)or(Key>#8)and(key < #46)or(key>#46)and(key <#48)or(key > #57);
if m then
key := #0;
end;
procedure TForm10.ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Trim(ComboBox1.Text)<>'')and(key = VK_RETurn) then
Edit3.SetFocus;
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -