|
|
|
|
unit AccCloseOffBacku;
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
Dialogs, StdCtrls, Grids, DBGridEh, DB, kbmMemTable,ImgList,DateUtils,
|
|
|
|
|
Buttons, DBCtrls, ADODB,Mask, bsSkinCtrls, BusinessSkinForm;
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
TfrmAccCloseOffBack = class(TForm)
|
|
|
|
|
memTblPeriod: TkbmMemTable;
|
|
|
|
|
dsrPeriod: TDataSource;
|
|
|
|
|
memTblPeriodPERIOD: TStringField;
|
|
|
|
|
memTblPeriodPYEAR: TIntegerField;
|
|
|
|
|
memTblPeriodPMONTH: TIntegerField;
|
|
|
|
|
memTblPeriodFDAY: TDateTimeField;
|
|
|
|
|
memTblPeriodTDAY: TDateTimeField;
|
|
|
|
|
memTblPeriodCLOSED: TStringField;
|
|
|
|
|
Label3: TLabel;
|
|
|
|
|
Memo1: TMemo;
|
|
|
|
|
memTblPeriodPeriodDsp: TStringField;
|
|
|
|
|
EditPeriod: TEdit;
|
|
|
|
|
bbtnExcute: TbsSkinButton;
|
|
|
|
|
bsSkinButton2: TbsSkinButton;
|
|
|
|
|
bsBusinessSkinForm1: TbsBusinessSkinForm;
|
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
|
procedure memTblPeriodCalcFields(DataSet: TDataSet);
|
|
|
|
|
procedure bbtnExcuteClick(Sender: TObject);
|
|
|
|
|
private
|
|
|
|
|
{ Private declarations }
|
|
|
|
|
public
|
|
|
|
|
{ Public declarations }
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
var
|
|
|
|
|
frmAccCloseOffBack: TfrmAccCloseOffBack;
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
uses my_sys_function, u_main;
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
procedure TfrmAccCloseOffBack.FormShow(Sender: TObject);
|
|
|
|
|
var aQuery : TAdoQuery;
|
|
|
|
|
begin
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
|
|
with aQuery do
|
|
|
|
|
try
|
|
|
|
|
Close;SQL.Clear;
|
|
|
|
|
SQL.Add('Select * from Period');
|
|
|
|
|
SQL.Add('where Closed=''T''');
|
|
|
|
|
Open;
|
|
|
|
|
with memTblPeriod do begin
|
|
|
|
|
Close;
|
|
|
|
|
EmptyTable;
|
|
|
|
|
Filtered:=false;
|
|
|
|
|
LoadFromDataSet(aQuery, []);
|
|
|
|
|
Last;
|
|
|
|
|
bbtnExcute.Enabled:=RecordCount>0;
|
|
|
|
|
if bbtnExcute.Enabled then
|
|
|
|
|
EditPeriod.Text:=FieldByName('PeriodDsp').AsString
|
|
|
|
|
else EditPeriod.Text:='û<>п<EFBFBD><D0BF>Է<EFBFBD><D4B7><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ڼ<EFBFBD>';
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
Close;Free;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrmAccCloseOffBack.memTblPeriodCalcFields(DataSet: TDataSet);
|
|
|
|
|
begin
|
|
|
|
|
with DataSet do
|
|
|
|
|
FieldByName('PeriodDsp').AsString:=
|
|
|
|
|
Format(' %d <20><> %d <20><>', [FieldByName('PYear').AsInteger, FieldByName('PMonth').AsInteger]);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TfrmAccCloseOffBack.bbtnExcuteClick(Sender: TObject);
|
|
|
|
|
var aQuery, aQuery2 : TAdoQuery;
|
|
|
|
|
aYear, aMonth : String;
|
|
|
|
|
tyear,tmonth:integer;
|
|
|
|
|
begin
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
|
|
aQuery2:=CreateAdoQuery;
|
|
|
|
|
with aQuery do
|
|
|
|
|
try
|
|
|
|
|
frm_main.db.BeginTrans;
|
|
|
|
|
|
|
|
|
|
with memTblPeriod do begin
|
|
|
|
|
aYear:=FieldByName('PYear').AsString;
|
|
|
|
|
aMonth:=FieldByName('PMonth').AsString;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
Close;SQL.Clear;
|
|
|
|
|
SQL.Add('Update Period Set Closed=''F''');
|
|
|
|
|
SQL.Add('where Period='''+memTblPeriod.FieldByName('Period').AsString+'''');
|
|
|
|
|
ExecSQL;
|
|
|
|
|
|
|
|
|
|
Close;SQL.Clear;
|
|
|
|
|
SQL.Add('Delete from t_ch_bank_genleg');
|
|
|
|
|
SQL.Add('where <20><>='+aYear+' and <20><>='+aMonth);
|
|
|
|
|
ExecSQL;
|
|
|
|
|
|
|
|
|
|
Close;SQL.Clear;
|
|
|
|
|
SQL.Add('Delete from t_ch_cust_genleg');
|
|
|
|
|
SQL.Add('where <20><>='+aYear+' and <20><>='+aMonth);
|
|
|
|
|
ExecSQL;
|
|
|
|
|
|
|
|
|
|
Close;SQL.Clear;
|
|
|
|
|
SQL.Add('Delete from t_ch_genleg');
|
|
|
|
|
SQL.Add('where <20><>='+aYear+' and <20><>='+aMonth);
|
|
|
|
|
ExecSQL;
|
|
|
|
|
|
|
|
|
|
Close;SQL.Clear;
|
|
|
|
|
SQL.Add('Delete from t_ch_custbalance');
|
|
|
|
|
SQL.Add('where <20><>='+aYear+' and <20><>='+aMonth);
|
|
|
|
|
ExecSQL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logininfo.offyear:=StrToInt(aYear);
|
|
|
|
|
Logininfo.offmonth:=StrToInt(amonth);
|
|
|
|
|
|
|
|
|
|
if strtoint(get_parameters_value(140,'0'))=0 then
|
|
|
|
|
Logininfo.endday:=EncodeDate(Logininfo.offyear, Logininfo.offmonth,1)-1
|
|
|
|
|
else begin
|
|
|
|
|
if Logininfo.offmonth=1 then begin
|
|
|
|
|
tYear:=Logininfo.offyear-1;
|
|
|
|
|
tmonth:=12;
|
|
|
|
|
end else begin
|
|
|
|
|
tYear:=Logininfo.offyear;
|
|
|
|
|
tmonth:=Logininfo.offmonth-1;
|
|
|
|
|
end;
|
|
|
|
|
Logininfo.endday:=EncodeDate(tyear,tmonth,strtoint(get_parameters_value(140,'0')));
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
frm_main.db.CommitTrans;
|
|
|
|
|
|
|
|
|
|
memTblPeriod.Delete;
|
|
|
|
|
memTblPeriod.Last;
|
|
|
|
|
bbtnExcute.Enabled:=memTblPeriod.RecordCount>0;
|
|
|
|
|
if bbtnExcute.Enabled then
|
|
|
|
|
EditPeriod.Text:=memTblPeriod.FieldByName('PeriodDsp').AsString
|
|
|
|
|
else EditPeriod.Text:='û<>п<EFBFBD><D0BF>Է<EFBFBD><D4B7><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ڼ<EFBFBD>';
|
|
|
|
|
|
|
|
|
|
MessageDlg('<27><><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ɣ<EFBFBD>', mtWarning, [mbOk], 0);
|
|
|
|
|
finally
|
|
|
|
|
Close;
|
|
|
|
|
FreeAndNil(aQuery);
|
|
|
|
|
aQuery2.Close;
|
|
|
|
|
FreeAndNil(aQuery2);
|
|
|
|
|
frm_main.db.RollbackTrans;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|