📄 unit3.pas
字号:
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons,printers,ExtCtrls;
type
TForm3 = class(TForm)
Image1: TImage;
Edittotal: TEdit;
Edit1: TEdit;
Edit9: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Editmoney: TEdit;
procedure FormShow(Sender: TObject);
procedure EditmoneyKeyPress(Sender: TObject; var Key: Char);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
Function writestring(str:string):integer;
procedure WriteInBase;
private
{ Private declarations }
public
{ Public declarations }
sno:integer;
tmpnumcode:string;
end;
var
Form3: TForm3;
lastsno:string;
procedure stc522open(port1:string);stdcall; external 'stc522.dll'
procedure stc522close(port1:string);stdcall; external 'stc522.dll'
implementation
uses unit2, Unit1,Unit15;
{$R *.DFM}
procedure TForm3.FormShow(Sender: TObject);
begin
edittotal.Text:=mainform.Edit2.text;
edit9.Text:=mainform.Edit3.text;
edit1.text:='';
edit2.text:='';
edit3.text:='';
edit4.text:='';
edit5.text:='';
edit6.text:='';
edit7.text:='';
edit8.Text:='';
editmoney.Text:='';
editmoney.SetFocus;
if mainform.IsShowed then
begin
//客显显示
//使用 COM1。
mainform.MSComm1.CommPort :=1;
//9600 波特,无奇偶校验,8 位数据,一个停止位。
mainform.MSComm1.Settings := '9600,N,8,1';
//当输入占用时,
//告诉控件读入整个缓冲区。
mainform.MSComm1.InputLen := 0;
//打开端口。
mainform.MSComm1.PortOpen := True;
//将 attention 命令送到调制解调器。
mainform.MSComm1.Output := Chr($1B) + Chr($51) + Chr($41) + ' THANKS'+ Chr(13); //确保
mainform.MSComm1.Output := Chr($1B) + Chr($51) + Chr($42) + 'TOTAL '+edittotal.text+ Chr(13); //确保
//关闭串行端口。
mainform.MSComm1.PortOpen := False;
//关闭form3
end;
end;
procedure TForm3.EditmoneyKeyPress(Sender: TObject; var Key: Char);
var
tmptotal:real;
pay1,pay2,pay3,pay4,pay5,pay6:real;
begin
if key='a' then //数字00
begin
postmessage(editmoney.handle,WM_KEYDOWN,48,0);
postmessage(editmoney.handle,WM_KEYDOWN,48,0);
end;
if key='y' then //50元
begin
if editmoney.Text='' then
editmoney.Text:='50'
else
begin
editmoney.Text:=floattostr(strtofloat(editmoney.text)+50);
end;
end;
if key='z' then //100元
begin
if editmoney.Text='' then
editmoney.Text:='100'
else
begin
editmoney.Text:=floattostr(strtofloat(editmoney.text)+100);
end;
end;
if key='r' then //付款1-现金
begin
if editmoney.text<>'' then
begin
try
strtofloat(editmoney.text);
except
Application.MessageBox('请输入实数!','提示',MB_OK+MB_ICONINFORMATION);
editmoney.SetFocus;
Exit;
end;
edit3.text:=formatfloat('0.00',strtofloat(editmoney.Text));
if edit3.Text='' then
pay1:=0
else
pay1:=strtofloat(edit3.text);
if edit4.Text='' then
pay2:=0
else
pay2:=strtofloat(edit4.text);
if edit5.Text='' then
pay3:=0
else
pay3:=strtofloat(edit5.text);
if edit6.Text='' then
pay4:=0
else
pay4:=strtofloat(edit6.text);
if edit7.Text='' then
pay5:=0
else
pay5:=strtofloat(edit7.text);
if edit8.Text='' then
pay6:=0
else
pay6:=strtofloat(edit8.text);
tmptotal:=pay1+pay2+pay3+pay4+pay5+pay6;
edit1.Text:=formatfloat('0.00',tmptotal);
edit2.Text:=formatfloat('0.00',strtofloat(edit1.text)-strtofloat(edittotal.text));
editmoney.Text:='';
editmoney.SetFocus;
end;
if mainform.IsShowed then
begin
//客显显示
//使用 COM1。
mainform.MSComm1.CommPort :=1;
//9600 波特,无奇偶校验,8 位数据,一个停止位。
mainform.MSComm1.Settings := '9600,N,8,1';
//当输入占用时,
//告诉控件读入整个缓冲区。
mainform.MSComm1.InputLen := 0;
//打开端口。
mainform.MSComm1.PortOpen := True;
//将 attention 命令送到端口。
mainform.MSComm1.Output := Chr($1B) + Chr($51) + Chr($41) + 'TOTAL '+edittotal.text+ Chr(13); //显示应收金额
mainform.MSComm1.Output := Chr($1B) + Chr($51) + Chr($42) + 'PAY '+edit1.text+' '+'CHG '+edit2.text+ Chr(13); //显示找钱
//关闭串行端口。
mainform.MSComm1.PortOpen := False;
end;
end;
if key='s' then //付款2-支票
begin
if editmoney.text<>'' then
begin
try
strtofloat(editmoney.text);
except
Application.MessageBox('请输入实数!','提示',MB_OK+MB_ICONINFORMATION);
editmoney.SetFocus;
Exit;
end;
//输入支票号码
application.CreateForm(Tformcodenum,formcodenum);
formcodenum.Caption:='请输入支票号码';
formcodenum.showmodal;
edit4.text:=formatfloat('0.00',strtofloat(editmoney.Text));
if edit3.Text='' then
pay1:=0
else
pay1:=strtofloat(edit3.text);
if edit4.Text='' then
pay2:=0
else
pay2:=strtofloat(edit4.text);
if edit5.Text='' then
pay3:=0
else
pay3:=strtofloat(edit5.text);
if edit6.Text='' then
pay4:=0
else
pay4:=strtofloat(edit6.text);
if edit7.Text='' then
pay5:=0
else
pay5:=strtofloat(edit7.text);
if edit8.Text='' then
pay6:=0
else
pay6:=strtofloat(edit8.text);
tmptotal:=pay1+pay2+pay3+pay4+pay5+pay6;
edit1.Text:=formatfloat('0.00',tmptotal);
edit2.Text:=formatfloat('0.00',strtofloat(edit1.text)-strtofloat(edittotal.text));
editmoney.Text:='';
editmoney.SetFocus;
end;
if mainform.IsShowed then
begin
//客显显示
//使用 COM1。
mainform.MSComm1.CommPort :=1;
//9600 波特,无奇偶校验,8 位数据,一个停止位。
mainform.MSComm1.Settings := '9600,N,8,1';
//当输入占用时,
//告诉控件读入整个缓冲区。
mainform.MSComm1.InputLen := 0;
//打开端口。
mainform.MSComm1.PortOpen := True;
//将 attention 命令送到端口。
mainform.MSComm1.Output := Chr($1B) + Chr($51) + Chr($41) + 'TOTAL '+edittotal.text+ Chr(13); //显示应收金额
mainform.MSComm1.Output := Chr($1B) + Chr($51) + Chr($42) + 'PAY '+edit1.text+' '+'CHG '+edit2.text+ Chr(13); //显示找钱
//关闭串行端口。
mainform.MSComm1.PortOpen := False;
end;
end;
if key='t' then //付款3-信用卡
begin
if editmoney.text<>'' then
begin
try
strtofloat(editmoney.text);
except
Application.MessageBox('请输入整数!','提示',MB_OK+MB_ICONINFORMATION);
editmoney.Text:='';
editmoney.SetFocus;
Exit;
end;
//输入卡号码
application.CreateForm(Tformcodenum,formcodenum);
formcodenum.Caption:='请输入信用卡号';
formcodenum.showmodal;
edit5.text:=formatfloat('0.00',strtofloat(editmoney.Text));
if edit3.Text='' then
pay1:=0
else
pay1:=strtofloat(edit3.text);
if edit4.Text='' then
pay2:=0
else
pay2:=strtofloat(edit4.text);
if edit5.Text='' then
pay3:=0
else
pay3:=strtofloat(edit5.text);
if edit6.Text='' then
pay4:=0
else
pay4:=strtofloat(edit6.text);
if edit7.Text='' then
pay5:=0
else
pay5:=strtofloat(edit7.text);
if edit8.Text='' then
pay6:=0
else
pay6:=strtofloat(edit8.text);
tmptotal:=pay1+pay2+pay3+pay4+pay5+pay6;
edit1.Text:=formatfloat('0.00',tmptotal);
edit2.Text:=formatfloat('0.00',strtofloat(edit1.text)-strtofloat(edittotal.text));
editmoney.Text:='';
editmoney.SetFocus;
end;
if mainform.IsShowed then
begin
//客显显示
//使用 COM1。
mainform.MSComm1.CommPort :=1;
//9600 波特,无奇偶校验,8 位数据,一个停止位。
mainform.MSComm1.Settings := '9600,N,8,1';
//当输入占用时,
//告诉控件读入整个缓冲区。
mainform.MSComm1.InputLen := 0;
//打开端口。
mainform.MSComm1.PortOpen := True;
//将 attention 命令送到端口。
mainform.MSComm1.Output := Chr($1B) + Chr($51) + Chr($41) + 'TOTAL '+edittotal.text+ Chr(13); //显示应收金额
mainform.MSComm1.Output := Chr($1B) + Chr($51) + Chr($42) + 'PAY '+edit1.text+' '+'CHG '+edit2.text+ Chr(13); //显示找钱
//关闭串行端口。
mainform.MSComm1.PortOpen := False;
end;
end;
if key='u' then //付款4-其他
begin
if editmoney.text<>'' then
begin
try
strtofloat(editmoney.text);
except
Application.MessageBox('请输入整数!','提示',MB_OK+MB_ICONINFORMATION);
editmoney.Text:='';
editmoney.SetFocus;
Exit;
end;
edit6.text:=formatfloat('0.00',strtofloat(editmoney.Text));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -