sale.php
来自「一个php的公司信息系统」· PHP 代码 · 共 359 行 · 第 1/2 页
PHP
359 行
<br><br><br><a href=sale.php?step=0>返回重填</a> <a href=index2.php>返回首页</a></div>";
}
else
{
$str_sql="select STORAGETB.pid as pid,PRODUCTTB.pname as pname from PRODUCTTB,STORAGETB
where STORAGETB.stid='$usern' and STORAGETB.pid=PRODUCTTB.pid;";
echo $str_sql;
?>
<table width="45%" border="0" cellspacing="0" cellpadding="0" align="right">
<tr>
<td height="199">
<form name="form1" method="post" action="sale.php?step=2">
<p><b><font face=Arial>Step 2 </font>- 填写销售单内容</b></p>
<br>
<table width="100%" border="0" cellspacing="3" cellpadding="0">
<tr>
<td>产 品 名
<select name="pid">
<?
$str_sql="select STORAGETB.pid as pid,PRODUCTTB.pname as pname from PRODUCTTB,STORAGETB
where STORAGETB.stid='$usern' and STORAGETB.pid=PRODUCTTB.pid;";
$result=mysql_db_query($db,$str_sql,$link_id);
if (!$result) html_error_exit('MySQL查询命令失败!');
else
{
$html='';
while ($record=mysql_fetch_object($result))
$html.='<option value="'.$record->pid.'">'.$record->pid.' - '.$record->pname.'</option>';
echo $html;
}
?>
</select>
</td>
</tr>
<tr>
<td>销 售 量
<input type="text" name="samount" maxlength="11">
</td>
</tr>
<tr>
<td>销售方式
<input type="radio" name="method" value="1" checked>
批发
<input type="radio" name="method" value="2">
零售</td>
</tr>
</table>
<?
if ($new==1)
$sadate=$y1.'-'.$m1.'-'.$d1;
$html=' <input type="hidden" name="said" value="'.$said.'">
<input type="hidden" name="sadate" value="'.$sadate.'">
<input type="hidden" name="mtp" value="'.$mtp.'">
<input type="hidden" name="memo" value="'.$memo.'">';
if ($new>=1)
$html.='<input type="hidden" name="new" value="1">';
else
$html.='<input type="hidden" name="new" value="0">';
echo $html;
?> <p>
<input type="submit" name="Submit" value="下一步" onClick="MM_validateForm('samount','','RisNum');return document.MM_returnValue">
<a href=index2.php>返回首页</a></p>
</form>
</td>
</tr>
</table>
<?
}
}
}
else
{
$str_sql="select said from SALERC where said='$said' and pid='$pid';";
$result=mysql_db_query($db,$str_sql,$link_id);
if (!$result) html_error_exit('MySQL查询命令失败!');
else
{
$flag=0;
if ($num=@mysql_num_rows($result))
$flag=1;
$str_sql="select amount from STORAGETB where stid='$usern' and pid='$pid';";
$result=mysql_db_query($db,$str_sql,$link_id);
if (!$result) html_error_exit('MySQL插入命令失败!');
$record=mysql_fetch_object($result);
if (!($num=@mysql_num_rows($result))||$samount>$record->amount)
{
$html=' <form name="form1" method="post" action="sale.php?step=1">
<input type="hidden" name="said" value="'.$said.'">
<input type="hidden" name="sadate" value="'.$sadate.'">
<input type="hidden" name="mtp" value="'.$mtp.'">
<input type="hidden" name="memo" value="'.$memo.'">';
if ($new==1)
$html.=' <input type="hidden" name="new" value="2">';
else
$html.=' <input type="hidden" name="new" value="0">';
echo $html."<div align=right><br>销售量不得大于库存量,请重填销售单<br><br><br><p><input type=submit name=Submit value=返回重填> <a href=sale.php?step=0>填写新的销售单</a> <a href=index2.php>返回首页</a></p></div></form>";
}
else
{
if ($method==1)
$str_sql="select pprice as p";
else $str_sql="select sprice as p";
$str_sql.=" from PRODUCTTB where pid='$pid';";
$result=mysql_db_query($db,$str_sql,$link_id);
if (!$result) html_error_exit('MySQL查询命令失败!');
$record=mysql_fetch_object($result);
$money=$samount*$record->p;
if (!$flag) $str_sql="insert into SALERC values (
'$said',
'$pid',
'$samount',
'$money');";
else $str_sql="update SALERC set
samount = samount + $samount,
money = money + $money
where said='$said' and pid='$pid';";
$result=mysql_db_query($db,$str_sql,$link_id);
if (!$result) html_error_exit('MySQL插入命令失败!');
$str_sql="update STORAGETB set
amount = amount - $samount
where stid='$usern' and pid='$pid';";
$result=mysql_db_query($db,$str_sql,$link_id);
if (!$result) html_error_exit('MySQL更新命令失败!');
if ($new==1)
{
$str_sql="insert into SALETB values (
'$said',
'$usern',
'$sadate',
'$mtp',
'$memo');";
$result=mysql_db_query($db,$str_sql,$link_id);
if (!$result) html_error_exit('MySQL插入命令失败!');
}
$html=' <form name="form1" method="post" action="sale.php?step=1">
<input type="hidden" name="said" value="'.$said.'">
<input type="hidden" name="sadate" value="'.$sadate.'">
<input type="hidden" name="mtp" value="'.$mtp.'">
<input type="hidden" name="memo" value="'.$memo.'">
<input type="hidden" name="new" value="0">';
echo $html."<div align=right><br>成功增添销售纪录<br><br><br><p><input type=submit name=Submit value=继续填写本销售单> <a href=sale.php?step=0>填写新的销售单</a> <a href=index2.php>返回首页</a></p></div></form>";
}
}
}
}
@mysql_close($link_id);
?>
</td>
</tr>
<tr>
<td height="40">
<table width="100%" border="0" cellspacing="0" cellpadding="0" height="40">
<tr>
<td valign="bottom" align="right"><font face="Arial"><b>Powered
by <img src="images/php.gif" width="39" height="20" align="absmiddle">
& <img src="images/mysql.gif" width="82" height="20" align="absmiddle"></b></font></td>
<td align="right" valign="bottom" width="200"><font face="Arial">©
<a href="mailto:lonelyp@etang.com">Lonely Passenger</a>,2001<br>
All rights reserved!</font></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<?
}
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?