📄 editpurchasedetail.asp
字号:
<!--#include file="../function/connect.asp"-->
<!--#include file="../function/function.asp"-->
<%
Purchase_ID=request("Purchase_ID")
if Purchase_ID="" then
response.write "参数错误"
response.end
end if
strsql="select pd.*,p.product_name,c1.cat1_name,c2.cat2_name from PurchaseDetails pd,products p,cat1 c1,cat2 c2 where pd.Product_ID=p.Product_ID and Product_Category_ID=c1.cat1_id and Product_CategoryII_ID=c2.cat2_id and Purchase_ID=" & Purchase_ID
Set objRs = Server.CreateObject("adodb.recordset")
objRs.Open strsql,objConn,1,1
%>
<%
Purchase_Detail_ID=request("Purchase_Detail_ID")
if Purchase_Detail_ID="" then
response.write "操作错误"
response.end
end if
strsql="select * from PurchaseDetails where Purchase_Detail_ID=" & Purchase_Detail_ID
Set objRs4 = Server.CreateObject("adodb.recordset")
objRs4.Open strsql,objConn,1,1
if not objrs4.eof then
Product_Category_ID=objrs4.fields("Product_Category_ID")
Product_CategoryII_ID=objrs4.fields("Product_CategoryII_ID")
Product_ID=objrs4.fields("Product_ID")
Unit_Price=objrs4.fields("Unit_Price")
Quantity=objrs4.fields("Quantity")
Amount=objrs4.fields("Amount")
Discount=objrs4.fields("Discount")
end if
%>
<html>
<head>
<title>购买明细</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../cssD.css" rel=stylesheet>
<style>
BODY {
BACKGROUND-COLOR: #FFFFFF; BORDER-RIGHT: #000000 0px outset; COLOR: #000000; FONT-SIZE: 9pt; LINE-HEIGHT: 14px; MARGIN-LEFT: 0px; MARGIN-TOP: 0px; TEXT-DECORATION: none; SCROLLBAR-FACE-COLOR: #333333; SCROLLBAR-HIGHLIGHT-COLOR: #FFFFFF; MARGIN-LEFT: 0px; SCROLLBAR-SHADOW-COLOR: #000000; SCROLLBAR-3DLIGHT-COLOR: #000000; SCROLLBAR-ARROW-COLOR: #ffffff; SCROLLBAR-DARKSHADOW-COLOR: #000000
}
</style>
<script>
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
function fnDo(strTable,strFIdName,strIdName,strIDValue,strShowName)
{
var xmlDom = new ActiveXObject("Msxml2.DOMDocument");
var strURL = "GetCity.asp?strIDValue=" + strIDValue + "&strIdName="+strIdName+"&strTable="+strTable+"&strShowName="+strShowName+"&strFIdName="+strFIdName;
//alert(strURL);
xmlhttp.Open("POST",strURL , true);
xmlhttp.onreadystatechange = fnRun;
xmlhttp.Send(xmlDom);
}
//--------------------------------------------------------
function fnRun()
{
var state = xmlhttp.readyState;
var xmlDom = new ActiveXObject("Msxml2.DOMDocument");
if (state == 4)
{
xmlDom.loadXML(xmlhttp.responseXML.xml);
//alert(xmlDom.documentElement.selectSingleNode("//objXML").text)
var getInfo = xmlDom.documentElement.selectSingleNode("//objXML").text;
//alert(getInfo);
subcat = new Array();
eval(getInfo);
changelocation(subcat)
}
}
function changelocation(subcat)
{
document.form2.Product_CategoryII_ID.length = 0;
var i;
document.form2.Product_CategoryII_ID.options[0] = new Option('====选择====','');
for (i=0;i <subcat.length; i++)
{
document.form2.Product_CategoryII_ID.options[document.form2.Product_CategoryII_ID.length] = new Option(subcat[i][0], subcat[i][1]);
if(subcat[i][1]=='<%=Product_CategoryII_ID%>')
{
document.form2.Product_CategoryII_ID.options[i+1].selected=true;
}
}
}
xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
function fnDo1(strTable,strFIdName,strIdName,strIDValue,strShowName)
{
var xmlDom1 = new ActiveXObject("Msxml2.DOMDocument");
var strURL = "GetCity.asp?strIDValue=" + strIDValue + "&strIdName="+strIdName+"&strTable="+strTable+"&strShowName="+strShowName+"&strFIdName="+strFIdName;
//alert(strURL);
xmlhttp1.Open("POST",strURL , true);
xmlhttp1.onreadystatechange = fnRun1;
xmlhttp1.Send(xmlDom1);
}
//--------------------------------------------------------
function fnRun1()
{
var state = xmlhttp1.readyState;
var xmlDom = new ActiveXObject("Msxml2.DOMDocument");
if (state == 4)
{
xmlDom.loadXML(xmlhttp1.responseXML.xml);
//alert(xmlDom.documentElement.selectSingleNode("//objXML").text)
var getInfo = xmlDom.documentElement.selectSingleNode("//objXML").text;
//document.write(getInfo);
subcat = new Array();
eval(getInfo);
changelocation1(subcat)
}
}
function changelocation1(subcat)
{
document.form2.Product_ID.length = 0;
var i;
document.form2.Product_ID.options[0] = new Option('====选择====','');
for (i=0;i <subcat.length; i++)
{
document.form2.Product_ID.options[document.form2.Product_ID.length] = new Option(subcat[i][0], subcat[i][1]);
if(subcat[i][1]=='<%=Product_ID%>')
{
document.form2.Product_ID.options[i+1].selected=true;
}
}
}
xmlhttp2 = new ActiveXObject("Msxml2.XMLHTTP");
function fnDo2(strTable,strIdName,strIDValue,strShowValue,strField)
{
var xmlDom2 = new ActiveXObject("Msxml2.DOMDocument");
var strURL = "GetCode.asp?strIDValue=" + strIDValue + "&strIdName="+strIdName+"&strTable="+strTable+"&strShowValue="+strShowValue+"&strField="+strField;
//alert(strURL);
xmlhttp2.Open("POST",strURL , true);
xmlhttp2.onreadystatechange = fnRun2;
xmlhttp2.Send(xmlDom2);
}
//--------------------------------------------------------
function fnRun2()
{
var state = xmlhttp2.readyState;
var xmlDom22 = new ActiveXObject("Msxml2.DOMDocument");
if (state == 4)
{
xmlDom22.loadXML(xmlhttp2.responseXML.xml);
//alert(xmlDom.documentElement.selectSingleNode("//objXML").text)
var getInfo = xmlDom22.documentElement.selectSingleNode("//objXML").text;
//alert(getInfo);
eval(getInfo);
}
}
</script>
<script>
function check2(){
if(document.form2.Product_Category_ID.value==""){
alert("产品大类不能为空");
document.form2.Product_Category_ID.focus();
return false;
}
if(document.form2.Product_CategoryII_ID.value==""){
alert("产品小类不能为空");
document.form2.Product_CategoryII_ID.focus();
return false;
}
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="102%" border="1" cellspacing="0" cellpadding="2" bordercolorlight='#000000' bordercolordark='#FFFFFF'>
<form name="form1" method="post" action="purchasedetail.asp">
<tr>
<td height="22" colspan="8" class="tablehead">
<div align="center">进货明细</div><input type="checkbox" name="Purchase_Detail_ID" value="0" disabled style="display:none;">
</td>
</tr>
<tr class="tablehead2" align="center">
<td height="22" width="2%">
<input type="checkbox" name="checkall" value="1" onclick="checkAll();">
</td>
<td height="22" nowrap>产品</td>
<td height="22" width="10%" nowrap>产品大类</td>
<td height="22" width="10%" nowrap>产品小类</td>
<td height="22" width="9%" nowrap>单价</td>
<td height="22" width="10%" nowrap>进货数量</td>
<td height="22" width="9%" nowrap>折扣</td>
<td width="9%" nowrap>金额</td>
</tr>
<%if not objrs.eof then
do while not objrs.eof
%>
<tr align="center">
<td height="22" width="2%" nowrap><input type="checkbox" name="Purchase_Detail_ID" value="<%=objrs.fields("Purchase_Detail_ID")%>"></td>
<td height="22" nowrap><%=objrs.fields("product_name")%></td>
<td height="22" width="9%" nowrap><%=objrs.fields("cat1_name")%></td>
<td height="22" width="9%" nowrap><%=objrs.fields("cat2_name")%></td>
<td height="22" width="9%" nowrap><%=objrs.fields("Unit_Price")%></td>
<td height="22" width="9%" nowrap><%=objrs.fields("Quantity")%></td>
<td height="22" width="9%" nowrap><%=objrs.fields("Discount")%>%</td>
<td width="9%" nowrap><%=objrs.fields("Amount")%></td>
</tr>
<%
objrs.movenext
loop
end if%>
<tr class="tablehead2">
<td height="22" colspan="7" align="left">
<input type="button" name="Submit" value=" 增加 " class="button" onclick="changeDis();">
<input type="button" name="Submit2" value=" 删除 " class="button" onclick="op('del')">
<input type="button" name="Submit3" value=" 修改 " class="button" onclick="op('edit')">
</td>
<td width="9%"> <input type="hidden" name="Purchase_ID" value="<%=Purchase_ID%>"><input type="hidden" name="meth" value=""></td>
</tr>
</form>
</table>
<table width="50%" border="1" cellspacing="0" cellpadding="2" bordercolorlight='#000000' bordercolordark='#FFFFFF' align="center" id="addpurchase">
<form name="form2" method="post" action="../function/UpdateToDB.asp?InsertTable=PurchaseDetails&ModifyID=<%=Purchase_Detail_ID%>&ModifyIDName=Purchase_Detail_ID&RedirectUrl=../clients/Purchase.asp?Purchase_ID=<%=Purchase_ID%>" target="_parent">
<tr>
<td colspan="2" height="22" class="tablehead">
<div align="center">添加进货明细</div>
</td>
</tr>
<tr>
<td width="25%" height="22">
<div align="right">产品大类:</div>
</td>
<td width="75%" height="22">
<select name="Product_Category_ID" onchange="fnDo('cat2','cat2_cat1_id','cat2_id',this.value,'cat2_name');">
<%
strsql="select * from cat1"
Set objRs = Server.CreateObject("adodb.recordset")
objRs.Open strsql,objConn,1,1
if not objrs.eof then
do while not objrs.eof
if Product_Category_ID=objrs.fields("cat1_id") then
response.write "<option value=" & objrs.fields("cat1_id") & " selected>" & objrs.fields("cat1_name") & "</option>"
else
response.write "<option value=" & objrs.fields("cat1_id") & ">" & objrs.fields("cat1_name") & "</option>"
end if
objrs.movenext
loop
end if
%>
</select>
</td>
</tr>
<tr>
<td width="25%" height="22">
<div align="right">产品小类:</div>
</td>
<td width="75%" height="22">
<select name="Product_CategoryII_ID" style="width:100" onchange="fnDo1('products','product_cat2_id','product_id',this.value,'product_name');">
<option value="">====选择====</option>
</select>
</td>
</tr>
<tr>
<td width="25%" height="22">
<div align="right">产品:</div>
</td>
<td width="75%" height="22">
<select name="Product_ID" style="width:150" onchange="fnDo2('products','product_id',this.value,'product_sale_price','document.form2.Unit_Price');">
<option value="">====选择====</option>
</select>
</td>
</tr>
<tr>
<td width="25%" height="22">
<div align="right">单价:</div>
</td>
<td width="75%" height="22">
<input type="text" name="Unit_Price" size="10" maxlength="10" class="input" value="<%=Unit_Price%>">
</td>
</tr>
<tr>
<td width="25%" height="22">
<div align="right">进货数量:</div>
</td>
<td width="75%" height="22">
<input type="text" name="Quantity" size="10" maxlength="5" class="input" value="<%=Quantity%>" onchange="getMoney();">
</td>
</tr>
<tr>
<td width="25%" height="22">
<div align="right">折扣:</div>
</td>
<td width="75%" height="11">
<input type="text" name="Discount" size="10" maxlength="5" class="input" value="<%=Discount%>" onchange="getMoney();">%
</td>
</tr>
<tr>
<td width="25%" height="22">
<div align="right">金额:</div>
</td>
<td width="75%" height="22">
<input type="text" name="Amount" size="20" maxlength="10" class="input" value="<%=Amount%>" onclick="getMoney();">
</td>
</tr>
<tr>
<td width="25%" height="22"> <input type="hidden" name="Purchase_ID" value="<%=Purchase_ID%>"></td>
<td width="75%" height="22">
<input type="submit" value=" 确定 " class="button" onclick="getMoney();">
<input type="reset" value=" 重设 " class="button">
</td>
</tr>
</form>
</table>
</body>
</html>
<script>
function changeDis()
{
if(addpurchase.style.display=="none"){
addpurchase.style.display="";
}else{
//addpurchase.style.display="none";
}
}
function getMoney()
{
var Unit_Price=document.form2.Unit_Price.value;
var Quantity=document.form2.Quantity.value;
var Discount=document.form2.Discount.value;
var allMoney=0;
if(isNaN(Unit_Price) || isNaN(Quantity) || isNaN(Discount)){
alert("请输入数字");
return false;
}
allMoney=Unit_Price * Quantity * Discount /100;
document.form2.Amount.value=allMoney;
}
function op(str){
if(str=="del"){
if(checkNum()>1){
document.form1.meth.value="del";
document.form1.submit();
}else{
alert("请选择要删除的项目");
}
}
if(str=="edit"){
if(checkNum()==1){
document.form1.action="editpurchasedetail.asp";
document.form1.meth.value="edit";
document.form1.submit();
}else{
alert("只能选择一个要修改的项目");
}
}
}
function checkNum()
{
rNum=0;
var actID=document.all.Purchase_Detail_ID;
for(i=0;i<actID.length;i++){
if(actID[i].checked==true){
rNum=rNum +1 ;
}
}
return rNum;
}
function checkAll()
{
var actID=document.all.Purchase_Detail_ID;
if(document.form1.checkall.checked==false){
for(i=0;i<actID.length;i++){
actID[i].checked=false;
}
}else{
for(i=0;i<actID.length;i++){
actID[i].checked=true;
}
}
}
</script>
<script>
function init(){
if(<%=Product_Category_ID%>!=""){
fnDo('cat2','cat2_cat1_id','cat2_id',<%=Product_Category_ID%>,'cat2_name');
}
return true;
}
function init2()
{
if(<%=Product_CategoryII_ID%>!=""){
fnDo1('products','product_cat2_id','product_id',<%=Product_CategoryII_ID%>,'product_name');
}
}
if(init()){
init2();
}
</script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -