?? 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 + -