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

📄 frm_ciqdata.pas

📁 这是一个基于delphi平台的物流空运管理系统!
💻 PAS
字号:
unit Frm_ciqdata;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Frm_Cargo, DB, ADODB, Grids, StdCtrls, Buttons, ExtCtrls,
  ComCtrls, EnterAsTab, XPMenu;

type
  TFrmciqdata = class(TFrmCargo)
    EnterAsTab1: TEnterAsTab;
    Shape2: TShape;
    GroupBox4: TGroupBox;
    Label8: TLabel;
    Label16: TLabel;
    Label15: TLabel;
    Label14: TLabel;
    Label13: TLabel;
    Label9: TLabel;
    Label32: TLabel;
    Label36: TLabel;
    Label58: TLabel;
    Label42: TLabel;
    Label38: TLabel;
    Label60: TLabel;
    Label59: TLabel;
    Comchengjiao: TComboBox;
    Edthetong: TEdit;
    Edtpizhun: TEdit;
    Edtxuke: TEdit;
    Edtbeian: TEdit;
    Commaoyi: TComboBox;
    Edtyundg: TEdit;
    Edtshuifu: TEdit;
    OrderDate: TDateTimePicker;
    EdtPort: TEdit;
    EdtShouH: TEdit;
    EdtJy: TEdit;
    ComZm: TComboBox;
    Panel1: TPanel;
    Panel2: TPanel;
    BitBtn3: TBitBtn;
    BitBtn4: TBitBtn;
    SG2: TStringGrid;
    BtnAdd: TBitBtn;
    BtnDel: TBitBtn;
    BtnSave: TBitBtn;
    QryTemp: TADOQuery;
    procedure FormCreate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure BtnAddClick(Sender: TObject);
    procedure BtnDelClick(Sender: TObject);
    procedure BtnSaveClick(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
    procedure SG2SelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
    procedure SG2SetEditText(Sender: TObject; ACol, ARow: Integer;
      const Value: String);
  private
  cgISChange:Boolean;
    CgIsEdit:Boolean;
    CRowLast:integer;
    CColLast:Integer;
    Function CSaveGoods:Boolean;
    Procedure cShowGoods;
    Procedure ClearSG2;
    { Private declarations }
  public
   VarHawb:String;
    { Public declarations }
  end;

var
  Frmciqdata: TFrmciqdata;

implementation

uses Frm_Main;

{$R *.dfm}
procedure TFrmCiqData.ClearSG2;
var
   count2:integer;
   count:integer;
begin
  inherited;
  if SG2.RowCount=2 then
    For Count2:= 0 to 11 do
       SG2.Cells[Count2,1]:= ''
  else
    begin
      For Count:=1 to SG2.RowCount-1 do
         For Count2:= 0 to 11 do
            SG2.Cells[Count2,Count]:='';
       SG2.RowCount :=2;
    end;
end;

function TFrmCiqData.CSaveGoods: Boolean;
var
  Count:integer;
  SqlStr:string;
  CgoodsCode:String;
begin
     Result:=false;
  Try
     {1 商品编号  2 货物描述  3 数量 4 单位 5 原产国  }
     {6 货物体积  7 单价  8  费用 9 币种 10 征免  }
     {11 货物自动编号  12 FileCode号}

   {商品编号,货物描述,数量,单位,原产国,货物体积,单价,费用,比重,征免}
   if FrmMain.TestTextNumber(SG2.Cells[2,CRowLast],'integer') then
    else
      begin
       ShowMessage('请在件数中输入数值类型的信息');
       exit;
      end;

    if FrmMain.TestTextNumber(SG2.Cells[5,CRowLast],'real') then
    else
      begin
       ShowMessage('请在货物体积中输入数值类型的信息');
       exit;
      end;

    if FrmMain.TestTextNumber(SG2.Cells[6,CRowLast],'real') then
    else
      begin
       ShowMessage('请在单价中输入数值类型的信息');
       exit;
      end;



    if FrmMain.TestTextNumber(SG2.Cells[7,CRowLast],'real') then
    else
      begin
       ShowMessage('请在总额中输入数值类型的信息');
       exit;
      end;


  if cgIsedit then
    begin
      FrmMain.UpStr(SqlStr,'PlaneGoods ');
      FrmMain.UpStr(SqlStr,'GoodsNO',SG2.Cells[0,CRowLast],',');
      FrmMain.UpStr(SqlStr,'Goods',SG2.Cells[1,CRowLast],',');
      FrmMain.UpStr(SqlStr,'pieces',strtofloat(SG2.Cells[2,CRowLast]),',');
      FrmMain.UpStr(SqlStr,'kgid',SG2.Cells[3,CRowLast],',');
      FrmMain.UpStr(SqlStr,'GoodsCity',SG2.Cells[4,CRowLast],',');
      FrmMain.UpStr(SqlStr,'Size',StrTofloat(SG2.Cells[5,CRowLast]),',');
      FrmMain.UpStr(SqlStr,'rate',strtofloat(SG2.Cells[6,CRowLast]),',');
      FrmMain.UpStr(SqlStr,'total',strtofloat(SG2.Cells[7,CRowLast]),',');
      FrmMain.UpStr(SqlStr,'Currency',SG2.Cells[8,CRowLast],',');
      FrmMain.UpStr(SqlStr,'Recuit',SG2.Cells[9,CRowLast],'');
      FrmMain.UpStr(SqlStr,'GoodsCode=',SG2.Cells[10,CRowLast],'w');
    end
  else
    begin
     {1 商品编号  2 货物描述  3 数量 4 单位 5 原产国  }
     {6 货物体积  7 单价  8  费用 9 币种 10 征免  }
     {11 货物自动编号  12 FileCode号}
      Cgoodscode:=FrmMain.GetCode('B') ;
      SqlStr:='Insert into PlaneGoods(GoodsCode,FileCode,GoodsNo,Goods,'+
        'Pieces,kgid,goodscity,size,rate,total,currency,recuit) Values(';
      FrmMain.InsStr(SqlStr,Cgoodscode,',');
      FrmMain.InsStr(SqlStr,varhawb,',');
      FrmMain.InsStr(SqlStr,SG2.Cells[0,CRowLast],',');
      FrmMain.InsStr(SqlStr,SG2.Cells[1,CRowLast],',');
      FrmMain.InsStr(SqlStr,strtoint(SG2.Cells[2,CRowLast]),',');
      FrmMain.InsStr(SqlStr,SG2.Cells[3,CRowLast],',');
      FrmMain.InsStr(SqlStr,SG2.Cells[4,CRowLast],',');
      FrmMain.InsStr(SqlStr,strtofloat(SG2.Cells[5,CRowLast]),',');
      FrmMain.InsStr(SqlStr,strtofloat(SG2.Cells[6,CRowLast]),',');
      FrmMain.InsStr(SqlStr,strtofloat(SG2.Cells[7,CRowLast]),',');
      FrmMain.InsStr(SqlStr,SG2.Cells[8,CRowLast],',');
      FrmMain.InsStr(SqlStr,SG2.Cells[9,CRowLast],'');
    end;

  if FrmMain.ExecSQL(SqlStr) then
  else
    Begin
     ShowMessage('分单货物记录存储失败,请检查!');
     exit;
    end;

   CGIsEdit:=True;  {把增加编辑标志置为编辑状态}
   btnadd.Enabled :=true;
  except
  end;
 Result:=True;
end;

procedure TFrmciqdata.FormCreate(Sender: TObject);
begin
  inherited;
 {商品编号,货物描述,数量,单位,原产国,净重,单价,总价,币种,征免}
  SG2.ColWidths[0]:=50;{商品编号}
  SG2.ColWidths[1]:=150; {货物描述}
  SG2.ColWidths[2]:=50; {数量}
  SG2.ColWidths[3]:=80; {单位}
  SG2.ColWidths[4]:=100; {原产国}
  SG2.ColWidths[5]:=75; {体积}
  SG2.ColWidths[6]:=80;  {单价}
  SG2.ColWidths[7]:=80; {费用}
  SG2.ColWidths[8]:=90;  {币种}
  SG2.ColWidths[9]:=100;  {征免}
  SG2.ColWidths[10]:=1;
  SG2.ColWidths[11]:=1;

  SG2.Cells[0,0]:='商品编号';
  SG2.Cells[1,0]:='货物描述';
  SG2.Cells[2,0]:='数量';
  SG2.Cells[3,0]:='单位';
  SG2.Cells[4,0]:='原产国';
  SG2.Cells[5,0]:='净重';
  SG2.Cells[6,0]:='单价';
  SG2.Cells[7,0]:='总价';
  SG2.Cells[8,0]:='币种';
  SG2.Cells[9,0]:='征免';
  SG2.Cells[10,0]:='';   {记录货物自动编号}
  SG2.Cells[11,0]:='';  {记录FileCode号}
end;

procedure TFrmCiqData.cShowGoods;
var
  Count:integer;
begin
  cgIsEdit:=true;//货物状态
  with QryTemp do
    begin
       close;
       sql.text:='select * from planegoods where filecode ='''+varHawb+'''';
       open;
    end;

  if QryTemp.RecordCount <1 then
     begin
       clearsg2;
       Exit;
     end;

  SG2.RowCount := QryTemp.RecordCount+1;

  QryTemp.First;
  For Count:=1 to QryTemp.RecordCount do
    begin
     {1 商品编号  2 货物描述  3 数量 4 单位 5 原产国  }
     {6 货物体积  7 单价  8  费用 9 币种 10 征免  }
     {11 货物自动编号  12 FileCode号}
      SG2.cells[0,Count]:=QryTemp.FieldByName('GoodsNo').asString;
      SG2.cells[1,Count]:=QryTemp.FieldByName('goods').asString;
      SG2.cells[2,Count]:=inttostr(QryTemp.FieldByName('Pieces').asinteger);
      SG2.cells[3,Count]:=QryTemp.FieldByName('kgid').asString;
      SG2.cells[4,Count]:=QryTemp.FieldByName('GoodsCity').asString;
      SG2.cells[5,Count]:=QryTemp.FieldByName('Size').asString;
      SG2.cells[6,Count]:=floattostr(QryTemp.FieldByName('rate').asfloat);
      SG2.cells[7,Count]:=floattostr(QryTemp.FieldByName('total').asfloat);
      SG2.cells[8,Count]:=QryTemp.FieldByName('currency').asString;
      SG2.cells[9,Count]:=QryTemp.FieldByName('recuit').asString;
      SG2.cells[10,Count]:=QryTemp.FieldByName('GoodsCode').asString;
      SG2.cells[11,Count]:=QryTemp.FieldByName('FileCode').asString;
      QryTemp.Next;
    end;
end;

procedure TFrmciqdata.FormActivate(Sender: TObject);
begin
  inherited;
   cshowgoods;
   with QryTemp do
    begin
        close;
        sql.text:='select * from filetable where filecode ='''+varhawb+'''';
        open;
     end;
   if qrytemp.recordcount>0 then
   else
     exit;

   {收货单位}
    EdtShouh.Text:=QryTemp.fieldbyName('AGENTACC').asstring;
   {经营单位}
    edtjy.Text:=QryTemp.fieldbyName('RealDept').asstring;
   {进口口岸}
    edtport.Text:=QryTemp.fieldbyName('jkport').asstring;
    {备案号}
    Edtbeian.Text:=QryTemp.fieldbyName('DocuNo').asstring;
    {许可证号}
    Edtxuke.Text:=QryTemp.fieldbyName('Docuxk').asstring;
    {批准文号}
    Edtpizhun.Text:=QryTemp.fieldbyName('Docupz').asstring;
    {合同协议号}
    Edthetong.Text:=QryTemp.fieldbyName('Docuxy').asstring;
    {成交方式}
    Comchengjiao.Text:=QryTemp.fieldbyName('Bargainstyle').asstring;
    {贸易方式}
    commaoyi.Text:=QryTemp.fieldbyName('Tradetype').asstring;
    {征免性质}
    comzm.Text:=QryTemp.fieldbyName('Recuitch').asstring;
    {随付单据}
    Edtshuifu.Text:=QryTemp.fieldbyName('Billfile').asstring;
    {启运国}
    Edtyundg.Text:=QryTemp.fieldbyName('citydest').asstring;
    {申报日期}
    Edtyundg.Text:=QryTemp.fieldbyName('citydest').asstring;
end;

procedure TFrmciqdata.BtnAddClick(Sender: TObject);
var
  Count:integer;
begin
  inherited;
  btnadd.Enabled :=false;  {把增加按钮置为假}

  Cgischange:=false;  {货物数据改变置为假}
  if (SG2.RowCount =2) and (SG2.Cells[11,1]='') then
  {如果StringGrid为两行,并且FileCode为空,则不进行增加StringGrid行的操作}
    begin
      cgIsEdit:=false;
      For Count:=0 to 11 do  {清空当前行的内容}
         SG2.Cells[Count,SG2.RowCount]:='';

     {到达新增加的一行上面,因为StringGrid是从零开始的,所以必须减一}
      SG2.Row:=SG2.RowCount-1;
      cRowLast:=SG2.Row; {把CrowLast的值设为当前行}
    end
  else
    begin
      SG2.RowCount:=SG2.RowCount+1;
      cgIsEdit:=false;
      For Count:=0 to 11 do
         SG2.Cells[Count,SG2.RowCount]:='';

      SG2.Row:=SG2.RowCount-1;  {到达新增加的一行上面}
      cRowLast:=SG2.Row; {把CrowLast的值设为当前行}
   end;
end;

procedure TFrmciqdata.BtnDelClick(Sender: TObject);
var
  Count:integer;
  Count2:integer;
  SqlStr:string;
  SqlStr1:string;
begin
  inherited;
  if (cRowLast<0)or(cRowLast>SG2.RowCount-1) then
      exit;

  SqlStr:='Delete PlaneGoods where GoodsCode='''+SG2.Cells[10,cRowLast]+'''';
  if FrmMain.ExecSQL(SqlStr) then
  else
    begin
      ShowMessage('货物数据记录删除操作失败,请检查!');
      exit;
    end;

   if SG2.RowCount=2 then
      For Count2:= 0 to 11 do
        SG2.Cells[Count2,1]:= ''
   else
     begin
        For Count:=cRowLast to SG2.RowCount-1 do
          For Count2:= 0 to 11 do
            SG2.Cells[Count2,Count]:= SG2.Cells[Count2,Count+1];
            SG2.RowCount := SG2.RowCount -1;
     end;
  cgISChange:=false;{货物数据改变}
end;

procedure TFrmciqdata.BtnSaveClick(Sender: TObject);
begin
  inherited;
  cSaveGoods;  {保存货物数据}
  cShowGoods;  {显示货物数据}
  cgIsEdit:=true;  {把增加编辑状态置为编辑状态}
  Btnadd.Enabled :=true;  {把增加按钮置为真}
  cgISChange:=false;  {货物数据改变置为假,即:货物数据没有改变}
end;

procedure TFrmciqdata.BitBtn3Click(Sender: TObject);
var
  SqlStr:string;
begin
  inherited;
  sqlstr:='';
  FrmMain.UpStr(sqlstr,'filetable');
  {收货单位}
  FrmMain.UpStr(sqlstr,'AGENTACC',edtshouh.Text,',');
  {经营单位}
  FrmMain.UpStr(sqlstr,'realdept',edtjy.Text,',');
  {进口口岸}
  FrmMain.UpStr(sqlstr,'jkport',Edtport.Text,',');
  {备案号}
  FrmMain.UpStr(sqlstr,'DocuNo',Edtbeian.Text,',');
  {许可证号}
  FrmMain.UpStr(sqlstr,'Docuxk',Edtxuke.Text,',');
  {批准文号}
  FrmMain.UpStr(sqlstr,'Docupz',Edtpizhun.Text,',');
  {合同协议号}
  FrmMain.UpStr(sqlstr,'Docuxy',Edthetong.Text,',');
  {成交方式}
  FrmMain.UpStr(sqlstr,'Bargainstyle',Comchengjiao.Text,',');
  {运抵国}
  FrmMain.UpStr(sqlstr,'citydest',Edtyundg.Text,',');
  {贸易方式}
  FrmMain.UpStr(sqlstr,'Tradetype',commaoyi.Text,',');
  {征免性质}
  FrmMain.UpStr(sqlstr,'Recuitch',comzm.Text,',');
 {随付单据}
  FrmMain.UpStr(sqlstr,'Billfile',Edtshuifu.Text,',');
 {申报日期}
  FrmMain.UpStr(sqlstr,'Declaredate',datetimetostr(int(orderdate.date)),'');
  FrmMain.UpStr(sqlstr,'filecode =',varhawb,'w');
  if FrmMain.execsql(sqlstr) then
  else
     begin
        ShowMessage('进口报关单记录未保存,请检查');
        exit;
    end;
  close;
end;

procedure TFrmciqdata.BitBtn4Click(Sender: TObject);
begin
  inherited;
 Close;
end;

procedure TFrmciqdata.SG2SelectCell(Sender: TObject; ACol, ARow: Integer;
  var CanSelect: Boolean);
var
  Rect:Trect;
begin
  inherited;
   if (ACol= 11)or(ACol=10) then
    begin
      CanSelect := False;
      Exit;
    end;
  if (cgischange) and (ARow<>cRowLast) then
    begin
       btnsaveclick(self);
    end;

  if btnadd.Enabled then
   else
    begin
        cgischange:=true;
    end;
 {1 商品编号  2 货物描述  3 数量 4 单位 5 原产国  }
     {6 货物体积  7 单价  8  费用 9 币种 10 征免  }
     {11 货物自动编号  12 FileCode号}

  Rect:=SG2.CellRect(ACol,ARow);

  cColLast:=ACol;
  cRowLast:=ARow;
  if SG2.Cells[11,CrowLast]='' then    {如果}
      cgischange:=true;
end;

procedure TFrmciqdata.SG2SetEditText(Sender: TObject; ACol, ARow: Integer;
  const Value: String);
begin
  inherited;
 cgISChange:=true;//货物数据改变
end;

end.

⌨️ 快捷键说明

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