CON003_1_1.php 1.54 KB
<?php 
//*****************************************************************************
//* 
//* プログラム名:部門情報DB設定処理
//* プログラムID:CON003_1_1
//* 機能        :部門情報をDB設定する
//* 作成者      :
//* 
//*****************************************************************************
header("Content-type: text/html; charset=EUC-JP");

//***************************
//* インクルードファイル
//***************************
include("./include/session_start.inc");			//セッション開始
include("./include/SessionChk.inc");				//セッションチェック
include("./include/dbcon.inc");							//DB接続

//新規登録
if ($_POST["syozoku_cd"] == "") {
	$strSql = "SELECT MAX(syozoku_cd) as a FROM mst_bumon";
	$rsResult = pg_exec($pg_con,$strSql);
	$intSyozokuNextValue = pg_result($rsResult,0,"a") + 1;
	if($intSyozokuNextValue == 99){
		//99はMYグループのためスキップ
		$intSyozokuNextValue = $intSyozokuNextValue + 1;
	}

	$strSql = "SELECT MAX(disp_rank) as b FROM mst_bumon Where del_flg=0 ";
	$rsResult = pg_exec($pg_con,$strSql);
	$intRankNextValue = pg_result($rsResult,0,"b") + 1;

	$strSql = "INSERT INTO mst_bumon (syozoku_cd, bumon_name, disp_rank, del_flg) VALUES(";
	$strSql = $strSql . "'$intSyozokuNextValue','".addslashes($_POST["bumon_name"])."',$intRankNextValue,0)";

	$rsResult = pg_exec($pg_con,$strSql);

//修正
}else{
	$strSql = "UPDATE mst_bumon SET ";
	$strSql .= "bumon_name='".addslashes($_POST["bumon_name"])."' ";
	$strSql .= "WHERE syozoku_cd =".$_POST["syozoku_cd"] ;
	$rsResult = pg_exec($pg_con,$strSql);
}

header("Location: CON003.php");
?>