?? pzlr.~pas
字號:
unit pzlr;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, ExtCtrls, Buttons, ComCtrls;
type
TForm2 = class(TForm)
Panel1: TPanel;
a: TStringGrid;
Memo2: TMemo;
Memo1: TMemo;
Edit1: TEdit;
Edit2: TEdit;
Label2: TLabel;
Label3: TLabel;
Shape1: TShape;
Label4: TLabel;
Label6: TLabel;
Edit4: TEdit;
Panel2: TPanel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
Panel3: TPanel;
Label7: TLabel;
Label9: TLabel;
Label8: TLabel;
Label10: TLabel;
BitBtn4: TBitBtn;
DateTimePicker1: TDateTimePicker;
BitBtn5: TBitBtn;
Shape2: TShape;
Panel4: TPanel;
Label1: TLabel;
Label5: TLabel;
Edit3: TEdit;
procedure FormShow(Sender: TObject);
procedure Edit4KeyPress(Sender: TObject; var Key: Char);
procedure aSelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
Function DPJD: Boolean;// 判斷同一摘要借方金額和貸方金額是否都存在
procedure aKeyPress(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 BitBtn1Click(Sender: TObject);
procedure aKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure aSetEditText(Sender: TObject; ACol, ARow: Integer;
const Value: String);
procedure Edit3KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure BitBtn3Click(Sender: TObject);
private
{ Private declarations }
public
Function JIsNull: Boolean;overload; //判斷當前行借方金額是否為空
Function JIsNull(Row: Integer): Boolean;overload ;//判斷指定行借方金額是否為空
Function DIsCz(Zy: String): Boolean;//判斷貸方是否有對應的貸方數據
Function JIsCz(Zy: String): Boolean;//判斷借方是否有對應的借方數據
Function DIsNull: Boolean; overload;// 判斷貸方金額當前是否為空
Function DIsNull(Row: integer): Boolean; Overload;
Function JCXmlb: Boolean;
Function JCZYKJ: Boolean; //檢查輸入的摘要或會計科目是否合法
Procedure ClearCurrent;
Procedure ClearEnd;
Function JSJJe(Row: Integer): real;//計算指定行借方金額
Function JsDJe(Row: Integer): Real;// 計算指定行貸方金額
Function GroupzyJJ(zy: String): real;//統計指定摘要的借方金額
Function GroupzyDJ(zy: String):real;// //統計指定摘要的貸方金額
Function JDisPH: Boolean; //判斷摘要借方金額與貸方金額是否平衡
Function JSJFje(Row: Integer): Real;//記錄指定行借方金額
Function JSDFje(Row: Integer): Real;//記錄指定行貸方金額
{ Public declarations }
end;
var
Form2: TForm2;
x: Integer = 1;
y : Integer = 0;
a1: double = 0.0 ;
a2: double = 0.0;
implementation
uses DataModal4;
{$R *.dfm}
procedure TForm2.FormShow(Sender: TObject);
begin
a.Cells[3,0]:= '百';
a.Cells[4,0]:='十';
a.Cells[5,0]:='億';
a.Cells[6,0]:='千';
a.Cells[7,0]:='百';
a.Cells[8,0]:='十';
a.Cells[9,0]:='萬';
a.Cells[10,0]:='千';
a.Cells[11,0]:='百';
a.Cells[12,0]:='十';
a.Cells[13,0]:='元';
a.Cells[14,0]:='角';
a.Cells[15,0]:='分';
a.Cells[17,0]:= '百';
a.Cells[18,0]:='十';
a.Cells[19,0]:='億';
a.Cells[20,0]:='千';
a.Cells[21,0]:='百';
a.Cells[22,0]:='十';
a.Cells[23,0]:='萬';
a.Cells[24,0]:='千';
a.Cells[25,0]:='百';
a.Cells[26,0]:='十';
a.Cells[27,0]:='元';
a.Cells[28,0]:='角';
a.Cells[29,0]:='分';
DateTimePicker1.Date := Now();
end;
procedure TForm2.Edit4KeyPress(Sender: TObject; var Key: Char);
var
mm: Boolean;
begin
mm := (Key<#8)or(Key>#8)and(Key<#48)or(Key>#57);
if mm then
Key := #0;
end;
procedure TForm2.aSelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
begin
x := ARow;
y := ACol;
end;
procedure TForm2.aKeyPress(Sender: TObject; var Key: Char);
var
aa: Boolean;
i: Integer;
begin
if y >15 then
For i :=2 to 15 do
begin
if Trim(a.Cells[i,x])<>'' then
Key := #0;
end;
if (y >1)and(y<16) then
For i :=17 to 29 do
begin
if Trim(a.Cells[i,x])<>'' then
Key := #0;
end;
if (y = 2)or(y= 16) then
if Key <> #45 then
Key := #0;
if (y>2)and(y<>16)then
begin
aa := (Key<#8)or(Key>#8)and(Key<#48)or(Key>#57);
if aa then
Key := #0;
if (a.Cells[y,x]<>'')and(Key<>#8) then
Key := #0;
end;
end;
procedure TForm2.BitBtn1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
TBitBtn(Sender).Font.Color := clRed;
end;
procedure TForm2.BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
TBitBtn(Sender).Font.Color := clBlue;
end;
procedure TForm2.BitBtn1Click(Sender: TObject);
var
s,m: String;
i: integer;
begin
s:= 'P'+ FormatDateTime('yyyy',Now());
With Da.ADOQuery2 do
begin
Close;
SQL.Clear;
SQL.Add('select max(憑證號) as ss From 憑證表 ');
Open;
end;
If Da.ADOQuery2.FieldByName('ss').Value = null then
s := s + '001'
else
begin
m:= Trim(Da.ADOQuery2.FieldByName('ss').Value) ;
i:= StrToInt(Trim(Copy(m,6,8))) ;
if i<9 then
s:= s + '00'+ InttoStr(i +1)
else if i<99 then
s:= s + '0'+ InttoStr(i +1)
else
s:= s +InttoStr(i +1);
end;
Label3.Caption := s;
Edit3.SetFocus;
end;
procedure TForm2.aKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
mm,nn: Integer;
begin
if Key = VK_Delete then
if Application.MessageBox('確實要刪除當前行數據嗎?','提示',MB_YesNo)= ID_Yes then
begin
if a.RowCount>2 then
begin
ClearCurrent;
if x<>a.RowCount-1 then
begin
For mm := x +1 to a.RowCount-1 do
For nn := 0 to a.ColCount-1 do
a.Cells[nn,mm-1] := a.Cells[nn,mm];
end;
ClearEnd;
a.RowCount := a.RowCount-1;
end
else if a.RowCount = 2 then
ClearCurrent;
Label8.Caption := '';
Label10.Caption := '';
end;
if Key = VK_Next then
if (x = a.RowCount-1)and(Trim(a.Cells[0,x])<>'')and(Trim(a.Cells[1,x])<>'')and((JIsNull = False)or(DIsNull = False)) then
begin
a.RowCount := a.RowCount +1;
a.Cells[0,x+1]:= a.Cells[0,x];
end;
if Key = VK_ReTurn then
begin
if (y = 0)and(Trim(a.Cells[y,x])<>'') then
begin
with Da.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 摘要表 where 摘要編號 = :a or 摘要名稱 = :b');
Parameters.ParamByName('a').Value := Trim(a.Cells[y,x]);
Parameters.ParamByName('b').Value := Trim(a.Cells[y,x]);
Open;
if Da.ADOQuery1.RecordCount>0 then
begin
a.Cells[y,x]:= Da.ADOQuery1.FieldByName('摘要名稱').Value;
a.Col := 1;
end
else
begin
Application.MessageBox('該摘要不存在,請重新輸入。','提示',64);
a.Cells[y,x]:='';
end;
end;
end
else if (y = 1)and(Trim(a.Cells[y,x])<>'') then
begin
With Da.ADOQuery1 do
begin
Close;
SQL.Clear;
SQL.Add('select * from 會計科目表 where 科目編號 = :a or 科目名稱 = :b');
Parameters.ParamByName('a').Value := Trim(a.Cells[y,x]);
Parameters.ParamByName('b').Value := Trim(a.Cells[y,x]);
Open;
if Da.ADOQuery1.RecordCount>0 then
begin
a.Cells[y,x]:= Da.ADOQuery1.FieldByName('科目名稱').Value;
a.Col := 2;
end
else
begin
Application.MessageBox('該摘要不存在,請重新輸入。','提示',64);
a.Cells[y,x]:='';
end;
end;
end
else if (y<>0)and(Y<>1)then
begin
if a.Col < a.ColCount-1 then
a.Col := a.Col +1;
end;
end;
end;
Function TForm2.JIsNull: Boolean;
var
i: Integer;
begin
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -