<?php

	$login=mysql_connect('localhost', 'wauhaha_karaoke', 'cross123','wauhaha_karaoke');

	mysql_selectDB("wauhaha_karaoke",$login);
$time = $_POST['time'];
	$TID =$_GET['TID'];
	$TID1 =$_POST['TID'];
	$AddQuan =$_POST['AddQuan'];
	$ProRQuan =$_POST['ProRQuan'];
	$TQuan =$_POST['TQuan'];
	$ProPrice =$_POST['ProPrice'];
	$ProTPrice =$_POST['ProTPrice'];
	$Date =$_POST['Date'];
	$result=mysql_query("select * from stocktran where TID='$TID' ");
	$row=mysql_fetch_array($result);
	$SupID =$row['SupID'];
	$SupName =$row['SupName'];
	$ProID =$row['ProID'];
	$ProName =$row['ProName'];
	$query=mysql_query("INSERT INTO stocktran(TID,SupID,SupName,ProID,ProName,ProRQuan,ProAddQuan,ProTQuan,ProPrice,ProTPrice,Date,EditDate)VALUE('$TID1','$SupID','$SupName','$ProID','$ProName','$ProRQuan','$AddQuan','$TQuan','$ProPrice','$ProTPrice','$Date','$time')");
	$query2=mysql_query("UPDATE stock Set ProRQuan='$ProRQuan' where ProID='$ProID'");
	
	if($query){
		echo "<script language=javascript>alert('Update successful!!');window.location='http://www.wauhaha.com/karaoke/viewtrans.php'</script>";
}
echo "<script language=javascript>alert('Update fail!!');window.location='http://www.wauhaha.com/karaoke/viewtrans.php'</script>";
	
	
	
	?>