?? jtzj.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 固定資產(chǎn)信息表');
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;//計(jì)提標(biāo)記
year,month,day: Word;
i: Integer;
begin
mm := False;
nn := False;
if Trunc(aa) > Trunc(DateTimePicker1.Date) then
begin
Application.MessageBox('計(jì)提折舊時間不能小于固定資產(chǎn)添加時間。','提示',64);
DateTimePicker1.Date := Now();
Exit;
end;
if Trunc(DateTimePicker1.Date)> Trunc(Now()) then
begin
Application.MessageBox('計(jì)提折舊時間不能大于系統(tǒng)當(dāng)前時間。','提示',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 計(jì)提折舊表 where 計(jì)提標(biāo)記 = :a');
Parameters.ParamByName('a').Value := Trim(bj);
Open;
end;
if Daz.ADOQuery1.RecordCount >0 then
begin
Application.MessageBox('本期固定資產(chǎn)已經(jīng)計(jì)提了折舊費(fèi)用。','提示',64);
Exit;
end;
Try
Daz.ADOConnection1.BeginTrans;
with Daz.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 固定資產(chǎn)信息表 where 固定資產(chǎn)編號 not in ( select 固定資產(chǎn)編號 from 固定資產(chǎn)信息表 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('預(yù)計(jì)使用月份').Value >Daz.ADOQuery1.FieldByName('已計(jì)提月份').Value then
begin
Daz.ADOQuery1.Edit;
if Trim(Daz.ADOQuery1.FieldByName('折舊方法').Value) = '年限平均法(1)' then
begin
Daz.ADOQuery1.FieldByName('累計(jì)折舊').Value :=Daz.ADOQuery1.FieldByName('累計(jì)折舊').Value + Daz.ADOQuery1.FieldByName('月折舊額').Value;
Daz.ADOQuery1.FieldByName('已計(jì)提月份').Value := Daz.ADOQuery1.FieldByName('已計(jì)提月份').Value +1;
Daz.ADOQuery1.Post;
end
else if Trim(Daz.ADOQuery1.FieldByName('折舊方法').Value) = '年限平均法(2)' then
begin
with Daz.ADOQuery1 do
begin
FieldByName('已計(jì)提月份').Value := FieldByName('已計(jì)提月份').Value +1;
FieldByName('月折舊額').Value := (FieldByName('入賬原值').Value - FieldByName('累計(jì)折舊').Value - FieldByName('預(yù)計(jì)凈殘值').Value)/(FieldByName('預(yù)計(jì)使用月份').Value-FieldByName('已計(jì)提月份').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 固定資產(chǎn)信息表 where 固定資產(chǎn)編號 in (Select 固定資產(chǎn)編號 From 固定資產(chǎn)減少表 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('預(yù)計(jì)使用月份').Value >Daz.ADOQuery1.FieldByName('已計(jì)提月份').Value then
begin
if Trim(Daz.ADOQuery1.FieldByName('折舊方法').Value) = '年限平均法(1)' then
begin
Daz.ADOQuery1.FieldByName('累計(jì)折舊').Value :=Daz.ADOQuery1.FieldByName('累計(jì)折舊').Value + Daz.ADOQuery1.FieldByName('月折舊額').Value;
Daz.ADOQuery1.FieldByName('已計(jì)提月份').Value := Daz.ADOQuery1.FieldByName('已計(jì)提月份').Value +1;
Daz.ADOQuery1.Post;
end
else if Trim(Daz.ADOQuery1.FieldByName('折舊方法').Value) = '年限平均法(2)' then
begin
with Daz.ADOQuery1 do
begin
FieldByName('已計(jì)提月份').Value := FieldByName('已計(jì)提月份').Value +1;
FieldByName('月折舊額').Value := (FieldByName('入賬原值').Value - FieldByName('累計(jì)折舊').Value - FieldByName('預(yù)計(jì)凈殘值').Value)/(FieldByName('預(yù)計(jì)使用月份').Value-FieldByName('已計(jì)提月份').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 計(jì)提折舊表 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('本期沒有可計(jì)提折舊的固定資產(chǎn),固定資產(chǎn)可能本期剛添加或已經(jīng)減少。','提示',64)
else Application.MessageBox('計(jì)提折舊成功。','提示',64);
Except
Daz.ADOConnection1.RollbackTrans;
Application.MessageBox('計(jì)提折舊失敗。','提示',64);
end;
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -