⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sj_ywkccx.pas

📁 省级集邮品管理ERP
💻 PAS
📖 第 1 页 / 共 3 页
字号:

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