📄 c_vcdback.pas
字号:
if e_yjid.Text='' then exit;
if dm.ADO_czbtmp.IsEmpty=false then exit;
dm.ADO_czdt.Open;
dm.ADO_czdt.First;
dm.ADO_czdt.Sort:='证号';
if not dm.ADO_czdt.Locate('证号',e_yjid.Text,[]) then //查询输入押金单号是否有对应的零租记录
begin
Application.MessageBox(PChar('无此零租用户租借记录,请重新录入!')
, PChar('提示'),MB_ICONEXCLAMATION);
e_yjid.Text:='';
e_yjid.SetFocus();
end
else
//如果有租借记录则:
begin
e_yj.Text:=formatfloat('0.00',dm.ADO_czdt.fieldbyname('押金').Asfloat);
//将租借表中该零租押金单对应的租借记录查询出来insert到表czbtmp中生成租借临时库
dm.adoq_czbtmp.Close;
dm.adoq_czbtmp.SQL.Clear;
sqlz:='insert into czbtmp select * from czb where 证号='+''''+e_yjid.text+'''';
dm.adoq_czbtmp.SQL.Add(sqlz);
dm.adoq_czbtmp.ExecSQL;
dm.ADO_czbtmp.close;//刷新
dm.ADO_czbtmp.Open;
dm.ado_qk.open; //查询有无欠款
dm.ado_qk.first;
if dm.ado_qk.locate('证号',e_yjid.Text,[]) then
e_qk.Text:=formatfloat('0.00',dm.ado_qk.fieldbyname('金额').asfloat);
dm.ado_qk.Close;
e_vcdid.SetFocus();
end;
end;
procedure Tcfrm_vcdback.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
dm.adoq_czbtmp.SQL.Clear;
dm.ADOQ_czbtmp.SQL.Add('delete from czbtmp');
dm.ADOQ_czbtmp.ExecSQL;
dm.adoq_czbtmp.Close;
dm.ADO_czbtmp.Close;
dm.ADO_czb.Close;
dm.ADO_czdt.Close;
dm.ADO_qk.Close;
dm.ADO_cash.Close;
dm.ADO_vip.Close;
dm.ADO_vcd.Close;
release;
end;
procedure Tcfrm_vcdback.e_vcdidExit(Sender: TObject);
begin
if e_vcdid.Text='' then exit;
case group_zlr.ItemIndex of
0:if e_hyid.Text='' then hylzcx;
1:if e_yjid.Text='' then hylzcx;
end;
dm.ADO_czbtmp.Open;
if not dm.ADO_czbtmp.Locate('编号',e_vcdid.Text,[]) then
begin
Application.MessageBox(PChar('用户未租借此图书(影碟),请检查!')
, PChar('提示'),MB_ICONEXCLAMATION);
e_vcdid.Text:='';
e_vcdid.SetFocus();
exit;
end
else
begin
dm.ADO_czbtmp.Edit;
dm.ADO_czbtmp.FieldByName('状态').AsString:='已还';
dm.ADO_czbtmp.Post;
end;
paymoney;
e_vcdid.Text:='';
e_vcdid.SetFocus();
end;
procedure Tcfrm_vcdback.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if dm.ADO_czbtmp.FieldByName('状态').AsString='已还' then
DBGrid1.Canvas.Font.Color := clred;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
procedure Tcfrm_vcdback.e_yjidChange(Sender: TObject);
begin
e_zlname.Text:='';
e_zlsex.Text:='';
e_zlzlx.Text:='';
e_zlyj.Text:='';
e_zltel.Text:='';
e_yj.Text:='0.00';
e_qk.Text:='0.00';
e_ys.Text:='0.00';
e_ss.Text:='0.00';
e_thyj.Text:='0.00';
dm.adoq_czbtmp.SQL.Clear;
dm.ADOQ_czbtmp.SQL.Add('delete from czbtmp');
dm.ADOQ_czbtmp.ExecSQL;
dm.adoq_czbtmp.Close;
dm.ADO_czbtmp.Close;
end;
procedure Tcfrm_vcdback.BitBtn1Click(Sender: TObject);
begin
if (dm.ADO_czbtmp.IsEmpty) or not dm.ADO_czbtmp.Locate('状态','已还',[]) then
begin
application.MessageBox(pchar('无图书、影碟的还租资料,不能结算!')
,pchar('提示'),MB_ICONEXCLAMATION);
exit;
end;
if group_zlr.ItemIndex=1 then
begin
if strtofloat(e_thyj.text)>strtofloat(e_yj.Text) then
begin
application.MessageBox(pchar('退还押金大于原预收押金,请检查!')
,pchar('提示'),MB_ICONEXCLAMATION);
exit;
end;
end;
//修改tsvcd表,使对应的影碟的状态恢复为未租
dm.ADO_czbtmp.First;
while not dm.ADO_czbtmp.eof do //遍历临时租借表中的记录
begin
if dm.ADO_czbtmp.FieldByName('状态').AsString='已还' then
begin
dm.ADO_vcd.Open;
dm.ADO_vcd.Locate('编号',dm.ADO_czbtmp.fieldbyname('编号').AsString,[]);
dm.ADO_vcd.Edit;
dm.ado_vcd.FieldByName('状态').AsString:='未租';
dm.ADO_vcd.Post;
dm.ADO_vcd.Close;
end;
dm.ADO_czbtmp.Next;
end;
//删除czb中多余记录
case group_zlr.ItemIndex of
0: begin
dm.ADOQ_czbtmp.Close;
dm.ADOQ_czbtmp.SQL.Clear;
dm.ADOQ_czbtmp.SQL.Add('delete from czb where 证号='+''''+e_hyid.Text+'''');
dm.adoq_czbtmp.ExecSQL;
dm.ADOQ_czbtmp.Close;
end;
1:begin
dm.ADOQ_czbtmp.Close;
dm.ADOQ_czbtmp.SQL.Clear;
dm.ADOQ_czbtmp.SQL.Add('delete from czb where 证号='+''''+e_yjid.Text+'''');
dm.adoq_czbtmp.ExecSQL;
dm.ADOQ_czbtmp.Close;
end;
end;
//向租借表czb中添加临时租借表记录
dm.ADOQ_czbtmp.Close;
dm.ADOQ_czbtmp.SQL.Clear;
dm.ADOQ_czbtmp.SQL.Add('insert into czb select * from czbtmp where 状态='+''''+'未还'+'''');
dm.adoq_czbtmp.ExecSQL;
dm.ADOQ_czbtmp.Close;
//判断能否删除czdt记录
dm.ADO_czbtmp.First;
if dm.ADO_czbtmp.Locate('状态','未还',[]) then
else //如果该证号没有对应的未还记录了就删除其在czbt表中对应的记录
begin
case group_zlr.ItemIndex of
0:begin //会员
dm.ADOQ_czbtmp.Close;
dm.ADOQ_czbtmp.SQL.Clear;
dm.ADOQ_czbtmp.SQL.Add('delete from czdt where 证号='+''''+e_hyid.Text+'''');
dm.adoq_czbtmp.ExecSQL;
dm.ADOQ_czbtmp.Close;
end;
1:begin //零租
if strtofloat(e_thyj.Text)=strtofloat(e_yj.Text) then
begin
dm.ADOQ_czbtmp.Close;
dm.ADOQ_czbtmp.SQL.Clear;
dm.ADOQ_czbtmp.SQL.Add('delete from czdt where 证号='+''''+e_yjid.Text+'''');
dm.adoq_czbtmp.ExecSQL;
dm.ADOQ_czbtmp.Close;
end;
end;
end;
end;
//欠款及现金库写入
case group_zlr.ItemIndex of
0:hylzbh:=e_hyid.Text;
1:hylzbh:=e_yjid.Text;
//2:exit;
end;
dm.ADO_qk.Open;
if (strtofloat(e_ys.Text)+ strtofloat(e_qk.Text)-strtofloat(e_ss.Text)>0)
or (strtofloat(e_ys.Text)+ strtofloat(e_qk.Text)-strtofloat(e_ss.Text)<0) then
begin
if not dm.ADO_qk.Locate('证号',hylzbh,[]) then
dm.ADO_qk.AppendRecord([hylzbh,(strtofloat(e_ys.Text)+ strtofloat(e_qk.Text)-strtofloat(e_ss.Text))])
else
begin
dm.ADO_qk.Edit;
dm.ADO_qk.FieldByName('金额').AsFloat:=strtofloat(e_ys.Text)+ strtofloat(e_qk.Text)-strtofloat(e_ss.Text);
dm.ADO_qk.Post;
end;
end
else
begin
if dm.ADO_qk.Locate('证号',hylzbh,[]) then
dm.ADO_qk.Delete;
end;
dm.ADO_qk.Close;
{写入cash表}
if e_ss.text<>'0.00' then
begin
dm.ADO_cash.Open;
dm.ADO_cash.AppendRecord([hylzbh,date(),'收租金',e_ss.text]);
dm.ADO_cash.Close;
end;
//退押金
if group_zlr.ItemIndex=1 then
begin
if strtofloat(e_thyj.text)<strtofloat(e_yj.Text) then //如果退的押金不足交纳的押金,则修改表czdt
begin
dm.ADO_czdt.Open;
dm.ADO_czdt.First;
dm.ADO_czdt.Locate('证号',hylzbh,[]);
dm.ADO_czdt.Edit;
dm.ADO_czdt.fieldbyname('押金').asfloat:=strtofloat(e_yj.Text)-strtofloat(e_thyj.text);
dm.ado_czdt.Post;
dm.ado_czdt.Close;
end;
if e_thyj.Text<>'0.00' then //如果有退还的押金额则写入cash表中
begin
dm.ADO_cash.Open;
dm.ADO_cash.AppendRecord([hylzbh,date(),'退零租押金','0.00',e_thyj.text]);
dm.ADO_cash.Close;
end;
end;
e_hyid.Text:='';
e_yjid.Text:='';
e_yj.Text:='0.00';
e_zlname.Text:='';
e_zlsex.Text:='';
e_zlzlx.Text:='';
e_zlyj.Text:='';
e_zltel.Text:='';
e_qk.Text:='0.00';
e_ys.Text:='0.00';
e_ss.Text:='0.00';
e_thyj.Text:='0.00';
//删除临时记录
dm.ADOQ_czbtmp.SQL.Clear;
dm.ADOQ_czbtmp.SQL.Add('delete from czbtmp');
dm.adoq_czbtmp.ExecSQL;
dm.ADO_czbtmp.Close;
e_vcdid.SetFocus();
end;
procedure Tcfrm_vcdback.e_thyjExit(Sender: TObject);
begin
if e_thyj.text='' then e_thyj.Text:='0.00';
e_thyj.Text:=formatfloat('0.00',strtofloat(e_thyj.text));
end;
procedure Tcfrm_vcdback.e_ssExit(Sender: TObject);
begin
if e_ss.text='' then e_ss.Text:='0.00';
e_ss.Text:=formatfloat('0.00',strtofloat(e_ss.text));
end;
procedure Tcfrm_vcdback.e_yjidKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
EnterToTab(Self, Key, Shift);
end;
procedure Tcfrm_vcdback.e_vcdidKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
EnterToTab(Self, Key, Shift);
end;
procedure Tcfrm_vcdback.e_hyidKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
EnterToTab(Self, Key, Shift);
end;
procedure Tcfrm_vcdback.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
EnterToTab(Self, Key, Shift);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -