📄 chang1.pas
字号:
unit chang1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBTables, Buttons, jpeg, ExtCtrls,shellapi;
type
Tchang = class(TForm)
Label6: TLabel;
Label5: TLabel;
Label4: TLabel;
Label3: TLabel;
Label2: TLabel;
Label1: TLabel;
Edit3: TEdit;
Edit2: TEdit;
Edit1: TEdit;
chang: TTable;
changSj: TStringField;
changKg: TStringField;
changCd: TStringField;
Button1: TSpeedButton;
bitbtn1: TSpeedButton;
button2: TSpeedButton;
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure Edit1Change(Sender: TObject);
procedure Edit2Change(Sender: TObject);
procedure Edit3Change(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ForchangmClose(Sender: TObject; var Action: TCloseAction);
procedure FormPaint(Sender: TObject);
procedure Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
chang: Tchang;
implementation
uses quan;
{$R *.dfm}
procedure Tchang.Button2Click(Sender: TObject);
begin
close;
end;
procedure Tchang.FormCreate(Sender: TObject);
begin
chang.Active:=false;
chang.DatabaseName:=s;
chang.TableName:='chang.db';
chang.Active:=true;
edit1.ReadOnly:=false;
edit2.ReadOnly:=false;
edit3.ReadOnly:=false;
button1.Enabled:=false;
end;
procedure Tchang.Button1Click(Sender: TObject);
begin
chang.Active:=true;
chang.Edit;
chang.FieldByName('kg').AsString:=qu.cf( edit1.Text);
chang.FieldByName('sj').AsString:=qu.cf( edit2.Text);
chang.FieldByName('cd').AsString:=qu.cf( edit3.Text);
chang.Post;
close;
end;
procedure Tchang.BitBtn1Click(Sender: TObject);
begin
shellexecute(application.Handle,'open',pchar(s+'\help\ding_zhi.htm'),'','',SW_SHOW);
end;
procedure Tchang.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
edit2.SetFocus;
end;
procedure Tchang.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
edit3.SetFocus;
end;
procedure Tchang.Edit1Change(Sender: TObject);
begin
button1.Enabled:=true;
end;
procedure Tchang.Edit2Change(Sender: TObject);
begin
button1.Enabled:=true;
end;
procedure Tchang.Edit3Change(Sender: TObject);
begin
button1.Enabled:=true;
end;
procedure Tchang.FormShow(Sender: TObject);
begin
ky:='';
chang.Active:=false;
chang.DatabaseName:=s;
chang.TableName:='chang.db';
chang.Active:=true;
edit1.ReadOnly:=false;
edit2.ReadOnly:=false;
edit3.ReadOnly:=false;
if chang.FieldByName('kg').AsString='' then
edit1.Text:='0'
else
edit1.Text:=qu.cf( chang.FieldByName('kg').AsString);
if chang.FieldByName('sj').AsString='' then
edit2.Text:='0'
else
edit2.Text:=qu.cf( chang.FieldByName('sj').AsString);
if chang.FieldByName('cd').AsString='' then
edit3.Text:='0'
else
edit3.Text:=qu.cf( chang.FieldByName('cd').AsString);
button1.Enabled:=false;
end;
procedure Tchang.ForchangmClose(Sender: TObject; var Action: TCloseAction);
begin
chang.Active:=false;
action:=cafree;
end;
procedure Tchang.FormPaint(Sender: TObject);
var a,b:real;
i:integer;
begin
a:=clientheight/256;
b:=0;
for i:=255 downto 0 do
begin
canvas.Brush.Color:=$000000000+i*$10000;
canvas.FillRect(rect(0,round(b),clientwidth,round(a+b)));
b:=b+a;
end;
end;
procedure Tchang.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
ky:=edit1.text;
if edit1.ReadOnly=false then
if (key <>48)and ((key<97) OR (key>105))and (key <>144) and (key <>49)and (key <>8)and (key <>50)and (key <>51)and (key <>52)and (key <>53)and (key <>54)and (key <>55)and (key <>56)and (key <>57)and (key <>13)then
begin
application.MessageBox('此处应输入数字','错误',mb_ok);
edit1.Text:=ky;
edit1.SelStart:=length(ky);
end
else
ky:=edit1.Text;
end;
procedure Tchang.Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
ky:=edit2.text;
if edit2.ReadOnly=false then
if (key <>48)and ((key<97) OR (key>105))and (key <>144) and (key <>49)and (key <>8)and (key <>50)and (key <>51)and (key <>52)and (key <>53)and (key <>54)and (key <>55)and (key <>56)and (key <>57)and (key <>13)then
begin
application.MessageBox('此处应输入数字','错误',mb_ok);
edit2.Text:=ky;
edit2.SelStart:=length(ky);
end
else
ky:=edit2.Text;
end;
procedure Tchang.Edit3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
ky:=edit3.text;
if edit3.ReadOnly=false then
if (key <>48)and ((key<97) OR (key>105))and (key <>144) and (key <>8)and (key <>49)and (key <>50)and (key <>51)and (key <>52)and (key <>53)and (key <>54)and (key <>55)and (key <>56)and (key <>57)and (key <>13)then
begin
application.MessageBox('此处应输入数字','错误',mb_ok);
edit3.Text:=ky;
edit3.SelStart:=length(ky);
end
else
ky:=edit3.Text;
end;
procedure Tchang.FormActivate(Sender: TObject);
begin
chang.Active:=false;
chang.DatabaseName:=s;
chang.TableName:='chang.db';
chang.Active:=true;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -