📄 bankpd.pas
字号:
begin
DefaultSubject_id:=-1;
DefaultCodeLongSubjectName:='';
end;
tq.Close;
t.Close;
t.TableName:='#TempBankCredence';
t.Open;
t.Sort:='Number';
tbAddRow.Click;
end;
procedure TFrmBankPD.FormClose(Sender: TObject; var Action: TCloseAction);
begin
tq.Close;
tq.SQL.Clear;
tq.SQL.Add('drop table #TempBankCredence');
tq.ExecSQL;
tq.Close;
tq.SQL.Clear;
tq.SQL.Add('drop table #TempSubject');
tq.ExecSQL;
t.Close;
end;
procedure TFrmBankPD.tbAddRowClick(Sender: TObject);
begin
t.Append;
t.FieldByName('Year').AsInteger:=DM.BankAccountYear;
t.FieldByName('Month').AsInteger:=DM.BankAccountMonth;
t.FieldByName('Number').AsInteger:=Fun_GetMaxID(DM.adoc,'#TempBankCredence','Number');
t.FieldByName('day').AsInteger:=MaxDay;
t.FieldByName('MakeOperator_id').AsInteger:=DM.UserID;
t.FieldByName('MakeOperator').AsString:=DM.UserName;
editZD.Text:=DM.UserName;
if DefaultSubject_id<>-1 then
begin
t.FieldByName('Subject_id').AsInteger:=DefaultSubject_id;
t.FieldByName('CodeLongSubjectName').AsString:=DefaultCodeLongSubjectName;
end;
t.Post;
EditChange;
Added:=true;//作过增加记录操作,用于记录 Log
end;
procedure TFrmBankPD.tbInsertRowClick(Sender: TObject);
var
CurrentNumber:integer;
begin
CurrentNumber:=t.FieldByName('Number').AsInteger;
tq.Close;
tq.SQL.Clear;
tq.SQL.Add('update #TempBankCredence set Number=Number+1 where Number>='+IntToStr(CurrentNumber));
tq.ExecSQL;
tq.Close;
t.Append;
t.FieldByName('Year').AsInteger:=DM.BankAccountYear;
t.FieldByName('Month').AsInteger:=DM.BankAccountMonth;
t.FieldByName('Number').AsInteger:=CurrentNumber;
t.FieldByName('day').AsInteger:=MaxDay;
t.FieldByName('MakeOperator_id').AsInteger:=DM.UserID;
t.FieldByName('MakeOperator').AsString:=DM.UserName;
editZD.Text:=DM.UserName;
if DefaultSubject_id<>-1 then
begin
t.FieldByName('Subject_id').AsInteger:=DefaultSubject_id;
t.FieldByName('CodeLongSubjectName').AsString:=DefaultCodeLongSubjectName;
end;
t.Post;
t.Requery;
EditChange;
Added:=true;//作过增加记录操作,用于记录 Log
end;
procedure TFrmBankPD.tbDeleteRowClick(Sender: TObject);
var
CurrentNumber:integer;
begin
CurrentNumber:=t.FieldByName('Number').AsInteger;
t.Delete;
tq.Close;
tq.SQL.Clear;
tq.SQL.Add('update #TempBankCredence set Number=Number-1 where Number>'+IntToStr(CurrentNumber));
tq.ExecSQL;
tq.Close;
t.Requery;
if t.RecordCount<1 then tbAddRow.Click;
EditChange;
Deleted:=true;//作过删除记录操作,用于记录 Log
end;
procedure TFrmBankPD.tbSwapClick(Sender: TObject);
var
tm:Currency;
begin
tm:=t.FieldByName('J_Money').AsCurrency;
t.Edit;
t.FieldByName('J_Money').AsCurrency:=t.FieldByName('D_Money').AsCurrency;
t.FieldByName('D_Money').AsCurrency:=tm;
t.Post;
EditChange;
end;
procedure TFrmBankPD.tbSaveClick(Sender: TObject);
begin
tq.Close;
tq.SQL.Clear;
tq.SQL.Add('update #TempBankCredence set DateTime=cast(cast([year] as varchar(4))+''-''+cast([month] as varchar(2))+''-''+cast([day] as varchar(2)) as Datetime)');
tq.ExecSQL;
tq.Close;
tq.SQL.Clear;
tq.SQL.Add('update #TempBankCredence set J_Money=null where J_Money=0');
tq.ExecSQL;
tq.Close;
tq.SQL.Clear;
tq.SQL.Add('update #TempBankCredence set D_Money=null where D_Money=0');
tq.ExecSQL;
tq.Close;
tq.SQL.Clear;
tq.SQL.Add('delete from BankCredence where [year]='+IntToStr(DM.BankAccountYear)+' and [Month]='+IntToStr(DM.BankAccountMonth));
tq.ExecSQL;
tq.Close;
tq.SQL.Clear;
tq.SQL.Add('insert into BankCredence select DateTime,Year,Month,Number,EarningNumber,PayNumber,CheckType_id,CheckNumber,Summary,Subject_id,J_Money,D_Money,MakeOperator_ID from #TempBankCredence where J_Money<>0 or D_Money<>0');
tq.ExecSQL;
tq.Close;
t.Requery;
tbSave.Enabled:=false;
Edited:=true;//作过修改记录操作,用于记录 Log
end;
procedure TFrmBankPD.tbCalcClick(Sender: TObject);
begin
WinExec('calc.exe',SW_SHOW);
end;
procedure TFrmBankPD.gColumns4EditButtonClick(Sender: TObject;
var Handled: Boolean);
var
id:integer;
d:pChar;
begin
GetMem(d,1000);
if Frm_CodeInput(DM.adoc,'Summary','ID','Code_PinYin','Code_WuBi','Name','Used',@id,d)=mrOK then
begin
t.Edit;
t.FieldByName('Summary').AsString:=d;
t.Post;
end;
FreeMem(d,1000);
g.Col:=1;
g.Col:=0;
EditChange;
end;
procedure TFrmBankPD.gExit(Sender: TObject);
begin
EditChange;
end;
procedure TFrmBankPD.GetMaxDay;
var
y,m,d:word;
dt:TDate;
begin
if DM.BankAccountMonth=12 then
dt:=StrToDate(IntToStr(DM.BankAccountYear+1)+'-1-1')-1
else
dt:=StrToDate(IntToStr(DM.BankAccountYear)+'-'+IntToStr(DM.BankAccountMonth+1)+'-1')-1;
DecodeDate(dt,y,m,d);
MaxDay:=d;
end;
procedure TFrmBankPD.btnBackMonthClick(Sender: TObject);
begin
tq.Close;
tq.SQL.Clear;
tq.SQL.Add('select count(*) as CountRow from BankCredence where [Year]='+IntToStr(DM.BankAccountYear)+' and [month]='+IntToStr(DM.BankAccountMonth));
tq.Open;
if tq.FieldByName('CountRow').AsInteger>0 then
begin
tq.Close;
Frm_MsgBox('系统信息','本月已经有收付记录,不能回到上月。如果需要查询上月银行日记记录,请从“银行日记查询”查询。',MsgBox_OK_ERROR);
Exit;
end;
tq.Close;
if Frm_MsgBox('系统信息','确信要退回到上一月吗?',MsgBox_YESNO)=mrNo then Exit;
//删除上月结转至本月的余额
tq.Close;
tq.SQL.Clear;
tq.SQL.Add('delete from BankBalance where [Year]='+IntToStr(DM.BankAccountYear)+' and [month]='+IntToStr(DM.BankAccountMonth));
tq.ExecSQL;
tq.Close;
//计算上月年度数和月份数
if DM.BankAccountMonth=1 then
begin
DM.BankAccountYear:=DM.BankAccountYear-1;
DM.BankAccountMonth:=12;
end
else
DM.BankAccountMonth:=DM.BankAccountMonth-1;
//保存选项
SetOptionsKeyValue(t.Connection,'当前银行日记年度',IntToStr(DM.BankAccountYear));
SetOptionsKeyValue(t.Connection,'当前银行日记月份',IntToStr(DM.BankAccountMonth));
isGoon:=true;
Close;
end;
procedure TFrmBankPD.btnNextMonthClick(Sender: TObject);
begin
tq.Close;
tq.SQL.Clear;
tq.SQL.Add('select count(*) as CountRow from BankCredence where [Year]='+IntToStr(DM.BankAccountYear)+' and [month]='+IntToStr(DM.BankAccountMonth));
tq.Open;
if tq.FieldByName('CountRow').AsInteger<1 then
begin
tq.Close;
if Frm_MsgBox('系统信息','本月还没有录入银行收付记录,确信要直接到下一月吗?',MsgBox_YESNO)=mrNo then Exit;
end
else
begin
tq.Close;
if Frm_MsgBox('系统信息','转到下一月份后,将不能再修改本月记录,确信要转到到下一月吗?',MsgBox_YESNO)=mrNo then Exit;
end;
tq.Close;
//计算余额,写入余额表,然后进入下月
tq.Close;
tq.SQL.Clear;
tq.SQL.Add('P_BankCarryForward');
tq.ExecSQL;
tq.Close;
//计算下月年度数和月份数
if DM.BankAccountMonth=12 then
begin
DM.BankAccountMonth:=1;
DM.BankAccountYear:=DM.BankAccountYear+1;
end
else
DM.BankAccountMonth:=DM.BankAccountMonth+1;
isGoon:=true;
Close;
end;
procedure TFrmBankPD.gColumns7EditButtonClick(Sender: TObject;
var Handled: Boolean);
var
id:integer;
d:pChar;
begin
GetMem(d,1000);
if Frm_CodeInput(DM.adoc,'#TempSubject','ID','Code_PinYin','Code_WuBi','CodeLongSubjectName','Used',@id,d)=mrOK then
begin
t.Edit;
t.FieldByName('Subject_id').AsInteger:=id;
t.FieldByName('CodeLongSubjectName').AsString:=d;
t.Post;
end;
FreeMem(d,1000);
g.Col:=6;
g.Col:=7;
EditChange;
end;
procedure TFrmBankPD.gColumns5EditButtonClick(Sender: TObject;
var Handled: Boolean);
var
id:integer;
d:pChar;
begin
GetMem(d,1000);
if Frm_CodeInput(DM.adoc,'CheckType','ID','Code_PinYin','Code_WuBi','Name','Used',@id,d)=mrOK then
begin
t.Edit;
t.FieldByName('CheckType_id').AsInteger:=id;
t.FieldByName('CheckType').AsString:=d;
t.Post;
end;
FreeMem(d,1000);
g.Col:=4;
g.Col:=5;
EditChange;
end;
procedure TFrmBankPD.tAfterScroll(DataSet: TDataSet);
begin
editZD.Text:=t.FieldByName('MakeOperator').AsString;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -