?? xggdzc.~pas
字號:
unit xggdzc;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Grids, DBGrids, Buttons, StdCtrls, ComCtrls, DB;
type
TForm9 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Label1: TLabel;
ComboBox1: TComboBox;
SpeedButton1: TSpeedButton;
Panel3: TPanel;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label6: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label5: TLabel;
Label7: TLabel;
Label11: TLabel;
Label12: TLabel;
Label14: TLabel;
Label15: TLabel;
Label13: TLabel;
Label27: TLabel;
Label17: TLabel;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
Edit3: TEdit;
Edit4: TEdit;
Edit2: TEdit;
ComboBox4: TComboBox;
Edit6: TEdit;
Label28: TLabel;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
ComboBox5: TComboBox;
Edit10: TEdit;
Edit11: TEdit;
Label16: TLabel;
Edit5: TEdit;
Label18: TLabel;
DateTimePicker1: TDateTimePicker;
Label19: TLabel;
Label20: TLabel;
Panel4: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
procedure FormShow(Sender: TObject);
Procedure EditValue;
procedure SpeedButton1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure Edit4Change(Sender: TObject);
procedure Edit6Change(Sender: TObject);
procedure Edit7Change(Sender: TObject);
procedure ComboBox5Change(Sender: TObject);
Procedure FindNext;
Procedure FindPrior;
procedure Edit10Change(Sender: TObject);
procedure DBGrid1DblClick(Sender: TObject);
procedure Edit8Change(Sender: TObject);
Function IsNull: Boolean;
Function IsWF: Boolean;
procedure Edit3KeyPress(Sender: TObject; var Key: Char);
procedure Edit8KeyPress(Sender: TObject; var Key: Char);
procedure BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure ComboBox2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
Procedure Clear;
{ Public declarations }
end;
var
Form9: TForm9;
implementation
uses Dataz;
{$R *.dfm}
{ TForm9 }
procedure TForm9.Clear;
var
i: Integer;
begin
Label19.Caption := '';
Label20.Caption := '';
For i := 0 to Panel3.ControlCount-1 do
begin
if Panel3.Controls[i]is TEdit Then
TEdit(Panel3.Controls[i]).Clear
else if Panel3.Controls[i]is TComboBox Then
TComboBox(Panel3.Controls[i]).Text := '';
end;
end;
procedure TForm9.FormShow(Sender: TObject);
begin
ComboBox1.Clear;
with Daz.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select distinct 固定資產名稱 From 固定資產信息表');
Open;
end;
while Not Daz.ADOQuery1.Eof do
begin
ComboBox1.Items.Add(Daz.ADOQuery1.FieldByName('固定資產名稱').Value);
Daz.ADOQuery1.Next;
end;
ComboBox2.Clear;
with Daz.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select 類別名稱 From 固定資產類別表');
Open;
end;
while Not Daz.ADOQuery1.Eof do
begin
ComboBox2.Items.Add(Daz.ADOQuery1.FieldByName('類別名稱').Value);
Daz.ADOQuery1.Next;
end;
ComboBox3.Clear;
with Daz.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select 增加方式 From 固定資產增加方式表');
Open;
end;
while Not Daz.ADOQuery1.Eof do
begin
ComboBox3.Items.Add(Daz.ADOQuery1.FieldByName('增加方式').Value);
Daz.ADOQuery1.Next;
end;
ComboBox4.Clear;
with Daz.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select 使用狀況 From 固定資產使用狀況表');
Open;
end;
while Not Daz.ADOQuery1.Eof do
begin
ComboBox4.Items.Add(Daz.ADOQuery1.FieldByName('使用狀況').Value);
Daz.ADOQuery1.Next;
end;
BitBtn2.OnClick(Sender);
end;
procedure TForm9.SpeedButton1Click(Sender: TObject);
begin
if Trim(ComboBox1.Text)<>'' then
begin
with Daz.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 固定資產信息表 where 固定資產名稱 = :a');
Parameters.ParamByName('a').Value := Trim(ComboBox1.Text);
Open;
end;
if Daz.ADOQuery2.RecordCount >0 then
begin
DataSource1.DataSet := Daz.ADOQuery2;
EditValue;
BitBtn1.Enabled := True;
end
else
begin
DataSource1.DataSet := Nil;
Label19.Caption := '';
Label20.Caption := '';
BitBtn1.Enabled := False;
end;
end;
end;
procedure TForm9.BitBtn2Click(Sender: TObject);
begin
Clear;
DataSource1.DataSet := Nil;
end;
procedure TForm9.Edit4Change(Sender: TObject);
begin
if Trim(Edit3.Text)<>'' then
begin
if (Trim(Edit10.Text)<>'')and(Trim(ComboBox5.Text)='年限平均法(1)') then
Edit11.Text := Format('%15.2f',[StrToFloat(Edit3.Text)*StrToFloat(Edit10.Text)/100])
else if (Trim(Edit10.Text)<>'')and(Trim(ComboBox5.Text)='年限平均法(2)')then
begin
if (Trim(Edit4.Text)<>'')and(Trim(Edit7.Text)<>'')and(Trim(Edit8.Text)<>'')and(Trim(Edit9.Text)<>'')then
Edit11.Text := Format('%15.2f',[(StrToFloat(Edit3.Text)-StrToFloat(Edit4.Text)-StrToFloat(Edit7.Text))/(StrToInt(Edit8.Text)-StrToInt(Edit9.Text))])
else
Edit11.Clear;
end
else
Edit11.Clear;
if Trim(Edit4.Text)<>''then
Edit5.Text := Format('%15.2f',[StrToFloat(Edit3.Text)-StrToFloat(Edit4.Text)])
else
Edit5.Clear;
if Trim(Edit6.Text)<>'' then
Edit7.Text := Format('%15.2f',[StrToFloat(Edit3.Text)*StrToFloat(Edit6.Text)/100]);
end
else
begin
Edit5.Clear;
Edit7.Clear;
Edit11.Clear;
end;
end;
procedure TForm9.Edit6Change(Sender: TObject);
begin
if Trim(Edit6.Text)<>'' then
begin
if StrToFloat(Edit6.Text)>100 then
begin
Application.MessageBox('凈殘值率不能大于100。','提示',64);
Edit6.Clear;
Exit;
end
else if Trim(Edit3.Text)<>'' then
Edit7.Text := Format('%15.2f',[StrToFloat(Edit3.Text)*StrToFloat(Edit6.Text)/100])
else
Edit7.Clear;
end
else
Edit7.Clear;
Edit8.OnChange(Sender);
end;
procedure TForm9.Edit7Change(Sender: TObject);
begin
if Trim(ComboBox5.Text)='年限平均法(2)' then
begin
if (Trim(Edit3.Text)<>'')and(Trim(Edit4.Text)<>'')and (Trim(Edit7.Text)<>'')and(Trim(Edit8.Text)<>'')
and(Trim(Edit9.Text)<>'') then
begin
if StrToFloat(Edit8.Text)>StrToFloat(Edit9.Text)then
Edit11.Text := Format('%15.2f',[(StrToFloat(Edit3.Text)-StrToFloat(Edit4.Text)-StrToFloat(Edit7.Text))/(StrToInt(Edit8.Text)-StrToInt(Edit9.Text))])
else
Edit11.Clear;
end
else
Edit11.Clear;
end;
end;
procedure TForm9.ComboBox5Change(Sender: TObject);
begin
Edit7.OnChange(Sender);
if (Trim(Edit8.Text)<>'')and(Trim(Edit6.Text)<>'')then
Edit10.Text := Format('%8.4f',[(1- StrToFloat(Edit6.Text)/100)/StrToFloat(Edit8.Text)*100])
else
Edit10.Clear;
end;
procedure TForm9.Edit10Change(Sender: TObject);
begin
if (Trim(Edit10.Text)<>'')and(Trim(ComboBox5.Text)='年限平均法(1)') then
Edit11.Text := Format('%15.2f',[StrToFloat(Edit3.Text)*StrToFloat(Edit10.Text)/100])
end;
procedure TForm9.EditValue;
begin
Label20.Caption := Daz.ADOQuery2.FieldByName('固定資產編號').Value;
Label19.Caption := Daz.ADOQuery2.FieldByName('固定資產名稱').Value;
ComboBox2.Text := Daz.ADOQuery2.FieldByName('固定資產類別').Value;
ComboBox3.Text := Daz.ADOQuery2.FieldByName('增加方式').Value;
Edit3.Text := FloatToStr(Daz.ADOQuery2.FieldByName('入賬原值').Value);
Edit4.Text := FloatToStr(Daz.ADOQuery2.FieldByName('累計折舊').Value);
Edit5.Text := FloatToStr(Daz.ADOQuery2.FieldByName('凈值').Value);
Edit2.Text := Daz.ADOQuery2.FieldByName('規格型號').Value;
ComboBox4.Text := Daz.ADOQuery2.FieldByName('使用狀況').Value;
Edit6.Text := FloatToStr(Daz.ADOQuery2.FieldByName('預計凈殘值率').Value);
Edit7.Text := FloatToStr(Daz.ADOQuery2.FieldByName('預計凈殘值').Value);
DateTimePicker1.Date := Daz.ADOQuery2.FieldByName('入賬日期').Value;
Edit8.Text := IntToStr(Daz.ADOQuery2.FieldByName('預計使用月份').Value);
Edit9.Text := IntToStr(Daz.ADOQuery2.FieldByName('已計提月份').Value);
ComboBox5.Text := Daz.ADOQuery2.FieldByName('折舊方法').Value;
Edit10.Text := Format('%8.4f',[Daz.ADOQuery2.FieldByName('月折舊率').AsFloat]);
Edit11.Text := FloatToStr(Daz.ADOQuery2.FieldByName('月折舊額').Value);
end;
procedure TForm9.DBGrid1DblClick(Sender: TObject);
begin
if Daz.ADOQuery2.Active = True then
if Daz.ADOQuery2.RecordCount >0 then
EditValue;
end;
procedure TForm9.Edit8Change(Sender: TObject);
begin
Edit7.OnChange(Sender);
if (Trim(Edit8.Text)<>'')and(Trim(Edit6.Text)<>'')then
Edit10.Text := Format('%8.4f',[(1- StrToFloat(Edit6.Text)/100)/StrToFloat(Edit8.Text)*100])
else
Edit10.Clear;
end;
procedure TForm9.Edit3KeyPress(Sender: TObject; var Key: Char);
var
mm: Boolean;
begin
mm := (Key<#8)or(Key>#8)and(Key<#46)or(Key>#46)and(Key<#48)or(Key>#57);
if mm then
Key := #0;
end;
procedure TForm9.Edit8KeyPress(Sender: TObject; var Key: Char);
var
nn: Boolean;
begin
nn := (Key<#8)or(Key>#8)and(Key<#48)or(Key>#57);
if nn then
Key := #0;
end;
procedure TForm9.BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
TBitBtn(Sender).Font.Color := clRed;
end;
procedure TForm9.BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
TBitBtn(Sender).Font.Color := clBlue;
end;
procedure TForm9.FindNext;
begin
if FindNextControl(ActiveControl,True,False,False)is TEdit then
begin
if TEdit(FindNextControl(ActiveControl,True,False,False)).Enabled = True then
TEdit(FindNextControl(ActiveControl,True,False,False)).SetFocus;
end
else if FindNextControl(ActiveControl,True,False,False)is TComboBox then
TComboBox(FindNextControl(ActiveControl,True,False,False)).SetFocus
else if FindNextControl(ActiveControl,True,False,False)is TDateTimePicker then
TDateTimePicker(FindNextControl(ActiveControl,True,False,False)).SetFocus;
end;
procedure TForm9.FindPrior;
begin
if FindNextControl(ActiveControl,False,False,False)is TEdit then
begin
if TEdit(FindNextControl(ActiveControl,False,False,False)).Enabled = True then
TEdit(FindNextControl(ActiveControl,False,False,False)).SetFocus;
end
else if FindNextControl(ActiveControl,False,False,False)is TComboBox then
TComboBox(FindNextControl(ActiveControl,False,False,False)).SetFocus
else if FindNextControl(ActiveControl,False,False,False)is TDateTimePicker then
TDateTimePicker(FindNextControl(ActiveControl,False,False,False)).SetFocus;
end;
procedure TForm9.ComboBox2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_ReTurn then
FindNext
else if Key = VK_Shift then
FindPrior;
end;
procedure TForm9.BitBtn1Click(Sender: TObject);
begin
if Application.MessageBox('確實要修改原始數據嗎?','提示',MB_YesNo)=ID_Yes then
begin
if IsNull = False then
begin
if IsWf = False then
begin
Try
With Daz.ADOQuery2 do
begin
Edit;
FieldByName('固定資產編號').Value := Trim(Label20.Caption);
FieldByName('固定資產名稱').Value := Trim(Label19.Caption);
FieldByName('固定資產類別').Value := Trim(ComboBox2.Text);
FieldByName('增加方式').Value := Trim(ComboBox3.Text);
FieldByName('入賬原值').Value := StrToFloat(Edit3.Text);
FieldByName('累計折舊').Value := StrToFloat(Edit4.Text);
FieldByName('凈值').Value := StrToFloat(Edit5.Text);
FieldByName('規格型號').Value := Trim(Edit2.Text);
FieldByName('使用狀況').Value := Trim(ComboBox4.Text);
FieldByName('預計凈殘值率').Value := StrToFloat(Edit6.Text);
FieldByName('預計凈殘值').Value := StrToFloat(Edit7.Text);
FieldByName('入賬日期').Value := DateTimePicker1.Date;
FieldByName('預計使用月份').Value := StrToInt(Edit8.Text);
FieldByName('已計提月份').Value := StrToInt(Edit9.Text);
FieldByName('折舊方法').Value := Trim(ComboBox5.Text);
FieldByName('月折舊率').Value := StrToFloat(Edit10.Text);
FieldByName('月折舊額').Value := StrToFloat(Edit11.Text);
Post;
end;
BitBtn2.OnClick(Sender);
BitBtn1.Enabled := False;
Application.MessageBox('修改成功。','提示',64);
Except
Application.MessageBox('修改失敗。','提示',64);
Close;
end;
end
else
Application.MessageBox('基礎數據不能小于零。','提示',64);
end
else
Application.MessageBox('基礎數據不能為空。','提示',64);
end;
end;
function TForm9.IsNull: Boolean;
begin
IsNull := False;
if (Trim(label19.Caption)='')or(Trim(Label20.Caption)='')or(Trim(ComboBox2.Text)='')or(Trim(ComboBox3.Text)='')or(Trim(Edit3.Text)='')or
(Trim(Edit4.Text)='')or(Trim(Edit5.Text)='')or(Trim(ComboBox4.Text)='')or(Trim(Edit6.Text)='')or(Trim(Edit7.Text)='')or(Trim(Edit8.Text)='')or
(Trim(Edit9.Text)='')or(Trim(ComboBox5.Text)='')or(Trim(Edit10.Text)='')or(Trim(Edit11.Text)='') then
IsNull := True;
end;
function TForm9.IsWF: Boolean;
begin
Iswf := False;
if (StrToFloat(Edit3.Text)<0)or(StrToFloat(Edit4.Text)<0)or(StrToFloat(Edit5.Text)<0)or
(StrToFloat(Edit6.Text)<0)or(StrToFloat(Edit7.Text)<0)or(StrToFloat(Edit10.Text)<0)or(StrToFloat(Edit11.Text)<0) then
Iswf := True;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -