📄 jk1.pas
字号:
unit jk1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, DBTables, Grids, StdCtrls,printers, DBGrids;
type
Tjkform = class(TForm)
grid1: TStringGrid;
q1: TQuery;
s1: TStoredProc;
Button1: TButton;
Button2: TButton;
Button3: TButton;
s2: TStoredProc;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button2Click(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
jkform: Tjkform;
implementation
uses dataproc;
{$R *.DFM}
var
lsrow:integer;
procedure datatogrid;
begin
with jkform do
begin
if (lsrow=1) or (lsrow=3) then
begin
if q1.fieldbyname('num').asfloat=0 then
grid1.cells[1,lsrow]:=''
else
begin
grid1.cells[1,lsrow]:=floattostr(q1.fieldbyname('num').asfloat);
grid1.Cells[1,lsrow]:=grid1.Cells[1,lsrow]+copy(' ',1,(length(grid1.Cells[1,lsrow]) mod 2));
end;
end;
if q1.fieldbyname('xj').asfloat=0 then
grid1.cells[2,lsrow]:=''
else
begin
grid1.cells[2,lsrow]:=floattostr(q1.fieldbyname('xj').asfloat);
grid1.Cells[2,lsrow]:=grid1.Cells[2,lsrow]+copy(' ',1,(length(grid1.Cells[2,lsrow]) mod 2));
end ;
if q1.fieldbyname('zp').asfloat=0 then
grid1.cells[3,lsrow]:=''
else
begin
grid1.cells[3,lsrow]:=floattostr(q1.fieldbyname('zp').asfloat);
grid1.Cells[3,lsrow]:=grid1.Cells[3,lsrow]+copy(' ',1,(length(grid1.Cells[3,lsrow]) mod 2));
end;
if q1.fieldbyname('card').asfloat=0 then
grid1.cells[4,lsrow]:=''
else
begin
grid1.cells[4,lsrow]:=floattostr(q1.fieldbyname('card').asfloat);
grid1.Cells[4,lsrow]:=grid1.Cells[4,lsrow]+copy(' ',1,(length(grid1.Cells[4,lsrow]) mod 2));
end;
if q1.fieldbyname('gz').asfloat=0 then
grid1.cells[5,lsrow]:=''
else
begin
grid1.cells[5,lsrow]:=floattostr(q1.fieldbyname('gz').asfloat);
grid1.Cells[5,lsrow]:=grid1.Cells[5,lsrow]+copy(' ',1,(length(grid1.Cells[5,lsrow]) mod 2));
end;
if q1.fieldbyname('md').asfloat=0 then
grid1.cells[6,lsrow]:=''
else
begin
grid1.cells[6,lsrow]:=floattostr(q1.fieldbyname('md').asfloat);
grid1.Cells[6,lsrow]:=grid1.Cells[6,lsrow]+copy(' ',1,(length(grid1.Cells[6,lsrow]) mod 2));
end;
if q1.fieldbyname('other').asfloat=0 then
grid1.cells[7,lsrow]:=''
else
begin
grid1.cells[7,lsrow]:=floattostr(q1.fieldbyname('other').asfloat);
grid1.Cells[7,lsrow]:=grid1.Cells[7,lsrow]+copy(' ',1,(length(grid1.Cells[7,lsrow]) mod 2));
end;
if q1.fieldbyname('xiaoj').asfloat=0 then
grid1.cells[8,lsrow]:=''
else
begin
grid1.cells[8,lsrow]:=floattostr(q1.fieldbyname('xiaoj').asfloat);
grid1.Cells[8,lsrow]:=grid1.Cells[8,lsrow]+copy(' ',1,(length(grid1.Cells[8,lsrow]) mod 2));
end;
end
end;
procedure formini;
var
lsdate,lscode:string;
i,groupnum:integer;
aa:array [0..1] of string;
begin
with jkform do
begin
lsdate:=datetostr(date());
{ q1.Active :=false;
q1.sql.clear;
q1.sql.Add('select custype1.CusName,codeclass,num,xj,zp,card,gz,md,other,xiaoj,lsgroup,master from jkmoney,custype1 where custype1.Custype=substring(jkmoney.Code,1,4)');
q1.Prepare;
q1.open;
}
{ grid1.RowCount:=q1.RecordCount+1 ;
lsrow:=1;
while not q1.EOF do
begin
lscode:=q1.FieldByName('code').asstring;
if lscode='rmcode' then
grid1.Cells [0,lsrow]:='包间';
if lscode='cscode' then
grid1.Cells [0,lsrow]:='超时';
if lscode='sacode' then
grid1.Cells [0,lsrow]:='散座';
if lscode='qtcode' then
grid1.Cells [0,lsrow]:='其他';
if lscode='xjcode' then
grid1.Cells [0,lsrow]:='小 计';
if ((lscode<>'rmcode') and (lscode<>'cscode') and (lscode<>'sacode') and (lscode<>'xjcode') and (lscode<>'qtcode')) then
begin
aa[0]:='';
getvalue(aa,'select cusname from custype where custype="'+trim(lscode)+'"');
if length(trim(aa[0]))=0 then
getvalue(aa,'select cusname from cusitem where cuscode="'+trim(lscode)+'"');
grid1.Cells [0,lsrow]:=aa[0];
end;
datatogrid;
q1.next;
lsrow:=lsrow+1;
end;
q1.active:=false;}
end;
end;
procedure Tjkform.FormCreate(Sender: TObject);
begin
shortdateformat:='yyyy-mm-dd';
grid1.Cells [1,0]:='数量';
grid1.cells [2,0]:='现金';
grid1.cells [3,0]:='支票';
grid1.cells [4,0]:='信用卡';
grid1.cells [5,0]:='挂帐';
grid1.cells [6,0]:='免单';
grid1.cells [7,0]:='其他';
grid1.cells [8,0]:='小计';
s1.Prepare;
s1.ExecProc ;
s2.ParamByName ('@ilsdate').asstring:=datetostr(date());
s2.Prepare;
s2.ExecProc ;
formini;
end;
procedure prn;
var
myfile:textfile;
s,spac:string;
i:integer;
begin
with jkform do
begin
assignprn(myfile);
rewrite(myfile);
i:=1;
spac:=' ';
printer.Canvas.Font.name:=jkform.Font.name;
printer.Canvas.Font.size:=18;
writeln(myfile,' 海霸王大厦营业班报表');
s:='┠──────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┨';
printer.Canvas.Font.size:=13;
writeln(myfile,' '+datetostr(date));
printer.Canvas.Font.size:=9;
writeln(myfile,'┏━━━━━━┯━━━━━┯━━━━━┯━━━━━┯━━━━━┯━━━━━┯━━━━━┯━━━━━┯━━━━━┓');
writeln(myfile,'┃ │ 数 量 │ 现 金 │ 支 票 │ 信用卡 │ 挂 帐 │ 免 单 │ 其 它 │ 小 计 ┃');
while i<=grid1.RowCount-1 do
begin
writeln(myfile,s);
writeln(myfile,'┃'+copy((grid1.cells[0,i])+spac,1,12)+'│'+copy((grid1.cells[1,i])+spac,1,10)+'│'+copy((grid1.cells[2,i])+spac,1,10)+'│'+copy((grid1.cells[3,i])+spac,1,10)+'│'+copy((grid1.cells[4,i])+spac,1,10)+'│'+copy((grid1.cells[5,i])+spac,1,10)+'│'+copy((grid1.cells[6,i])+spac,1,10)+'│'+copy((grid1.cells[7,i])+spac,1,10)+'│'+copy((grid1.cells[8,i])+spac,1,10)+'┃');
i:=i+1;
end;
writeln(myfile,'┗━━━━━━┷━━━━━┷━━━━━┷━━━━━┷━━━━━┷━━━━━┷━━━━━┷━━━━━┷━━━━━┛');
writeln(myfile,' 班次:'+curper.curbc+' 制表人:'+curper.name);
system.CloseFile (myfile);
end;
end;
procedure Tjkform.Button1Click(Sender: TObject);
begin
prn;
button2.Enabled :=true;
end;
procedure Tjkform.Button3Click(Sender: TObject);
begin
jkform.Close;
end;
procedure Tjkform.FormClose(Sender: TObject; var Action: TCloseAction);
begin
q1.Free;
s1.free;
s2.free;
end;
procedure Tjkform.Button2Click(Sender: TObject);
begin
q1.Active :=false;
q1.sql.clear;
q1.sql.add('update jkmoney set num=0,xj=0,zp=0,card=0,gz=0,md=0,other=0,xiaoj=0 ');
q1.Prepare;
q1.ExecSQL ;
q1.Active :=false;
showmessage('交款成功');
jkform.close;
end;
procedure Tjkform.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=13 then
selectnext(activecontrol,true,true);
if key=27 then
jkform.close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -