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

📄 jtzj.pas

📁 用delphi编写的固定资产管理系统
💻 PAS
字号:
unit jtzj;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, ComCtrls, Buttons;

type
  TForm8 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    DateTimePicker1: TDateTimePicker;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Edit1: TEdit;
    Panel3: TPanel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Memo1: TMemo;
    procedure FormShow(Sender: TObject);
    procedure BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var  Form8: TForm8;
     mm: Boolean = False;
     nn: Boolean = False;
     aa: Real = 0.0;
implementation
  uses Dataz;
{$R *.dfm}

procedure TForm8.FormShow(Sender: TObject);
begin
  with Daz.ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select Min(入账日期) as ss from 固定资产信息表');
    Open;
  end;
  if Daz.ADOQuery1.FieldByName('ss').Value <>Null then
  aa :=  Daz.ADOQuery1.FieldByName('ss').Value;
  Edit1.Text := FormatDateTime('yyyy-mm-dd',Now());
  DateTimePicker1.Date := Now();
end;

procedure TForm8.BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  TBitBtn(Sender).Font.Color := clRed;
end;

procedure TForm8.BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  TBitBtn(Sender).Font.Color := clBlue;
end;

procedure TForm8.BitBtn1Click(Sender: TObject);
var
  bj: String;//计提标记
  year,month,day: Word;
  i: Integer;
begin
  mm := False;
  nn := False;
  if Trunc(aa) > Trunc(DateTimePicker1.Date) then
  begin
   Application.MessageBox('计提折旧时间不能小于固定资产添加时间。','提示',64);
   DateTimePicker1.Date := Now();
   Exit;
  end;
  if Trunc(DateTimePicker1.Date)> Trunc(Now()) then
  begin
    Application.MessageBox('计提折旧时间不能大于系统当前时间。','提示',64);
    Exit;
  end;
  DecodeDate(DateTimePicker1.Date,year,month,day);
  bj:= FormatDateTime('yyyymm',DateTimePicker1.Date);
  with Daz.ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from 计提折旧表 where 计提标记 = :a');
    Parameters.ParamByName('a').Value := Trim(bj);
    Open;
  end;
  if Daz.ADOQuery1.RecordCount >0 then
  begin
    Application.MessageBox('本期固定资产已经计提了折旧费用。','提示',64);
    Exit;
  end;
  Try
  Daz.ADOConnection1.BeginTrans;
  with Daz.ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from 固定资产信息表 where 固定资产编号 not in ( select 固定资产编号 from 固定资产信息表 where Year(入账日期) = :a and Month(入账日期)= :b)and 增减 = 0 ');
    Parameters.ParamByName('a').Value := Year;
    Parameters.ParamByName('b').Value := Month;
    Open;
  end;
  if Daz.ADOQuery1.RecordCount>0 then
  begin
    mm := True;
    Daz.ADOQuery1.Edit;
    while Not Daz.ADOQuery1.Eof do
    begin
      if Daz.ADOQuery1.FieldByName('预计使用月份').Value >Daz.ADOQuery1.FieldByName('已计提月份').Value then
      begin
        Daz.ADOQuery1.Edit;
        if Trim(Daz.ADOQuery1.FieldByName('折旧方法').Value) = '年限平均法(1)' then
        begin
          Daz.ADOQuery1.FieldByName('累计折旧').Value :=Daz.ADOQuery1.FieldByName('累计折旧').Value + Daz.ADOQuery1.FieldByName('月折旧额').Value;
          Daz.ADOQuery1.FieldByName('已计提月份').Value := Daz.ADOQuery1.FieldByName('已计提月份').Value +1;
          Daz.ADOQuery1.Post;
        end
        else if Trim(Daz.ADOQuery1.FieldByName('折旧方法').Value) = '年限平均法(2)' then
        begin
          with Daz.ADOQuery1 do
          begin
            FieldByName('已计提月份').Value := FieldByName('已计提月份').Value +1;
            FieldByName('月折旧额').Value := (FieldByName('入账原值').Value - FieldByName('累计折旧').Value - FieldByName('预计净残值').Value)/(FieldByName('预计使用月份').Value-FieldByName('已计提月份').Value);
            Post;
          end;
        end;
      end;
      Daz.ADOQuery1.Next;
    end;
  end
  else
    mm := False;
  with Daz.ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from 固定资产信息表 where 固定资产编号 in (Select 固定资产编号 From 固定资产减少表 where year(日期)=:a and Month(日期) = :b)');
    If Month = 1 then
    begin
      Parameters.ParamByName('a').Value := Year -1;
      Parameters.ParamByName('b').Value := 12;
    end
    else
    begin
      Parameters.ParamByName('a').Value := Year;
      Parameters.ParamByName('b').Value := Month -1;
    end;
    Open;
  end;
  if Daz.ADOQuery1.RecordCount>0 then
  begin
    nn := True;
    Daz.ADOQuery1.Edit;
    while Not Daz.ADOQuery1.Eof do
    begin
      if Daz.ADOQuery1.FieldByName('预计使用月份').Value >Daz.ADOQuery1.FieldByName('已计提月份').Value then
      begin
        if Trim(Daz.ADOQuery1.FieldByName('折旧方法').Value) = '年限平均法(1)' then
        begin
          Daz.ADOQuery1.FieldByName('累计折旧').Value :=Daz.ADOQuery1.FieldByName('累计折旧').Value + Daz.ADOQuery1.FieldByName('月折旧额').Value;
          Daz.ADOQuery1.FieldByName('已计提月份').Value := Daz.ADOQuery1.FieldByName('已计提月份').Value +1;
          Daz.ADOQuery1.Post;
        end
        else if Trim(Daz.ADOQuery1.FieldByName('折旧方法').Value) = '年限平均法(2)' then
        begin
          with Daz.ADOQuery1 do
          begin
            FieldByName('已计提月份').Value := FieldByName('已计提月份').Value +1;
            FieldByName('月折旧额').Value := (FieldByName('入账原值').Value - FieldByName('累计折旧').Value - FieldByName('预计净残值').Value)/(FieldByName('预计使用月份').Value-FieldByName('已计提月份').Value);
            Post;
          end;
        end;
      end;
      Daz.ADOQuery1.Next;
    end;
  end
  else
    nn := False;
  if (mm = True)or(nn = True) then
  begin
    with Daz.ADOQuery1 do
    begin
      Close;
      SQL.Clear;
      SQL.Add('insert 计提折旧表 values(:a,:b)');
      Parameters.ParamByName('a').Value := Trim(BJ);
      Parameters.ParamByName('b').Value := DateTimePicker1.Date;
      ExecSQL
    end;
  end ;
  Daz.ADOConnection1.CommitTrans;
  if (mm = False)and(nn = False) then
    Application.MessageBox('本期没有可计提折旧的固定资产,固定资产可能本期刚添加或已经减少。','提示',64)
  else Application.MessageBox('计提折旧成功。','提示',64);
  Except
    Daz.ADOConnection1.RollbackTrans;
    Application.MessageBox('计提折旧失败。','提示',64);
  end;
end;

end.

⌨️ 快捷键说明

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