?? sj_ywkccx.pas
字號:
l_SQL:= 'select TZDM, TZJC from TG_YZPPTZDM where (1=2' + l_SQL + ') order by TZDM';
{添充票品特征}
with RxQry_Tmp do
begin
Close;
SQL.Text:= l_SQL;
Open;
while not Eof do
begin
fcb_TZ.Items.Add(FieldByName('TZJC').AsString);
fcb_TZ.FieldItems.Add(FieldByName('TZDM').AsString);
Next;
end;
Close;
end;
if fcb_TZ.Items.Count > 0 then
fcb_TZ.ItemIndex:= 0;
end;
{-------------------------------------------------------------------------------}
{查詢按鈕單擊}
procedure TFrm_YWKCCX.Act_selExecute(Sender: TObject);
var
l_SQL: string;
begin
{如果庫房數為零,不繼續進行}
if fcb_KFMC.Items.Count < 0 then
begin
Exit;
end;
{構造SQL}
if RG_KC.ItemIndex = 0 then
case vl_Io_Type of
io_jyp:
begin
l_SQL:= ' select a.KFDM,a.PPDM,a.KWH,a.TS,a.BZ,b.KFMC, c.TMC, c.ZH, a.JJ, a.XJ, a.ZK, a.JSJ,'#13
+ ' c.TPMZ MZ, nvl(e.KCHSJ,0) KCHSJ ,a.JJ*a.TS JJJE, c.TPMZ*a.TS MZJE, nvl(e.KCHSJ,0)*a.TS KCHSJJE,a.XJ*a.TS SJJE '#13
+ ' from TYS_JYPPKC a, TGS_KFB b, TB_YZPPXXB c, TGS_KFRYDZB d, TG_GJPPJGB e '#13
+ ' where a.PPDM=e.PPDM(+) and a.KFDM = b.KFDM and a.PPDM = c.TDM and a.KFDM = d.KFDM and d.YGDM = ' + QuotedStr(VG_UserID) + ''#13;
end;
io_txp:
begin
l_SQL:= ' select a.PPDM,a.KWH,a.TS,b.KFMC, c.TMC, c.ZH, a.JJ, a.XJ, a.ZK, a.JSJ, '#13
+ ' c.TPMZ MZ, nvl(e.KCHSJ,0) KCHSJ ,a.JJ*a.TS JJJE, c.TPMZ*a.TS MZJE, nvl(e.KCHSJ,0)*a.TS KCHSJJE,a.XJ*a.TS SJJE '#13
+ ' from TYS_TXPPKC a, TGS_KFB b, TB_YZPPXXB c, TGS_KFRYDZB d, TG_GJPPJGB e '#13
+ ' where a.PPDM=e.PPDM(+) and a.KFDM = b.KFDM and a.PPDM = c.TDM and a.KFDM = d.KFDM and d.YGDM = ' + QuotedStr(VG_UserID) + ''#13;
end;
io_yp: {郵品沒有面值,所以面值按0處理}
begin
l_SQL:= ' select a.KFDM,a.PPDM,a.KWH,a.TS,a.BZ,b.KFMC, c.MC TMC, c.ZH, a.JJ, a.XJ, a.ZK, a.JSJ,'#13
+ ' 0 MZ, 0 KCHSJ ,a.JJ*a.TS JJJE, 0 MZJE, 0 KCHSJJE, a.XJ*a.TS SJJE '#13
+ ' from TYS_YPPKC a, TGS_KFB b, TB_JYPTXXB c, TGS_KFRYDZB d '#13
+ ' where a.KFDM = b.KFDM and a.PPDM = c.TDM and a.KFDM = d.KFDM and d.YGDM = ' + QuotedStr(VG_UserID) + ''#13;
end;
io_grp:
begin
l_SQL:= ' select a.KFDM,a.PPDM,a.KWH,a.TS,a.BZ,b.KFMC, c.TMC, c.ZH, a.JJ, a.XJ, a.ZK, a.JSJ, '#13
+ ' c.TPMZ MZ, nvl(e.KCHSJ,0) KCHSJ ,a.JJ*a.TS JJJE, c.TPMZ*a.TS MZJE, nvl(e.KCHSJ,0)*a.TS KCHSJJE,a.XJ*a.TS SJJE '#13
+ ' from TYS_GRPPKC a, TGS_KFB b, TB_YZPPXXB c, TGS_KFRYDZB d, TG_GJPPJGB e '#13
+ ' where a.PPDM=e.PPDM(+) and a.KFDM = b.KFDM and a.PPDM = c.TDM and a.KFDM = d.KFDM and d.YGDM = ' + QuotedStr(VG_UserID) + ''#13;
end;
end
else
case vl_Io_Type of
io_jyp:
begin
l_SQL:= ' select a.KFDM,a.PPDM,a.KWH,a.TS,a.BZ,b.KFMC, c.TMC, c.ZH, a.JJ, a.XJ, a.ZK, a.JSJ,'#13
+ ' c.TPMZ MZ, nvl(e.KCHSJ,0) KCHSJ ,a.JJ*a.TS JJJE, c.TPMZ*a.TS MZJE, nvl(e.KCHSJ,0)*a.TS KCHSJJE,a.XJ*a.TS SJJE '#13
+ ' from ( ' + jyp_llkc + ' ) a, TGS_KFB b, TB_YZPPXXB c, TGS_KFRYDZB d, TG_GJPPJGB e '#13
+ ' where a.PPDM=e.PPDM(+) and a.KFDM = b.KFDM and a.PPDM = c.TDM and a.KFDM = d.KFDM and d.YGDM = ' + QuotedStr(VG_UserID) + ''#13;
end;
io_txp:
begin
l_SQL:= ' select a.PPDM,a.KWH,a.TS,b.KFMC, c.TMC, c.ZH, a.JJ, a.XJ, a.ZK, a.JSJ,'#13
+ ' c.TPMZ MZ, nvl(e.KCHSJ,0) KCHSJ ,a.JJ*a.TS JJJE, c.TPMZ*a.TS MZJE, nvl(e.KCHSJ,0)*a.TS KCHSJJE,a.XJ*a.TS SJJE '#13
+ ' from ( ' + txp_llkc + ' ) a, TGS_KFB b, TB_YZPPXXB c, TGS_KFRYDZB d, TG_GJPPJGB e '#13
+ ' where a.PPDM=e.PPDM(+) and a.KFDM = b.KFDM and a.PPDM = c.TDM and a.KFDM = d.KFDM and d.YGDM = ' + QuotedStr(VG_UserID) + ''#13;
end;
io_yp: {集郵品沒有面值,按0處理}
begin
l_SQL:= ' select a.KFDM,a.PPDM,a.KWH,a.TS,a.BZ,b.KFMC, c.MC TMC, c.ZH, a.JJ, a.XJ, a.ZK, a.JSJ,'#13
+ ' 0 MZ, 0 KCHSJ ,a.JJ*a.TS JJJE, 0 MZJE, 0 KCHSJJE, a.XJ*a.TS SJJE '#13
+ ' from ( ' + yp_llkc + ' ) a, TGS_KFB b, TB_JYPTXXB c, TGS_KFRYDZB d '#13
+ ' where a.KFDM = b.KFDM and a.PPDM = c.TDM and a.KFDM = d.KFDM and d.YGDM = ' + QuotedStr(VG_UserID) + ''#13;
end;
io_grp:
begin
l_SQL:= ' select a.KFDM,a.PPDM,a.KWH,a.TS,a.BZ,b.KFMC, c.TMC, c.ZH, a.JJ, a.XJ, a.ZK, a.JSJ,'#13
+ ' c.TPMZ MZ, nvl(e.KCHSJ,0) KCHSJ ,a.JJ*a.TS JJJE, c.TPMZ*a.TS MZJE, nvl(e.KCHSJ,0)*a.TS KCHSJJE,a.XJ*a.TS SJJE '#13
+ ' from ( ' + grp_llkc + ' ) a, TGS_KFB b, TB_YZPPXXB c, TGS_KFRYDZB d, TG_GJPPJGB e'#13
+ ' where a.PPDM=e.PPDM(+) and a.KFDM = b.KFDM and a.PPDM = c.TDM and a.KFDM = d.KFDM and d.YGDM = ' + QuotedStr(VG_UserID) + ''#13;
end;
end;
if chk_MHCX.Checked then
begin
if RG_ZHMC.ItemIndex = 1 then
begin
if vl_Io_Type = io_yp then
l_SQL:= l_SQL + ' and c.MC like ''%' + edt_ZHMC.Text + '%'' '
else
l_SQL:= l_SQL + ' and c.TMC like ''%' + edt_ZHMC.Text + '%'' '
end
else
l_SQL:= l_SQL + ' and Upper(c.ZH) like ''%' + UpperCase(edt_ZHMC.Text) + '%'' ';
end
else
begin
{年度}
if (chk_ND.Checked) and (Length(se_ND.Text) = 4) then
begin
if fcb_PPMC.Text = '' then
begin
if vl_Io_Type = io_yp then {郵品--進口票(票品代碼長度為15位)的票品代碼的第6位起4位是年度,非進口票(票品代碼長度為13位)的票品代碼的第4位起4位是年度}
l_SQL:= l_SQL + 'and decode(length(a.PPDM),15,substr(a.PPDM,6,4),substr(a.PPDM,4,4))=' + QuotedStr(se_ND.Text)
else {其它的票品代碼的第4位起4位是年度}
l_SQL:= l_SQL + 'and substr(a.PPDM,4,4)=' + QuotedStr(se_ND.Text);
end;
end;
{銷價}
if cb_XJ.Text <> '' then
l_SQL:= l_SQL + ' and to_Char(a.XJ) = ' + QuotedStr(cb_XJ.Text);
{庫房}
if fcb_KFMC.Text <> '' then
l_SQL:= l_SQL + ' and a.KFDM = ' + QuotedStr(fcb_KFMC.FieldString);
{大類}
if fcb_DL.Text <> '' then
begin
if fcb_PPLB.Text = '' then
if vl_Io_Type <> io_yp then
l_SQL:= l_SQL + ' and c.PPLB in (select YZLDM from TG_YZPPLDMB where DL=' + QuotedStr(fcb_DL.Text) + ')'
else
l_SQL:= l_SQL + ' and c.YPLB in (select JYPLDM from TG_JYPLDMB where substr(JYPLDM,1,1)='
+ '(select JYPLDM from TG_JYPLDMB where LB=''大類'' and MC=' + QuotedStr(fcb_DL.Text) + ') and LB<>''大類'')';
end;
{小類}
if fcb_PPLB.Text <> '' then
begin
if fcb_PPMC.Text = '' then
begin
case vl_Io_Type of
io_jyp, io_txp:
l_SQL:= l_SQL + ' and substr(c.TDM,1,3) = ' + QuotedStr(fcb_PPLB.FieldString);
io_yp:
l_SQL:= l_SQL + ' and c.YPLB = ' + QuotedStr(fcb_PPLB.FieldString);
io_grp:
l_SQL:= l_SQL + ' and c.TYPE = ' + QuotedStr(fcb_PPLB.FieldString);
end;
end;
end;
{特征}
if fcb_TZ.Text <> '' then
begin
if fcb_PPMC.Text = '' then
begin
if vl_Io_Type = io_yp then
l_SQL:= l_SQL + ' and c.TZ=' + QuotedStr(fcb_TZ.FieldString)
else
l_SQL:= l_SQL + ' and substr(c.TDM,10,2)=' + QuotedStr(fcb_TZ.FieldString);
end;
end;
{票品名稱}
if fcb_PPMC.Text <> '' then
l_SQL:= l_SQL + ' and c.TDM = ' + QuotedStr(fcb_PPMC.FieldString);
end;
if not chk_BHKC.Checked then
l_SQL:= l_SQL + ' and a.TS > 0 ';
l_SQL:= l_SQL + ' order by c.ZH,a.KFDM';
{查詢滿足條件記錄}
with RxQry_KC do
begin
Close;
SQL.Text:= l_SQL;
Open;
end;
end;
{-------------------------------------------------------------------------------}
{打印}
procedure TFrm_YWKCCX.bbtn_PrintClick(Sender: TObject);
begin
if RxQry_KC.IsEmpty then Exit;
PrintDBGrid(dbgEh_KC, pCaption[Integer(vl_Io_Type)] + '庫存');
end;
{-------------------------------------------------------------------------------}
{字段顯示格式設置}
procedure TFrm_YWKCCX.RxQry_KCMZGetText(Sender: TField; var Text: string;
DisplayText: Boolean);
begin
CurrGetText(Sender, Text, DisplayText);
end;
procedure TFrm_YWKCCX.RxQry_KCKCHSJGetText(Sender: TField;
var Text: string; DisplayText: Boolean);
begin
CurrGetText(Sender, Text, DisplayText);
end;
procedure TFrm_YWKCCX.RxQry_KCJJJEGetText(Sender: TField; var Text: string;
DisplayText: Boolean);
begin
CurrGetText(Sender, Text, DisplayText);
end;
procedure TFrm_YWKCCX.RxQry_KCMZJEGetText(Sender: TField; var Text: string;
DisplayText: Boolean);
begin
CurrGetText(Sender, Text, DisplayText);
end;
procedure TFrm_YWKCCX.RxQry_KCKCHSJJEGetText(Sender: TField;
var Text: string; DisplayText: Boolean);
begin
CurrGetText(Sender, Text, DisplayText);
end;
procedure TFrm_YWKCCX.RxQry_KCSJJEGetText(Sender: TField; var Text: string;
DisplayText: Boolean);
begin
CurrGetText(Sender, Text, DisplayText);
end;
procedure TFrm_YWKCCX.RxQry_KCAfterOpen(DataSet: TDataSet);
begin
TNumericField(DataSet.FieldByName('TS')).DisPlayFormat:= '#,##0';
end;
procedure TFrm_YWKCCX.RxQry_KCJJGetText(Sender: TField; var Text: string;
DisplayText: Boolean);
begin
CurrGetText(Sender, Text, DisplayText);
end;
{-------------------------------------------------------------------------------}
{顯示全計}
procedure TFrm_YWKCCX.dbgEh_KCGetFooterParams(Sender: TObject; DataCol,
Row: Integer; Column: TColumnEh; AFont: TFont; var Background: TColor;
var Alignment: TAlignment; State: TGridDrawState; var Text: string);
begin
try
if (Column.Field is TFloatField) and ((Column.FieldName = 'JJJE') or (Column.FieldName = 'MZJE') or (Column.FieldName = 'KCHSJJE') or (Column.FieldName = 'SJJE')) then
Text:= FormatFloat('#,##0.00', StrToFloat(Text) / 100);
except
Application.MessageBox('總計出錯!', '提示', 48 + mb_ok);
Exit;
end;
if Column.FieldName = 'TMC' then
Text:= '記錄數:' + Text;
if Column.FieldName = 'ZH' then
Text:= '合計';
end;
{-------------------------------------------------------------------------------}
{退出}
procedure TFrm_YWKCCX.Act_rtnExecute(Sender: TObject);
begin
RxQry_Tmp.Close;
Close;
end;
{-------------------------------------------------------------------------------}
{將dbGrid列寬記錄入INI文件}
procedure TFrm_YWKCCX.FormClose(Sender: TObject; var Action: TCloseAction);
begin
SaveAllColWidth(Self);
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -