<!--#INCLUDE FILE="../HXINCLUDE/HXINCLUDEHEAD.ASP"-->
<%
ColumnName="":Tablename="HX_ProductSaleRecord":Tablename1="HX_Product":Orderby=""
action=request("action")
id=request("id")
if not WS_S.HX_IsNUM(id) then
    HX_GoBack "非法操作","" 
end if
Orderby=" where WS_PSID="&id
set rs=WS_S.HX_SetRSD(ColumnName,Tablename,Orderby)
if action="saveinfo" then
 PTID=WS_s.HX_Replace(request("PTID"))
 SaleMan=WS_s.HX_Replace(request("SaleMan"))
 SaleDate=WS_s.HX_Replace(request("SaleDate"))
 SaleDescribe=WS_s.HX_Replace(request("SaleDescribe"))
 DetailDate=WS_s.HX_Replace(request("DetailDate"))
 DetailContent =WS_s.HX_Replace(request("DetailContent"))
 SaleCnt=WS_s.HX_Replace(request("SaleCnt"))
 SaleDetailFlag=request("SaleDetailFlag")
   rs("WS_PTID")=PTID
   rs("WS_ProductSaleMan")=SaleMan
   if isdate(SaleDate) then   rs("WS_ProductSaleDate")=SaleDate
   rs("WS_ProductSaleDescribe")=SaleDescribe
   rs("WS_ProductSaleDetailDate")=DetailDate
   rs("WS_ProductSaleDetailContent")=DetailContent
   if WS_s.HX_ISnum(SaleCnt) then rs("WS_ProductSaleCnt")=SaleCnt
   if WS_s.HX_ISnum(SaleDetailFlag) then rs("WS_ProductSaleDetailFlag")=SaleDetailFlag
 rs.update
 if WS_s.HX_ISnum(SaleDetailFlag) and SaleDetailFlag=1 then 
   set prs=WS_S.HX_SetRSD("","HX_Product"," where WS_PTID="&PTID)
   if prs.recordcount>0 then
     if prs("WS_ProductStocks")>=cint(SaleCnt) then
	   prs("WS_ProductStocks")=prs("WS_ProductStocks")-SaleCnt
	   prs.update
	 else
	   HX_GoBack "库存量不足！",""
	 end if  
   end if
 end if
 HX_GoBack "修改成功","ProductSaleRecord.asp" 
end if
Orderby=""
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>修改销售记录</title>
<link rel=stylesheet type=text/css href="../HXinclude/HX_Style.css">
<script src="../HXinclude/HX_Function.js"></script>
<!--#INCLUDE FILE="../HXINCLUDE/SelectDate.ASP"-->
</head>
<body topmargin="20" leftmargin="0" bottommargin="0">
<table width="596"  border="0" cellspacing="1" cellpadding="0" align=center bgcolor="#613c25">
  <tr>
    <td colspan="2" bgcolor=FFFBE8><table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="25" background="../hximages/titleline.gif"><font class="fontmenu">修改销售记录</font>　　　　　　<a href="ProductSaleRecordCreate.asp" class="menu">添加销售记录</a>　　<a href="ProductSaleRecord.asp" class="menu">销售记录管理</a></td>
  </tr>
</table>
<table width="100%"  border="0" cellspacing="1" cellpadding="3" bgcolor=FFFBE8>
  <form name="form1" method="post" action="?action=saveinfo"><tr bgcolor="#FFFBE8">
    <td width="23%" align="right">产品名称：</td>
    <td width="77%"><select name="PTID" id="PTID">
	<%
     Orderby=" where WS_ProductCreateMan="&loginuid&" order by WS_PTID desc"
	set urs=WS_S.HX_SetRSD(ColumnName,Tablename1,Orderby)
	if urs.recordcount>0 then
	  do until urs.eof
	%>
      <option value="<%=urs("WS_PTID")%>" <%if rs("WS_PTID")=urs("WS_PTID") then response.write "selected"%>><%=urs("WS_ProductName")%></option><%
	   urs.movenext
	   loop
	  end if
	WS_S.HX_RSClose urs  
	  %>
    </select>      </td>
  </tr>
  <tr bgcolor="#FFFBE8">
    <td align="right">出售日期：</td>
    <td>      <input name="SaleDate" type="text" value="<%=rs("WS_ProductSaleDate")%>" size="28" readonly>
      <input name="button" type="button" title="选择时间" onClick="popUpcalendar(this, form1.SaleDate, 'yyyy/mm/dd')" value="选择"></td>
  </tr>
  <tr bgcolor="#FFFBE8">
    <td align="right">清单日期：</td>
    <td>      <input type="text" size="28" name="DetailDate" readonly value="<%=rs("WS_ProductSaleDetailDate")%>" >
      <input name="button" type="button" title="选择开始时间" onClick="popUpcalendar(this, form1.DetailDate, 'yyyy-mm-dd')" value="选择"></td>
  </tr>
    <tr bgcolor="#FFFBE8">
      <td align="right">是否清单：</td>
      <td><input type="radio" name="SaleDetailFlag" value="1" <%if rs("WS_ProductSaleDetailFlag")=1 then response.Write "checked"%> id="DetailFlag" style="border:0 "><label for="DetailFlag" style="cursor:hand; ">是</label>
	  <input type="radio" name="SaleDetailFlag" value="0" <%if rs("WS_ProductSaleDetailFlag")=0 then response.Write "checked"%> id="DetailFlag1" style="border:0 "><label for="DetailFlag1" style="cursor:hand; ">否</label></td>
    </tr>
    <tr bgcolor="#FFFBE8">
      <td align="right">清单意见：</td>
      <td><input type="text" size="36" name="DetailContent" value="<%=rs("WS_ProductSaleDetailContent")%>"></td>
  </tr>
  <tr bgcolor="#FFFBE8">
    <td align="right">购 买 人：</td>
    <td>
	<select name="SaleMan"><%
	ColumnName="":Tablename="HX_CustomInfo":Tablename1="HX_CustomContact":Orderby=""
    set crs=WS_S.HX_SetRSD(ColumnName,Tablename,Orderby)
	if crs.recordcount>0 then
	  do until crs.eof
	   if crs("WS_CIID")=0 then
	     sql=" where WS_CIID=0"
	   else
	     sql=" where WS_CIID="&crs("WS_CIID")
	   end if
	     set cors=WS_S.HX_SetRSD(ColumnName,Tablename1,sql)
		  if cors.recordcount>0 then
		    do until cors.eof
             response.Write "<option value='"&cors("WS_CCID")&"' "
			 if rs("WS_ProductSaleMan")=cors("WS_CCID") then response.Write "selected"
			 response.Write ">["&crs("WS_CustomInfoName")&"]"&cors("WS_CustomContactName")&"</option>"
		    cors.movenext
			loop
		end if
	  crs.movenext
	  loop
	end if	
		%>
      </select>	</td>
  </tr>
    <tr bgcolor="#FFFBE8">
    <td align="right">购买数量：</td>
    <td><input type="text" size="36" name="SaleCnt" value="<%=rs("WS_ProductSaleCnt")%>"></td>
  </tr>
  <tr bgcolor="#FFFBE8">
    <td align="right">备　　注：</td>
    <td><input name="SaleDescribe" type="text" value="<%=rs("WS_ProductSaleDescribe")%>" size="36"></td>
  </tr>
  <tr bgcolor="#FFFBE8">
    <td align="right" valign=top>&nbsp;</td>
    <td><input type="submit" name="Submit" value=" 修 改 ">
      <input type="reset" name="Submit2" value=" 重 置 ">
      <input name="id" type="hidden" id="id" value="<%=id%>"></td>
  </tr></form>
</table></td>
  </tr>
</table>
<%WS_S.HX_RSClose rs%>
