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

📄 ad_enter_assetcard_d.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 4 页
字号:
      abort;
    end;
    if Trim(edt_UseStatusCode.Text)='' then
    begin
      DispInfo('使用状态不能为空!',1);
      if edt_UseStatusCode.CanFocus then
      edt_UseStatusCode.SetFocus;
      abort;
    end;
    if Trim(edt_CurrencyCode.Text)='' then
    begin
      DispInfo('货币不能为空!',1);
      if edt_CurrencyCode.CanFocus then
      edt_CurrencyCode.SetFocus;
      abort;
    end;
    if Trim(edt_Intendingperiod.Text)='' then
    begin
      DispInfo('使用年限不能为空!',1);
      if edt_Intendingperiod.CanFocus then
      edt_Intendingperiod.SetFocus;
      abort;
    end;
    
  end;

  edt_FirstAmount.OnExit(edt_FirstAmount) ;
  edt_Draffrate.OnExit(edt_Draffrate);
  edt_DepreciationValue.OnExit(edt_DepreciationValue);
  if cmbx_Depreciationway.ItemIndex=0 then
    begin
      if strtofloat(Trim(EDT_IntendingPeriod.Text))*12-strtofloat(Trim(edt_usedperiod.text))>0 then
        begin
          edt_PeriodValue.Text:=formatfloat('0.00000000',(strtofloat(Trim(edt_netValue.text))-strtofloat(Trim(edt_DraffValue.text)))/(strtofloat(Trim(edt_intendingperiod.text))*12-strtofloat(Trim(edt_usedperiod.text))));
          edt_Periodrate.Text:=formatfloat('0.00',strtofloat(edt_PeriodValue.text)/(strtofloat(edt_netValue.text)-strtofloat(edt_DraffValue.text)));
        end
      else
        begin
          edt_PeriodValue.Text:=formatfloat('0.00000000',(strtofloat(Trim(EDT_FirstFAmount.text))-strtofloat(Trim(edt_DraffValue.text)))/(strtofloat(Trim(edt_intendingperiod.text))*12));
          edt_Periodrate.Text:=formatfloat('0.00',strtofloat(edt_PeriodValue.text)/(strtofloat(EDT_FirstFAmount.text)-strtofloat(edt_DraffValue.text)));
        end;
    end;
  if cmbx_Depreciationway.ItemIndex=1 then
    begin
      if(strtofloat(edt_intending.Text)-strtofloat(EDT_FinishTask.Text))=0 Then edt_PcDepreciation.Text:='0'
      else edt_PcDepreciation.Text:=floattostr((strtofloat(edt_netValue.text)-strtofloat(edt_DraffValue.text))/(strtofloat(edt_intending.Text)-strtofloat(EDT_FinishTask.Text)));
      if Trim(edt_DepreciationValue.Text)='' then
        edt_DepreciationValue.Text:=floattostr(strtofloat(edt_Finishtask.text)*strtofloat(edt_PcDepreciation.text));
    end;
  inherited;
end;

procedure TFrm_Ad_Enter_AssetCard_D.InitDeptInfo;
var
  i:Integer;
begin
  With AdoQry_Tmp Do
  begin
    Close;
    Sql.clear;
    Sql.Text:='select a.AssetCode,a.fixingName,a.fixingspec,a.UomCode,b.UomName,a.fixingAmount,a.fixingsum,a.RemArk '+
              'from Ad_Pertainfixing a Left outer join Uom b On a.UomCode=b.UomCode '+
              'where a.AssetCode='''+Edt_AssetCode.Text+''' ';
    Open;
    First;
    i:=0;
    DeptInfo.RecordCountKm:=AdoQry_Tmp.RecordCount;
    While Not Eof do
    begin
      DeptInfo.AssetCodeKm[i]:=fieldbyname('AssetCode').AsString;
      DeptInfo.fixingName[i]:=fieldbyname('fixingName').AsString;
      DeptInfo.fixingspec[i]:=fieldbyname('fixingspec').AsString;
      DeptInfo.UomCode[i]:=fieldbyname('UomCode').AsString;
      DeptInfo.UomName[i]:=fieldbyname('UomName').AsString;
      DeptInfo.fixingAmount[i]:=fieldbyname('fixingAmount').Asfloat;
      DeptInfo.fixingsum[i]:=fieldbyname('fixingsum').Asfloat;
      DeptInfo.RemArkKm[i]:=fieldbyname('RemArk').AsString;
      i:=i+1;
      Next;
    end;

    Close;
    Sql.clear;
    Sql.Text:='select a.AssetCode,a.DeptCode,b.DeptName,a.kmCode,c.kmName,a.AssignRate,a.RemArk '+
              'from Ad_UseDept a Left Join Dept b On a.DeptCode=b.DeptCode '+
                                'left join Gl_AccountSubject c on a.kmCode=c.kmCode '+
              'where a.AssetCode='''+Edt_AssetCode.Text+''' ';
    Open;
    First;
    i:=0;
    DeptInfo.RecordCount:=AdoQry_Tmp.RecordCount;
    While Not Eof do
    begin
      DeptInfo.AssetCode[i]:=fieldbyname('AssetCode').AsString;
      DeptInfo.DeptCode[i]:=fieldbyname('DeptCode').AsString;
      DeptInfo.DeptName[i]:=fieldbyname('DeptName').AsString;
      DeptInfo.kmCode[i]:=fieldbyname('KmCode').asstring;
      DeptInfo.kmName[i]:=fieldbyname('KmName').asstring;
      DeptInfo.AssignRate[i]:=fieldbyname('AssignRate').AsString;
      DeptInfo.RemArk[i]:=fieldbyname('RemArk').AsString;
      i:=i+1;
      Next;
    end;
  end;
end;

procedure TFrm_Ad_Enter_AssetCard_D.Edt_UomCodeChange(Sender: TObject);
begin
  inherited;
  btn_ok.Enabled:=True;
end;

procedure TFrm_Ad_Enter_AssetCard_D.MEDT_StArtStopUseDateExit(
  Sender: TObject);
begin
 // inherited;

end;

procedure TFrm_Ad_Enter_AssetCard_D.Edt_UomCodeButtonClick(
  Sender: TObject);
begin
  inherited;
  CommOnHint(Sender,AdoQry_Tmp,'UomName','单位名称','UomCode',
             '单位代码',' Uom ');
end;

procedure TFrm_Ad_Enter_AssetCard_D.Edt_UomCodeKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key=120 then
  CommOnHint(Sender,AdoQry_Tmp,'UomName','单位名称','UomCode',
             '单位代码',' Uom ');
end;

procedure TFrm_Ad_Enter_AssetCard_D.Edt_UomCodeExit(Sender: TObject);
begin
  inherited;
  if(ActiveControl.Name='btn_Cancel')then
    Abort;
  if  TCustomEdit(Sender).Text <>'' then
  begin
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.clear;
    AdoQry_Tmp.SQL.Text:=' Select UomCode,UomName from Uom'
                        +'          where UomCode= '''+TCustomEdit(Sender).Text+''' ';
    AdoQry_Tmp.Open;
    if not AdoQry_Tmp.Eof then
    begin
      Extedit1.Text := AdoQry_Tmp.fieldbyname('UomName').AsString;
    end
    else
    begin
      DispInfo('单位代码错误,请重新输入!',1);
      TWinControl(Sender).SetFocus;
      Abort;
    end;
  end
  else
    Extedit1.Text:='';
end;

procedure TFrm_Ad_Enter_AssetCard_D.CMBX_DepreciationWayChange(
  Sender: TObject);
begin
  inherited;
  case  CMBX_DepreciationWay.ItemIndex of
   4: begin
//        edt_intendingperiod.Enabled:=False;
        edt_Periodrate.Enabled:=False;
        edt_PeriodValue.Enabled:=False;
        edt_DepreciationValue.Enabled:=False;
        edt_intending.Enabled:=False;
        edt_Finishtask.Enabled:=False;
        edt_taskUom.Enabled:=False;
        edt_PcDepreciation.Enabled:=False;
      end;
   3,2,0: begin
//        edt_intendingperiod.Enabled:=True;
        edt_Periodrate.Enabled:=True;
        edt_PeriodValue.Enabled:=True;
        edt_DepreciationValue.Enabled:=True;

        edt_intending.Enabled:=False;
        edt_Finishtask.Enabled:=False;
        edt_taskUom.Enabled:=False;
        edt_PcDepreciation.Enabled:=False;
      end;
   1: begin
//        edt_Intendingperiod.Enabled:=False;
//        EDT_UsedPeriod.Enabled:=False;
        edt_Periodrate.Enabled:=False;
        edt_PeriodValue.Enabled:=False;
        EDT_PcDepreciation.Enabled:=False;

        edt_DepreciationValue.Enabled:=True;
        edt_intending.Enabled:=True;
        edt_Finishtask.Enabled:=True;
        edt_taskUom.Enabled:=True;
//        edt_PcDepreciation.Enabled:=True;
      end;
  end;
  btn_ok.Enabled:=True;
end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_FirstAmountExit(Sender: TObject);
begin
  inherited;
  floatcheck(sender);
  EDT_FirstFAmount.Text:=floattostr(strtofloat(Trim(EDT_FirstAmount.text))*strtofloat(Trim(EDT_ExchangeRate.text)));
  edt_netValue.Text:=floattostr(strtofloat(Trim(edt_FirstAmount.text))-strtofloat(iifstring(Trim(edt_DepreciationValue.Text)='','0',edt_DepreciationValue.Text)));
  edt_DraffValue.Text:=floattostr(strtofloat(Trim(edt_FirstAmount.text))*strtofloat(iifstring(Trim(edt_Draffrate.Text)='','0',edt_Draffrate.Text))/100.0);
end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_DepreciationValueExit(
  Sender: TObject);
begin
  inherited;
  floatcheck(sender);
  edt_netValue.Text:=floattostr(strtofloat(Trim(EDT_FirstFAmount.text))-strtofloat(iifstring(Trim(edt_DepreciationValue.Text)='','0',edt_DepreciationValue.Text)));
end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_DraffRateExit(Sender: TObject);
begin
  inherited;
  floatcheck(sender);
  edt_DraffValue.Text:=floattostr(strtofloat(Trim(EDT_FirstFAmount.text))*strtofloat(iifstring(Trim(edt_Draffrate.Text)='','0',edt_Draffrate.Text))/100.0);
end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_AssetSujectCodeChange(
  Sender: TObject);
begin
  inherited;
  if  TCustomEdit(Sender).Text <>'' then
  begin
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.clear;
    AdoQry_Tmp.SQL.Text:=' Select KmCode,KmName from Gl_AccountSubject '
                        +'          where KmCode= '''+TCustomEdit(Sender).Text+''' ';
    AdoQry_Tmp.Open;
    if not AdoQry_Tmp.Eof then
    begin
      EDT_AssetSujectName.Text := AdoQry_Tmp.fieldbyname('KmName').AsString;
    end;
  end;
end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_DepreciationSubjectCodeChange(
  Sender: TObject);
begin
  inherited;
  if  TCustomEdit(Sender).Text <>'' then
  begin
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.clear;
    AdoQry_Tmp.SQL.Text:=' Select KmCode,KmName from Gl_AccountSubject '
                        +'          where KmCode= '''+TCustomEdit(Sender).Text+''' ';
    AdoQry_Tmp.Open;
    if not AdoQry_Tmp.Eof then
    begin
      EDT_DepreciationSubjectName.Text := AdoQry_Tmp.fieldbyname('KmName').AsString;
    end;
  end;  
end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_CreateEmployeeCodeChange(
  Sender: TObject);
begin
  inherited;
  if  TCustomEdit(Sender).Text <>'' then
  begin
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.clear;
    AdoQry_Tmp.SQL.Text:=' Select EmployeeCode,EmployeeName from Employee '
                        +'          where EmployeeCode= '''+TCustomEdit(Sender).Text+''' ';
    AdoQry_Tmp.Open;
    if not AdoQry_Tmp.Eof then
    begin
      EDT_CreateEmployeeName.Text := AdoQry_Tmp.fieldbyname('EmployeeName').AsString;
    end;
  end;
end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_EdItEmployeeCodeChange(
  Sender: TObject);
begin
  inherited;
  if  TCustomEdit(Sender).Text <>'' then
  begin
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.clear;
    AdoQry_Tmp.SQL.Text:=' Select EmployeeCode,EmployeeName from Employee '
                        +'          where EmployeeCode= '''+TCustomEdit(Sender).Text+''' ';
    AdoQry_Tmp.Open;
    if not AdoQry_Tmp.Eof then
    begin
      EDT_EdItEmployeeName.Text := AdoQry_Tmp.fieldbyname('EmployeeName').AsString;
    end;
  end;

end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_FirstFAmountChange(
  Sender: TObject);
begin
  inherited;
  If (EDT_FirstFAmount.Text<>'') And (EDT_FirstFAmount.Enabled) Then
  begin
    FloatCheck(Sender);
    EDT_FirstAmount.Text:=EDT_FirstFAmount.Text;
  end;
end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_UsedPeriodExit(Sender: TObject);
begin
  inherited;
  IntegerCheck(Sender);
  If (StrToInt(EDT_UsedPeriod.Text)>StrTofloat(EDT_IntendingPeriod.Text)*12) Then
  begin
    DispInfo('已计提月份不能大于使用年限',3);
    Abort;
  end;
end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_IntendingPeriodExit(
  Sender: TObject);
begin
  inherited;
  //IntegerCheck(Sender);
  if frac(strtofloat(EDT_IntendingPeriod.Text)*12 )<>0 then
    begin
      DispInfo('数值非法!',3);
      EDT_IntendingPeriod.SetFocus;
      exit;
    end;
  case  CMBX_DepreciationWay.ItemIndex of
   3,2,0: begin
        If (StrTofloat(EDT_IntendingPeriod.Text)<=0) Or (EDT_IntendingPeriod.Text='') Then
        begin
          DispInfo('使用年限小于或等于零',3);
          EDT_IntendingPeriod.SetFocus;
          Abort;
        end;
      end;
  end;
end;

end.

⌨️ 快捷键说明

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