📄 sj_ywkccx.pas
字号:
{库房改变}
procedure TFrm_YWKCCX.fcb_KFMCChange(Sender: TObject);
begin
{清空票品大类}
fcb_DL.ClearAll;
fcb_DL.Text:= '';
{清空票品类别}
fcb_PPLB.ClearAll;
fcb_PPLB.Text:= '';
{清空票品名称}
fcb_PPMC.ClearAll;
fcb_PPMC.Text:= '';
{清空票品特征}
fcb_TZ.ClearAll;
fcb_TZ.Text:= '';
{如果库房名称为空,退出}
if fcb_KFMC.Text = '' then
Exit;
{添充选中库房对应的大类}
with RxQry_Tmp do
begin
Close;
case vl_Io_Type of
io_jyp:
begin
SQL.Text:= ' select distinct c.DL '#13
+ ' from TYS_JYPPKC a, TG_YZPPLDMB c, TGS_KFRYDZB d '#13
+ ' where substr(a.PPDM,1,3) = c.YZLDM and a.KFDM = d.KFDM and d.YGDM = ' + QuotedStr(VG_UserID) + ' and a.KFDM = ' + QuotedStr(fcb_KFMC.FieldString) + ''#13;
end;
io_txp:
begin
SQL.Text:= ' select distinct c.DL '#13
+ ' from TYS_TXPPKC a, TG_YZPPLDMB c, TGS_KFRYDZB d '#13
+ ' where substr(a.PPDM,1,3) = c.YZLDM and a.KFDM = d.KFDM and d.YGDM = ' + QuotedStr(VG_UserID) + ' and a.KFDM = ' + QuotedStr(fcb_KFMC.FieldString) + ''#13;
end;
io_yp:
begin
SQL.Text:= 'select MC DL, JYPLDM from TG_JYPLDMB where JYPLDM in (select distinct substr(c.JYPLDM,1,1) DLDM'#13
+ ' from TYS_YPPKC a, TB_JYPTXXB b,TG_JYPLDMB c, TGS_KFRYDZB d '#13
+ ' where a.PPDM=b.TDM and b.YPLB = c.JYPLDM and a.KFDM = d.KFDM and d.YGDM = ' + QuotedStr(VG_UserID) + ' and a.KFDM = ' + QuotedStr(fcb_KFMC.FieldString) + ''#13;
end;
io_grp:
begin
SQL.Text:= ' select distinct c.DL'#13
+ ' from TYS_GRPPKC a, TB_YZPPXXB b, TG_YZPPLDMB c, TGS_KFRYDZB d '#13
+ ' where substr(a.PPDM,1,3) = c.YZLDM and a.PPDM=b.TDM and a.KFDM = d.KFDM and d.YGDM = ' + QuotedStr(VG_UserID) + ' and a.KFDM = ' + QuotedStr(fcb_KFMC.FieldString) + ''#13;
end;
end;
if (chk_ND.Checked) and (Length(se_ND.Text) = 4) then
begin
if vl_Io_Type = io_yp then {邮品--进口票(票品代码长度为15位)的票品代码的第6位起4位是年度,非进口票(票品代码长度为13位)的票品代码的第4位起4位是年度}
SQL.Text:= SQL.Text + 'and decode(length(a.PPDM),15,substr(a.PPDM,6,4),substr(a.PPDM,4,4))=' + QuotedStr(se_ND.Text)
else {其它的票品代码的第4位起4位是年度}
SQL.Text:= SQL.Text + 'and substr(a.PPDM,4,4)=' + QuotedStr(se_ND.Text);
end;
if vl_Io_Type = io_yp then
SQL.Text:= SQL.Text + ') order by JYPLDM ';
Open;
while not Eof do
begin
fcb_DL.Items.Add(FieldByName('DL').AsString);
if vl_Io_Type = io_yp then {邮品,添充集邮品类代码为大类代码}
fcb_DL.FieldItems.Add(FieldByName('JYPLDM').AsString)
else {其它,添充-1占位,没有实际意义}
fcb_DL.FieldItems.Add('-1');
Next;
end;
end;
{大类改变,刷新小类}
if fcb_DL.Items.Count > 0 then
fcb_DL.ItemIndex:= 0;
fcb_DLChange(nil);
end;
{-------------------------------------------------------------------------------}
{大类改变}
procedure TFrm_YWKCCX.fcb_DLChange(Sender: TObject);
begin
{清空票品类别}
fcb_PPLB.ClearAll;
fcb_PPLB.Text:= '';
{清空票品名称}
fcb_PPMC.ClearAll;
fcb_PPMC.Text:= '';
{清空票品特征}
fcb_TZ.ClearAll;
fcb_TZ.Text:= '';
{如果不为购入票并且大类为空,则忽略以后过程}
if (fcb_DL.Text = '') and (vl_Io_Type <> io_grp) then
Exit;
with RxQry_Tmp do
begin
Close;
case vl_Io_Type of
io_jyp:
begin
SQL.Text:= ' select distinct c.MC, c.YZLDM'#13
+ ' from TYS_JYPPKC a, TG_YZPPLDMB c, TGS_KFRYDZB d '#13
+ ' where substr(a.PPDM,1,3) = c.YZLDM and a.KFDM = d.KFDM and d.YGDM = ' + QuotedStr(VG_UserID)
+ ' and a.KFDM = ' + QuotedStr(fcb_KFMC.FieldString) + ''#13
+ ' and c.DL=' + QuotedStr(fcb_DL.Text);
end;
io_txp:
begin
SQL.Text:= ' select distinct c.MC, c.YZLDM'#13
+ ' from TYS_TXPPKC a, TG_YZPPLDMB c, TGS_KFRYDZB d '#13
+ ' where substr(a.PPDM,1,3) = c.YZLDM and a.KFDM = d.KFDM and d.YGDM = ' + QuotedStr(VG_UserID)
+ ' and a.KFDM = ' + QuotedStr(fcb_KFMC.FieldString)
+ ' and c.DL=' + QuotedStr(fcb_DL.Text);
end;
io_yp:
begin
SQL.Text:= ' select distinct c.MC, c.JYPLDM YZLDM'#13
+ ' from TYS_YPPKC a, TB_JYPTXXB b,TG_JYPLDMB c, TGS_KFRYDZB d '#13
+ ' where a.PPDM=b.TDM and b.YPLB = c.JYPLDM and a.KFDM = d.KFDM and d.YGDM = ' + QuotedStr(VG_UserID)
+ ' and a.KFDM = ' + QuotedStr(fcb_KFMC.FieldString)
+ ' and c.JYPLDM=' + QuotedStr(fcb_DL.FieldString);
end;
io_grp:
begin
SQL.Text:= ' select distinct b.TYPE'#13
+ ' from TYS_GRPPKC a, TB_YZPPXXB b, TGS_KFRYDZB d '#13
+ ' where a.PPDM=b.TDM and a.kfdm = d.kfdm and d.YGDM = ' + QuotedStr(VG_UserID)
+ ' and a.KFDM = ' + QuotedStr(fcb_KFMC.FieldString);
end;
end;
if (chk_ND.Checked) and (Length(se_ND.Text) = 4) then
begin
if vl_Io_Type = io_yp then {邮品--进口票(票品代码长度为15位)的票品代码的第6位起4位是年度,非进口票(票品代码长度为13位)的票品代码的第4位起4位是年度}
SQL.Text:= SQL.Text + 'and decode(length(a.PPDM),15,substr(a.PPDM,6,4),substr(a.PPDM,4,4))=' + QuotedStr(se_ND.Text)
else {其它的票品代码的第4位起4位是年度}
SQL.Text:= SQL.Text + 'and substr(a.PPDM,4,4)=' + QuotedStr(se_ND.Text);
end;
Open;
while not Eof do
begin
if vl_Io_Type <> io_grp then
begin
fcb_PPLB.Items.Add(FieldByName('MC').AsString);
fcb_PPLB.FieldItems.Add(FieldByName('YZLDM').AsString);
Next;
end
else
begin
if Fields[0].AsString = 'fpj' then
fcb_PPLB.Items.Add('封片简');
if Fields[0].AsString = 'jtlm' then
fcb_PPLB.Items.Add('纪特零枚');
if Fields[0].AsString = 'jttp' then
fcb_PPLB.Items.Add('纪特套票');
if Fields[0].AsString = 'ptyp' then
fcb_PPLB.Items.Add('普通邮票');
if Fields[0].AsString = 'yp' then
fcb_PPLB.Items.Add('邮品');
fcb_PPLB.FieldItems.Add(FieldByName('TYPE').AsString);
Next;
end;
end
end;
if fcb_PPLB.Items.Count > 0 then
fcb_PPLB.ItemIndex:= 0;
fcb_PPLBChange(nil);
end;
{-------------------------------------------------------------------------------}
{小类改变}
procedure TFrm_YWKCCX.fcb_PPLBChange(Sender: TObject);
var
i: Integer;
l_SQL: string;
l_lst_TZDM: TStringList;
begin
{清空票品名称}
fcb_PPMC.ClearAll;
fcb_PPMC.Text:= '';
{清空票品特征}
fcb_TZ.ClearAll;
fcb_TZ.Text:= '';
if fcb_PPLB.Text = '' then
Exit;
{重新添充票品名称}
with RxQry_Tmp do
begin
Close;
case vl_Io_Type of
io_jyp:
begin
SQL.Text:= ' select TMC, TDM, KFDM, ZH from(select distinct c.TMC, c.tdm, a.KFDM, c.zh'#13
+ ' from TYS_JYPPKC a, TB_YZPPXXB c, TGS_KFRYDZB d '#13
+ ' where a.ppdm = c.tdm and a.kfdm = d.kfdm and d.YGDM = ' + QuotedStr(VG_UserID) + ' and a.kfdm = ' + QuotedStr(fcb_KFMC.FieldString) + ''#13
+ ' and substr(c.TDM,1,3) = ' + QuotedStr(fcb_PPLB.FieldString);
end;
io_txp:
begin
SQL.Text:= ' select TMC, TDM, KFDM, ZH from(select distinct c.tmc, c.tdm, a.kfdm, c.zh'#13
+ ' from TYS_TXPPKC a, TB_YZPPXXB c, TGS_KFRYDZB d '#13
+ ' where a.ppdm = c.tdm and a.kfdm = d.kfdm and d.YGDM = ' + QuotedStr(VG_UserID) + ' and a.kfdm = ' + QuotedStr(fcb_KFMC.FieldString) + ''#13
+ ' and substr(c.TDM,1,3) = ' + QuotedStr(fcb_PPLB.FieldString);
end;
io_yp:
begin
SQL.Text:= ' select TMC, TDM, KFDM, ZH from(select distinct c.mc tmc, c.tdm, a.kfdm, c.zh'#13
+ ' from TYS_YPPKC a, TB_JYPTXXB c, TGS_KFRYDZB d '#13
+ ' where a.ppdm = c.tdm and a.kfdm = d.kfdm and d.YGDM = ' + QuotedStr(VG_UserID) + ' and a.kfdm = ' + QuotedStr(fcb_KFMC.FieldString) + ''#13
+ ' and c.yplb = ' + QuotedStr(fcb_PPLB.FieldString);
end;
io_grp:
begin
SQL.Text:= ' select TMC, TDM, KFDM, ZH from(select distinct c.tmc, c.tdm, a.kfdm, c.zh'#13
+ ' from TYS_GRPPKC a,TB_YZPPXXB c, TGS_KFRYDZB d '#13
+ ' where a.ppdm = c.tdm and a.kfdm = d.kfdm and d.YGDM = ' + QuotedStr(VG_UserID) + ' and a.kfdm = ' + QuotedStr(fcb_KFMC.FieldString) + ''#13
+ ' and c.TYPE = ' + QuotedStr(fcb_PPLB.FieldString);
end;
end;
if (chk_ND.Checked) and (Length(se_ND.Text) = 4) then
begin
if vl_Io_Type = io_yp then {邮品--进口票(票品代码长度为15位)的票品代码的第6位起4位是年度,非进口票(票品代码长度为13位)的票品代码的第4位起4位是年度}
SQL.Text:= SQL.Text + 'and decode(length(a.PPDM),15,substr(a.PPDM,6,4),substr(a.PPDM,4,4))=' + QuotedStr(se_ND.Text)
else {其它的票品代码的第4位起4位是年度}
SQL.Text:= SQL.Text + 'and substr(a.PPDM,4,4)=' + QuotedStr(se_ND.Text);
end;
SQL.Text:= SQL.Text + ') order by ZH,KFDM';
Open;
while not Eof do
begin
fcb_PPMC.Items.Add(FieldByName('TMC').AsString);
fcb_PPMC.FieldItems.Add(FieldByName('TDM').AsString);
Next;
end;
end;
if fcb_PPMC.Items.Count > 0 then
fcb_PPMC.ItemIndex:= 0;
{刷新票品特征}
fcb_TZ.ClearAll;
fcb_TZ.Text:= '';
if fcb_PPMC.Items.Count = 0 then
Exit;
{生成查询特征的SQL语句}{特征代码从套代码的倒数第3-4位取}
l_lst_TZDM:= TStringList.Create;
for i:= 0 to fcb_PPMC.Items.Count - 1 do
begin
l_SQL:= Copy(fcb_PPMC.FieldItems[i], Length(fcb_PPMC.FieldItems[i]) - 3, 2);
if l_lst_TZDM.IndexOf(l_SQL) = -1 then
l_lst_TZDM.Add(l_SQL);
end;
l_SQL:= '';
for i:= 0 to l_lst_TZDM.Count - 1 do
begin
l_SQL:= l_SQL + ' or TZDM=' + QuotedStr(l_lst_TZDM[i])
end;
l_lst_TZDM.Free;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -