📄 sy_ck_jyp.pas
字号:
with qry_tmp do
begin
Close;
SQL.Text := 'delete TYS_JYCKJHDPPB where CKJHDH = ' + QuotedStr(VL_CKJHDH);
ExecSQL;
end;
with qry_Detail do
begin
DisableControls;
First;
while not Eof do
begin
qry_tmp.Close;
qry_tmp.SQL.Text := 'insert into TYS_JYCKJHDPPB (CKJHDH, DWDM, PPDM, KFDM, PPMC, JJ , XJ, ZK, JSJ, FPSL,DWMC)values( ' +
QuotedStr(VL_CKJHDH) + ', ' +
QuotedStr(FieldByName('DWDM').AsString) + ', ' +
QuotedStr(FieldByName('PPDM').AsString) + ', ' +
QuotedStr(FieldByName('KFDM').AsString) + ', ' +
QuotedStr(FieldByName('PPMC').AsString) + ', ' +
QuotedStr(FloatToStr(FieldByName('JJ').AsFloat * 100)) + ', ' +
QuotedStr(FloatToStr(FieldByName('XJ').AsFloat * 100)) + ', ' +
QuotedStr(FieldByName('ZK').AsString) + ', ' +
QuotedStr(FloatToStr(FieldByName('JSJ').AsFloat * 100)) + ', ' +
QuotedStr(FieldByName('FPSL').AsString) + ',' +
QuotedStr(FieldByName('DWMC').AsString) +
' )';
qry_tmp.ExecSQL;
Next;
end;
EnableControls;
end;
end;
{-------------------------------------------------------------------------------}
{取消}
procedure TFrm_SY_CK_JYP.bbtn_CancelClick(Sender: TObject);
begin
{询问}
if Application.MessageBox('是否要取消对出库计划单的修改?', '询问', MB_ICONQUESTION + MB_YESNO + MB_DEFBUTTON2) = mrNo then
Exit;
qry_Detail.CancelUpdates;
qry_List.CancelUpdates;
qry_Detail.CommitUpdates;
qry_List.CommitUpdates;
{※※※顺序不可以更换※※※}
SetState(False); {设置界面可修改状态}
qry_List.AfterScroll(nil); {刷新数据}
if VL_CKJHDH = '' then {新增时}
pgc_LM.ActivePageIndex := 0;
end;
{-------------------------------------------------------------------------------}
{调用存储过程,生成单号}
function TFrm_SY_CK_JYP.Create_DH(A_BILLID, A_SORTCODE, A_DEPARTMENT, A_CYEAR: string): string;
begin
with sp_DH do
begin
ParamByName('BILLID').AsString := a_BILLID;
ParamByName('SORTCODE').AsString := a_SORTCODE;
ParamByName('DEPARTMENT').AsString := a_DEPARTMENT;
ParamByName('CYEAR').AsString := a_CYEAR;
ExecProc;
Result := Params[0].AsString;
end;
end;
{-------------------------------------------------------------------------------}
{取理论库存}
function TFrm_SY_CK_JYP.ShowTheoryKC(A_PPDM, A_JJ: string): Integer;
var
l_KC: Integer;
begin
{实际库存}
with qry_tmp do
begin
Close;
SQL.Text := ' select a.TS from TYS_JYPPKC a where a.KFDM =' +
QuotedStr(qry_Detail.FieldByName('KFDM').AsString) +
' and a.PPDM =' + QuotedStr(qry_Detail.FieldByName('PPDM').AsString) +
' and a.JJ=' + A_JJ;
Open;
if IsEmpty then
L_KC := 0
else
l_KC := Fields[0].AsInteger;
Close;
end;
{零枚票出库计划单表TYS_JYCKJHDB中的ZT:0-未处理,2-已签批时的数量}
with qry_tmp do
begin
Close;
SQL.Text := ' select a.KFDM, a.PPDM, sum(a.FPSL) FPSL from TYS_JYCKJHDPPB a, TYS_JYCKJHDB b ' +
' where a.CKJHDH = b.CKJHDH and (b.ZT = ''0'' or b.ZT = ''2'') ' +
' and a.KFDM =' + QuotedStr(qry_Detail.FieldByName('KFDM').AsString) +
' and a.PPDM =' + QuotedStr(qry_Detail.FieldByName('PPDM').AsString) +
' and a.JJ =' + A_JJ +
' group by a.KFDM, a.PPDM, a.JJ';
Open;
if not IsEmpty then
l_KC := l_KC - FieldByName('FPSL').AsInteger;
Close;
end;
{零枚票出库计划单表TYS_JYCKJHDB中的ZT :1-已处理
(TK_TXFHD 中的HDR 为空时-未复核【计算理论库存时需要减去】,)}
with qry_tmp do
begin
Close;
{ SQL.Text := 'select a.KFDM, a.PPDM, sum(a.FPSL)FPSL from TYS_TXCKJHDPPB a, TYS_TXPCKJHDB b, TK_TXFHD c ' +
' where a.CKJHDH = b.CKJHDH and c.YJDH(+) = b.CKJHDH and b.ZT = ''1'' ' +
' and a.KFDM =' + QuotedStr(qry_Detail.FieldByName('KFDM').AsString) +
' and a.PPDM =' + QuotedStr(qry_Detail.FieldByName('PPDM').AsString) +
' and a.JJ =' + A_JJ +
' group by a.KFDM, a.PPDM, a.JJ ';}
SQL.Text := 'select SUM(A.SL) FPSL from TKS_JYCKPP a,TKS_JYFHD b ' +
' where a.FHDH=b.FHDH and b.JSZT = ''0'' and b.HDR is null ' +
' and a.KFDM = ' + QuotedStr(qry_Detail.FieldByName('KFDM').AsString) +
' and a.PPDM = ' + QuotedStr(qry_Detail.FieldByName('PPDM').AsString) + {集邮票用的是票品代码不是图代码 YJ}
' and a.JJ =' + A_JJ;
Open;
if not IsEmpty then
l_KC := l_KC - FieldByName('FPSL').AsInteger;
Close;
end;
Result := l_KC;
end;
{-------------------------------------------------------------------------------}
{取计划单中的分配总数}
function TFrm_SY_CK_JYP.GetFPSL_Total: Integer;
var
l_SL: Integer;
l_dbgPlace: TBookMark;
begin
l_sl := 0;
{取计划单中的分配总数}
with qry_Detail do
begin
DisableControls;
l_dbgPlace := GetBookMark;
First;
while not Eof do
begin
l_SL := l_SL + FieldByName('FPSL').AsInteger;
Next;
end;
EnableControls;
GotoBookMark(l_dbgPlace);
FreeBookMark(l_dbgPlace);
end;
Result := l_SL;
end;
{-------------------------------------------------------------------------------}
{取得凑整的规格}
procedure TFrm_SY_CK_JYP.GetGG(A_PPDM: string);
var
l_sql: string;
begin
(*{type为 'ptyp'—普通邮票,'jtlm'—纪特零枚,'fpj—封片简}
try
if (A_Type = 'ptyp') or (A_Type = 'jtlm') then {普票、零枚} {}
l_sql := 'select a.BZLSH, A.BJC, sum(c.GBGTMS * e.GBGBBS) BZSL ' +
' from TB_BZSJB A, TB_YZPPTUXXB b,TB_BTGXB c, TB_BSJB d, TB_BBGXB e ' +
' where a.BZLSH = e.BZLSH and b.TUDM = c.TUDM and c.BLSH = d.BLSH and d.BLSH = e.BLSH ' +
' and (e.GBGBBS is not NULL) and c.TUDM= ' + QuotedStr(A_PPDM) +
' group by a.BZLSH, a.BJC order by a.BZLSH ';
if A_Type = 'fpj' then {封片} {}
with qry_tmp do
begin
Close;
SQL.Text := 'select BZFS from TB_YZPPTXXB where TDM = ' + QuotedStr(A_PPDM);
Open;
if Fields[0].AsString = '1' then {按套包装}
l_sql := 'select a.BZLSH, A.BJC, a.ZXTS BZSL ' +
' from TB_BZSJB A where a.BZBBJ <>''2'' and a.TDM = ' + QuotedStr(A_PPDM) +
' order by a.BZLSH '
else
l_sql := 'select a.BZLSH, A.BJC, sum(c.GBGTMS * e.GBGBBS) BZSL ' +
' from TB_BZSJB A, TB_YZPPTUXXB b,TB_BTGXB c, TB_BSJB d, TB_BBGXB e ' +
' where a.BZLSH = e.BZLSH and b.TUDM = c.TUDM and c.BLSH = d.BLSH and d.BLSH = e.BLSH ' +
' and (e.GBGBBS is not NULL) and a.TDM = ' + QuotedStr(A_PPDM) +
' group by a.BZLSH, a.BJC order by a.BZLSH ';
Close;
end;
{取得该票品的所有包装规格,资料包除外}
fcb_BZGG.ClearAll;
with qry_tmp do
begin
Close;
SQL.Text := l_sql;
Open;
while not eof do
begin
fcb_BZGG.Items.Add(FieldByName('BJC').AsString);
fcb_BZGG.FieldItems.Add(FieldByName('BZSL').AsString);
Next;
end;
if not IsEmpty then
fcb_BZGG.ItemIndex := 0;
Close;
end;
if (A_Type = 'ptyp') or (A_Type = 'jtlm') then {普票、零枚} {}
l_sql := 'select b.GBGTMS from TB_YZPPTUXXB a,TB_BTGXB b where a.TUDM = b.TUDM ' +
' and a.TUDM= ' + QuotedStr(A_PPDM);
if A_Type = 'fpj' then {封片} {}
l_sql := 'select b.GBGTMS from TB_YZPPTUXXB a,TB_BTGXB b where a.TUDM = b.TUDM ' +
' and substr(a.TUDM, 1, 11) = ' + QuotedStr(Copy(A_PPDM, 1, 11));
{取得该票品的版的规格}
with qry_tmp do
begin
Close;
SQL.Text := l_sql;
Open;
VL_Ban_GG := Fields[0].AsInteger;
Close;
end;
except
raise Exception.Create('包装规格不完整!');
end;
*)
cb_BGG.Clear;
cb_BZGG.Clear;
VL_MBMS.Clear;
with qry_Tmp do
begin
Close;
SQL.Text := 'select distinct BZGG,ZXTS from TB_BZSJB where BZBBJ<>2 and TDM =' + QuotedStr(A_PPDM);
Open;
while not Eof do
begin
cb_BZGG.Items.Add(FieldByName('BZGG').AsString);
VL_MBMS.Add(FieldByName('ZXTS').AsString);
Next;
end;
if cb_BZGG.Items.Count > 0 then
cb_BZGG.ItemIndex := 0;
Close;
SQL.Text := 'select distinct GBGTMS from TB_BTGXB where TUDM like' + QuotedStr(Copy(A_PPDM, 1, 11) + '%') + ' order by GBGTMS ';
Open;
while not Eof do
begin
cb_BGG.Items.Add(FieldByName('GBGTMS').AsString);
Next;
end;
if cb_BGG.Items.Count > 0 then
begin
cb_BGG.ItemIndex := cb_BGG.Items.Count - 1;
cb_BGG.OnChange(cb_BGG);
end;
end;
end;
{-------------------------------------------------------------------------------}
{凑包凑版调用}
procedure TFrm_SY_CK_JYP.SetRounding;
var
l_Dest: Integer;
begin
l_Dest := 0;
case rg_Round.ItemIndex of
0: {凑包} {}
begin
if cb_BZGG.Items.Count = 0 then
begin
Application.MessageBox('包装规格可能不完整,无法按包进行凑整!', '提示', MB_OK + MB_IconInformation);
rg_Round.ItemIndex := 2; {默认为不凑}
Exit;
end;
{ l_Dest := StrToInt(cb_BZGG.Text);}
l_Dest := StrToInt(VL_MBMS[cb_BZGG.ItemIndex]);
end;
1: {凑版} {}
l_Dest := VL_Ban_GG;
2: {不用凑整数} {}
l_Dest := 0;
end;
SetRoundSL(rg_Round.ItemIndex, rg_Round_Style.ItemIndex, L_Dest); {分配数量的凑整处理}
end;
{-------------------------------------------------------------------------------}
{分配数量的凑整处理}
procedure TFrm_SY_CK_JYP.SetRoundSL(A_Round, A_Round_Style, A_SingleDest: Integer);
{参数说明:凑包方式、凑整的方式(向上、向下)、凑整时的单包或者单版包装规格}
var
l_dbgPlace: TBookMark;
begin
{凑整}
qry_Detail.BeforePost := nil;
with qry_Detail do
begin
DisableControls;
l_dbgPlace := GetBookMark;
First;
while not Eof do
begin
Edit;
if A_Round = 2 then {不凑} {}
FieldByName('FPSL').AsInteger := FieldByName('FPSL_OLD').AsInteger
else
FieldByName('FPSL').AsInteger :=
GetRoundNumber(FieldByName('FPSL_OLD').AsInteger, A_SingleDest, A_Round_Style); {返回凑整后的数据}
Post;
Next;
end;
EnableControls;
GotoBookMark(l_dbgPlace);
FreeBookMark(l_dbgPlace);
end;
qry_Detail.BeforePost := qry_DetailBeforePost;
end;
{-------------------------------------------------------------------------------}
{返回凑整后的数据}
function TFrm_SY_CK_JYP.GetRoundNumber(A_source, A_SingleDest, A_type: Integer): Integer;
var
l_Mod, l_Div: Integer;
begin
Result := 0;
if A_SingleDest <= 0 then {为0或者小于0时直接返回}
begin
Result := A_Source;
Exit;
end;
//????
l_Mod := A_Source Mod A_SingleDest; {求余数,为0时整除}
if (l_Mod = 0) and (A_Source >= A_SingleDest) then {恰好为整包或整版}
begin
Result := A_Source;
Exit;
end;
l_Div := A_Source Div A_SingleDest; {}
case A_type of
0: {向上} {}
Result := (l_Div + 1) * A_SingleDest;
1: {向下} {}
begin
Result := l_Div * A_SingleDest;
end;
end;
if Result < 0 then {向下取整时为负数时返回0}
Result := 0;
end;
{-------------------------------------------------------------------------------}
{设置界面可修改状态}
procedure TFrm_SY_CK_JYP.SetState(A_Enabled: boolean);
begin
tbs_List.TabVisible := not A_Enabled;
dbnv_List.Enabled := not A_Enabled;
bbtn_Search.Enabled := not A_Enabled;
bbtn_Print.Enabled := not A_Enabled;
rg_Round.Enabled := A_Enabled;
rg_Round_Style.Enabled := A_Enabled;
cb_BZGG.Enabled := A_Enabled;
cb_BGG.Enabled := A_Enabled;
bbtn_Add.Enabled := not A_Enabled;
bbtn_Del.Enabled := not A_Enabled;
bbtn_Modify.Enabled := not A_Enabled;
bbtn_AddDW.Enabled := A_Enabled;
bbtn_DeleteDW.Enabled := A_Enabled;
bbtn_Save.Enabled := A_Enabled;
bbtn_Cancel.Enabled := A_Enabled;
dbgEh_Detail.ReadOnly := not A_Enabled;
end;
{-------------------------------------------------------------------------------}
procedure TFrm_SY_CK_JYP.cb_BGGChange(Sender: TObject);
begin
VL_Ban_GG := StrToInt(cb_BGG.Text);
SetRounding; {凑包凑版调用}
end;
{-------------------------------------------------------------------------------}
{凑包凑版}
procedure TFrm_SY_CK_JYP.cb_BZGGChange(Sender: TObject);
begin
SetRounding; {凑包凑版调用}
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -