<!-- #include virtual="/sj4web/include.asp" -->

<%
'<!--
'################################################
'	名称	:損益計算書(報告書形式)の照会
'	作成日:2002/10/31
'	作成者:川崎
'	目的 :損益計算書(報告書形式)の照会画面を表示する。
'	概要	:
'	 <<表示>>
'	・貸借対照表(報告書形式)の照会
'	 <<処理>>
'		1.書式データ取得
'		2.金額データ取得
'		3.当期利益の算出
'		4.画面出力
'################################################
'-->
'
'
%>

<%
	Dim WK_Zandaka_KanjyoCD()
	Dim WK_Zandaka_KanjyoName()
	Dim WK_Zandaka_KariKingaku()
	Dim WK_Zandaka_KashiKingaku()
	Dim WK_Zandaka_KanjyoKubun()
	Dim WK_Zandaka_TaisyakuKubun()
	Dim WK_Zandaka_SyukeiCD()
	Dim ShowCount
	Dim MaxCount

main()
Sub main()
	If Not(SessionCheck()) Then
		Exit Sub
	End If

	Dim tmp
	Dim Kaishibi
	Dim Syuryobi
	Dim TanaorosiFlg, HiNikubun, HiNikubunFlg
	Dim TanaorosiKubun
	Dim PageType
	PageType = "損益計算書(報告書形式)"

	Dim bExistSyuseiKinyu
	bExistSyuseiKinyu = 0
	Query = "exec SPK伝票集計取得 '" & GB_SystemCD & "','" & EnshuCD & "', '" & KaisyaCD & "', '', -1, -1, 9"
	Set Content = OpenQuery(Query)
	If Not(Content.BOF Or Content.EOF) Then
		bExistSyuseiKinyu = 1
	End If

	Kaishibi = Request("Kaishibi")
	Syuryobi = Request("Syuryobi")
	TanaorosiKubun = Request("TanaorosiKubun")
	HiNikubun = Request("HiNikubun")
	If Kaishibi = "" Then
		Kaishibi = GB_KaikeiKaishibi
	End If
	IF Syuryobi = "" Then
		Syuryobi = GB_KaikeiSyuryobi
	End If

	If HiNikubun = "1" Then	'チェックあり
		HiNikubunFlg = "checked"
	Else
		HiNikubunFlg = ""
	End If

	Dim RouteType
	RouteType = Request("RouteType")



	Dim KanjyoCDShiire, KanjyoCDKurikoshiSyohin
	Dim KanjyoCDKisyuSyohinTanaoroshidaka, KanjyoCDKimatsuSyohinTanaoroshidaka
	Dim KanjyoCDKurikoshiSoneki


	Query = "exec SPM勘定科目取得特別勘定 '" & GB_SystemCD & "','" & EnshuCD & "', ''"
	Set Content = OpenQuery(Query)
	Do While Not(Content.BOF OR Content.EOF)
		If Content.Fields("特別勘定区分") = "DL" Then
			KanjyoCDShiire = Content.Fields("勘定CD")
		ElseIf Content.Fields("特別勘定区分") = "DG" Then
			KanjyoCDKisyuSyohinTanaoroshidaka = Content.Fields("勘定CD")
		ElseIf Content.Fields("特別勘定区分") = "DH" Then
			KanjyoCDKimatsuSyohinTanaoroshidaka = Content.Fields("勘定CD")
		ElseIf Content.Fields("特別勘定区分") = "DJ" Then
			KanjyoCDKurikoshiSyohin = Content.Fields("勘定CD")
		ElseIf Content.Fields("特別勘定区分") = "DY" Then
			KanjyoCDKurikoshiSoneki = Content.Fields("勘定CD")
		End If
		
		Content.MoveNext
	Loop

%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="-1">
<link href="/sj4web/binx/sj3web.css" rel="stylesheet" type="text/css">
<title><% = AppTitle %></title>
<script language="JScript" src="/sj4web/include.js"></script>
<script language="JScript" src="/sj4web/includesj.js"></script>
<script language="JScript.Encode" src="/sj4web/include_enc.js"></script>
<script language="JScript.Encode" src="/sj4web/includesj_enc.js"></script>
</head>
<SCRIPT LANGUAGE="JavaScript">
<!--
	ExitFlg = 1;
-->
</SCRIPT>


<body onkeydown="if(ExitFlg==2)ExitFlg=3;" onBeforeUnload="window.event.returnValue = ExitMsg(ExitFlg)" bgcolor="#5C70B6" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form OnKeyDown="FormKeyDown(this)" name="form1"	method="GET" action="rm_sonekikeisansyohoukoku.asp" target="_top">
<input type="hidden" name="RouteType" value="<% = RouteType %>">

<%
	If InStr(RouteType, "ViewOnly") > 0 Then
		Response.Write(HtmlDesign(4))
	Else
		Response.Write(HtmlDesign(1))
	End If

	Response.Write(HttpL1(3))

	If InStr(RouteType, "ViewOnly") > 0 Then
		Response.Write(HttpL2("照会・集計ウィンドウ" ,"tblbtn( '/sj4web/user/bk/menu_s_viewonly.asp')", "経理部", "", "自動転記帳簿", "", "損益計算書", "", "", "", "", ""))
	Else
		Response.Write(HttpL2("会社選択" ,"tblbtn( '/sj4web/user/bk/')", GB_GyosyuMeisyo, "tblbtn( '/sj4web/user/bk/menu_" & GB_Gyosyu & ".asp')", "社長室・総務部", "tblbtn( '/sj4web/user/bk/menu_s4.asp')", "財務諸表", "tblbtn( '/sj4web/user/bk/menu_s41.asp')", "損益計算書", "tblbtn( 'rm_sonekikeisansyohoukoku_main.asp')", "", ""))
	End If

	Response.Write(HttpL3("印刷", "PrintoutReal()", "", "", "", "", "", "", "", "", "", "", "", "", "", ""))

	Response.Write(HttpL3_1("印刷", "PrintoutReal()", "", "", "", "", "", "", "", ""))

	Response.Write(HttpL3_2("販売管理費一覧", "tblbtn('rm_sonekikeisansyohoukoku_hanbaikairihi.asp?RouteType=" & RouteType & "')", "", "", "", "", "", "", "", ""))

	Response.Write(HttpL4(PageType, ""))
%>

<div id="L0" style="position: absolute; visibility: hidden; left: 0px; top: -2000px;">

	<table border="0" width="100%" BORDER="0" CELLSPACING="5" CELLPADDING="0" height="100%">
		<tr>
			<td height="30" align="center">
				<TABLE WIDTH="600" HEIGHT="20" BORDER="0" CELLSPACING="5" CELLPADDING="0" BGCOLOR="#FFFFFF" STYLE="BORDER:1px solid #000000">
					<TR>
						<TD ALIGN="CENTER" BACKGROUND="/sj4web/images/window_bk.gif">
							<table height="26" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td align="right" class="tx1416">日付</td>
									<td align="left"><input type="text" name="Syuryobi" size="16" value="<% = Syuryobi %>" onBlur="SetDate(this, 1, true)" class="tbox2" style="width: 72; height: 16"></td>
									<td width="50" align="left" class="tx1416"></td>

									<td width="250" class="tx1416"><%
									If bExistSyuseiKinyu = 0 Then %>
									<input type="checkbox" value="1" name="TanaorosiKubun" <% If TanaorosiKubun = "1" Then %> checked<% End If %>>[帳簿棚卸後を表示]
									<% Else %>
									<input type="checkbox" value="1" name="HiNikubun" <% = HiNikubunFlg %>>[売上原価を仕入高に集計する]
									<% End If %>
									</td>
									<td>
										<TABLE onClick="SubmitReal(form1);" BORDER="0" CELLSPACING="0" CELLPADDING="0" HEIGHT="30" BGCOLOR="#33CCFF" CLASS="tbtn1" WIDTH="58">
											<TR>
												<TD WIDTH="10" BACKGROUND="/sj4web/images/dlogbtn_bl.gif"> </TD>
												<TD ALIGN="CENTER" VALIGN="MIDDLE" BACKGROUND="/sj4web/images/dlogbtn_bc.gif" WIDTH="60">更新</TD>
												<TD WIDTH="10" BACKGROUND="/sj4web/images/dlogbtn_br.gif"> </TD>
											</TR>
										</TABLE>
									</td>

								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td align="center">
				<TABLE BORDER="0" CELLSPACING="5" CELLPADDING="15" BGCOLOR="#FFFFFF" STYLE="BORDER:1px solid #000000" WIDTH="660" HEIGHT="100%">
					<TR>
						<TD ALIGN="CENTER">
							<TABLE WIDTH="600" BORDER="0" CELLSPACING="0" CELLPADDING="0" HEIGHT="100%">
								<TR>
									<TD HEIGHT="25" valign="top" WIDTH="600" align="center">
										<table border="0" width="600" cellspacing="0" cellpadding="0">
											<tr>
												<td width="170"> </td>
												<td class="tx1416" align="center" style="border-bottom: 1px solid black;" nowrap><% = SetStringInsertSpace(PageType) %></td>
												<td width="170" class="tx1214" align="right"><% If HiNikubun = "1" Then Response.write("[売上原価を仕入高に集計]") End If %> </td>
											</tr>
										</table>
									</TD>
								</TR>
								<TR>
									<TD HEIGHT="20" VALIGN="BOTTOM" WIDTH="600">
										<TABLE WIDTH="600" HEIGHT="20" BORDER="1" CELLPADDING="0" CELLSPACING="0" BORDERCOLOR="#000000" BGCOLOR="#DDDDDD" CLASS="tx1416" STYLE="border-collapse: collapse">
											<TR ALIGN="CENTER">
												<TD WIDTH="240" HEIGHT="20">区分</TD>
												<TD WIDTH="241" HEIGHT="20">金額</TD>
												<TD HEIGHT="20">構成比</TD>
											</TR>
										</TABLE>
									</TD>
								</TR>

								<TR>
									<TD VALIGN="TOP">
										<DIV ID="Layer1" STYLE="position:relative; left:0px; top:-1px; width:620px; height:100%; z-index:1; border: 1px none #000000; overflow: auto;"> 
											<TABLE ID="SyoukaiList" WIDTH="600" BORDER="1" CELLSPACING="0" CELLPADDING="0" BORDERCOLOR="#000000" BGCOLOR="#FFFFFF" CLASS="tx1214" STYLE="border-collapse: collapse">
												<tr>
													<td VALIGN="TOP" width="100%">

														<%
															Dim Query
															Dim Content

															Dim DC,ww
															Dim TBLAC(2, 100)
															Dim TBLKIN(2, 100)
															Dim TBLNAME(2, 100)
															Dim TBLSUMCD(2, 100)
															Dim TBLSUMPM(2, 100)
															Dim TBLDCKubun(2, 100)
															Dim TBLKOSEI(2, 100)
															Dim TBLDSPLR(2, 100)
															Dim TBLDSPUL(2, 100)
															Dim TBLTKIN(2)

															Dim ii, jj, kk
															ii = 0
														'###########################################1.書式データ取得
															Query = "exec SPM報告書書式一覧 '" & GB_SystemCD & "','" & EnshuCD & "','P'"

															Set Content = OpenQuery(Query)

															Do While Not(Content.BOF Or Content.EOF)
																Dim SyukeiCD
																SyukeiCD = Content.Fields("集計CD")

																If bExistSyuseiKinyu = 0 Or (bExistSyuseiKinyu = 1 And (HiNikubun <> "1" Or (SyukeiCD <> "P201" And SyukeiCD <> "P203" And SyukeiCD <> "P204" And SyukeiCD <> "P205"))) Then
																	If IsNumeric(Content.Fields("ラインコントロール")) Then
																		ii = ii + Int(Content.Fields("ラインコントロール"))
																	Else
																		ii = ii + 1
																	End If
																	ww = ii
																	DC = 1

																	TBLAC(DC, ww) = SyukeiCD
																	TBLNAME(DC, ww) = Content.Fields("集計名称")
																	TBLSUMCD(DC, ww) = Content.Fields("集計先")
																	TBLSUMPM(DC, ww) = Content.Fields("加減区分")
																	TBLDCKubun(DC, ww) = Content.Fields("貸借")
																	TBLKOSEI(DC, ww) = Content.Fields("構成表示")
																	TBLDSPLR(DC, ww) = Content.Fields("右方表示")
																	TBLDSPUL(DC, ww) = Content.Fields("アンダーライン")
																	If bExistSyuseiKinyu = 1 And HiNikubun = "1" Then
																		If SyukeiCD = "P202" Then
																			TBLNAME(DC, ww) = Replace(TBLNAME(DC, ww), "2.", "")
																			TBLSUMCD(DC, ww) = "P295"
																			TBLSUMPM(DC, ww) = "-"
																		End If
																		If SyukeiCD = "P200" Then
																			TBLDSPUL(DC, ww) = ""
																		End If
																	End If

																	If InStr(TBLNAME(DC, ww), "小計") > 0 Then
																		TBLNAME(DC, ww) = Replace(TBLNAME(DC, ww), "  ", " ")
																	End If
																End If
																Content.MoveNext
															Loop

															Dim HokokusyoLines,yy

															HokokusyoLines = ii
															yy = jj

															Dim RowCount, RowBreakNum

															ii = 0
															jj = 0

															RowCount = 0

														'###########################################2.金額データ取得
															Query = "exec SPK自動転記帳簿_財務諸表 '" & GB_SystemCD & "','" & EnshuCD & "', '" & KaisyaCD & "','" & Kaishibi & "','" & Syuryobi & "','P', 1, 9"
'															Query = "exec SPL合併財務諸表 '" & GB_EnshuCD & "', '" & GB_KaisyaCD & "','" & GB_GakuseiNo & "','P'"

															Set Content = OpenQuery(Query)
															Dim RecordCount
															RecordCount = 0
															Do While Not(Content.BOF Or Content.EOF)
																RecordCount = RecordCount + 1
																Content.MoveNext
															Loop
															ShowCount = RecordCount
															MaxCount = RecordCount + 5
															RowBreakNum = MaxCount

															ReDim WK_Zandaka_KanjyoCD(MaxCount)
															ReDim WK_Zandaka_KanjyoName(MaxCount)
															ReDim WK_Zandaka_KariKingaku(MaxCount)
															ReDim WK_Zandaka_KashiKingaku(MaxCount)
															ReDim WK_Zandaka_KanjyoKubun(MaxCount)
															ReDim WK_Zandaka_TaisyakuKubun(MaxCount)
															ReDim WK_Zandaka_SyukeiCD(MaxCount)


															Set Content = OpenQuery(Query)
															'//////////////////////////////// ワーク「残高F」を作成
															Do While Not(Content.BOF Or Content.EOF)
																ii = ii + 1
																WK_Zandaka_KanjyoCD(ii) = Content.Fields("勘定CD")
																WK_Zandaka_KanjyoName(ii) = Content.Fields("勘定名称")
																WK_Zandaka_KanjyoKubun(ii) = Content.Fields("勘定区分")
																WK_Zandaka_TaisyakuKubun(ii) = Content.Fields("貸借区分")
																WK_Zandaka_SyukeiCD(ii) = Content.Fields("諸表集計CD")


																WK_Zandaka_KariKingaku(ii) = Content.Fields("借方金額")
																WK_Zandaka_KashiKingaku(ii) = Content.Fields("貸方金額")
'																Select Case KaisyaKbn
'																	Case "0"
'																		WK_Zandaka_KariKingaku(ii) = Content.Fields("本社借方")
'																		WK_Zandaka_KashiKingaku(ii) = Content.Fields("本社貸方")
'																	Case "1"
'																		WK_Zandaka_KariKingaku(ii) = Content.Fields("支店借方")
'																		WK_Zandaka_KashiKingaku(ii) = Content.Fields("支店貸方")
'																	Case Else
'																		WK_Zandaka_KariKingaku(ii) = Content.Fields("本社借方") + Content.Fields("支店借方")
'																		WK_Zandaka_KashiKingaku(ii) = Content.Fields("本社貸方") + Content.Fields("支店貸方")
'																End Select

																If Content.Fields("勘定CD") = KanjyoCDKurikoshiSoneki Then
																	WK_Zandaka_SyukeiCD(ii) = "P910"
																End If
																Content.MoveNext
															Loop


												'棚卸の調整ここから
												If (bExistSyuseiKinyu = 0 And TanaorosiKubun = "1") Or (bExistSyuseiKinyu = 1 And HiNikubun <> "1") Then	

													'在庫数をチェックする。
													Dim KimatsuSyohinTanaoroshidaka, KisyuSyohinTanaoroshidaka
													KisyuSyohinTanaoroshidaka = KisyuTanaoroshiKingaku(Syuryobi)
													KimatsuSyohinTanaoroshidaka = KimatsuTanaoroshiKingaku(Syuryobi)


													Dim KurikosiFLG, InsertNo
													Dim i ,j

'													For jj = 1 To RecordCount
'														Response.Write(jj & "-" & WK_Zandaka_KanjyoCD(jj) & "<br>")
'													Next

													'繰越商品を削除ここから
													For jj = 1 To RecordCount
														If WK_Zandaka_KanjyoCD(jj) = KanjyoCDKurikoshiSyohin Then
															For ii = jj To RecordCount - 1
																WK_Zandaka_KanjyoCD(ii) = WK_Zandaka_KanjyoCD(ii + 1)
																WK_Zandaka_KanjyoName(ii) = WK_Zandaka_KanjyoName(ii + 1)
																WK_Zandaka_KariKingaku(ii) = WK_Zandaka_KariKingaku(ii + 1)
																WK_Zandaka_KashiKingaku(ii) = WK_Zandaka_KashiKingaku(ii + 1)
																WK_Zandaka_TaisyakuKubun(ii) = WK_Zandaka_TaisyakuKubun(ii + 1)
																WK_Zandaka_SyukeiCD(ii) = WK_Zandaka_SyukeiCD(ii + 1)
															Next
															WK_Zandaka_KanjyoCD(ii) = ""
															WK_Zandaka_KanjyoName(ii) = ""
															WK_Zandaka_KariKingaku(ii) = null
															WK_Zandaka_KashiKingaku(ii) = null
															WK_Zandaka_TaisyakuKubun(ii) = ""
															WK_Zandaka_SyukeiCD(ii) = ""
															ShowCount = ShowCount - 1
															Exit For
														End If
													Next
													'繰越商品を削除ここまで


													'期首商品棚卸高ここから
														tmp = ReplaceKanjyo(KanjyoCDKisyuSyohinTanaoroshidaka, KisyuSyohinTanaoroshidaka, 0)

														Query = "exec SPK伝票集計取得 '" & GB_SystemCD & "','" & EnshuCD & "', '" & KaisyaCD & "', '" & KanjyoCDKisyuSyohinTanaoroshidaka & "', 0, 1, 9"
														Set Content = OpenQuery(Query)
														If Not(Content.BOF Or Content.EOF) Then
															tmp = ReplaceKanjyo(KanjyoCDKisyuSyohinTanaoroshidaka, Content.Fields("借方金額"), Content.Fields("貸方金額"))
														End If
													'期首商品棚卸高ここまで



													'期末商品棚卸高ここから
														tmp = ReplaceKanjyo(KanjyoCDKimatsuSyohinTanaoroshidaka, 0, KimatsuSyohinTanaoroshidaka)

														Query = "exec SPK伝票集計取得 '" & GB_SystemCD & "','" & EnshuCD & "', '" & KaisyaCD & "', '" & KanjyoCDKimatsuSyohinTanaoroshidaka & "', 0, 1, 9"
														Set Content = OpenQuery(Query)
														If Not(Content.BOF Or Content.EOF) Then
															tmp = ReplaceKanjyo(KanjyoCDKimatsuSyohinTanaoroshidaka, Content.Fields("借方金額"), Content.Fields("貸方金額"))
														End If
													'期末商品棚卸高ここまで

														If bExistSyuseiKinyu = 1 Then
															tmp = ReplaceKanjyo(KanjyoCDShiire, KityuShiireKingaku(Syuryobi), 0)
														End If

'													チェック用
'													For jj = 1 To RecordCount + 2
'														Response.Write(WK_Zandaka_KanjyoCD(jj) & "-")
'														Response.Write(WK_Zandaka_KanjyoName(jj) & "-")
'														Response.Write(WK_Zandaka_KariKingaku(jj) & "-")
'														Response.Write(WK_Zandaka_KashiKingaku(jj) & "-")
'														Response.Write(WK_Zandaka_TaisyakuKubun(jj) & "-")
'														Response.Write(WK_Zandaka_SyukeiCD(jj) & "-")
'														Response.Write("<br>")
'													Next

												End If


															ReDim DSP_KarikataKingakuTotal(RecordCount),DSP_KashikataKingakuTotal(RecordCount)
															Dim DSP_SisanFusaiKingakuTotal,DSP_SisanKingakuTotal

															'/////////////////////////////////ワーク「残高F」から書式の科目毎に振り分ける
															ii = 0
															Dim WK_KIN,WK_AC,WK_DC,WK_PM,W_NOTF,Sww,Sxx_SET,Sxx
															For ii = 1 To MaxCount

																DC = 1
																If WK_Zandaka_TaisyakuKubun(ii) = "D" Then
																	WK_KIN = WK_Zandaka_KariKingaku(ii) - WK_Zandaka_KashiKingaku(ii)
																Else
																	WK_KIN = WK_Zandaka_KashiKingaku(ii) - WK_Zandaka_KariKingaku(ii)
																End If


																WK_PM = "+"
																W_NOTF = True

																If WK_KIN <> 0 Then
																	WK_AC = WK_Zandaka_SyukeiCD(ii)
																	WK_DC = WK_Zandaka_TaisyakuKubun(ii)

																	If TBLTKIN(DC)<>0 Then
																		TBLTKIN(DC) = ConvMoneyToInt(TBLTKIN(DC)) + ConvMoneyToInt(WK_KIN)
																	Else
																		TBLTKIN(DC) = ConvMoneyToInt(WK_KIN)
																	End If


																	For jj = 1 To HokokusyoLines

																		If (TBLAC(DC, jj) = WK_AC) Then

																			If (WK_DC <> TBLDCKubun(DC, jj)) Then
																				WK_KIN = WK_KIN * -1
																			End If

																			If (WK_PM <> "+") Then
																				WK_KIN = WK_KIN * -1
																			End If

																			TBLKIN(DC, jj) = TBLKIN(DC, jj) + WK_KIN

																			WK_AC = TBLSUMCD(DC, jj)
																			WK_PM = TBLSUMPM(DC, jj)
																			W_NOTF = False
																			ww = jj


																			Exit For
																		End If
																	Next
																End If
															Next

															For jj = 1 To HokokusyoLines
																If TBLKIN(DC, jj) <> "" Then
																	For kk = jj + 1 To HokokusyoLines
																		If TBLAC(DC, kk) = TBLSUMCD(DC, jj) Then
																			If TBLSUMPM(DC, jj) <> "-" Then
																				TBLKIN(DC, kk) = TBLKIN(DC, kk) + TBLKIN(DC, jj)
																			Else
																				TBLKIN(DC, kk) = TBLKIN(DC, kk) - TBLKIN(DC, jj)
																			End If

																		End If
																	Next
																End If
															Next

														'###########################################3.当期利益の算出


														'###########################################4.画面出力
															ii = 0
															'/////////////////////// 資産の列(左)
															Response.Write("<table width=""100%"" border=""0"" CELLSPACING=""0"" CELLPADDING=""0"" CLASS=""tx1214"">")
															For ii = 1 To HokokusyoLines

																Response.Write("<tr>" & vbCrLf)

																'名称
																Response.Write("<td nowrap width=""240""")
																If TBLDSPUL(1, ii) = "1" Then
																	Response.Write(" style=""border-bottom: solid 1 #000000;""")
																Else
																	Response.Write(" style=""border-bottom: solid 1 #FFFFFF;""")
																End If
																Response.Write(" style=""border-right: solid 1 #000000;"">" & TBLNAME(1,ii))
																Response.Write("<br></td>" & vbCrLf)

																'金額
																If TBLDSPLR(1,ii) = "R" Then
																	Response.Write("<td width=""120"" align=""right""")
																	If TBLDSPUL(1, ii) = "1" Then
																		Response.Write(" style=""border-bottom: solid 1 #000000;""")
																	End If
																	Response.Write(" style=""border-right: solid 1 #000000;"">")
																	Response.Write("<br></td>" & vbCrLf)

																	Response.Write("<td width=""120"" align=""right""")
																	If TBLDSPUL(1, ii) = "1" Then
																		Response.Write(" style=""border-bottom: solid 1 #000000;""")
																	End If
																	Response.Write(" style=""border-right: solid 1 #000000;"">" & ConvIntToMoney(TBLKIN(1,ii), false, true))
																	Response.Write("<br></td>" & vbCrLf)
																Else
																	Response.Write("<td width=""120"" align=""right""")
																	If TBLDSPUL(1, ii) = "1" Then
																		Response.Write(" style=""border-bottom: solid 1 #000000;""")
																	End If
																	Response.Write(" style=""border-right: solid 1 #000000;"">" & ConvIntToMoney(TBLKIN(1,ii), false, true))
																	Response.Write("<br></td>" & vbCrLf)

																	Response.Write("<td width=""120"" align=""right""")
																	If TBLDSPUL(1, ii) = "1" Then
																		Response.Write(" style=""border-bottom: solid 1 #000000;""")
																	End If
																	Response.Write(" style=""border-right: solid 1 #000000;"">")
																	Response.Write("<br></td>" & vbCrLf)
																End If

																'構成比
																Response.Write("<td align=""right""")
																If TBLDSPUL(1, ii) = "1" Then
																	Response.Write(" style=""border-bottom: solid 1 #000000;""")
																End If
																Response.Write("><img src=""/sj4web/images/spacer.gif"" width=""1"" height=""1"">")

																If TBLKOSEI(1,ii) = "1" and TBLKIN(1,ii) <> 0 and TBLKIN(1,ii) <> "" and TBLKIN(1,1) <> "" Then
																	Response.Write(" " & Int(TBLKIN(1,ii) * 1000 / TBLKIN(1, 1)) / 10 & "%")
																End If

																Response.Write("<br></td>" & vbCrLf)

																Response.Write("</tr>" & vbCrLf)
															Next

															Response.Write("</table>" & vbCrLf)
															'/////////////////////// 負債及び資本の列(右)

														%>
													</td>
												</tr>
											</TABLE>
										</DIV>
									</TD>
								</TR>
							</TABLE>
						</TD>
					</TR>
				</TABLE>
			</td>
		</tr>
	</table>
</div>
</form>

</body>
<% = HtmlFooter %>
</html>
<%
End Sub

Function ReplaceKanjyo(F_KanjyoCD, F_KarikataKingaku, F_KashikataKingaku)
	If IsNull(F_KarikataKingaku) Then F_KarikataKingaku = 0 End If
	If IsNull(F_KashikataKingaku) Then F_KashikataKingaku = 0 End If
	Dim InsertNo, KurikosiFLG
	Dim ii, jj
	Dim Query, Content
	InsertNo = -1
	KurikosiFLG = 0
	If F_KarikataKingaku <> 0 OR F_KashikataKingaku <> 0  Then
		For jj = 1 To MaxCount
			If WK_Zandaka_KanjyoCD(jj) = "" Then
				Exit For
			End If

			If WK_Zandaka_KanjyoCD(jj) > F_KanjyoCD Then

				If KurikosiFLG = 0 Then
					For ii = MaxCount - 1 To jj Step -1
						WK_Zandaka_KanjyoCD(ii + 1) = WK_Zandaka_KanjyoCD(ii)
						WK_Zandaka_KanjyoName(ii + 1) = WK_Zandaka_KanjyoName(ii)
						WK_Zandaka_KariKingaku(ii + 1) = WK_Zandaka_KariKingaku(ii)
						WK_Zandaka_KashiKingaku(ii + 1) = WK_Zandaka_KashiKingaku(ii)
						WK_Zandaka_TaisyakuKubun(ii + 1) = WK_Zandaka_TaisyakuKubun(ii)
						WK_Zandaka_SyukeiCD(ii + 1) = WK_Zandaka_SyukeiCD(ii)
					Next
					InsertNo = jj
					KurikosiFLG = 1
					ShowCount = ShowCount + 1
					Exit For
				End If
			ElseIf WK_Zandaka_KanjyoCD(jj) = F_KanjyoCD Then
			'すでに残高に「期末商品棚卸高」がある場合
				KurikosiFLG = 1
				InsertNo = jj
			End If
		Next
		If KurikosiFLG = 0 Then
			InsertNo = jj
			ShowCount = ShowCount + 1
		End If
	End If

	If InsertNo <> -1 Then
		Query = "exec SPM勘定科目取得 '" & GB_SystemCD & "','" & EnshuCD & "', '" & F_KanjyoCD & "'"
		Set Content = OpenQuery(Query)
		If Not(Content.BOF Or Content.EOF) Then
			WK_Zandaka_TaisyakuKubun(InsertNo) = Content.Fields("貸借区分")
			WK_Zandaka_KanjyoName(InsertNo) = Content.Fields("勘定名称")
			WK_Zandaka_SyukeiCD(InsertNo) = Content.Fields("諸表集計CD")
		End If

		WK_Zandaka_KanjyoCD(InsertNo) = F_KanjyoCD

		If WK_Zandaka_TaisyakuKubun(InsertNo) = "C" Then
			WK_Zandaka_KariKingaku(InsertNo) = 0
			WK_Zandaka_KashiKingaku(InsertNo) = F_KashikataKingaku - F_KarikataKingaku
		Else
			WK_Zandaka_KariKingaku(InsertNo) = F_KarikataKingaku - F_KashikataKingaku
			WK_Zandaka_KashiKingaku(InsertNo) = 0
		End If
	End If
End Function
%>