<?php
$login=mysql_connect('localhost', 'wauhaha_karaoke', 'cross123','wauhaha_karaoke');
mysql_selectDB("wauhaha_karaoke",$login);

$time = $_POST['time1'];
$SupID = $_GET['SupID'];
$ProName =$_POST['ProName'];
$ProID =$_POST['ProID'];
$TID =$_POST['TID'];
$Quantity =$_POST['Quantity'];
$UPrice=$_POST['UPrice'];
$TPrice=$_POST['TPrice'];
$Discount=$_POST['Discount'];
$result=mysql_query("select * from supplier where SupID='$SupID'");
$row = mysql_fetch_array($result);
$SupName = $row['SupName'];

$query3=mysql_query("INSERT INTO stock(ProID,SupID,SupName,ProName,ProQuan,ProPrice,Discount,ProTPrice,Date)Value('$ProID','$SupID','$SupName','$ProName','$Quantity','$UPrice','$Discount','$TPrice','$time')");

$query2= mysql_query("INSERT into stocktran(TID,SupID,SupName,ProID,ProName,ProAddQuan,ProPrice,Discount,ProTPrice,Date)Value('$TID','$SupID','$SupName','$ProID','$ProName','$Quantity','$UPrice','$Discount','$TPrice','$time')");
if($query3){
	echo "<script language=javascript>alert('Add successful!!');window.location='http://www.wauhaha.com/karaoke/instock1.php?SupID=$SupID'</script>";
}
echo "<script language=javascript>alert('Add fail!!');window.location='http://www.wauhaha.com/karaoke/instock1.php?SupID=$SupID '</script>";
?>