<?xml version="1.0" encoding="utf-8" standalone="no"?>
<TfrxReport Version="6.9.2" DotMatrixReport="False" EngineOptions.SilentMode="True" EngineOptions.NewSilentMode="simSilent" IniFile="\Software\Fast Reports" PreviewOptions.Buttons="12287" PreviewOptions.Modal="False" PreviewOptions.Zoom="1" PrintOptions.Printer="Default" PrintOptions.PrintOnSheet="0" ReportOptions.CreateDate="41546.6611873611" ReportOptions.Description.Text="" ReportOptions.LastChange="44949.5629144329" ScriptLanguage="PascalScript" ScriptText.Text="&#13;&#10;procedure DialogPage1OnActivate(Sender: TfrxComponent);&#13;&#10;begin&#13;&#10;&#13;&#10;&#13;&#10;  qry_stock.close ;&#13;&#10;  qry_stock.open ;&#13;&#10;&#13;&#10;  date1.date:=now ;&#13;&#10;  date2.date:=now ;&#13;&#10;&#13;&#10;  cbb_stock.keyvalue:=&#60;MY_STOCK_CODE&#62; ;&#13;&#10;&#13;&#10;&#13;&#10;&#13;&#10;end;&#13;&#10;&#13;&#10;procedure DialogPage1OnShow(Sender: TfrxComponent);&#13;&#10;begin&#13;&#10;&#13;&#10;end;&#13;&#10;&#13;&#10;&#13;&#10;&#13;&#10;&#13;&#10;&#13;&#10;begin&#13;&#10;&#13;&#10;end." OnReportPrint="DialogPage1OnActivate">
  <Datasets>
    <item DataSet="qry_rp" DataSetName="rp"/>
    <item DataSet="qry_stock" DataSetName="stock"/>
  </Datasets>
  <Variables>
    <item Name="MY_STOCK_CODE"/>
    <item Name="MY_STOCK_NAME"/>
  </Variables>
  <TfrxDataPage Name="Data" HGuides.Text="" VGuides.Text="" Height="1000" Left="0" Top="0" Width="1000">
    <TfrxUniDACQuery Name="qry_rp" UserName="rp" CloseDataSource="True" FieldAliases.Text="" BCDToCurrency="False" IgnoreDupParams="False" SQL.Text="{IF SQL SERVER}                                        &#13;&#10;select  T.NLEM_DES,                           &#13;&#10;SUM(CASE when T.NLEM='ED'   then T.DIS_VALUE else NULL end)  as XED_AMT,&#13;&#10;SUM(CASE when T.NLEM='NED'  then T.DIS_VALUE else NULL end)   as XNED_AMT  &#13;&#10;from (&#13;&#10;select e.NAME as  NLEM_DES, dbo.IS_ED(g.IS_ED) as NLEM,g.GROUP_CODE,Cx.DIS_QTY ,Cx.DIS_VALUE&#13;&#10;from INV_MD  i (NOLOCK)       &#13;&#10;left join DRUG_GN g (NOLOCK) on (i.WORKING_CODE=g.WORKING_CODE)&#13;&#10;left join  (select c1.WORKING_CODE,c1.STOCK_ID,&#13;&#10;SUM(CASE when c1.R_S_STATUS in ('R','I','G','A') then c1.ACTIVE_QTY &#13;&#10;         when c1.R_S_STATUS in ('B') then c1.ACTIVE_QTY*-1 else NULL end&#13;&#10;) as RCV_QTY,          &#13;&#10;						SUM(CASE when c1.R_S_STATUS in ('T','S')  then c1.ACTIVE_QTY &#13;&#10;										 when (c1.R_S_STATUS='C') then c1.ACTIVE_QTY*-1 else NULL end) as DIS_QTY,&#13;&#10;						SUM(CASE when c1.R_S_STATUS in ('T','S')  then c1.[VALUE] &#13;&#10;										 when (c1.R_S_STATUS='C') then c1.[VALUE]*-1 else NULL end) as DIS_VALUE&#13;&#10;						from CARD c1  (NOLOCK)    &#13;&#10;            where  c1.STOCK_ID=:stock                         &#13;&#10;            and    c1.R_S_DATE between  :date1 and :date2&#13;&#10;            group by c1.WORKING_CODE,c1.STOCK_ID ) as Cx on (Cx.WORKING_CODE = i.WORKING_CODE  and Cx.STOCK_ID=i.DEPT_ID)&#13;&#10;left join ED_GROUP e (NOLOCK) on (left(g.GROUP_CODE,2)+'000000'=e.CODE)    &#13;&#10;where  i.DEPT_ID=:stock  and   g.WORKING_CODE is not null            &#13;&#10;) as T&#13;&#10;WHERE   T.NLEM_DES&#60;&#62;'' and T.NLEM_DES is not null                                                                  &#13;&#10;group BY T.NLEM_DES&#13;&#10;{ELSE}&#13;&#10;&#13;&#10;select  T.NLEM_DES,                           &#13;&#10;SUM(CASE when T.NLEM='ED'   then T.DIS_VALUE else NULL end)  as XED_AMT,&#13;&#10;SUM(CASE when T.NLEM='NED'  then T.DIS_VALUE else NULL end)   as XNED_AMT  &#13;&#10;from (&#13;&#10;select e.NAME as  NLEM_DES,IS_ED(g.IS_ED) as NLEM,g.GROUP_CODE,Cx.DIS_QTY ,Cx.DIS_VALUE&#13;&#10;from INV_MD  i         &#13;&#10;left join DRUG_GN g   on (i.WORKING_CODE=g.WORKING_CODE)&#13;&#10;left join  (select c1.WORKING_CODE,c1.STOCK_ID,&#13;&#10;SUM(CASE when c1.R_S_STATUS in ('R','I','G','A') then c1.ACTIVE_QTY &#13;&#10;         when c1.R_S_STATUS in ('B') then c1.ACTIVE_QTY*-1 else NULL end&#13;&#10;) as RCV_QTY,          &#13;&#10;SUM(CASE when c1.R_S_STATUS in ('T','S')  then c1.ACTIVE_QTY &#13;&#10;when (c1.R_S_STATUS='C') then c1.ACTIVE_QTY*-1 else NULL end) as DIS_QTY,&#13;&#10;SUM(CASE when c1.R_S_STATUS in ('T','S')  then c1.VALUE &#13;&#10;when (c1.R_S_STATUS='C') then c1.VALUE*-1 else NULL end) as DIS_VALUE&#13;&#10;from CARD c1       &#13;&#10;            where  c1.STOCK_ID=:stock                         &#13;&#10;            and    c1.R_S_DATE between  :date1 and :date2&#13;&#10;            group by c1.WORKING_CODE,c1.STOCK_ID ) as Cx on (Cx.WORKING_CODE = i.WORKING_CODE  and Cx.STOCK_ID=i.DEPT_ID)&#13;&#10;left join ED_GROUP e   on (concat(left(g.GROUP_CODE,2),'000000')=e.CODE)    &#13;&#10;where  i.DEPT_ID=:stock  and   g.WORKING_CODE is not null            &#13;&#10;) as T&#13;&#10;WHERE   T.NLEM_DES&#60;&#62;'' and T.NLEM_DES is not null                                                                  &#13;&#10;group BY T.NLEM_DES&#13;&#10;  &#13;&#10;&#13;&#10;{ENDIF}                " SpecificOptions.Text="" PropData="05704C65667402380470546F70022C0A506172616D657465727301010641204E616D653D2273746F636B222044617461547970653D226674537472696E67222045787072657373696F6E3D226362625F73746F636B2E6B657976616C75652200010654204E616D653D226461746531222044617461547970653D226674537472696E67222045787072657373696F6E3D22466F726D61744461746554696D652827595959596D6D6464272C64617465312E64617465292200010654204E616D653D226461746532222044617461547970653D226674537472696E67222045787072657373696F6E3D22466F726D61744461746554696D652827595959596D6D6464272C64617465322E64617465292200010641204E616D653D2273746F636B222044617461547970653D226674537472696E67222045787072657373696F6E3D226362625F73746F636B2E6B657976616C75652200010641204E616D653D2273746F636B222044617461547970653D226674537472696E67222045787072657373696F6E3D226362625F73746F636B2E6B657976616C75652200010654204E616D653D226461746531222044617461547970653D226674537472696E67222045787072657373696F6E3D22466F726D61744461746554696D652827595959596D6D6464272C64617465312E64617465292200010654204E616D653D226461746532222044617461547970653D226674537472696E67222045787072657373696F6E3D22466F726D61744461746554696D652827595959596D6D6464272C64617465322E64617465292200010641204E616D653D2273746F636B222044617461547970653D226674537472696E67222045787072657373696F6E3D226362625F73746F636B2E6B657976616C7565220000"/>
    <TfrxUniDACQuery Name="qry_stock" UserName="stock" CloseDataSource="True" FieldAliases.Text="" BCDToCurrency="False" IgnoreDupParams="False" SQL.Text="{IF SQLSERVER}                             &#13;&#10;select * from DEPT_ID (NOLOCK) where (HIDE='' or HIDE is null or HIDE='N')&#13;&#10;&#13;&#10;{ELSE}&#13;&#10;&#13;&#10;select * from DEPT_ID  where (HIDE='' or HIDE is null or HIDE='N')&#13;&#10;&#13;&#10;&#13;&#10;{ENDIF}                " SpecificOptions.Text="" PropData="05704C65667402380470546F700384000A506172616D65746572730100"/>
  </TfrxDataPage>
  <TfrxReportPage Name="Page1" HGuides.Text="" VGuides.Text="" PaperWidth="210" PaperHeight="297" PaperSize="9" LeftMargin="10" RightMargin="10" TopMargin="10" BottomMargin="10" ColumnWidth="0" ColumnPositions.Text="" Frame.Typ="0" MirrorMode="0">
    <TfrxPageFooter Name="PageFooter1" FillType="ftBrush" FillGap.Top="0" FillGap.Left="0" FillGap.Bottom="0" FillGap.Right="0" Frame.Typ="0" Height="30.23624" Left="0" Top="316" Width="718.1107">
      <TfrxMemoView Name="Memo1" AllowVectorExport="True" Left="647.5201" Top="2" Width="68.03154" Height="22.67718" Font.Charset="1" Font.Color="0" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" Frame.Typ="0" HAlign="haRight" ParentFont="False" Text="[Page#]"/>
    </TfrxPageFooter>
    <TfrxMasterData Name="MasterData1" FillType="ftBrush" FillGap.Top="0" FillGap.Left="0" FillGap.Bottom="0" FillGap.Right="0" Frame.Typ="0" Height="30.23624" Left="0" Top="196" Width="718.1107" ColumnWidth="0" ColumnGap="0" DataSet="qry_rp" DataSetName="rp" RowCount="0" Stretched="True">
      <TfrxMemoView Name="rpDEPT_NAME" AllowVectorExport="True" ShiftMode="smWhenOverlapped" Left="0" Top="1.55905999999999" Width="393.07112" Height="26.45671" StretchMode="smActualHeight" DataSet="qry_rp" DataSetName="rp" Font.Charset="1" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" Frame.Typ="0" ParentFont="False" Text="[Line#]. [rp.&#34;NLEM_DES&#34;]"/>
      <TfrxMemoView Name="Memo20" AllowVectorExport="True" Left="399.20501" Top="1" Width="105.82684" Height="26.45671" DataSet="qry_rp" DataSetName="rp" DisplayFormat.FormatStr="%2.2n" DisplayFormat.Kind="fkNumeric" Font.Charset="1" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" Frame.Typ="0" HAlign="haRight" ParentFont="False" Text="[rp.&#34;XED_AMT&#34;]"/>
      <TfrxMemoView Name="Memo21" AllowVectorExport="True" Left="508.81138" Top="1" Width="94.48825" Height="26.45671" DataSet="qry_rp" DataSetName="rp" DisplayFormat.FormatStr="%2.2n" DisplayFormat.Kind="fkNumeric" Font.Charset="1" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" Frame.Typ="0" HAlign="haRight" ParentFont="False" Text="[rp.&#34;XNED_AMT&#34;]"/>
      <TfrxMemoView Name="Memo27" AllowVectorExport="True" Left="607.07916" Top="1" Width="102.04731" Height="26.45671" DataSet="qry_rp" DataSetName="rp" DisplayFormat.FormatStr="%2.2n" DisplayFormat.Kind="fkNumeric" Font.Charset="1" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" Frame.Typ="0" HAlign="haRight" ParentFont="False" Text="[&#60;rp.&#34;XNED_AMT&#34;&#62;+&#60;rp.&#34;XED_AMT&#34;&#62;]"/>
    </TfrxMasterData>
    <TfrxPageHeader Name="PageHeader1" FillType="ftBrush" FillGap.Top="0" FillGap.Left="0" FillGap.Bottom="0" FillGap.Right="0" Frame.Typ="0" Height="158.74026" Left="0" Top="16" Width="718.1107">
      <TfrxMemoView Name="Memo2" AllowVectorExport="True" Left="2" Top="2" Width="714.33117" Height="60.47248" Font.Charset="1" Font.Color="0" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="1" Frame.Typ="0" HAlign="haCenter" ParentFont="False" Text="รายงานมูลค่าการจ่ายเวชภัณฑ์จำแนกตามกลุ่มยา&#13;&#10;[TRIM(cbb_stock.text)]"/>
      <TfrxLineView Name="Line1" AllowVectorExport="True" Left="2.77953" Top="100.47248" Width="714.33117" Height="0" Color="0" Frame.Color="12632256" Frame.Typ="0" Diagonal="True"/>
      <TfrxMemoView Name="Memo3" AllowVectorExport="True" Left="1.77953" Top="67.67718" Width="714.33117" Height="26.45671" Font.Charset="1" Font.Color="0" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" Frame.Typ="0" ParentFont="False" Text="ตั้งแต่วันที่ [formatdatetime('dd/mm/YYYY',date1.date)] ถึงวันที่  [formatdatetime('dd/mm/YYYY',date2.date)] "/>
      <TfrxMemoView Name="Memo4" AllowVectorExport="True" Left="177.63791" Top="115.47248" Width="79.37013" Height="26.45671" Font.Charset="1" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" Frame.Typ="0" HAlign="haCenter" ParentFont="False" Text="กลุ่มยา"/>
      <TfrxMemoView Name="Memo7" AllowVectorExport="True" Left="478.57514" Top="99.5906" Width="147.40167" Height="26.45671" Font.Charset="1" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" Frame.Typ="0" HAlign="haCenter" ParentFont="False" Text="มูลค่าการจ่ายยา (บาท)"/>
      <TfrxMemoView Name="Memo11" AllowVectorExport="True" Left="450.55937" Top="127.48825" Width="34.01577" Height="26.45671" Font.Charset="1" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" Frame.Typ="0" HAlign="haCenter" ParentFont="False" Text="ED"/>
      <TfrxMemoView Name="Memo12" AllowVectorExport="True" Left="548.04762" Top="127.48825" Width="34.01577" Height="26.45671" Font.Charset="1" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" Frame.Typ="0" HAlign="haCenter" ParentFont="False" Text="NED"/>
      <TfrxMemoView Name="Memo13" AllowVectorExport="True" Left="644.87446" Top="127.48825" Width="34.01577" Height="26.45671" Font.Charset="1" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" Frame.Typ="0" HAlign="haCenter" ParentFont="False" Text="รวม"/>
      <TfrxLineView Name="Line7" AllowVectorExport="True" Left="427.32313" Top="128.82684" Width="291.02381" Height="0" Color="0" Frame.Color="12632256" Frame.Typ="0" Diagonal="True"/>
      <TfrxLineView Name="Line2" AllowVectorExport="True" Left="0" Top="155.72449" Width="718.1107" Height="0" Color="0" Frame.Color="12632256" Frame.Typ="0" Diagonal="True"/>
    </TfrxPageHeader>
    <TfrxReportSummary Name="ReportSummary1" FillType="ftBrush" FillGap.Top="0" FillGap.Left="0" FillGap.Bottom="0" FillGap.Right="0" Frame.Typ="0" Height="49.13389" Left="0" Top="248" Width="718.1107">
      <TfrxLineView Name="Line4" AllowVectorExport="True" Left="2.77953" Top="6.77953000000002" Width="714.33117" Height="0" Color="0" Frame.Color="12632256" Frame.Typ="0" Diagonal="True"/>
      <TfrxMemoView Name="Memo22" AllowVectorExport="True" Left="63.5906" Top="9.55905999999999" Width="60.47248" Height="26.45671" Font.Charset="1" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" Frame.Typ="0" HAlign="haCenter" ParentFont="False" Text="รวม"/>
      <TfrxLineView Name="Line5" AllowVectorExport="True" Left="2.77953" Top="41.57483" Width="714.33117" Height="0" Color="0" Frame.Color="12632256" Frame.Typ="0" Diagonal="True"/>
      <TfrxMemoView Name="Memo33" AllowVectorExport="True" Left="395.10266" Top="9.55905999999999" Width="105.82684" Height="26.45671" DisplayFormat.FormatStr="%2.2n" DisplayFormat.Kind="fkNumeric" Font.Charset="1" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" Frame.Typ="0" HAlign="haRight" ParentFont="False" Text="[SUM(&#60;rp.&#34;XED_AMT&#34;&#62;,MasterData1)]"/>
      <TfrxMemoView Name="Memo34" AllowVectorExport="True" Left="501.70903" Top="9.55905999999999" Width="105.82684" Height="26.45671" DisplayFormat.FormatStr="%2.2n" DisplayFormat.Kind="fkNumeric" Font.Charset="1" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" Frame.Typ="0" HAlign="haRight" ParentFont="False" Text="[SUM(&#60;rp.&#34;XNED_AMT&#34;&#62;,MasterData1)]"/>
      <TfrxMemoView Name="Memo35" AllowVectorExport="True" Left="606.75634" Top="8.55905999999999" Width="102.04731" Height="26.45671" DisplayFormat.FormatStr="%2.2n" DisplayFormat.Kind="fkNumeric" Font.Charset="1" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" Frame.Typ="0" HAlign="haRight" ParentFont="False" Text="[SUM(&#60;rp.&#34;XNED_AMT&#34;&#62;+&#60;rp.&#34;XED_AMT&#34;&#62;,MasterData1)]"/>
    </TfrxReportSummary>
  </TfrxReportPage>
  <TfrxDialogPage Name="DialogPage1" Font.Charset="1" Font.Color="-16777208" Font.Height="-12" Font.Name="Arial" Font.Style="0" HGuides.Text="" VGuides.Text="" Caption="มูลค่าการจ่ายเวชภัณฑ์จำแนกตามกลุ่มยา" DoubleBuffered="False" Height="288" ClientHeight="256" Left="371" Top="208" Width="521" Scaled="True" ClientWidth="515" OnActivate="DialogPage1OnActivate">
    <TfrxDateEditControl Name="date1" Left="168" Top="65" Width="97" Height="25" ShowHint="True" Color="-16777211" Date="41559" Time="0.697135868096666" WeekNumbers="False"/>
    <TfrxDateEditControl Name="date2" Left="336" Top="65" Width="101" Height="25" ShowHint="True" Color="-16777211" Date="41559" Time="0.697135868096666" WeekNumbers="False"/>
    <TfrxBitBtnControl Name="" Left="216" Top="187" Width="87" Height="33" Font.Charset="0" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" ParentFont="False" ShowHint="True" Glyph.PropData="04446174610AE2010000DE010000424DDE01000000000000760000002800000024000000120000000100040000000000680100000000000000000000100000000000000000000000000080000080000000808000800000008000800080800000C0C0C000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF003333333333333333333333333333333333330000333333333333333333333333F3333333333300003333344333333333333333388F3333333333000033334224333333333333338338F3333333330000333422224333333333333833338F3333333300003342222224333333333383333338F3333333000034222A22224333333338F338F3338F33333300003222A3A2224333333338F3838F338F33333300003A2A333A222433333338F83338F338F33333000033A33333A222433333338333338F338F33330000333333333A222433333333333338F338F33300003333333333A222433333333333338F338F33000033333333333A222433333333333338F338F30000333333333333A222433333333333338F338F00003333333333333A224333333333333338F38F000033333333333333A223333333333333338F830000333333333333333A3333333333333333383300003333333333333333333333333333333333330000" Kind="bkOK" Caption="OK" ModalResult="1" NumGlyphs="2"/>
    <TfrxLabelControl Name="Label1" Left="28" Top="63" Width="125" Height="29" Font.Charset="0" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" ParentFont="False" ShowHint="True" Caption="วันที่รับของ ตั้งแต่วันที่" Color="16768462"/>
    <TfrxLabelControl Name="Label2" Left="284" Top="63" Width="41" Height="29" Font.Charset="0" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" ParentFont="False" ShowHint="True" Caption="ถึงวันที่" Color="16768462"/>
    <TfrxDBLookupComboBox Name="cbb_stock" Left="164" Top="115" Width="305" Height="37" Font.Charset="0" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" ParentFont="False" ShowHint="True" DataSet="qry_stock" DataSetName="stock" ListField="DEPT_NAME" KeyField="DEPT_ID" DropDownWidth="0" DropDownRows="7"/>
    <TfrxLabelControl Name="Label3" Left="72" Top="117" Width="79" Height="29" Font.Charset="0" Font.Color="-16777208" Font.Height="-21" Font.Name="AngsanaUPC" Font.Style="0" ParentFont="False" ShowHint="True" Caption="เลือกคลังใหญ่" Color="16768462"/>
  </TfrxDialogPage>
</TfrxReport>
