You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
6.2 KiB

<?php
header('Content-Type: text/html; charset=utf-8');
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>课程管理</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
<style type="text/css">
body {
background-color: #FFF;
}
</style>
</head>
<style type="text/css">
#d3{background:url(images/%E8%93%9D%E8%89%B2%E8%B0%83.png); background-repeat:no-repeat; background-size:cover;}
</style>
<body>
<?php
include "fun.php";
@$KCM=$_POST['kcm'];
@$XS=$_POST['xs'];
@$XF=$_POST['xf'];
@$XKCM=$_POST['xkcm'];
$kc_sql = "select * from kc where kcm ='$KCM'";
$result = $db->query(iconv('UTF-8', 'UTF-8', $kc_sql));
//单击【更新】按钮
if(@$_POST["a"] == '更新')
{
if(!empty($KCM)and(!empty($XKCM)or!empty($XF)or!empty($XS)))
{
if($result->rowCount() != 0)
{
if(!empty($XS))$update_sql = "update kc set xs='$XS' where kcm ='$KCM'";
if(!empty($XF))$update_sql = "update kc set xf='$XF' where kcm ='$KCM'";
if(!empty($XKCM))$update_sql = "update kc set kcm='$XKCM' where kcm ='$KCM'";
if(!empty($XS)and!empty($XF))$update_sql = "update kc set xs='$XS',xf='$XF' where kcm ='$KCM'";
if(!empty($XS)and!empty($XKCM))$update_sql = "update kc set xs='$XS',kcm='$XKCM' where kcm ='$KCM'";
if(!empty($XKCM)and!empty($XF))$update_sql = "update kc set kcm='$XKCM',xf='$XF' where kcm ='$KCM'";
if(!empty($XKCM)and!empty($XF)and!empty($XS))$update_sql = "update kc set kcm='$XKCM',xs='$XS',xf='$XF' where kcm ='$KCM'";
$update_result = $db->query(iconv('UTF-8', 'UTF-8', $update_sql));
if($update_result->rowCount() != 0)
{
if(!empty($XF)){$s2="call update_xs()";$s3=$db->query(iconv('UTF-8', 'UTF-8', $s2));}
if(!empty($XKCM)){$s2="call update_cj('$KCM','$XKCM')";$s3=$db->query(iconv('UTF-8', 'UTF-8', $s2));}
echo "<script>alert('更新成功!');location.href='courseManage.php';</script>";
}
else
echo "<script>alert('更新失败,请确保有此课程!');location.href='courseManage.php';</script>";
}
else
echo "<script>alert('更新失败,请确保有此课程!');location.href='courseManage.php';</script>";//存在才可以更新
}
else
echo"<script>alert('请输入需要更改的信息!');location.href='courseManage.php';</script>";
}
//单击【录入】按钮
if(@$_POST["a"] == '录入')
{
if(!empty($KCM)and!empty($XS)and!empty($XF)){
if($result->rowCount() != 0)
echo "<script>alert('该记录已经存在!');location.href='courseManage.php';</script>";
else{
$insert_sql = "insert into kc values('$KCM', '$XS', '$XF')";
$insert_result = $db->query(iconv('UTF-8', 'UTF-8', $insert_sql));
if($insert_result->rowCount() != 0)
echo "<script>alert('添加成功!');location.href='courseManage.php';</script>";
else
echo "<script>alert('添加失败!');location.href='courseManage.php';</script>";
}}
else echo"<script>alert('请输入完整信息');location.href='courseManage.php';</script>";
}
//单击【删除】按钮
if(@$_POST["a"] == '删除')
{
if(!empty($KCM))
{
if($result->rowCount() != 0)
{
$delete_sql = "delete from kc,xmcj_view where kcm ='$KCM'";
$del_affected = $db->exec(iconv('UTF-8', 'UTF-8', $delete_sql));
$s2="call delete_cj1('$KCM')";
$s3=$db->query(iconv('UTF-8', 'UTF-8', $s2));
$s2="call update_xs()";
$s3=$db->query(iconv('UTF-8', 'UTF-8', $s2));
if($del_affected)
echo "<script>alert('删除成功!');location.href='courseManage.php';</script>";
else
echo "<script>alert('删除失败,请检查操作权限!');location.href='courseManage.php';</script>";
}
else
echo "<script>alert('该记录不存在!');location.href='courseManage.php';</script>";
}
else
echo "<script>alert('请输入信息!');location.href='courseManage.php';</script>";
}
?>
<div>
<form method="post">
<table width="543" align="center">
<tr><br>
<td width="151" height="30" style="font-size: 14px">课程名:</td>
<td width="378"><input type="text" name="kcm" style="font-size: 16px"/></td>
</tr>
<tr>
<td width="151" height="30" style="font-size: 14px">学时:</td>
<td><input type="text" name="xs" style="font-size: 16px"/></td>
</tr>
<tr>
<td width="151" height="31" style="font-size: 14px">学分:</td>
<td><input type="text" name="xf" style="font-size: 16px"/></td>
</tr>
<tr>
<td></td>
<td><input id="d3" name="a" type="submit" value="录入" style="width: 72px; height: 20px; font-size: 14px; background: #CCC">
&nbsp;&nbsp;&nbsp;
<input id="d3" name="a" type="submit" value="删除" style="width: 72px; height: 20px; font-size: 14px; background: #CCC">
&nbsp;&nbsp;&nbsp;
<input id="d3" name="a" type="submit" value="更新" style="width: 72px; height: 20px; font-size: 14px; background: #CCC">
&nbsp;&nbsp;&nbsp;
<input id="d3" name="a" type="submit" value="查询" style="width: 72px; height: 20px; font-size: 14px; background: #CCC"></td>
</tr>
<tr></tr>
</table>
<br><br>
<?php
if(@$_POST["a"] == '查询')
{
$kc_sql = "select * from kc order by xf desc";
if(!empty($KCM))
$kc_sql = "select * from kc where kcm ='$KCM'";
$result = $db->query(iconv('UTF-8', 'UTF-8', $kc_sql));
if($result->rowCount() == 0 and !empty($KCM))
echo "<script>alert('该课程不存在!');location.href='courseManage.php';</script>";
else if($result->rowCount()!= 0)
{
echo"<table border=1 width=200px height=30px style=font-size:25px align=center>
<tr bgcolor=#CCC>
<td align=center>课程名</td>
<td align=center>学时</td>
<td align=center>学分</td>
</tr>";
while (list ($KCM,$XS,$XF) = $result->fetch(PDO::FETCH_NUM))
echo "<tr><td align=center>$KCM</td><td align=center>$XS</td><td align=center>$XF</td></tr>";
}
else echo"<script>alert('暂无任何课程!');location.href='courseManage.php';</script></table>";
}
?>
</form>
</body>
</html>