📄 save_outward_2.asp
字号:
<%@ LANGUAGE="VBSCRIPT" %>
<%const title="确认数据"%>
<%
response.buffer=true
Response.Expires = 0
Response.CacheControl = "Private"
%>
<!-- #include file=../data/username.inc-->
<!-- #include file=../data/connect.asp-->
<!--#include file=../data/myPrg.asp-->
<head>
<meta http-equiv="Content-Type"content="text/html; charset=gb_2312-80">
<title><%=title%></title>
<link rel="stylesheet" type="text/css" href="../data/forum.css">
</head>
<body topmargin=0>
<%
newcompanyid = request("companyid")
if newcompanyid = "" then
call closedatabase
Response.Write "<script language=javascript>"
Response.Write "alert(""请先选择公司再做此步操作!"");"
Response.write "history.go(-1);"
Response.Write "</script>"
Response.End
elseif not isnumeric(newcompanyid) then
call closedatabase
Response.Write "<script language=javascript>"
Response.Write "alert(""companyid必须为整数!"");history.go(-1);"
Response.Write "</script>"
Response.End
else
newcompanyid = cint(newcompanyid)
end if
arra = split(session("username"),";")
UserCompanyid = arra(0)
flag = arra(1)
User = arra(2)
userno = arra(4)
database = request("database")
if flag > 4 then
call closedatabase
Response.End
end if
direct = trim(request("direct"))
if direct = 1 then
inwa_take_address = Request.Cookies("take_address")
inwa_line_no = trim(Request.Cookies("line_no"))
if inwa_line_no = "" then inwa_line_no = " "
inwa_take_no = trim(Request.Cookies("take_no"))
if inwa_take_no = "" then inwa_take_no = " "
else
direct = 0
end if
msg=""
'得到OUTWARD表中的对应系统编号
dim outwardid
outwardid = request("id")
if not isnumeric(outwardid) then
call closedatabase
Response.Write "<script language=javascript>"
Response.Write "alert(""id必须为整数!"");history.go(-1);"
Response.Write "</script>"
Response.End
end if
dc_id = request("dc_id")
dc_id = replace(dc_id,"'","")
prod_id = request("smalllocation")
prod_id = replace(prod_id,"'","")
if prod_id = "" then
Response.Write "<script language=javascript>"
Response.Write "alert(""请务必先选择产品编号!"");"
Response.Write "history.go(-1);"
Response.Write "</script>"
Response.End
end if
'出库数量outw_no
outw_no = trim(Request.Form("outw_no"))
guest_code=request("guest_code")
'得到库存表相对应的ID,以免由于管理员忘记初始化库存而引起误操作.
sql = "select inve_id,inve_maysent,inve_total from inventory where inve_dc_id = "&dc_id&" and inve_prod_id = "&prod_id&" and inve_disabled = 0 and inve_companyid = "&newcompanyid&""
'Response.Write sql
'Response.End
set rs_inve = conn.execute(sql)
if not rs_inve.eof then
id = rs_inve("inve_id")
inve_maysent = rs_inve("inve_maysent")
inve_total = rs_inve("inve_total")
'出库方式outw_type
'目的地outw_where,takeman_id,时限要求yuji_time
'出库摘要outw_beizu
outw_where = trim(Request.Form("outw_where"))
outw_type = request("outw_type")
takeman_id = trim(Request.Form("takeman_id"))
takeman_id = replace(takeman_id,"'","’")
yuji_time = trim(Request.Form("yuji_time"))
outw_beizu = trim(Request("outw_beizu"))
outw_beizu = replace(outw_beizu,"'","’")
guest_id_cookies = Request.Cookies("outw_where")
if outw_where <> guest_id_cookies then
sql = "select detail_id from outward_detail where detail_outw_id = "&outwardid&" and detail_guest_id = "&outw_where&" "
set rs_check = conn.execute(sql)
if rs_check.eof then
if outw_type = "" then
msg = msg + "出库方式必须选择!<br>"
end if
if isdate(yuji_time) = false then
msg = msg + "预计到达时间格式错误!<br>"
end if
check_flag = 1
else
check_flag = 0
'exist
end if
rs_check.close
set rs_check = nothing
end if
if cint(direct) = 0 then
if clng(inve_maysent) <= 0 then
rs_inve.close
set rs_inve = nothing
call closedatabase
Response.Write "<script language=javascript>"
response.write "alert(""现在的总库存是 " & inve_total & " ,\n可分发数量是" & inve_maysent & " ,\n由于可分发数量不大于0 \n所以你不能做该产品的出库操作!"");"
response.write "history.back();"
response.write "</script>"
response.end
end if
if (clng(outw_no) > clng(inve_maysent)) then
rs_inve.close
set rs_inve = nothing
call closedatabase
Response.Write "<script language=javascript>"
response.write "alert(""现在的总库存是 " & inve_total & " \n可分发数量是 " & inve_maysent & " \n出库数量是" & outw_no & "\n由于出库数量大与可分发数量!\n所以你不能做该产品的出库操作!"");"
response.write "history.back();"
response.write "</script>"
response.end
'msg = msg + "出库数量不得大与可分发数量!<br>"
end if
end if
if outw_where = 0 then
msg = msg + "请选择客户!<br>"
end if
if msg<>"" then
rs_inve.close
set rs_inve = nothing
call closedatabase
showerror(msg)
Response.End
else
'将相应的日期格式转换成正确的日期格式
'并且将信息写入到cookies中以便用户在下次录入时不必输入
if outw_where <> guest_id_cookies then
if outw_yuji_time = "" then outw_yuji_time = now()
yuji_time = replace(yuji_time,":",":")
Response.Cookies("yuji_time") = yuji_time
Response.Cookies("outw_where") = outw_where
Response.Cookies("info_type") = outw_type
Response.Cookies("takeman_id") = takeman_id
end if
prod_flag = request("biglocation")
Response.Cookies("prod_flag") = prod_flag
Response.Cookies("prod_id") = prod_id
if takeman_id = "" then takeman_id = " "
if outw_beizu = "" then outw_beizu = " "
if outw_type = "" then outw_type = " "
if yuji_time = "" then yuji_time = now()
if trim(session("username")) = "" then
rs_inve.close
set rs_inve = nothing
call closedatabase
Response.Redirect "../user/defaut.asp"
Response.End
end if
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from guest where guest_code='"&guest_code&"'", conn, 1, 3
if not rs.eof then
guest_id=rs("guest_id")
end if
rs.close
set rs=nothing
'如果出的是同一个客户的产品,则只更新OUTWARD_DETAIL表和INVENTORY表
'如果出给另一客户,则还需更新DETAIL_INFO表
'if outw_where = guest_id_cookies then
'cmd.Parameters("@flag") = 0
'else
'if check_flag = 1 then
' cmd.Parameters("@flag") = 1
'elseif check_flag = 0 then
' cmd.Parameters("@flag") = 0
'end if
'end if
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from outward_detail", conn, 1, 3
rs.AddNew
rs("detail_companyid")=newcompanyid
rs("detail_outw_id")=outwardid
rs("detail_prod_id")=prod_id
rs("detail_no")=outw_no
rs("detail_man")=user
rs("detail_guest_id")=guest_id
rs("detail_io_flag")=0
rs.Update
rs.close
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from outward_detail where detail_outw_id="&outwardid&"", conn, 1, 3
if not rs.eof then
detail_id=rs("detail_id")
end if
rs.close
set rs=nothing
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from detail_info", conn, 1, 3
rs.AddNew
rs("info_outw_id")=outwardid
rs("info_type")=outw_type
rs("info_takeman_id")=takeman_id
rs("info_yuji_time")=yuji_time
rs("info_order_beizu")=outw_beizu
rs("info_detail_id")=detail_id
rs.Update
rs.close
if outw_flag = 0 then 'o为等待
sql = "update inventory set inve_fenpei = inve_fenpei + " & outw_no & " where inve_dc_id = "&dc_id&" and inve_prod_id = "&prod_id&" and inve_companyid = "&newcompanyid&" and inve_disabled = 0"
conn.execute(sql)
'lseif inwa_flag = 1 then
' sql = "update inventory set inve_ruku = inve_ruku + " & inwa_rec_no & ",inve_maysent = inve_maysent + " & inwa_rec_no & ",inve_total = inve_total +"&inwa_rec_no&",inve_last_date = '"&inve_last_date & "' where inve_dc_id = "&dc_id&" and inve_prod_id = "&prod_id&" and inve_companyid = "&newcompanyid&" and inve_disabled = 0 "
' conn.execute(sql)
end if
'结束事务处理
'update语句-----更新"已分配数量"数据
if err.number <> 0 then
rs_inve.close
set rs_inve = nothing
call closedatabase
response.write "<p>无法保存,数据库操作出错:" + err.description + "</p>"
Response.Write "<p>请稍后再试!</p>"
Response.End
end if
rs_inve.close
set rs_inve = nothing
call closedatabase
Response.Write "<script language=javascript>"
Response.Write "var myTime = new Date(); "
Response.Write "var timeNow = myTime.getTime();"
Response.Write "{if (confirm(""数据已确认,继续进行该笔单子的出库操作吗?""))"
if database = "" then
if direct = 1 then
Response.Write "window.location ='outward_2.asp?direct=1&id="&outwardid&"&companyid="&newcompanyid&"&inward_second=yes&tt='+timeNow;"
else
Response.Write "window.location ='outward_2.asp?id="&outwardid&"&companyid="&newcompanyid&"&inward_second=yes&tt='+timeNow;"
end if
else
if direct = 1 then
Response.Write "window.location ='outward_2.asp?direct=1&id="&outwardid&"&companyid="&newcompanyid&"&inward_second=yes&database=yestt='+timeNow;"
else
Response.Write "window.location ='outward_2.asp?id="&outwardid&"&companyid="&newcompanyid&"&inward_second=yes&database=yestt='+timeNow;"
end if
end if
Response.Write "else "
Response.Write "{"
Response.Write "window.location ='outward.asp?companyid="&newcompanyid&"&tt='+timeNow;"
Response.Write "}"
Response.Write "}"
Response.Write "</script>"
Response.End
end if
else
Response.Write "您没有权限对这个数据进行操作<br>"
Response.Write "想要更多操作,请与管理员联系<br>"
Response.Write "<a href=javascript:history.go(-1);>后退</a>"
end if
rs_inve.close
set rs_inve = nothing
call closedatabase
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -