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

📄 ad_enter_assetcard_d.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 4 页
字号:
procedure TFrm_Ad_Enter_AssetCard_D.EDT_AssetTypeCodeExit(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 AssetTypeCode,AssetTypeName from Ad_AssetType '
                        +'          where AssetTypeCode= '''+TCustomEdit(Sender).Text+''' ';
    AdoQry_Tmp.Open;
    if not AdoQry_Tmp.Eof then
    begin
      EDT_AssetTypeName.Text := AdoQry_Tmp.fieldbyname('AssetTypeName').AsString;
    end
    else
    begin
      DispInfo('固定资产类别代码错误,请重新输入',1);
      TWinControl(Sender).SetFocus;
      Abort;
    end;
  end
  else
    EDT_AssetTypeName.Text:='';

end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_DepositaryCodeExit(
  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 DepositaryCode,DepositaryName from Ad_Depositary '
                        +'          where DepositaryCode= '''+TCustomEdit(Sender).Text+''' ';
    AdoQry_Tmp.Open;
    if not AdoQry_Tmp.Eof then
    begin
      EDT_DepositaryName.Text := AdoQry_Tmp.fieldbyname('DepositaryName').AsString;
    end
    else
    begin
      DispInfo('存放地点代码错误,请重新输入',1);
      TWinControl(Sender).SetFocus;
      Abort;
    end;

  end
  else
    EDT_DepositaryName.Text:='';
end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_AdChangeTypeCodeExit(
  Sender: TObject);
begin
  inherited;
  if  TCustomEdit(Sender).Text <>'' then
  begin
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.clear;
    AdoQry_Tmp.SQL.Text:=' Select AdChangeTypeCode,AdChangeTypeName from Ad_ChangeType '
                        +'          where AdChangeTypeCode= '''+TCustomEdit(Sender).Text+''' ';
    AdoQry_Tmp.Open;
    if not AdoQry_Tmp.Eof then
    begin
      EDT_AdChangeTypeName.Text := AdoQry_Tmp.fieldbyname('AdChangeTypeName').AsString;
    end
    else
    begin
      DispInfo('增减方式代码错误,请重新输入',1);
      TWinControl(Sender).SetFocus;
      Abort;
    end;

  end
  else
    EDT_AdChangeTypeName.Text:='';
end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_UseStatusCodeExit(Sender: TObject);
begin
  inherited;
  if  TCustomEdit(Sender).Text <>'' then
  begin
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.clear;
    AdoQry_Tmp.SQL.Text:=' Select UseStatusCode,UseStatusName from Ad_UseStatus '
                        +'          where UseStatusCode= '''+TCustomEdit(Sender).Text+''' ';
    AdoQry_Tmp.Open;
    if not AdoQry_Tmp.Eof then
    begin
      EDT_UseStatusName.Text := AdoQry_Tmp.fieldbyname('UseStatusName').AsString;
    end
    else
    begin
      DispInfo('使用状态代码错误,请重新输入',1);
      TWinControl(Sender).SetFocus;
      Abort;
    end;
  end
  else
    EDT_UseStatusName.Text:='';
end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_AssetSujectCodeExit(
  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 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
    else
    begin
      DispInfo('固定资产科目代码错误,请重新输入',1);
      TWinControl(Sender).SetFocus;
      Abort;
    end;

  end
  else
    EDT_AssetSujectName.Text:='';
end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_AssetSujectCodeKeyDown(
  Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  inherited;
  If key=120 Then
  CommOnHint(Sender,AdoQry_Tmp,'KmName','会计科目名称','KmCode',
             '会计科目代码',' Gl_AccountSubject ', 'endkm=1 and kmfreeze=0');
end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_AssetSujectCodeButtonClick(
  Sender: TObject);
begin
  inherited;
  CommOnHint(Sender,AdoQry_Tmp,'KmName','会计科目名称','KmCode',
             '会计科目代码',' Gl_AccountSubject ', 'endkm=1 and kmfreeze=0');
end;

procedure TFrm_Ad_Enter_AssetCard_D.EDT_DepreciationSubjectCodeExit(
  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 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
    else
    begin
      DispInfo('累计折旧科目代码错误,请重新输入',1);
      TWinControl(Sender).SetFocus;
      Abort;
    end;
  end
  else
    EDT_DepreciationSubjectName.Text:='';
end;

procedure TFrm_Ad_Enter_AssetCard_D.Button2Click(Sender: TObject);
begin
  inherited;
  If Not (Status='ReadOnly') Then AllChange(Sender);
  HeadText[0]:=Edt_AssetCode.Text;
  HeadText[1]:=EDT_AssetName.Text;
  HeadText[2]:=MEDT_InAccountDate.Text;
  HeadText[3]:=MEDT_StartUseDate.Text;
  HeadText[4]:=IntToStr(CMBX_DepreciationWay.ItemIndex);
  HeadText[5]:=EDT_FirstFAmount.Text;
  HeadText[6]:=EDT_IntendingPeriod.Text;
  HeadText[7]:=EDT_DepositaryCode.Text;
  HeadText[8]:=EDT_DepositaryName.Text;
  HeadText[9]:=EDT_AdChangeTypeCode.Text;
  HeadText[10]:=EDT_AdChangeTypeName.Text;
  HeadText[11]:=EDT_UseStatusCode.Text;
  HeadText[12]:=EDT_UseStatusName.Text;
  Frm_Ad_Enter_AssetCardUseDept:=TFrm_Ad_Enter_AssetCardUseDept.Create(self);
  Frm_Ad_Enter_AssetCardUseDept.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
  Frm_Ad_Enter_AssetCardUseDept.init(self,DBConnect,HeadText,Status='ReadOnly');
  Frm_Ad_Enter_AssetCardUseDept.ShowModal;

end;

procedure TFrm_Ad_Enter_AssetCard_D.FormCreate(Sender: TObject);
begin
  inherited;
  DeptInfo:=TDeptInfo.Create();
  DeptInfo.RecordCount:=0;
  DeptInfo.RecordCountKm:=0;
end;

procedure TFrm_Ad_Enter_AssetCard_D.SaveDeptInfo;
var
  i:Integer;
begin
  If DeptInfo.RecordCount<0 Then Abort;
  with AdoQry_Tmp do
  begin
    Close;
    Sql.clear;
    SQL.Text:='delete from Ad_UseDept where AssetCode='''+Edt_AssetCode.Text+''' ';
    ExecSQL;
  end;
  For i:=0 to DeptInfo.RecordCount-1 do
  begin
    with AdoQry_Tmp do
    begin
      Close;
      Sql.clear;
      SQL.Text:='Insert into Ad_UseDept(AssetCode,DeptCode,kmCode,AssignRate,RemArk)'
        +' Values('
        +' '''+DeptInfo.AssetCode[i]+''''
        +','''+DeptInfo.DeptCode[i]+''''
        +','''+iifstring(DeptInfo.kmCode[i]='','null',DeptInfo.kmCode[i])+''''
        +','''+DeptInfo.AssignRate[i]+''''
        +','''+DeptInfo.RemArk[i]+''''
        +')';
      ExecSQL;
    end;
  end;
  DeptInfo.RecordCount:=0;
end;

procedure TFrm_Ad_Enter_AssetCard_D.FormDestroy(Sender: TObject);
begin
  if DeptInfo<>nil Then DeptInfo.Free;
  inherited;
end;

procedure TFrm_Ad_Enter_AssetCard_D.Button1Click(Sender: TObject);
begin
  If Not (Status='ReadOnly') Then AllChange(Sender);
  HeadText[0]:=Edt_AssetCode.Text;
  HeadText[1]:=EDT_AssetName.Text;
  HeadText[2]:=MEDT_InAccountDate.Text;
  HeadText[3]:=MEDT_StartUseDate.Text;
  HeadText[4]:=IntToStr(CMBX_DepreciationWay.ItemIndex);
  HeadText[5]:=EDT_FirstFAmount.Text;
  HeadText[6]:=EDT_IntendingPeriod.Text;
  HeadText[7]:=EDT_DepositaryCode.Text;
  HeadText[8]:=EDT_DepositaryName.Text;
  HeadText[9]:=EDT_AdChangeTypeCode.Text;
  HeadText[10]:=EDT_AdChangeTypeName.Text;
  HeadText[11]:=EDT_UseStatusCode.Text;
  HeadText[12]:=EDT_UseStatusName.Text;
  Frm_Ad_Enter_AssetCardDepreciationSubject:=TFrm_Ad_Enter_AssetCardDepreciationSubject.Create(self);
  Frm_Ad_Enter_AssetCardDepreciationSubject.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
  Frm_Ad_Enter_AssetCardDepreciationSubject.init(self,DBConnect,HeadText,Status='ReadOnly');
  Frm_Ad_Enter_AssetCardDepreciationSubject.ShowModal;
end;

procedure TFrm_Ad_Enter_AssetCard_D.SaveKmInfo;
var
  i:Integer;
begin
  If DeptInfo.RecordCountKm<0 Then Abort;
  with AdoQry_Tmp do
  begin
    Close;
    Sql.clear;
    SQL.Text:='delete from Ad_Pertainfixing where AssetCode='''+Edt_AssetCode.Text+''' ';
    ExecSQL;
  end;
  For i:=0 to DeptInfo.RecordCountKm-1 do
  begin
    with AdoQry_Tmp do
    begin
      Close;
      Sql.clear;
      SQL.Text:='Insert into Ad_Pertainfixing(AssetCode,fixingName,fixingspec,UomCode,fixingAmount,fixingsum,RemArk)'
        +' Values('
        +' '''+DeptInfo.AssetCodeKm[i]+''''
        +','''+DeptInfo.fixingName[i]+''''
        +','''+DeptInfo.fixingspec[i]+''''
        +','''+DeptInfo.UomCode[i]+''''
        +','+floattostr(DeptInfo.fixingAmount[i])
        +','+floattostr(DeptInfo.fixingsum[i])
        +','''+DeptInfo.RemArkKm[i]+''''
        +')';
      ExecSQL;
    end;
  end;
  DeptInfo.RecordCountKm:=0;
end;

procedure TFrm_Ad_Enter_AssetCard_D.btn_okClick(Sender: TObject);
begin
  If (DeptInfo.RecordCount=0) Then
  begin
    DispInfo('使用部门没有记录,不能保存',1);
    Abort;
  end;
  if Add then 
  begin
    if Trim(edt_assetCode.Text)='' then
    begin
      DispInfo('固定资产编号不能为空!',1);
      if edt_assetCode.CanFocus then
      Edt_AssetCode.SetFocus;
      abort;
    end;
    ExecuteSql(AdoQry_Tmp,'select * from Ad_AssetCard where AssetCode='+quotedstr(Trim(Edt_AssetCode.text)),0);
    if AdoQry_Tmp.RecordCount>0 then
    begin
      DispInfo('固定资产编号重复!',1);
      if edt_assetCode.CanFocus then
      Edt_AssetCode.SetFocus;
      abort;
    end;    
    if Trim(edt_assetName.Text)='' then
    begin
      DispInfo('固定资产名称不能为空!',1);
      if edt_assetName.CanFocus then
      Edt_AssetName.SetFocus;
      abort;
    end;
    if Trim(edt_AssetTypeCode.Text)='' then
    begin
      DispInfo('固定资产类别不能为空!',1);
      if edt_AssetTypeCode.CanFocus then
      Edt_AssetTypeCode.SetFocus;
      abort;
    end;
    if Trim(edt_AdChangeTypeCode.Text)='' then
    begin
      DispInfo('固定资产增减方式不能为空!',1);
      if edt_AdChangeTypeCode.CanFocus then
      edt_AdChangeTypeCode.SetFocus;

⌨️ 快捷键说明

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