主题:[讨论]此代码会导致小妹我终生的幸福,望各位高手帮我解决下吧
小妹我在做毕业设计,却碰上了好多问题,望各位delphi高手帮帮我啊,否则毕业设计不及格,毕不了业,会毁了偶一生啊555555555555
毕业设计是做一个小区物业管理系统,我做其中的一个模块,也就是停车场管理.主要功能如下:
当汽车进入停车场时,发放一个停车牌编号,停车牌编号可以根据停车场的车位数量来决定。输入停车牌编号后,将在数据表中查找该编号是否有停车状态,如果没有找到,则表明该停车牌是入场状态,将在数据表中追加一条记录;如果找到有记录,则表明该停车牌是离场状态,要求输入收费金额。实现代码如下:
procedure Ttctj_Form.cmdokClick(Sender: TObject);
var
je,sqlstr:string;
begin
je:='0';
sqlstr:='select sum(je) as je from t_tcb where (lcsj>=:ksrq)and(lcsj<=:jsrq)';
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(sqlstr);
Query1.ParamByName('ksrq').AsDateTime:=DateTimePicker1.DateTime;
Query1.ParamByName('jsrq').AsDateTime:=DateTimePicker2.DateTime;
Query1.Open;
je:=Query1.fieldbyname('je').AsString;
StatusBar1.Panels[1].Text:=je;
sqlstr:='select * from t_tcb where (lcsj>=:ksrq)and(lcsj<=:jsrq)';
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(sqlstr);
Query1.Open;
Query1.ParamByName('ksrq').AsDateTime:=DateTimePicker1.DateTime;
Query1.ParamByName('jsrq').AsDateTime:=DateTimePicker2.DateTime;
StatusBar1.Panels[0].Text:=inttostr(Query1.RecordCount);
end;
procedure Ttctj_Form.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
mainform.N42.Enabled:=true;
end;
procedure Ttctj_Form.cmdcloseClick(Sender: TObject);
begin
Close;
end;
end.
实现收费登记
输入停车牌编号后,如果是离场状态则将进场时间和离场时间显示在文本框中,并且要求输入停车收费的金额,然后单击“确定”按钮完成收费登记。实现代码如下:
procedure Ttcgl_Form.cmdokClick(Sender: TObject);
var
sqlstr,id,je,lcsj:string;
begin
try
je:=trim(je_ledit.Text);
if strtofloat(je) <=0 then
begin
ShowMessage('请输入收费金额');
exit;
end;
lcsj:=trim(lcsj_ledit.Text);
id:=Query1.fieldbyname('id').AsString;
sqlstr:='update t_tcb set lcsj='''+lcsj+''',je='''+je+''',zt=1 where(id='''+id+''')';
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(sqlstr);
Query1.ExecSQL;
Close;
except
ShowMessage('请输入合法的收费金额');
end;
end;
procedure Ttcgl_Form.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
mainform.N41.Enabled:=true;
end;
procedure Ttcgl_Form.bh_LEditExit(Sender: TObject);
var
rcsj,zt,sqlstr,bh:string;
begin
bh:=trim(bh_ledit.Text);
strtoint(bh);
sqlstr:='select * from t_tcb where(bh='''+bh+''')and(zt=0)';
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(sqlstr);
Query1.Open;
if Query1.RecordCount > 0 then
begin
rcsj_ledit.Text:=Query1.fieldbyname('rcsj').AsString;
lcsj_ledit.Text:=datetimetostr(now);
end
else
begin
zt:='0';
rcsj:=datetimetostr(now);
sqlstr:='insert into t_tcb(bh,rcsj,zt)valuse('''+bh+''','''+rcsj+''','''+zt+''')';
ShowMessage(sqlstr);
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(sqlstr);
Query1.ExecSQL;
Close;
end;
end;
procedure Ttcgl_Form.cmdcloseClick(Sender: TObject);
begin
Close;
end;
end.
procedure Tlpgl_FormClose(Sender:Tobject;var Action:TCloseAction);
begin
Action:=caFree;
Mainform.n41.Enabled:=ture:
end;
编译能通过,但是运行是就不对了,比如输入车辆编号1,如果数据库里没有这条记录,就应该是入场,入场时间(rcsj)就为输入编号的时间,但现在却变成离场时间了
毕业设计是做一个小区物业管理系统,我做其中的一个模块,也就是停车场管理.主要功能如下:
当汽车进入停车场时,发放一个停车牌编号,停车牌编号可以根据停车场的车位数量来决定。输入停车牌编号后,将在数据表中查找该编号是否有停车状态,如果没有找到,则表明该停车牌是入场状态,将在数据表中追加一条记录;如果找到有记录,则表明该停车牌是离场状态,要求输入收费金额。实现代码如下:
procedure Ttctj_Form.cmdokClick(Sender: TObject);
var
je,sqlstr:string;
begin
je:='0';
sqlstr:='select sum(je) as je from t_tcb where (lcsj>=:ksrq)and(lcsj<=:jsrq)';
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(sqlstr);
Query1.ParamByName('ksrq').AsDateTime:=DateTimePicker1.DateTime;
Query1.ParamByName('jsrq').AsDateTime:=DateTimePicker2.DateTime;
Query1.Open;
je:=Query1.fieldbyname('je').AsString;
StatusBar1.Panels[1].Text:=je;
sqlstr:='select * from t_tcb where (lcsj>=:ksrq)and(lcsj<=:jsrq)';
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(sqlstr);
Query1.Open;
Query1.ParamByName('ksrq').AsDateTime:=DateTimePicker1.DateTime;
Query1.ParamByName('jsrq').AsDateTime:=DateTimePicker2.DateTime;
StatusBar1.Panels[0].Text:=inttostr(Query1.RecordCount);
end;
procedure Ttctj_Form.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
mainform.N42.Enabled:=true;
end;
procedure Ttctj_Form.cmdcloseClick(Sender: TObject);
begin
Close;
end;
end.
实现收费登记
输入停车牌编号后,如果是离场状态则将进场时间和离场时间显示在文本框中,并且要求输入停车收费的金额,然后单击“确定”按钮完成收费登记。实现代码如下:
procedure Ttcgl_Form.cmdokClick(Sender: TObject);
var
sqlstr,id,je,lcsj:string;
begin
try
je:=trim(je_ledit.Text);
if strtofloat(je) <=0 then
begin
ShowMessage('请输入收费金额');
exit;
end;
lcsj:=trim(lcsj_ledit.Text);
id:=Query1.fieldbyname('id').AsString;
sqlstr:='update t_tcb set lcsj='''+lcsj+''',je='''+je+''',zt=1 where(id='''+id+''')';
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(sqlstr);
Query1.ExecSQL;
Close;
except
ShowMessage('请输入合法的收费金额');
end;
end;
procedure Ttcgl_Form.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
mainform.N41.Enabled:=true;
end;
procedure Ttcgl_Form.bh_LEditExit(Sender: TObject);
var
rcsj,zt,sqlstr,bh:string;
begin
bh:=trim(bh_ledit.Text);
strtoint(bh);
sqlstr:='select * from t_tcb where(bh='''+bh+''')and(zt=0)';
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(sqlstr);
Query1.Open;
if Query1.RecordCount > 0 then
begin
rcsj_ledit.Text:=Query1.fieldbyname('rcsj').AsString;
lcsj_ledit.Text:=datetimetostr(now);
end
else
begin
zt:='0';
rcsj:=datetimetostr(now);
sqlstr:='insert into t_tcb(bh,rcsj,zt)valuse('''+bh+''','''+rcsj+''','''+zt+''')';
ShowMessage(sqlstr);
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(sqlstr);
Query1.ExecSQL;
Close;
end;
end;
procedure Ttcgl_Form.cmdcloseClick(Sender: TObject);
begin
Close;
end;
end.
procedure Tlpgl_FormClose(Sender:Tobject;var Action:TCloseAction);
begin
Action:=caFree;
Mainform.n41.Enabled:=ture:
end;
编译能通过,但是运行是就不对了,比如输入车辆编号1,如果数据库里没有这条记录,就应该是入场,入场时间(rcsj)就为输入编号的时间,但现在却变成离场时间了