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

📄 mylib.pas

📁 delphi作得信息业进销存源码.功能全面,运行稳定.
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  //Union All
  Result := sCGSH + ' union all ' + sCGTH + ' union all ' + sXSKD + ' union all ' +
    sXSTH + ' union all ' + sLL + ' union all ' + sTL + ' union all ' +
    sCPJC + ' union all ' + sKCPD + ' union all ' + sDR + ' union all ' +
    sDC + ' union all ' + sQBJX + ' union all ' + sQBZJ + ' union all ' +
    sTHJX + ' union all ' + sTHZJ;
end;

//All ZHJC
function  GetSqlZhmx(RQA, RQB: TDate; ZHID: integer): string;
var
  sCGSH, sCGFK, sCGTH, sXSKD, sXSSK, sXSTH, sFYKZ, sQTSR, sYHCK, sYHQK: string;
  sWhere: string;
begin
  //Common Where
  if RQA = 0 then
    sWhere := 'RQ <= #' + FormatDateTime('yyyy-mm-dd', RQB) + '#'
  else
    sWhere := 'RQ between #' + FormatDateTime('yyyy-mm-dd', RQA) + '# and ' +
      '#' + FormatDateTime('yyyy-mm-dd', RQB) + '#';
  if ZHID > 0 then
    sWhere := sWhere + ' and ZHID = ' + IntToStr(ZHID);
  //Set SQL  (JCLX   1,结余增加  2,结余减少)
  sCGSH :=
    'select ''采购收货'' as LX, ZHID, RQ, ID, DJBH, 0.000 as JEA, JE as JEB, JE as JYJE ' +
    'from CGSHZB where CGLX = 1 and ' + sWhere;
  sCGFK :=
    'select ''采购付款'' as LX, ZHID, RQ, ID, DJBH, 0.000 as JEA, JE as JEB, JE as JYJE  ' +
    'from CGFKZB where ' + sWhere;
  sCGTH :=
    'select ''采购退货'' as LX, ZHID, RQ, ID, DJBH, JE as JEA, 0.000 as JEB, JE as JYJE  ' +
    'from CGTHZB where THLX = 1 and ' + sWhere;
  sXSKD :=
    'select ''销售开单'' as LX, ZHID, RQ, ID, DJBH, JE as JEA, 0.000 as JEB, JE as JYJE  ' +
    'from XSKDZB where XSLX = 1 and ' + sWhere;
  sXSSK :=
    'select ''销售收款'' as LX, ZHID, RQ, ID, DJBH, JE as JEA, 0.000 as JEB, JE as JYJE  ' +
    'from XSSKZB where ' + sWhere;
  sXSTH :=
    'select ''销售退货'' as LX, ZHID, RQ, ID, DJBH, 0.000 as JEA, JE as JEB, JE as JYJE  ' +
    'from XSTHZB where THLX = 1 and ' + sWhere;
  sFYKZ :=
    'select ''费用开支'' as LX, ZHID, RQ, ID, DJBH, 0.000 as JEA, JE as JEB, JE as JYJE  ' +
    'from FYKZZB where ' + sWhere;
  sQTSR :=
    'select ''其它收入'' as LX, ZHID, RQ, ID, DJBH, JE as JEA, 0.000 as JEB, JE as JYJE  ' +
    'from QTSRZB where ' + sWhere;
  sYHCK :=
    'select ''帐户转入'' as LX, ZRZHID as ZHID, RQ, ID, '''' as DJBH, JE as JEA, 0.000 as JEB, JE as JYJE  ' +
    'from YHCKQK where ' + StringReplace(sWhere, 'ZHID', 'ZRZHID', [rfReplaceAll]);
  sYHQK :=
    'select ''帐户转出'' as LX, ZCZHID as ZHID, RQ, ID, '''' as DJBH, 0.000 as JEA, JE as JEB, JE as JYJE  ' +
    'from YHCKQK where ' + StringReplace(sWhere, 'ZHID', 'ZCZHID', [rfReplaceAll]);
  //Union All
  Result := sCGSH + ' union all ' + sCGFK + ' union all ' + sCGTH + ' union all ' + sXSKD + ' union all ' + sXSSK + ' union all ' + sXSTH + ' union all ' + sFYKZ + ' union all ' + sQTSR + ' union all ' + sYHCK + ' union all ' + sYHQK;
end;

//RqLsz
function  GetSqlRqLsz(RQA, RQB: TDate): string;
var
  sCGDD, sCGSH, sCGFK, sCGTH, sXSDD, sXSKD, sXSSK, sXSTH,
  sLL, sTL, sCPJC, sKCPD, sCPTJ, sCKDB, sQTKCBD, sFYKZ, sQTSR: string;
  sWhere: string;
begin
  sWhere := 'Z.RQ between #' + FormatDateTime('yyyy-mm-dd', RQA) + '# and ' +
    '#' + FormatDateTime('yyyy-mm-dd', RQB) + '#';
  sCGDD :=
    'select ''采购订单'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from CGDDZB Z, GYS K ' +
    'where Z.GYSID = K.ID and ' + sWhere;
  sCGSH :=
    'select ''采购收货'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from CGSHZB Z, GYS K ' +
    'where Z.GYSID = K.ID and ' + sWhere;
  sCGFK :=
    'select ''采购付款'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from CGFKZB Z, GYS K ' +
    'where Z.GYSID = K.ID and ' + sWhere;
  sCGTH :=
    'select ''采购退货'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from CGTHZB Z, GYS K ' +
    'where Z.GYSID = K.ID and ' + sWhere;
  sXSDD :=
    'select ''销售订单'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from XSDDZB Z, KH K ' +
    'where Z.KHID = K.ID and ' + sWhere;
  sXSKD :=
    'select ''销售开单'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from XSKDZB Z, KH K ' +
    'where Z.KHID = K.ID and ' + sWhere;
  sXSSK :=
    'select ''销售收款'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from XSSKZB Z, KH K ' +
    'where Z.KHID = K.ID and ' + sWhere;
  sXSTH :=
    'select ''销售退货'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from XSTHZB Z, KH K ' +
    'where Z.KHID = K.ID and ' + sWhere;
  sLL :=
    'select ''领料'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from LLZB Z, CK K ' +
    'where Z.CKID = K.ID and ' + sWhere;
  sTL :=
    'select ''退料'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from TLZB Z, CK K ' +
    'where Z.CKID = K.ID and ' + sWhere;
  sCPJC :=
    'select ''产品进仓'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from CPJCZB Z, CK K ' +
    'where Z.CKID = K.ID and ' + sWhere;
  sKCPD :=
    'select ''库存盘点'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from CPJCZB Z, CK K ' +
    'where Z.CKID = K.ID and ' + sWhere;
  sCPTJ :=
    'select ''存货调价'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from CHTJZB Z, CK K ' +
    'where Z.CKID = K.ID and ' + sWhere;
  sCKDB :=
    'select ''仓库调拨'' as LX, Z.RQ, Z.ID, Z.DJBH, K1.MC + '' -> '' + K2.MC as MC1, Z.JE, Z.BZ ' +
    'from CKDBZB Z, CK K1, CK K2 ' +
    'where Z.DCCID = K1.ID and Z.DRCID = K2.ID and ' + sWhere;
  sQTKCBD :=
    'select ''库存变动'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from QTKCBDZB Z, CK K ' +
    'where Z.CKID = K.ID and ' + sWhere;
  sFYKZ :=
    'select ''费用开支'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from FYKZZB Z, ZH K ' +
    'where Z.ZHID = K.ID and ' + sWhere;
  sQTSR :=
    'select ''其它收入'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from QTSRZB Z, ZH K ' +
    'where Z.ZHID = K.ID and ' + sWhere;
  //Union All
  Result := sCGDD + ' union all ' + sCGSH + ' union all ' + sCGFK + ' union all ' + sCGTH + ' union all ' + sXSDD + ' union all ' + sXSKD + ' union all ' + sXSSK + ' union all ' + sXSTH + ' union all ' +
    sLL + ' union all ' + sTL + ' union all ' + sCPJC + ' union all ' + sKCPD + ' union all ' + sCPTJ + ' union all ' + sCKDB + ' union all ' + sQTKCBD + ' union all ' + sFYKZ + ' union all ' + sQTSR
end;

//KhLsz
function  GetSqlKhLsz(RQA, RQB: TDate; KHID: integer): string;
var
  sXSDD, sXSKD, sXSSK, sXSTH: string;
  sWhere: string;
begin
  sWhere := 'Z.KHID = ' + IntToStr(KHID) + ' and ' +
    'Z.RQ between #' + FormatDateTime('yyyy-mm-dd', RQA) + '# and ' +
    '#' + FormatDateTime('yyyy-mm-dd', RQB) + '#';
  sXSDD :=
    'select ''销售订单'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from XSDDZB Z, KH K ' +
    'where Z.KHID = K.ID and ' + sWhere;
  sXSKD :=
    'select ''销售开单'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from XSKDZB Z, KH K ' +
    'where Z.KHID = K.ID and ' + sWhere;
  sXSSK :=
    'select ''销售收款'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from XSSKZB Z, KH K ' +
    'where Z.KHID = K.ID and ' + sWhere;
  sXSTH :=
    'select ''销售退货'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from XSTHZB Z, KH K ' +
    'where Z.KHID = K.ID and ' + sWhere;
  //Union All
  Result := sXSDD + ' union all ' + sXSKD + ' union all ' + sXSSK + ' union all ' + sXSTH;
end;

//GysLsz
function  GetSqlGysLsz(RQA, RQB: TDate; GYSID: integer): string;
var
  sCGDD, sCGSH, sCGFK, sCGTH: string;
  sWhere: string;
begin
  sWhere := 'Z.GYSID = ' + IntToStr(GYSID) + ' and ' +
    'Z.RQ between #' + FormatDateTime('yyyy-mm-dd', RQA) + '# and ' +
    '#' + FormatDateTime('yyyy-mm-dd', RQB) + '#';
  sCGDD :=
    'select ''采购订单'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from CGDDZB Z, GYS K ' +
    'where Z.GYSID = K.ID and ' + sWhere;
  sCGSH :=
    'select ''采购收货'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from CGSHZB Z, GYS K ' +
    'where Z.GYSID = K.ID and ' + sWhere;
  sCGFK :=
    'select ''采购付款'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from CGFKZB Z, GYS K ' +
    'where Z.GYSID = K.ID and ' + sWhere;
  sCGTH :=
    'select ''采购退货'' as LX, Z.RQ, Z.ID, Z.DJBH, K.MC as MC1, Z.JE, Z.BZ ' +
    'from CGTHZB Z, GYS K ' +
    'where Z.GYSID = K.ID and ' + sWhere;
  //Union All
  Result := sCGDD + ' union all ' + sCGSH + ' union all ' + sCGFK + ' union all ' + sCGTH;
end;

//SzLsz
function  GetSqlSzLsz(RQA, RQB: TDate): string;
var
  sFYKZ, sQTSR: string;
  sWhere: string;
begin
  sWhere := 'Z.RQ between #' + FormatDateTime('yyyy-mm-dd', RQA) + '# and ' +
    '#' + FormatDateTime('yyyy-mm-dd', RQB) + '#';
  sFYKZ :=
    'select ''费用开支'' as LX, K.MC as ZHMC, Z.RQ, Z.ID, Z.DJBH, ' +
    'S.MC as SFKFSMC, 0.00 as JEA, Z.JE as JEB, Z.BZ ' +
    'from FYKZZB Z, ZH K, SFKFS S ' +
    'where Z.ZHID = K.ID and Z.SFKFSID = S.ID and ' + sWhere;
  sQTSR :=
    'select ''其它收入'' as LX, K.MC as ZHMC, Z.RQ, Z.ID, Z.DJBH, ' +
    'S.MC as SFKFSMC, Z.JE as JEA, 0.00 as JEB, Z.BZ ' +
    'from QTSRZB Z, ZH K, SFKFS S ' +
    'where Z.ZHID = K.ID and Z.SFKFSID = S.ID and ' + sWhere;
  //Union All
  Result := sFYKZ + ' union all ' + sQTSR;
end;

//LrMx
function  GetSqlLrmx(RQA, RQB: TDate): string;
var
  sXSKD, sXSTH, sFYKZ, sQTSR: string;
  sWhere: string;
begin
  sWhere := 'Z.RQ between #' + FormatDateTime('yyyy-mm-dd', RQA) + '# and ' +
    '#' + FormatDateTime('yyyy-mm-dd', RQB) + '#';
  sXSKD :=
    'select Z.RQ, M.SL as SL1, M.DJ, M.CBDj, 0.000 as FYJE1, 0.000 as SRJE1 ' +
    'from XSKDZB Z, XSKD M ' +
    'where M.ZBID = Z.ID and ' + sWhere;
  sXSTH :=
    'select Z.RQ, - M.SL as SL1, M.DJ, M.CBDj, 0.000 as FYJE1, 0.000 as SRJE1 ' +
    'from XSTHZB Z, XSTH M ' +
    'where M.ZBID = Z.ID and ' + sWhere;
  sFYKZ :=
    'select Z.RQ, 0 as SL1, 0 as DJ, 0 as CBDj, JE as FYJE1, 0.000 as SRJE1 ' +
    'from FYKZZB Z ' +
    'where ' + sWhere;
  sQTSR :=
    'select Z.RQ, 0 as SL1, 0 as DJ, 0 as CBDj, 0.000 as FYJE1, JE as SRJE1 ' +
    'from QTSRZB Z ' +
    'where ' + sWhere;
  //Union All
  Result := sXSKD + ' union all ' + sXSTH + ' union all ' + sFYKZ + ' union all ' + sQTSR;
end;

//CGSH + CGTH (CHTH.SL -> -CGTH.SL)
function  GetSqlCgmx(RQA, RQB: TDate; strTj: string): string;
begin
  if strTj <> '' then
    strTj := 'where ' + strTj;
  Result :=
    'select * from (' +
    'select iif(Z.CGLX=1, ''现金采购'', ''挂帐采购'') as LX, ' +
    'M.ZBID, Z.DJBH, Z.RQ, Z.GYSID, L.MC as HPLBMC, Z.YWY, M.HPID, M.SL as SL1, M.DJ, M.NSL ' +
    'from CGSHZB Z, CGSH M, GYS K, HP H, HPLB L ' +
    'where Z.ID = M.ZBID and K.ID = Z.GYSID and H.ID = M.HPID and L.ID = H.HPLBID and ' +
    'M.RQ between  #' + FormatDateTime('yyyy-mm-dd', RQA) + '# and #' + FormatDateTime('yyyy-mm-dd', RQB) + '#) m ' +
    strtj + ' ' +
    'union all ' +
    'select * from (' +
    'select ''采购退货'' as LX, ' +
    'M.ZBID, Z.DJBH, Z.RQ, Z.GYSID, L.MC as HPLBMC, Z.YWY, M.HPID, -M.SL as SL1, M.DJ, M.NSL ' +
    'from CGTHZB Z, CGTH M, GYS K, HP H, HPLB L ' +
    'where Z.ID = M.ZBID and K.ID = Z.GYSID and H.ID = M.HPID and L.ID = H.HPLBID and ' +
    'M.RQ between  #' + FormatDateTime('yyyy-mm-dd', RQA) + '# and #' + FormatDateTime('yyyy-mm-dd', RQB) + '#) m ' +
    strtj;
end;

//XSKD + XSTH (XSTH.SL -> -XSTH.SL)
function  GetSqlXsmx(RQA, RQB: TDate; strTj: string): string;
begin
  if strTj <> '' then
    strTj := 'where ' + strTj;
  Result :=
    'select * from (' +
    'select iif(Z.XSLX=1, ''现金销售'', ''挂帐销售'') as LX, ' +
    'M.ZBID, Z.DJBH, Z.RQ, Z.KHID, D.MC as DQMC, L.MC as HPLBMC, Z.YWY, M.HPID, M.SL as SL1, M.DJ, M.CBDJ, M.NSL ' +
    'from XSKDZB Z, XSKD M, KH K, DQ D, HP H, HPLB L ' +
    'where Z.ID = M.ZBID and K.ID = Z.KHID and D.ID = K.DQID and H.ID = M.HPID and L.ID = H.HPLBID and ' +
    'M.RQ between  #' + FormatDateTime('yyyy-mm-dd', RQA) + '# and #' + FormatDateTime('yyyy-mm-dd', RQB) + '#) m ' +
    strtj + ' ' +
    'union all ' +
    'select * from (' +
    'select ''销售退货'' as LX, ' +
    'M.ZBID, Z.DJBH, Z.RQ, Z.KHID, D.MC as DQMC, L.MC as HPLBMC, Z.YWY, M.HPID, -M.SL as SL1, M.DJ, M.CBDJ, M.NSL ' +
    'from XSTHZB Z, XSTH M, KH K, DQ D, HP H, HPLB L ' +
    'where Z.ID = M.ZBID and K.ID = Z.KHID and D.ID = K.DQID and H.ID = M.HPID and L.ID = H.HPLBID and ' +
    'M.RQ between  #' + FormatDateTime('yyyy-mm-dd', RQA) + '# and #' + FormatDateTime('yyyy-mm-dd', RQB) + '#) m ' +
    strtj;
end;

//XSKD(LX=2) + XSSK + XSTH(LX=2)
function  GetSqlKhwl(RQA, RQB: TDate; KHID: integer): string;
var
  sXSKD, sXSTH, sXSSK: string;
  sWhere: string;
begin
  if RQA = 0 then
    sWhere := '(Z.RQ is null or Z.RQ <= #' + FormatDateTime('yyyy-mm-dd', RQB) + '#)'
  else
    sWhere := '(Z.RQ is null or Z.RQ between #' + FormatDateTime('yyyy-mm-dd', RQA) + '# and ' +
      '#' + FormatDateTime('yyyy-mm-dd', RQB) + '#)';
  if KHID > 0 then
    sWhere := sWhere + ' and Z.KHID = ' + IntToStr(KHID);
  sXSKD :=
    'select ''挂帐销售'' as LX, Z.RQ, Z.ID as ZBID, Z.DJBH, Z.KHID, ' +
    'Z.JE as JEA, 0.00000 as JEB, Z.JE as JYJE ' +
    'from XSKDZB Z ' +
    'where Z.XSLX <> 1 and ' + sWhere;
  sXSTH :=
    'select ''销售退货'' as LX, Z.RQ, Z.ID as ZBID, Z.DJBH, Z.KHID, ' +
    '0.00000 as JEA, Z.JE as JEB, Z.JE as JYJE ' +
    'from XSTHZB Z ' +
    'where Z.THLX <> 1 and ' + sWhere;
  sXSSK :=
    'select ''销售收款'' as LX, Z.RQ, Z.ID as ZBID, Z.DJBH, Z.KHID, ' +
    '0.00000 as JEA, Z.JE as JEB, Z.JE as JYJE ' +
    'from XSSKZB Z ' +
    'where ' + sWhere;
  //Union All
  Result := sXSKD + ' union all ' + sXSTH + ' union all ' + sXSSK;
end;

//XSKD(LX=2) + XSSK + XSTH(LX=2)
function  GetSqlYsmx(RQ: TDate; KHID: integer): string;
var
  sWhere: string;
begin
  sWhere := '(RQ is null or RQ <= #' + FormatDateTime('yyyy-mm-dd', RQ) + '#)';
  if KHID > 0 then
    sWhere := sWhere + ' and KHID = ' + IntToStr(KHID);
  Result :=
    'select *, #' + FormatDateTime('yyyy-mm-dd', RQ) + '# - RQ + 1 as TS_1, ' +
    'iif(isnull(TS_1), 9999, TS_1) as TS, JE - YSJE as JE1 ' +
    'from XSKDZB ' +
    'where XSLX <> 1 and YSJE < JE and ' + sWhere;
end;

//CGSH(LX=2) + CGFK + CGTH(LX=2)
function  GetSqlGyswl(RQA, RQB: TDate; GYSID: integer): string;
var
  sCGSH, sCGTH, sCGFK: string;
  sWhere: string;
begin
  if RQA = 0 then
    sWhere := '(Z.RQ is null or Z.RQ <= #' + FormatDateTime('yyyy-mm-dd', RQB) + '#)'
  else
    sWhere := '(Z.RQ is null or Z.RQ between #' + FormatDateTime('yyyy-mm-dd', RQA) + '# and ' +
      '#' + FormatDateTime('yyyy-mm-dd', RQB) + '#)';
  if GYSID > 0 then
    sWhere := sWhere + ' and Z.GYSID = ' + IntToStr(GYSID);
  sCGSH :=
    'select ''挂帐采购'' as LX, Z.RQ, Z.ID as ZBID, Z.DJBH, Z.GYSID, ' +
    'Z.JE as JEA, 0.00000 as JEB, Z.JE as JYJE ' +
    'from CGSHZB Z ' +
    'where Z.CGLX <> 1 and ' + sWhere;
  sCGTH :=
    'select ''采购退货'' as LX, Z.RQ, Z.ID as ZBID, Z.DJBH, Z.GYSID, ' +
    '0.00000 as JEA, Z.JE as JEB, Z.JE as JYJE ' +
    'from CGTHZB Z ' +
    'where Z.THLX <> 1 and ' + sWhere;
  sCGFK :=
    'select ''采购付款'' as LX, Z.RQ, Z.ID as ZBID, Z.DJBH, Z.GYSID, ' +
    '0.00000 as JEA, Z.JE as JEB, Z.JE as JYJE ' +
    'from CGFKZB Z ' +
    'where ' + sWhere;
  //Union All
  Result := sCGSH + ' union all ' + sCGTH + ' union all ' + sCGFK;
end;

//CGSH
function  GetSqlYfmx(RQ: TDate; GYSID: integer): string;
var
  sWhere: string;
begin
  sWhere := '(RQ is null or RQ <= #' + FormatDateTime('yyyy-mm-dd', RQ) + '#)';
  if GYSID > 0 then
    sWhere := sWhere + ' and GYSID = ' + IntToStr(GYSID);
  Result :=
    'select *, #' + FormatDateTime('yyyy-mm-dd', RQ) + '# - RQ + 1 as TS_1, ' +
    'iif(isnull(TS_1), 9999, TS_1) as TS, JE - YFJE as JE1 ' +
    'from CGSHZB ' +
    'where CGLX <> 1 and YFJE < JE and ' + sWhere;
end;

//FYKZ + QTSR
function  GetSqlSzmx(RQA, RQB: TDate; SRZCLBID: integer): string;
var
  sWhere: string;
begin
  sWhere := 'Z.RQ between #' + FormatDateTime('yyyy-mm-dd', RQA) + '# and ' +
    '#' + FormatDateTime('yyyy-mm-dd', RQB) + '#';
  if SRZCLBID > 0 then
    sWhere := sWhere + ' and M.SRZCLBID = ' + IntToStr(SRZCLBID);
  Result :=
    'select ''费用开支'' as LX, Z.RQ, Z.ID as ZBID, Z.DJBH, M.SRZCLBID, ' +
    'M.JE as JEA, 0.00000 as JEB ' +
    'from FYKZZB Z, FYKZ M ' +
    'where M.ZBID = Z.ID and ' + sWhere + ' ' +
    'union all ' +
    'select ''其它收入'' as LX, Z.RQ, Z.ID as ZBID, Z.DJBH, M.SRZCLBID, ' +
    '0.00000 as JEA, M.JE as JEB ' +
    'from QTSRZB Z, QTSR M ' +
    'where M.ZBID = Z.ID and ' + sWhere;
end;

//DBGrid 的行颜色
procedure SetDBGridColor(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn;
  State: TGridDrawState; ColColor: TColor);
begin
  with TDBGrid(Sender).Canvas Do
  Begin
    if gdSelected in State Then
    begin
      Brush.Color := ColColor;
      Font.Color := clWhite;
    end else
    begin
      Brush.Color := clWhite;
      Font.Color := ColColor;
    end;
    DBGridAlign(TDBGrid(Sender), Column.Alignment, Rect, Column.Field.DisplayText);
  end;
end;

procedure StrToFile(Str, FileName: string);
var
  Stream: TStream;
begin
  Stream := TFileStream.Create(FileName, fmCreate);
  try
    Stream.WriteBuffer(Pointer(Str)^, Length(Str));
  finally
    Stream.Free;
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -