<?php
session_start();
if($_SESSION["username"]=="")
{
echo "<script>javascript:alert('对不起,请您先登陆!');location.href='index.php';</script>";
exit;
}
include_once 'conn.php';
$ndate =date("Y-m-d");
$addnew=$_POST["addnew"];
if ($addnew=="1" )
{
$shangpinbianhao=$_POST["shangpinbianhao"];
$shangpinmingcheng=$_POST["shangpinmingcheng"];
$pinpai=$_POST["pinpai"];
$jiage=$_POST["jiage"];
$kucunshuliang=$_POST["kucunshuliang"];
$goumaishuliang=$_POST["goumaishuliang"];
$goumairen=$_POST["goumairen"];
$jine=$_POST["jine"];
//lixandonxgjixelxb
$jinej=$kucunshuliang*$goumaishuliang;
//ischongfu("select id from goumaiche where goumairen='".$goumairen."'");
$sql="insert into goumaiche(shangpinbianhao,shangpinmingcheng,pinpai,jiage,kucunshuliang,goumaishuliang,goumairen,jine) values('$shangpinbianhao','$shangpinmingcheng','$pinpai','$jiage','$kucunshuliang','$goumaishuliang','$goumairen','$jinej') ";
mysql_query($sql);
$sql="update shangpinxinxi set kucunshuliang=kucunshuliang-'".$goumaishuliang."' where shangpinbianhao='".$shangpinbianhao."'";
mysql_query($sql);
//danjuzhixi;mysql_query($sql);
echo "<script>javascript:alert('操作成功!');location.href='shangpinxinxilist.php';</script>";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD>
<TITLE>购买车</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="qtimages/style.css" type=text/css rel=stylesheet>
<META content="MSHTML 6.00.2900.6058" name=GENERATOR></HEAD>
<script type="text/javascript" src="js/My97DatePicker/WdatePicker.js" charset="gb2312"></script>
<script language="javascript">
function OpenScript(url,width,height)
{
var win = window.open(url,"SelectToSort",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
}
function OpenDialog(sURL, iWidth, iHeight)
{
var oDialog = window.open(sURL, "_EditorDialog", "width=" + iWidth.toString() + ",height=" + iHeight.toString() + ",resizable=no,left=0,top=0,scrollbars=no,status=no,titlebar=no,toolbar=no,menubar=no,location=no");
oDialog.focus();
}
function check()
{
if(document.form1.shangpinbianhao.value==""){alert("请输入商品编号");document.form1.shangpinbianhao.focus();return false;}
if(document.form1.shangpinmingcheng.value==""){alert("请输入商品名称");document.form1.shangpinmingcheng.focus();return false;}
if((/^(+|-)?(0|[1-9]d*)(.d*[1-9])?$/.test(document.form1.goumaishuliang.value))){}else{alert("购买数量必需数字型");document.form1.goumaishuliang.focus();return false;}
if(parseFloat(document.form1.kucunshuliang.value)<parseFloat(document.form1.goumaishuliang.value)){alert("对不起,库存数量必需大于购买数量");return false;}
}
function gow()
{
location.href='goumaicheadd.php?jihuabifffanhao='+document.form1.jihuabifffanhao.value+"&id=<?php echo $_GET["id"]?>";
}
</script>
<!--hxsglxiangdxongjxs-->
<BODY>
<?php include_once 'qttop.php';?>
<TABLE cellSpacing=0 cellPadding=0 width=1120 align=center bgColor=#ffffff
border=0>
<TBODY>
<TR>
<TD width=5> </TD>
<TD vAlign=top width=230>
<?php include_once 'qtleft.php';?>
</TD>
<TD vAlign=top width=10> </TD>
<TD vAlign=top>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=bottom height=40>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD width=44 height=40><IMG height=35
src="qtimages/B0039.gif"
width=30></TD>
<TD width=11> </TD>
<TD width=209><span class="red"><strong>购买车</strong></span></TD>
<TD vAlign=bottom align=right width=50></TD>
<TD vAlign=bottom align=right width=45> </TD>
<TD align=left width=291> </TD>
</TR></TBODY></TABLE></TD></TR>
<TR>
<TD bgColor=#dadada height=1></TD></TR>
<TR>
<TD bgColor=#f6f6f6 height=4></TD></TR>
<TR>
<TD bgColor=#ffffff height=6>
<?php
$sql="select * from shangpinxinxi where id=".$_GET["id"];
$query=mysql_query($sql);
$rowscount=mysql_num_rows($query);
if($rowscount>0)
{
$shangpinbianhao=mysql_result($query,0,shangpinbianhao);
$shangpinmingcheng=mysql_result($query,0,shangpinmingcheng);
$pinpai=mysql_result($query,0,pinpai);
$jiage=mysql_result($query,0,jiage);
$kucunshuliang=mysql_result($query,0,kucunshuliang);
}
?>
<form id="form1" name="form1" method="post" action="">
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bordercolor="#00FFFF" style="border-collapse:collapse" class="newsline">
<tr><td>商品编号:</td><td><input name='shangpinbianhao' type='text' id='shangpinbianhao' value='' style='border:solid 1px #000000; color:#666666' /> *</td></tr><script language="javascript">document.form1.shangpinbianhao.value='<?php echo $shangpinbianhao?>';</script>
<tr><td>商品名称:</td><td><input name='shangpinmingcheng' type='text' id='shangpinmingcheng' value='' style='border:solid 1px #000000; color:#666666' /> *</td></tr><script language="javascript">document.form1.shangpinmingcheng.value='<?php echo $shangpinmingcheng?>';</script>
<tr><td>品牌:</td><td><input name='pinpai' type='text' id='pinpai' value='' style='border:solid 1px #000000; color:#666666' /></td></tr><script language="javascript">document.form1.pinpai.value='<?php echo $pinpai?>';</script>
<tr><td>价格:</td><td><input name='jiage' type='text' id='jiage' value='' style='border:solid 1px #000000; color:#666666' /></td></tr><script language="javascript">document.form1.jiage.value='<?php echo $jiage?>';</script>
<tr><td>库存数量:</td><td><input name='kucunshuliang' type='text' id='kucunshuliang' value='' style='border:solid 1px #000000; color:#666666' /></td></tr><script language="javascript">document.form1.kucunshuliang.value='<?php echo $kucunshuliang?>';</script>
<tr><td>购买数量:</td><td><input name='goumaishuliang' type='text' id='goumaishuliang' value='' style='border:solid 1px #000000; color:#666666' /> 必需数字型</td></tr>
<tr><td>购买人:</td><td><input name='goumairen' type='text' id='goumairen' value='<?php echo $_SESSION['username'];?>' style='border:solid 1px #000000; color:#666666' readonly='readonly' /></td></tr>
<tr><td>金额:</td><td><input name='jine' type='text' id='jine' value='' style='border:solid 1px #000000; color:#666666; background-color:#CCCCCC' /> 此项不必填写,系统自动计算</td></tr>
<tr>
<td> </td>
<td><input type="hidden" name="addnew" value="1" />
<input type="submit" name="Submit" value="确定" onClick="return check();" style='border:solid 1px #000000; color:#666666' />
<input type="reset" name="Submit2" value="重置" style='border:solid 1px #000000; color:#666666' /></td>
</tr>
</table>
</form>
<p> </p>
<?php
function ischongfu($sql)
{
$query=mysql_query($sql);
$rowscount=mysql_num_rows($query);
if($rowscount>0)
{
echo "<script>javascript:alert('对不起,该购买人已经存在,请换其他购买人!');history.back();</script>";
exit;
}
}
?>
</TD>
</TR></TBODY></TABLE>
</TD>
<TD width=5> </TD></TR></TBODY></TABLE>
<?php include_once 'qtdown.php';?>
<!-- dfexnxxiaxng -->
</BODY></HTML>