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

📄 frm_allexportbilledit.pas

📁 这是一个基于delphi平台的物流空运管理系统!
💻 PAS
📖 第 1 页 / 共 5 页
字号:
     goodscode:string;  {主单货物代码}
     Cgoodscode:String; {分单货物代码}
     Function Calculate(Value,ValueMark,Formula:string):Real;  {统计}
     Function Calculate2(Day,Weight:real;Formula: string): Real;     
     procedure Pchargeweight;  {计算主单记费重量}
     procedure CPchargeweight;  {计算分单记费重量}
     procedure ChangePrice(OldCode,NewCode,FileCode:string);   {更新报价号之后应当进行的操作}
     procedure Saveifdiscard;   {主单作废与否后,分单是否作废}
     procedure Saveifchecked;   {主单作废与否后,分单是否作废}
     procedure SaveMainstat;
     procedure SaveHawbstat;
     procedure SaveMawbparpay;
     procedure SaveHawbparpay;
     function Havefendan:boolean;
    { Private declarations }
  public
    { Public declarations }
    IsEdit:Boolean;  {主单编辑标记}
    cIsEdit:Boolean; {分单编辑标记}
    gIsEdit:Boolean; {主单货物的编辑标记}
    gISChange:Boolean;{货物数据改变标记}
    cgIsEdit:Boolean; {分单货物的编辑标记}
    cgISChange:Boolean;{分单货物数据改变}
    Alone :Boolean; {主单独出现标记}
    ColLast:integer; {主单当前货物行}
    RowLast:integer; {主单当前货物列}
    cColLast:integer; {分单当前货物行}
    cRowLast:integer; {分单当前货物列}
    inserted:Boolean; //
    cFIsEdit:Boolean;  {判断费用的增加与编辑}
    COIsEdit:Boolean;  {判断业务操作的增加与编辑}
    BeConfirm:String;{是否经过财务的确认}
    procedure ClearSG;
    Constructor CreateFromP(Edit:Boolean;Lone:Boolean;Code:string;Sender: TComponent);
    Destructor Destroy;Override;
    procedure showChild(Code:string);
    Function SaveGoods:Boolean;
    Procedure ShowGoods;
    Function CSaveGoods:Boolean;
    Procedure cShowGoods;
    Procedure ShowFare(Code:string);
    Procedure ShowPreDo(Code:string);
    Procedure ClearSG2;
    Function GetGrade(Carrier,LoadPort,UnloadPort,GradeStr:String):String;
  end;

var
  FrmAllExportBillEdit: TFrmAllExportBillEdit;

implementation

uses Frm_Main, Frm_AllExportBillInfo, Frm_agreedocuedit;

{$R *.dfm}

procedure TFrmAllExportBillEdit.ShowGoods;
var
  Count:integer;
begin
  {检查完毕}
  gIsEdit:=true;{货物状态 处于编辑状态}

  with QryTemp do
    begin
       close;
       sql.text:='select * from planegoods where filecode ='''+Varmain+'''';
       open;
    end;

  if QryTemp.RecordCount <1 then
         Exit;

  SG.RowCount := QryTemp.RecordCount+1;
  QryTemp.First;
  For Count:=1 to QryTemp.RecordCount do
    begin
      SG.cells[0,Count]:=inttostr(QryTemp.FieldByName('Pieces').asinteger);
      SG.cells[1,Count]:=floattostr(QryTemp.FieldByName('weight').asfloat);
      SG.cells[2,Count]:=QryTemp.FieldByName('kgid').asString;
      SG.cells[3,Count]:=QryTemp.FieldByName('Size').asString;
      SG.cells[4,Count]:=QryTemp.FieldByName('rateclass').asString;
      SG.cells[5,Count]:=QryTemp.FieldByName('Formula').asString;
      SG.cells[6,Count]:=QryTemp.FieldByName('chargweight').asString;
      SG.cells[7,Count]:=floattostr(QryTemp.FieldByName('rate').asfloat);
      SG.cells[8,Count]:=floattostr(QryTemp.FieldByName('total').asfloat);
      SG.cells[9,Count]:=QryTemp.FieldByName('goods').asString;
      {记录货物自动编号}
      SG.cells[10,Count]:=QryTemp.FieldByName('GoodsCode').asString;
      {记录主单编号}
      SG.cells[11,Count]:=QryTemp.FieldByName('FileCode').asString;
      SG.cells[12,Count]:=QryTemp.FieldByName('SpeGoods').asString;
      SG.cells[13,Count]:=QryTemp.FieldByName('SpeRemark').asString;
      QryTemp.Next;
    end;
end;

Function TFrmAllExportBillEdit.Calculate(Value, ValueMark,Formula: string): Real;
var
  VarArray:Array[0..40] of string;
  Pstr:char;
  WordStr:string;
  i:integer;
  j:integer;
  VarFormula:String;
  FormulaChar:Pchar;
  StrLen:Integer;
  Data:real;
  k:integer;
  DataTemp:real;
begin
try
  J:=0;
  StrLen:=Length(Formula);
  Formulachar:=pchar(formula);
  VarFormula:='';
  for i:=0 to Strlen-1 do
    begin
       if  FormulaChar[i]=' ' then
          Continue;
       VarFormula:=VarFormula+FormulaChar[i];
    end;
//Split VarFromula into an Array VarArray
  StrLen:=Length(varFormula);
  Formulachar:=pchar(VarFormula);
  WordStr:='';
  for i:=0 to Strlen-1 do
    begin
        pstr:=FormulaChar[i];
        If Pos(Pstr,'+-*/')>0 then
         begin
             VarArray[j]:=WordStr;
             WordStr:='';
             j:=j+1;
             VarArray[j]:=pstr;
             j:=j+1;
          end
       Else
           WordStr:=WordStr+PStr;
   end;
   VarArray[j]:=WordStr;

//Do Formula calculate
    if uppercase(VarArray[0])=uppercase(ValueMark) then
       VarArray[0]:=Value;

    if uppercase(VarArray[2])=uppercase(ValueMark) then
       VarArray[2]:=Value;
    if vararray[1]='+' then
        Data:=StrToFloat(vararray[0])+StrToFloat(vararray[2]);
    if vararray[1]='-' then
        Data:=StrToFloat(vararray[0])-StrToFloat(vararray[2]);
    if vararray[1]='*' then
        Data:=StrToFloat(vararray[0])*StrToFloat(vararray[2]);
    if vararray[1]='/' then
        Data:=StrToFloat(vararray[0])/StrToFloat(vararray[2]);
    i:=3;
    while true do
      begin
          if i>j then
             Break;
          if uppercase(VarArray[i+1])=uppercase(ValueMark) then
            VarArray[i+1]:=Value;
          if vararray[i]='+' then
              Data:=Data+StrToFloat(vararray[i+1]);
          if vararray[i]='-' then
              Data:=Data-StrToFloat(vararray[i+1]);
          if vararray[i]='*' then
              Data:=Data*StrToFloat(vararray[i+1]);
          if vararray[i]='/' then
              Data:=Data/StrToFloat(vararray[i+1]);
          i:=i+2;
      end;
    Data:=strtofloat(FormatFloat('0.0',Data));
    datatemp:=data-int(data);
    if datatemp>0.5 then
      data:=int(data)+1
    else
      if datatemp=0 then
      else
        data:=int(data)+0.5;

    result:=strtofloat(FormatFloat('0.0',Data));
except
     ShowMessage('公式中存在错误的字符,请检查!');
end;
end;

function TFrmAllExportBillEdit.Calculate2(Day, Weight: real;
  Formula: string): Real;
var
  VarArray:Array[0..40] of string;
  Pstr:char;
  WordStr:string;
  i:integer;
  j:integer;
  VarFormula:String;
  FormulaChar:Pchar;
  StrLen:Integer;
  Data:real;
  k:integer;
  DataTemp:real;
begin
try
  J:=0;
//Delete all Blank From this Formula and Save it to VarFormula
  StrLen:=Length(Formula);
  Formulachar:=pchar(formula);
  VarFormula:='';
  for i:=0 to Strlen-1 do
    begin
       if  FormulaChar[i]=' ' then
          Continue;
       VarFormula:=VarFormula+FormulaChar[i];
    end;
//Split VarFromula into an Array VarArray
  StrLen:=Length(varFormula);
  Formulachar:=pchar(VarFormula);
  WordStr:='';
  for i:=0 to Strlen-1 do
    begin
        pstr:=FormulaChar[i];
        If Pos(Pstr,'+-*/')>0 then
         begin
             VarArray[j]:=WordStr;
             WordStr:='';
             j:=j+1;
             VarArray[j]:=pstr;
             j:=j+1;
          end
       Else
           WordStr:=WordStr+PStr;
   end;
   VarArray[j]:=WordStr;

//Do Formula calculate
    if uppercase(VarArray[0])=uppercase('X') then
       VarArray[0]:=Floattostr(day);

    if uppercase(VarArray[2])=uppercase('X') then
       VarArray[2]:=floattostr(day);

    if vararray[1]='+' then
        Data:=StrToFloat(vararray[0])+StrToFloat(vararray[2]);
    if vararray[1]='-' then
        Data:=StrToFloat(vararray[0])-StrToFloat(vararray[2]);
    if vararray[1]='*' then
        Data:=StrToFloat(vararray[0])*StrToFloat(vararray[2]);
    if vararray[1]='/' then
        Data:=StrToFloat(vararray[0])/StrToFloat(vararray[2]);
    i:=3;
    while true do
      begin
          if i>j then
             Break;
          if uppercase(VarArray[i+1])='X' then
            VarArray[i+1]:=floattostr(day);

          if vararray[i]='+' then
              Data:=Data+StrToFloat(vararray[i+1]);
          if vararray[i]='-' then
              Data:=Data-StrToFloat(vararray[i+1]);
          if vararray[i]='*' then
              Data:=Data*StrToFloat(vararray[i+1]);
          if vararray[i]='/' then
              Data:=Data/StrToFloat(vararray[i+1]);
          i:=i+2;
      end;
    Data:=Data*Weight;
    Data:=strtofloat(FormatFloat('0.00',Data));
    result:=data;
except
     ShowMessage('公式中存在错误的字符,请检查!');
end;
end;

procedure TFrmAllExportBillEdit.Pchargeweight;
Var
   chargeweight,str1,str2:real;
Begin
  {0 件数  1重量 2 单位}
  {3 货物体积 4 费用等级}
  {5 公式 6 计费重量}
  {7 单价 8 费用}
  {9 货物描述 12 C.M.I. 13}
  {}
 if FrmMain.TestTextNumber(SG.Cells[1,RowLast],'Real') then  {测试重量是否是数字}
 else
    SG.Cells[1,RowLast]:='0';
//    exit;

{如果不是数字,则复制为零}
 if FrmMain.TestTextNumber(SG.Cells[3,RowLast],'Real') then  {测试体积是否为数字}
  else
     SG.Cells[3,RowLast]:='0';
//     exit;

 if  SG.Cells[6,RowLast]=''  then   {如果计费重量为空,则付值为零}
      SG.Cells[6,RowLast]:='0';

 if  SG.Cells[7,RowLast]=''  then  {如果单价为空,则附值为零}
     SG.Cells[7,RowLast]:='0';

  if (SG.Cells[6,RowLast]='') or (SG.Cells[6,RowLast]='0') then
    begin
      if SG.Cells[5,RowLast]='' then
        begin
          {公式为空} {如果重量大于体积 计费重量便取重量,否则取体积}
          if strtoFloat(SG.Cells[1,RowLast])>strtoFloat(SG.Cells[3,RowLast]) then
             SG.Cells[6,RowLast]:=SG.Cells[1,RowLast]
          else
             SG.Cells[6,RowLast]:=SG.Cells[3,RowLast];
        end
     else
        begin
           {公式不为空}
           chargeweight:=calculate(SG.Cells[3,RowLast],'X',SG.Cells[5,RowLast]);
           {根据体积计算出相应的计费重量}
           {如果实际重量大于计费重量 计费重量便取得到的计费重量,否则取实际重量}
            if chargeweight>strtofloat(SG.Cells[1,RowLast]) then
                SG.Cells[6,RowLast]:=floattostr(chargeweight)
            else
                SG.Cells[6,RowLast]:=SG.Cells[1,RowLast];
        end;
     end;

        str1:=strtofloat(SG.Cells[6,RowLast]); {计费重量}
        str2:=strtofloat(SG.Cells[7,RowLast]); {单价}

        if SG.Cells[4,RowLast]='M' then   {费用等级}
        {如果 等级为M 则直接取计费重量,否则取单价和计费重量相乘的积}
           SG.Cells[8,RowLast]:=SG.Cells[6,RowLast]
        else
           SG.Cells[8,RowLast]:=Formatfloat('0.00',(str1*str2));


end;

procedure TFrmAllExportBillEdit.CPchargeweight; {计算分单}
Var
  chargeweight,str1,str2:real;
Begin
{1 件数,2 重量,3 单位,4 体积,5 等级,6 公式,7 计费重量,8 单价,}
{9 费用,10 货物描述,11 编号,12 编号,13 CMI,14 DD}

  {件数}
  if FrmMain.TestTextNumber(SG2.Cells[0,cRowLast],'Integer') then
  else
     SG2.Cells[1,CRowLast]:='0';

  {重量}
  if FrmMain.TestTextNumber(SG2.Cells[1,cRowLast],'Real') then
  else
     SG2.Cells[1,CRowLast]:='0';
     //exit;
  {体积}
  if FrmMain.TestTextNumber(SG2.Cells[3,cRowLast],'Real') then
  else
     SG2.Cells[3,CRowLast]:='0';
     //exit;

   {计费重量}
  if  SG2.Cells[6,cRowLast]=''  then SG2.Cells[6,cRowLast]:='0';

   {单价}
  if  SG2.Cells[7,cRowLast]=''  then SG2.Cells[7,cRowLast]:='0';

  if (SG2.Cells[6,cRowLast]='') or (SG2.Cells[6,cRowLast]='0') then
  begin
          {等级}
         if SG2.Cells[5,cRowLast]='' then
            begin
                {如果重量大于体积,则计费重量取重量,否则取体积}
              if strtofloat(SG2.Cells[1,cRowLast])>strtofloat(SG2.Cells[3,cRowLast]) then
                 SG2.Cells[6,cRowLast]:=SG2.Cells[1,cRowLast]
              else
                 SG2.Cells[6,cRowLast]:=SG2.Cells[3,cRowLast];
            end
         else
            begin
                chargeweight:=calculate(SG2.Cells[3,cRowLast],'X',SG2.Cells[5,cRowLast]);
                if chargeweight>strtofloat(SG2.Cells[1,cRowLast]) then

⌨️ 快捷键说明

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