📄 carout.pas
字号:
begin
if not (key in [#46,#48,#49,#50,#51,#52,#53,#54,#55,#56,#57,#13,#8]) then
begin
showmessage('只能为数字!');
key:=#0;
end;
if key = #13 then
edit2.SetFocus;
end;
procedure TForm_carout.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in [#46,#48,#49,#50,#51,#52,#53,#54,#55,#56,#57,#13,#8]) then
begin
showmessage('只能为数字!');
key:=#0;
end;
if key = #13 then
edit3.SetFocus;
end;
procedure TForm_carout.ComboBox7KeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
ComboBox8.SetFocus;
end;
procedure TForm_carout.ComboBox8KeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
edit1.SetFocus;
end;
procedure TForm_carout.ComboBox4Change(Sender: TObject);
begin
Edit3Change(nil);
end;
procedure TForm_carout.ComboBox3Change(Sender: TObject);
begin
edit3change(nil);
end;
procedure TForm_carout.ComboBox1Enter(Sender: TObject);
begin
with form_dm.ADOTable_car do
begin
open;
form_dm.ADOTable_car.Sort:='id';
first;
combobox1.Items.Clear;
repeat
combobox1.Items.Add(form_dm.ADOtable_car.fieldbyname('id').AsString);
form_dm.ADOtable_car.Next;
until eof;
end;
end;
procedure TForm_carout.Edit7KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in [#46,#48,#49,#50,#51,#52,#53,#54,#55,#56,#57,#13,#8]) then
begin
showmessage('只能为数字!');
key:=#0;
end;
if key = #13 then
bitbtn9.SetFocus;
end;
procedure TForm_carout.Edit2Change(Sender: TObject);
begin
if (edit1.Text<>'') and (edit2.Text<>'') then
edit3.Text:=floattostr(strtofloat(edit2.text)-strtofloat(edit1.text));
end;
procedure TForm_carout.Edit1Change(Sender: TObject);
begin
if (edit2.Text<>'')and (edit1.Text<>'') then
edit3.Text:=floattostr(strtofloat(edit2.text)-strtofloat(edit1.text));
end;
procedure TForm_carout.ComboBox7Enter(Sender: TObject);
begin
with form_dm.ADOtable_begin1 do
begin
open;
first;
combobox7.Items.Clear;
repeat
combobox7.Items.Add(fieldbyname('begin1').AsString);
Next;
until eof;
end;
combobox7.ItemIndex:=0;
end;
procedure TForm_carout.ComboBox8Enter(Sender: TObject);
begin
with form_dm.ADOtable_end1 do
begin
open;
Sort:='end1';
first;
combobox8.Items.Clear;
repeat
combobox8.Items.Add(fieldbyname('end1').AsString);
Next;
until eof;
end;
end;
procedure TForm_carout.DateTimePicker2Change(Sender: TObject);
var
jd:double;
begin
form_dm.ADOTable_params.Open;
getlistbox2(nil);
getlistbox3(nil);
edit6.text:=floattostr(trunc((form_dm.ADOTable_params.FieldValues['jdj']*listbox3.Items.count)*100)/100);
form_dm.ADOTable_params.Close;
end;
procedure TForm_carout.DateTimePicker3Change(Sender: TObject);
var
jd:double;
begin
form_dm.ADOTable_params.Open;
getlistbox2(nil);
getlistbox3(nil);
edit6.text:=floattostr(trunc((form_dm.ADOTable_params.FieldValues['jdj']*listbox3.Items.count)*100)/100);
form_dm.ADOTable_params.Close;
end;
procedure TForm_carout.BitBtn10Click(Sender: TObject);
begin
datetimepicker1.Date:=date;
datetimepicker2.time:=now;
datetimepicker3.time:=now;
combobox1.ItemIndex:=-1;
combobox2.ItemIndex:=-1;
combobox3.ItemIndex:=-1;
combobox4.ItemIndex:=-1;
combobox5.ItemIndex:=-1;
combobox6.ItemIndex:=-1;
combobox7.ItemIndex:=-1;
combobox8.ItemIndex:=-1;
combobox9.ItemIndex:=-1;
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
edit5.Text:='';
edit6.Text:='';
edit7.Text:='';
edit8.Text:='';
listbox2.Clear;
listbox3.Clear;
listbox5.Clear;
mglbt:=0;
end;
procedure TForm_carout.BitBtn9Click(Sender: TObject);
var s:string;
id:integer;
begin
for id:=1 to 99 do
begin
form_dm.ADOTable_car_out.Open ;
s:=formatdatetime('yyyymmdd',datetimepicker1.Datetime);
s:=s+copy('00',1,2-length(inttostr(id)))+inttostr(id);
if not form_dm.ADOTable_car_out.Locate('id',s,[]) then
break
else
continue;
end;
if combobox1.Text='' then
begin
showmessage('请输入完整的信息!');
combobox1.SetFocus;
abort;
end;
if combobox2.Text='' then
begin
showmessage('请输入完整的信息!');
combobox2.SetFocus;
abort;
end;
if combobox3.Text='' then
begin
showmessage('请输入完整的信息!');
combobox3.SetFocus;
abort;
end;
if combobox4.Text='' then
begin
showmessage('请输入完整的信息!');
combobox4.SetFocus;
abort;
end;
if combobox5.Text='' then
begin
showmessage('请输入完整的信息!');
combobox5.SetFocus;
abort;
end;
if combobox6.Text='' then
begin
showmessage('请输入完整的信息!');
combobox6.SetFocus;
abort;
end;
if combobox7.Text='' then
begin
showmessage('请输入完整的信息!');
combobox7.SetFocus;
abort;
end;
if combobox8.Text='' then
begin
showmessage('请输入完整的信息!');
combobox8.SetFocus;
abort;
end;
if combobox9.Text='' then
begin
showmessage('请输入完整的信息!');
combobox9.SetFocus;
abort;
end;
if edit2.Text='' then
begin
showmessage('请输入完整的信息!');
edit2.SetFocus;
abort;
end;
if edit3.Text='' then
begin
showmessage('请输入完整的信息!');
edit3.SetFocus;
abort;
end;
if edit4.Text='' then
begin
edit4.Text:='0';
end;
if edit6.Text='' then
begin
edit6.Text:='0';
end;
if edit8.Text='' then
begin
edit8.Text:='0';
end;
if strtofloat(edit3.Text)<0 then
begin
showmessage('收车里程不能小于发车里程!');
edit2.SetFocus;
abort;
end;
getlistbox5(nil);
with form_dm.ADOTable_car_out do
begin
Open;
append;
FieldByName('id').AsString:=s;
FieldByName('car_id').AsString:=combobox1.Text;
FieldByName('driver_name').AsString:=combobox2.Text;
FieldByName('type1').AsString:=combobox3.Text;
FieldByName('type2').AsString:=combobox4.Text;
FieldByName('unit').AsString:=combobox5.Text;
FieldByName('signer').AsString:=combobox6.Text;
FieldByName('from').AsString:=combobox7.Text;
FieldByName('to').AsString:=combobox8.Text;
FieldByName('weekend').AsString:=combobox9.Text;
FieldByName('km1').asfloat:=strtofloat(edit1.Text);
FieldByName('km2').asfloat:=strtofloat(edit2.Text);
FieldByName('km').asfloat:=strtofloat(edit3.Text);
FieldByName('toll').asfloat:=strtofloat(edit4.Text);
FieldByName('km_bounty').asfloat:=strtofloat(edit5.Text);
FieldByName('duty_bounty').asfloat:=strtofloat(edit6.Text);
FieldByName('spend').asfloat:=strtofloat(edit7.Text);
FieldByName('other').asfloat:=strtofloat(edit8.Text);
fieldvalues['date']:=formatdatetime('yyyy-mm-dd',datetimepicker1.Datetime);
fieldvalues['time1']:=formatdatetime('HH:MM:SS',datetimepicker2.Datetime);
fieldvalues['time2']:=formatdatetime('HH:MM:SS',datetimepicker3.Datetime);
if combobox9.Text='是' then
begin
if (listbox5.Items.count>0)then
FieldByName('jb').asfloat:=1
else
FieldByName('jb').asfloat:=0.5;
end
else
FieldByName('jb').asfloat:=0;
post;
end;
if combobox3.Text<>'车队用车' then
begin
form_dm.ADOTable_params.Open;
form_dm.ADOTable_params.First;
with form_dm.ADOQuery_signers do
begin
SQL.Text:='select * from car_out where date='''+formatdatetime('yyyy-mm-dd',datetimepicker1.Datetime)+''' and driver_name='''+combobox2.Text+''' and type1<>''车队用车''';
open;
first;
repeat
edit;
fieldbyname('sjb').AsFloat:=RoundTo(form_dm.ADOTable_params.FieldValues['sjf']/RecordCount,-2);
post;
Next;
until eof;
end;
with form_dm.ADOQuery_signers do
begin
SQL.Text:='select * from car_out where date='''+formatdatetime('yyyy-mm-dd',datetimepicker1.Datetime)+''' and driver_name='''+combobox2.Text+''' and weekend=''是'' and type1<>''车队用车''';
open;
if recordcount<>0 then
begin
first;
repeat
edit;
if recordcount=1 then
fieldbyname('jjb').AsFloat:=form_dm.ADOTable_params.FieldValues['jjj']*fieldvalues['jb']
else
fieldbyname('jjb').AsFloat:=roundto(form_dm.ADOTable_params.FieldValues['jjj']/recordcount,-2);
post;
Next;
until eof;
end;
end;
end;
form_dm.ADOTable_car.Open;
form_dm.ADOTable_car.Locate('id',combobox1.Text,[]);
form_dm.ADOTable_car.Edit;
form_dm.ADOTable_car.FieldValues['km']:=strtofloat(edit2.Text);
form_dm.ADOTable_car.post;
form_dm.ADOTable_car.Close;
bitbtn10.OnClick(nil);
showmessage('出车登记成功!');
end;
procedure TForm_carout.BitBtn2Click(Sender: TObject);
begin
form_addtype1.showmodal;
end;
procedure TForm_carout.BitBtn3Click(Sender: TObject);
begin
form_addtype2.showmodal;
end;
procedure TForm_carout.BitBtn5Click(Sender: TObject);
begin
form_addunit.showmodal;
end;
procedure TForm_carout.BitBtn6Click(Sender: TObject);
begin
form_addsigner.showmodal;
end;
procedure TForm_carout.BitBtn7Click(Sender: TObject);
begin
form_addbegin.showmodal;
end;
procedure TForm_carout.BitBtn8Click(Sender: TObject);
begin
form_addend.showmodal;
end;
procedure TForm_carout.FormCreate(Sender: TObject);
begin
mglbt:=0;
end;
procedure TForm_carout.Edit8KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in [#46,#48,#49,#50,#51,#52,#53,#54,#55,#56,#57,#13,#8]) then
begin
showmessage('只能为数字!');
key:=#0;
end;
if key = #13 then
edit7.SetFocus;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -