?? sj_grpfhdck.pas
字號(hào):
procedure Tfrm_GRPFHDCK.ModiPanel1BtnClick(Index: TBtnVisible);
begin
inherited;
case index of
bnAdd: SetState(dtInsert);
bnDelete:
if CHQMsgBox(MSG_DELETE, 2) = IDYES then
with qryFHD do {query}
begin
Database.StartTransaction;
try
Delete; {query1}
Database.Commit;
except
if Database.InTransaction then Database.RollBack;
if errMsg = '' then
raise
else
raise exception.Create(errMsg);
end;
end;
bnEdit:
begin
if qryFHDPP.IsEmpty then
exit;
SetState(dtEdit);
end;
bnSave:
Save;
bnCancel:
if CHQMsgBox('取消編輯, 確定嗎?', 2) = IDYES then
begin
qryFHD.CancelUpdates;
qryFHDPP.CancelUpdates;
SetState(dtBrowse);
end;
bnPrint: {print}
;
bnClose: Close;
end;
end;
procedure Tfrm_GRPFHDCK.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
if (FDtstate in [dtInsert, dtEdit]) then
case CHQMsgBox(MSG_EXITSAVE, 3) of
IDYES:
if not Save then Action := caNone;
IDCANCEL: Action := caNone;
end;
end;
procedure Tfrm_GRPFHDCK.FormCreate(Sender: TObject);
begin
inherited;
DWMC.Caption := '使用單位:' + VG_UNITNAME;
InitData;
qryFHDPP.open;
SetState(dtBrowse);
end;
procedure Tfrm_GRPFHDCK.InitData;
begin
qryFHD.Close;
qryFHD.MacroByName('CON').AsString := ' HDR is null ';
qryFHD.MacroByName('YGDM').AsString := '''' + VG_UserID + '''';
qryFHD.Open;
end;
procedure Tfrm_GRPFHDCK.BitBtn1Click(Sender: TObject);
begin
inherited;
if qryFHDPP.IsEmpty then
exit;
end;
{
1 集郵票總帳表
2 *集郵票總分戶帳表
3/*集郵票明細(xì)分類帳*/
4/*集郵票進(jìn)發(fā)存明細(xì)帳表*/
5/*集郵票明細(xì)分類帳(庫(kù)管員)*/
}
procedure Tfrm_GRPFHDCK.BitBtn5Click(Sender: TObject);
var
v_s_yjr: string;
begin
if qryFHD.IsEmpty then
exit;
if DBDateEdit1.Date = 0 then
begin
CHQMsgBox('請(qǐng)先確定出庫(kù)日期!');
exit;
end;
if not CheckINYJRQ(io_grp, qryFHD.FieldByName('FHDH').AsString, v_s_yjr) then
begin
CHQMsgBox('該入庫(kù)單不在月結(jié)范圍(' + format('%s年%s月', [copy(v_s_yjr, 1, 4), copy(v_s_yjr, 5, 2)]) + ')內(nèi),不能復(fù)核!');
exit;
end;
if Check(qryFHD.FieldByName('FHDH').Asstring) then
CHQMsgBox('復(fù)核記帳成功!');
qryFHDAfterScroll(nil);
end;
function Tfrm_GRPFHDCK.Check(id: string): boolean;
begin
Result := false;
data.dm.StartTransaction;
try
with StoredProc1 do
begin
ParamByName('PC_FHDH').Asstring := id;
ParamByName('PC_USERID').Asstring := VG_USERName;
ExecProc;
result := Params[0].asInteger = 0;
if Params[0].asInteger = 0 then
begin
qryFHD.Edit;
qryFHD.FieldByName('HDR').Asstring := VG_USERNAME;
qryFHD.FieldByName('ZTZT').Asstring := '1';
qryFHD.ApplyUpdates;
end;
end;
data.dm.commit;
except
if data.dm.inTransaction then data.dm.rollback;
raise;
end;
qryFHD.CommitUpdates;
case StoredProc1.Params[0].asInteger of
0: ;
1: CHQMsgBox('復(fù)核記帳失敗! 沒(méi)有初始化或結(jié)轉(zhuǎn) [購(gòu)入票總帳表] 數(shù)據(jù).');
2: CHQMsgBox('復(fù)核記帳失敗! 沒(méi)有初始化或結(jié)轉(zhuǎn) [購(gòu)入票總分戶帳表] 數(shù)據(jù).');
3: CHQMsgBox('復(fù)核記帳失敗! 沒(méi)有初始化或結(jié)轉(zhuǎn) [購(gòu)入票明細(xì)分類帳] 數(shù)據(jù).');
4: CHQMsgBox('復(fù)核記帳失敗! 沒(méi)有初始化或結(jié)轉(zhuǎn) [購(gòu)入票進(jìn)發(fā)存明細(xì)帳表] 數(shù)據(jù).');
5: CHQMsgBox('復(fù)核記帳失敗! 沒(méi)有初始化或結(jié)轉(zhuǎn) [購(gòu)入票明細(xì)分類帳(庫(kù)管員)] 數(shù)據(jù).');
10: CHQMsgBox('復(fù)核記帳失敗! 沒(méi)有初始化或結(jié)轉(zhuǎn) [購(gòu)入票待銷存總帳表] 數(shù)據(jù).');
11: CHQMsgBox('復(fù)核記帳失敗! 沒(méi)有初始化或結(jié)轉(zhuǎn) [購(gòu)入票待銷存明細(xì)分類帳] 數(shù)據(jù).');
12: CHQMsgBox('復(fù)核記帳失敗! 沒(méi)有初始化或結(jié)轉(zhuǎn) [購(gòu)入票待銷存明細(xì)分類帳(庫(kù)管員)] 數(shù)據(jù)] 數(shù)據(jù).');
- 1: CHQMsgBox('找不到相應(yīng)的發(fā)貨單!');
- 2: CHQMsgBox('錯(cuò)誤:此發(fā)貨單已復(fù)核過(guò)!');
- 3: CHQMsgBox('錯(cuò)誤:此發(fā)貨單的出庫(kù)性質(zhì)沒(méi)找到或不需記帳!');
else
CHQMsgBox('復(fù)核記帳失敗! ');
end;
end;
procedure Tfrm_GRPFHDCK.qryFHDUpdateError(DataSet: TDataSet;
E: EDatabaseError; UpdateKind: TUpdateKind;
var UpdateAction: TUpdateAction);
begin
inherited;
case GetErrCode(DataSet, E, ErrMsg) of
Err_NoMasterRec: errMsg := errMsg + '&_&' + Format(MST_NOREC, ['', '', '']);
Err_HasDetailRec: errMsg := errMsg + '&_&' + Format(DTL_EXSTREC, ['']);
Err_RecDouble: errMsg := errMsg + '&_&' + Format(DBL_REC, ['']);
Err_NotNull: errMsg := errMsg + '&_&' + Format(NOTNULL, ['']);
else
errMsg := errMsg + '&_&' + OTHERERROR;
end;
end;
procedure Tfrm_GRPFHDCK.DBGrid2DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
inherited;
DrawCheckedGrid(not qryFHD.FieldByName('HDR').IsNull, Sender, Rect, DataCol, Column);
end;
procedure Tfrm_GRPFHDCK.BitBtn6Click(Sender: TObject);
var
i: integer;
v_b_skip: boolean;
v_s_yjr: string;
begin
inherited;
if qryFHD.IsEmpty then
exit;
i := 0;
with qryFHD do
begin
DisableControls;
First;
while not Eof do
begin
v_b_skip := false;
if qryFHD.FieldByName('HDR').IsNull and (not qryFHD.FieldByName('CKRQ').IsNull) then
begin
if not CheckINYJRQ(io_grp, qryFHD.FieldByName('FHDH').AsString, v_s_yjr) then
begin
v_b_skip := true;
// CHQMsgBox('該入庫(kù)單不在月結(jié)范圍(' + format('%s年%s月', [copy(v_s_yjr, 1, 4), copy(v_s_yjr, 5, 2)]) + ')內(nèi),不能復(fù)核!');
end;
if not v_b_skip then
if Check(FieldByName('FHDH').Asstring) then
i := i + 1;
end;
Next;
end;
EnableControls;
if i > 0 then
CHQMsgBox('共完成' + inttostr(i) + '筆發(fā)貨復(fù)核!');
end;
qryFHDAfterScroll(nil);
end;
procedure Tfrm_GRPFHDCK.BitBtn7Click(Sender: TObject);
begin
inherited;
qryFHD.Close;
qryFHD.MacroByName('CON').AsString := ' TO_CHAR(KDRQ, ''YYYYMMDD'') >= ''' + FormatDateTime('YYYYMMDD', DateEdit1.Date) + '''';
qryFHD.MacroByName('YGDM').AsString := '''' + VG_UserID + '''';
qryFHD.Open;
end;
procedure Tfrm_GRPFHDCK.qryFHDAfterScroll(DataSet: TDataSet);
begin
inherited;
Modipanel1.FButtons[bnEdit].Enabled := qryFHD.FieldByName('HDR').IsNull;
BitBtn5.Enabled := qryFHD.FieldByName('HDR').IsNull;
BBt_send.Enabled := not BitBtn5.Enabled;
end;
procedure Tfrm_GRPFHDCK.qryFHDPPJJGetText(Sender: TField; var Text: String;
DisplayText: Boolean);
begin
inherited;
nDisplay.GetText(Sender, Text, DisplayText);
end;
procedure Tfrm_GRPFHDCK.BBt_SendClick(Sender: TObject);
var
vs_fhdh: string;
begin
vs_fhdh := SelFHD(io_grp, DBEdit6.Text);
if vs_fhdh <> '' then
begin
data.dm.StartTransaction;
try
with data.qrytmp do
begin
Close;
SQL.Clear;
SQL.Add('update TKS_GRPFHD set SDATE=sysdate where FHDH in (' + vs_fhdh + ')');
ExecSQL;
Close;
SQL.Clear;
SQL.Add('insert into TKS_GRPFHD_CACO(FHDH, YJDH, CKXZ, FHDW, QXDW, KDRQ, ZTZT, GHRQ, JSZT, ZPRQ, FZDS, CKRQ, DJRQ, ZGR, KGY, HDR, ZBR, BZ, SDATE, COMM_DEPT) ');
SQL.Add('select FHDH, YJDH, CKXZ, FHDW, QXDW, KDRQ, ZTZT, GHRQ, JSZT, ZPRQ, FZDS, CKRQ, DJRQ, ZGR, KGY, HDR, ZBR, BZ, SDATE, QXDW from TKS_GRPFHD where FHDH in (' + vs_fhdh + ')');
ExecSQL;
Close;
SQL.Clear;
SQL.Add('insert into TKS_GRPCKPP_CACO(FHDH, PPDM, JJ, KFDM, KWH, DW, SL, YJ, XJ, JSJ, ZK, COMM_DEPT) ');
SQL.Add('select a.FHDH, a.PPDM, a.JJ, a.KFDM, a.KWH, a.DW, a.SL, a.YJ, a.XJ, a.JSJ, a.ZK, b.QXDW from TKS_GRPCKPP a, TKS_GRPFHD b where a.FHDH=b.FHDH and a.FHDH in (' + vs_fhdh + ')');
ExecSQL;
end;
data.dm.Commit;
except
data.dm.Rollback;
end;
end;
end;
end.
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -