⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 updatecarout.pas

📁 管理车队用车记录
💻 PAS
📖 第 1 页 / 共 2 页
字号:
edit3change(nil);
end;

procedure TForm_updatecarout.ComboBox1Enter(Sender: TObject);
begin
    with form_dm.ADOTable_car do
    begin
        open;
        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_updatecarout.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_updatecarout.Edit2Change(Sender: TObject);
begin
if (edit1.Text<>'') and (edit2.Text<>'') then
edit3.Text:=floattostr(strtofloat(edit2.text)-strtofloat(edit1.text));
end;

procedure TForm_updatecarout.Edit1Change(Sender: TObject);
begin
if (edit2.Text<>'')and (edit1.Text<>'') then
edit3.Text:=floattostr(strtofloat(edit2.text)-strtofloat(edit1.text));
end;

procedure TForm_updatecarout.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_updatecarout.ComboBox8Enter(Sender: TObject);
begin
with form_dm.ADOtable_end1 do
        begin
        open;
        first;
        combobox8.Items.Clear;
        repeat
            combobox8.Items.Add(fieldbyname('end1').AsString);
            Next;
        until eof;
        end;
end;

procedure TForm_updatecarout.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_updatecarout.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_updatecarout.BitBtn10Click(Sender: TObject);
begin
if edit8.Text<>'' then
begin
 with form_dm.ADOTable_car_out do
  begin
  open;
  locate('id',edit8.Text,[]);
  if messagedlg('确定要删除该记录吗?',mtwarning,[mbyes,mbno],0)=mryes then
    Delete;
    close;
 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:=roundto(form_dm.ADOTable_params.FieldValues['jjj']*fieldvalues['jb'],-2)
            else
            fieldbyname('jjb').AsFloat:=roundto(form_dm.ADOTable_params.FieldValues['jjj']/recordcount,-2);
            post;
            Next;
        until eof;
        end;
        end;
  end;

 ///////////////////////////////////////////////
  form_updatecarout.OnShow(nil);
end
  else
  begin
    showmessage('请先选择要删除的记录!');
    abort;
  end;

end;

procedure TForm_updatecarout.BitBtn9Click(Sender: TObject);
begin

if edit8.Text<>'' then
begin

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 edit7.Text='' then
begin
 showmessage('请输入完整的信息!');
 edit7.SetFocus;
 abort;
end;
if edit4.Text='' then
begin
  edit4.Text:='0';
end;
if edit6.Text='' then
begin
  edit6.Text:='0';
end;
if edit9.Text='' then
begin
  edit9.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;
  locate('id',edit8.Text,[]);
  edit;
  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(edit9.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;
     FieldByName('jjb').asfloat:=0;
  post;
  close;
  open;
end;
 if edit2.Text<>scgl then
 begin
    with form_dm.ADOTable_car do
    begin
      open;
      locate('id',combobox1.Text,[]);
      if scgl=floattostr(fieldvalues['km']) then
      begin
        edit;
        fieldvalues['km']:=strtofloat(edit2.Text);
        post;
      end;
      close;
    end;
 end;

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:=roundto(form_dm.ADOTable_params.FieldValues['jjj']*fieldvalues['jb'],-2)
            else
            fieldbyname('jjb').AsFloat:=roundto(form_dm.ADOTable_params.FieldValues['jjj']/recordcount,-2);
            post;
            Next;
        until eof;
        end;
        end;

  showmessage('修改成功!');
  end
  else
  begin
    showmessage('请先选择要修改的记录!');
    abort;
  end;
  listbox2.Clear;
   listbox3.Clear;
    listbox5.Clear;
end;

procedure TForm_updatecarout.BitBtn2Click(Sender: TObject);
begin
form_addtype1.showmodal;
end;

procedure TForm_updatecarout.BitBtn3Click(Sender: TObject);
begin
form_addtype2.showmodal;
end;

procedure TForm_updatecarout.BitBtn5Click(Sender: TObject);
begin
form_addunit.showmodal;
end;

procedure TForm_updatecarout.BitBtn6Click(Sender: TObject);
begin
form_addsigner.showmodal;
end;
procedure TForm_updatecarout.BitBtn7Click(Sender: TObject);
begin
form_addbegin.showmodal;
end;

procedure TForm_updatecarout.BitBtn8Click(Sender: TObject);
begin
form_addend.showmodal;
end;

procedure TForm_updatecarout.DBGrid1CellClick(Column: TColumn);
begin
combobox1.Text:=dbgrid1.Fields[0].AsString;
combobox2.Text:=dbgrid1.Fields[1].AsString;
combobox3.Text:=dbgrid1.Fields[2].AsString;
combobox4.Text:=dbgrid1.Fields[3].AsString;
combobox5.Text:=dbgrid1.Fields[5].AsString;
combobox6.Text:=dbgrid1.Fields[6].AsString;
combobox7.Text:=dbgrid1.Fields[7].AsString;
combobox8.Text:=dbgrid1.Fields[8].AsString;
combobox9.Text:=dbgrid1.Fields[11].AsString;
edit1.Text:=dbgrid1.Fields[12].AsString;
edit2.Text:=dbgrid1.Fields[13].AsString;
scgl:=dbgrid1.Fields[13].AsString;
edit3.Text:=dbgrid1.Fields[14].AsString;
edit4.Text:=dbgrid1.Fields[15].AsString;
edit5.Text:=dbgrid1.Fields[16].AsString;
edit6.Text:=dbgrid1.Fields[17].AsString;
edit7.Text:=dbgrid1.Fields[20].AsString;
edit8.Text:=dbgrid1.Fields[18].AsString;
edit9.Text:=dbgrid1.Fields[19].AsString;
datetimepicker1.Date:=strtodate(dbgrid1.Fields[4].asstring);
datetimepicker2.time:=strtotime(dbgrid1.Fields[9].asstring);
datetimepicker3.time:=strtotime(dbgrid1.Fields[10].asstring);
form_dm.ADOTable_car.Open;
if form_dm.ADOTable_car.Locate('id',combobox1.Text,[]) then
  begin
    mglbt:= form_dm.ADOTable_car.FieldValues['glj'];
end;
form_dm.ADOTable_car.close;
end;

procedure TForm_updatecarout.Edit10KeyPress(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_updatecarout.FormCreate(Sender: TObject);
begin
mglbt:=0;
end;

procedure TForm_updatecarout.DBGrid1TitleClick(Column: TColumn);
var
     i:integer;
     fieldname:string;
begin//排序
     i:=Column.Index;
     if bSort=0 then
     begin
         fieldname:=DBGrid1.Columns[i].FieldName+' ASC';
         bSort:=1;
     end
     else
     begin
         fieldname:=DBGrid1.Columns[i].FieldName+' DESC';
         bSort:=0;
     end;
     form_dm.ADOTable_car_out.open;
     form_dm.ADOTable_car_out.Sort:=fieldname;
end;

procedure TForm_updatecarout.Edit7Change(Sender: TObject);
begin
if edit7.Text<>'' then
begin
  edit7.Text:=floattostr(roundto(strtofloat(edit7.Text),-1));
end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -