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

📄 frm_allimportbillinfo.pas

📁 这是一个基于delphi平台的物流空运管理系统!
💻 PAS
📖 第 1 页 / 共 5 页
字号:
        SqlStr := 'insert into landtrans(transcode,trustcode,goodshw,' +
          'carname,carrela,thdate,stationcode,' +
          'stationaddr,stationrelation,stationtele,jcno,jcdate,' +
          'jctime,ccdate,cctime,goodsplace,' +
          'goodsrelationstyle,goodsrelation,dodate,jcpc,benative,remark) values(';
        FrmMain.InsStr(sqlstr, CodeGet, ',');
        FrmMain.InsStr(sqlstr, varhawb, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.goodshw, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.carname, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.carrela, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.thdate, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.station, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.stationaddr, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.stationrela, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.stationstyle, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.jcno, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.jcdate, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.jctime, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.ccdate, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.cctime, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.goodsplace, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.goodsrelastyle, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.goodsrela, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.recorddate, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.ifpc, ',');
        FrmMain.InsStr(sqlstr, jcpcfile.ifnative, ',');

        FrmMain.InsStr(sqlstr, jcpcfile.remark, '');
        if FrmMain.ExecSQL(sqlstr) then
        else
        begin
          ShowMessage('分单进舱派车数据导入插入时出错,记录导入失败,请检查!');
          exit;
        end;
      end;

      {报关文件}
      if ztrustfile.bgnumber > 0 then
      begin
        for i := 1 to ztrustfile.bgnumber do
        begin
          context := fileread(myfilehandle, bgfile, sizeof(bgfile));
          codeget := FrmMain.GetCode('K');
          sqlstr := 'insert into truckfile(kcode,trustcode,fileno,mawb,cuscode,'
            +
            'ciqname,filename,filenameno,recedate,returndate,ciqrecedate,ciqreturndate,' +
            'occurtime,PlaneOcean,operator,remark) values(';
          FrmMain.InsStr(sqlstr, codeget, ',');
          FrmMain.InsStr(sqlstr, varhawb, ',');
          FrmMain.InsStr(sqlstr, bgfile.fileno, ',');
          FrmMain.InsStr(sqlstr, bgfile.mawb, ',');
          FrmMain.InsStr(sqlstr, bgfile.jyname, ',');
          FrmMain.InsStr(sqlstr, bgfile.bghname, ',');
          FrmMain.InsStr(sqlstr, bgfile.filename, ',');
          FrmMain.InsStr(sqlstr, bgfile.filenameno, ',');
          FrmMain.InsStr(sqlstr, bgfile.cusrecedate, ',');
          FrmMain.InsStr(sqlstr, bgfile.cusretudate, ',');
          FrmMain.InsStr(sqlstr, bgfile.ciqrecedate, ',');
          FrmMain.InsStr(sqlstr, bgfile.ciqretudate, ',');
          FrmMain.InsStr(sqlstr, bgfile.recorddate, ',');
          FrmMain.InsStr(sqlstr, 0, ',');
          FrmMain.InsStr(sqlstr, bgfile.opercode, ',');
          FrmMain.InsStr(sqlstr, bgfile.remark, '');
          if FrmMain.ExecSQL(SqlStr) then
          else
          begin
            ShowMessage('分单报关文件数据导入插入时出错,记录导入失败,请检查!');
            exit;
          end;
        end;
      end;

      {费用记录}
      if ztrustfile.farenumber > 0 then
      begin
        for i := 1 to ztrustfile.farenumber do
        begin
          context := fileread(myfilehandle, farefile, sizeof(farefile));
          codeget := FrmMain.GetCode('F');
          SqlStr := 'insert into FareInfo(Fareno,Filecode,cuscode,cuscodename,'
            +
            'Farecode,Farepaytodate,Billno,invoiceno,bxno,operator,Acount,FareType,' +
            'Writedate,currencytype,currencyrate,recedeal,' +
            'goodscode,unitprice,opercwmark,Remark) values (';
          FrmMain.InsStr(sqlstr, codeget, ',');
          FrmMain.InsStr(sqlstr, varhawb, ',');
          FrmMain.InsStr(sqlstr, farefile.cuscode, ',');
          FrmMain.InsStr(sqlstr, farefile.cuscodename, ',');
          FrmMain.InsStr(sqlstr, farefile.farename, ',');
          FrmMain.InsStr(sqlstr, farefile.paytodate, ',');
          FrmMain.InsStr(sqlstr, farefile.billno, ',');
          FrmMain.InsStr(sqlstr, farefile.invoiceno, ',');
          FrmMain.InsStr(sqlstr, '', ',');
          FrmMain.InsStr(sqlstr, farefile.opercode, ',');
          FrmMain.InsStr(sqlstr, farefile.fareacount, ',');
          FrmMain.InsStr(sqlstr, farefile.faretype, ',');
          FrmMain.InsStr(sqlstr, farefile.recorddate, ',');
          FrmMain.InsStr(sqlstr, farefile.currencytype, ',');
          FrmMain.InsStr(sqlstr, farefile.rate, ',');
          FrmMain.InsStr(sqlstr, farefile.recedeal, ',');
          FrmMain.InsStr(sqlstr, farefile.farefl, ',');
          FrmMain.InsStr(sqlstr, farefile.unitprice, ',');
          FrmMain.InsStr(sqlstr, farefile.opercwmark, ',');
          FrmMain.InsStr(sqlstr, '', '');
          if FrmMain.ExecSQL(SqlStr) then
          else
          begin
            ShowMessage('分单费用数据导入插入时出错,记录导入失败,请检查!');
            exit;
          end;
        end;
      end;
    end;
    ShowMessage('导入文件成功,请检查!');
    Fileclose(myfilehandle);
  except
    Fileclose(myfilehandle);
    ShowMessage('导入文件失败,请检查!');
  end;
end;

procedure TFrmAllImportBillInfo.Reopen;
begin
  try
    LV.Items.Clear;
    if QryTemp.Active then QryTemp.Close;
    QryTemp.open;
    FrmMain.AddData(LV, QryTemp);
    QryTemp.Close;
  except
    ShowMessage('数据库打开失败!');
  end;
end;

procedure TFrmAllImportBillInfo.EditItem(string1, string2, string3, string4,
  string5, string6: string);
begin
  LV.Selected.Caption := String1;
  LV.Selected.SubItems[0] := string2;
  LV.Selected.SubItems[1] := string3;
  LV.Selected.SubItems[2] := string4;
  LV.Selected.SubItems[3] := string5;
  LV.Selected.SubItems[4] := string6;
end;

procedure TFrmAllImportBillInfo.AddItem(string1, string2, string3, string4,
  string5, string6: string);
var
  ItemNew: TlistItem;
begin
  ItemNew := TlistItem.Create(LV.Items);
  ItemNew := LV.Items.add;
  ItemNew.Caption := String1;
  ItemNew.SubItems.add(string2);
  ItemNew.SubItems.add(string3);
  ItemNew.SubItems.add(string4);
  ItemNew.SubItems.add(string5);
  ItemNew.SubItems.add(string6);
  ItemNew.Selected := true;
end;

procedure TFrmAllImportBillInfo.Search(value: string);
begin
  QryTemp.SQL.Text := value;
  LV.Items.Clear;
  try
    if QryTemp.Active then QryTemp.Close;
    QryTemp.open;
    FrmMain.AddData(LV, QryTemp);
    QryTemp.Close;
  except
    showmessage('数据库打开失败!');
  end;
end;

procedure TFrmAllImportBillInfo.FormCreate(Sender: TObject);
begin
  inherited;
  FrmMain.AddColumn(LV, '自动编号', 100);
  FrmMain.AddColumn(LV, '工作单号', 100);
  FrmMain.AddColumn(LV, '全部工作单号', 100);
  FrmMain.AddColumn(LV, '主运单号', 100);
  FrmMain.AddColumn(LV, '发货人', 150);
  FrmMain.AddColumn(LV, '航班号', 80);
  FrmMain.AddColumn(LV, '代理名称', 100);
  FrmMain.AddColumn(LV, '品名', 80);
  FrmMain.AddColumn(LV, '件数', 40);
  FrmMain.AddColumn(LV, '重量', 40);
  FrmMain.AddColumn(LV, '体积', 40);
  FrmMain.AddColumn(LV, '签发日期', 100);
  self.Top := 20;
  self.Left := 20;
  try
    {自动编号  FileNo   主单号  发货人,航次,发货港,代理名称,}
    {品名,件数,重量,体积,业务员,到达日期}
    QryTemp.Close;
    QryTemp.SQL.text := 'select a.Filecode,a.filegroup,a.hawb,' +
      'a.Maincode,a.cuscodename,a.by1,a.agentcode,' +
      'goodsdesc,goodsnumber,goodsweight,goodssize,' +
      'a.dExecdate ' +
      ' from FileTable a ' +
      ' where a.inout=0 and ' +
      ' Substring(a.filecode,1,1)=''K'' and a.operate=''' + Frmmain.loginname +
      ''' ' +
      ' and a.ifdiscard=0  and a.dEXECDATE>=''' + DatetoStr(Now) + '''';
    QryTemp.Open;
    FrmMain.AddData(LV, QryTemp);
    QryTemp.Close;
  except
    ShowMessage('进口业务数据表打开失败,请检查!');
  end;
  IsFirstOpen := False;

  IsFirstOpen := true;
end;

procedure TFrmAllImportBillInfo.BtnNewClick(Sender: TObject);
begin
  inherited;
  if FrmMain.IncludeValue('进口业务操作') then
  else
  begin
    ShowMessage('对不起,你不具有该操作的权限!');
    exit;
  end;
  FrmAllImportBillEdit := FrmAllImportBillEdit.CreateFromP(false, false, '',
    self);
  FrmAllImportBillEdit.Show;

end;

procedure TFrmAllImportBillInfo.BtnEditClick(Sender: TObject);
begin
  inherited;
  if FrmMain.IncludeValue('进口业务操作') then
  else
  begin
    ShowMessage('对不起,您不具备此项权限!');
    exit;
  end;

  if lv.SelCount = 0 then
    ShowMessage('请选中一条记录进行编辑')
  else
  begin
    VarCode := lv.Selected.Caption;
    FrmAllImportBillEdit := TFrmAllImportBillEdit.CreateFromP(True, false,
      VarCode, self);
    FrmAllImportBillEdit.Show;
  end;
end;

procedure TFrmAllImportBillInfo.BtnQueryClick(Sender: TObject);
begin
  inherited;
  FrmAllImportBillSearch := FrmAllImportBillSearch.create(self);
  FrmAllImportBillSearch.Showmodal;
end;

procedure TFrmAllImportBillInfo.BtnDeleteClick(Sender: TObject);
var
  SearchCode, SqlStr, baojiahao: string;
begin
  inherited;
  try
    if FrmMain.IncludeValue('进口业务操作') then
    else
    begin
      ShowMessage('对不起,您不具备此项权限!');
      exit;
    end;

    if lv.Items.Count = 0 then
    begin
      ShowMessage('记录集为空,不能够删除');
      exit;
    end;

    if LV.SelCount = 0 then
    begin
      ShowMessage('请选中一条要删除的记录');
      exit;
    end;

    QryTemp.close;
    QryTemp.SQL.text := 'select keydown from filetable where filecode=''' +
      lv.selected.caption + '''';
    QryTemp.open;
    if QryTemp.FieldByName('keydown').asinteger = 1 then
    begin
      ShowMessage('该委托记录已经确认完成,请先修改确认完成标记,再进行删除!');
      exit;
    end;

    SearchCode := LV.Selected.Caption;
    if FrmMain.CheckExistCount(' maincode', SearchCode, 'filetable') <> 0 then
    begin
      ShowMessage('此主单包含分单记录请先删除分单记录!记录未删除!');
      exit;
    end;

    QryTemp.close;
    QryTemp.SQL.text := 'select ShMark from filetable where filecode=''' +
      lv.selected.caption + '''';
    QryTemp.open;
    if QryTemp.FieldByName('shmark').asstring = 'TRUE' then
    begin
      ShowMessage('该委托记录所具有的费用已经导入到财务中,不能够删除!');
      exit;
    end;

    if MessageDlg('是否删除所选中的记录,请确定', mtConfirmation, [mbYes, mbNo],
      0) = mrno then
      exit
    else
    begin
      if FrmMain.UseDB.InTransaction then
      else
        FrmMain.UseDB.BeginTrans;

      QryTemp.Close;
      QryTemp.SQL.text := 'select  * from FileTable where  filecode=''' +
        searchcode + '''';
      QryTemp.open;
      baojiahao := QryTemp.fieldbyname('quotecode').asstring;
      QryTemp.Close;
      if baojiahao = '' then
      begin

        if FrmMain.ExecSQL('delete from fareinfo where filecode=''' + searchcode
          + '''') then
        else
        begin
          ShowMessage('与该主单相关联的费用数据删除有误,记录未删除,请检查!');
          FrmMain.UseDB.RollbackTrans;
          exit;
        end;

        if FrmMain.ExecSQL('delete from Planegoods where filecode=''' +
          searchcode + '''') then
        else
        begin
          ShowMessage('主单货物数据删除有误,

⌨️ 快捷键说明

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