?? c_salesum.asp
字號:
<%
'*********************************頁面說明 **************************************************
'開發者:金壽吉
'首次開發時間:2001-09-05
'最后一次修改時間:
'主要功能:促銷活動的統計分析
'主要的傳遞參數描述
'1--vYear,vMonth 起始年月
'2--eYear,eMonth 終止年月
'3--DepartID 查詢部門
'4--Sales 查詢員工
'5--condition 查 詢條件
%>
<!--#include file="../include/Pubconn.asp"-->
<!--#include file="../include/PubFun.asp"-->
<%
dim username '當前用戶名
dim userclass '表示用戶的權限級別
dim userCheck '表示用戶是否有審核權限
dim AdoRs '數據記錄集
dim lcSql 'SQL語句
dim keyitem(7) '表示保存數據的數組
dim vYear,vMonth '起始年月
dim eYear,eMonth '終止年月
dim departID,Sales '查詢的部門和員工
dim departCode(),departname() '所有部門的編碼和名稱
dim Count1 '表示部門查詢的結果
dim departcode1(),StuffNum(),StuffName() '表示查詢員工所在的部門,員工號和姓名
dim Count2 '查詢員工的數量
dim Condition '查詢條件
'*********************************得到用戶名并進行表訪問權限判斷 ***********************************
username=GetUser() '得到當前的用戶名
userclass=TableVisitor("C_SalePromotion",username) '得到用戶對表的最高訪問權限
'usercheck=TableCheck("C_SalePromotion",username) '得到文檔的審核權
'***********************************設置傳遞參數的值 *********************************************
vYear=Request("vYear")
eYear=Request("eYear")
vMonth=Request("vMonth")
eMonth=Request("eMonth")
departId=Request("departID")
Sales=Request("Sales")
Condition=Request("Condition")
'**********************************設置ADO數據 ****************************************************
'讀取部門信息
set AdoRs=Server.CreateObject("AdoDB.RecordSet")
lcsql="select * from A_departInfo where delflag='0'"
AdoRS.Open lcSql,PubConn,1,3
if not adors.eof then
Count1=Adors.recordcount
redim DepartCode(Count1),departName(Count1)
i=1
Do while not adors.eof
DepartCode(i)=Adors("departcode")
departName(i)=Adors("name")
AdoRs.MoveNext
i=i+1
Loop
else
Count1=0
End if
set Adors=Nothing
'讀取員工信息
set AdoRs=Server.CreateObject("AdoDB.RecordSet")
lcsql="select * from A_StuffInfo where saleflag='1' and delflag<>'1'"
AdoRS.Open lcSql,PubConn,1,1
if not adors.eof then
Count2=Adors.recordcount
redim DepartCode1(Count2),StuffNum(Count2),StuffName(Count2)
i=1
Do while not adors.eof
DepartCode1(i)=Adors("departcode")
StuffNum(i)=Adors("StuffNum")
StuffName(i)=Adors("name")
AdoRs.MoveNext
i=i+1
Loop
else
Count2=0
End if
set Adors=Nothing
set AdoRs=Server.CreateObject("AdoDB.RecordSet")
lcsql="select Count(*) as DataRow,Sum(planCost) as PlanCost1, Sum(FactCost) as FactCost1,Sum(SaleMoney) as SaleMoney1,"
lcsql=lcsql+" Sum (Assorts) as Assorts1, sum(Guests) as Guests1, Sum(Consumes) as Consumes1 from C_SalePromotion where delflag<>'1'"
'******************************根據查詢條件和排序條件修改lcSQL語句 ********************************
if Condition<>"" then
lcSql=lcSql+" AND "+Condition
End if
'response.write lcsql
'response.end
AdoRS.Open lcSql,PubConn,1,3
if not Adors.eof then
Keyitem(1)=Adors("DataRow")
Keyitem(2)=Adors("PlanCost1")
Keyitem(3)=Adors("FactCost1")
Keyitem(4)=Adors("SaleMoney1")
Keyitem(5)=Adors("Assorts1")+Keyitem(1)
Keyitem(6)=Adors("Guests1")
Keyitem(7)=Adors("Consumes1")
for i=1 to 7
if isNull(keyitem(i)) then keyitem(i)=0
next
end if
Set Adors=Nothing '關閉數據集和連接
Set PubConn=Nothing
%>
<Script Language="VBScript">
dim count1,count2
dim departcode(),departname()
dim departcode1(),stuffnum(),stuffname()
Sub DepartCodeIni() '部門初始化
if Count1>0 then
Redim departcode(Count1),departname(count1)
<% for i=1 to Count1 %>
departcode(<%=i%>)="<%=departcode(i)%>"
departName(<%=i%>)="<%=departName(i)%>"
<% Next %>
document.forms(0).departID.length=Count1+1
for i=1 to Count1
document.forms(0).departID.options(i).text=departcode(i)+"-"+departName(i)
document.forms(0).departID.options(i).value=departcode(i)
next
end if
document.forms(0).departID.selectedindex=0
End Sub
Sub StuffIni() '部門初始化
if Count2>0 then
Redim departcode1(Count2),StuffNum(count2),StuffName(Count2)
<% for i=1 to Count2 %>
departcode1(<%=i%>)="<%=departcode1(i)%>"
StuffNum(<%=i%>)="<%=StuffNum(i)%>"
StuffName(<%=i%>)="<%=StuffName(i)%>"
<% Next %>
document.forms(0).Sales.length=Count2+1
for i=1 to Count2
document.forms(0).Sales.options(i).text=StuffNum(i)+"-"+StuffName(i)
document.forms(0).Sales.options(i).value=StuffNum(i)
next
end if
document.forms(0).sales.selectedindex=0
End Sub
'改變部門編碼,調整員工編碼
Sub departcodeclick()
dim sindex
dim Childstuff,Childname '表示調整后的員工編碼和姓名
sindex=document.forms(0).departid.selectedindex
if sindex>0 then
'*****************計算相應的員工工號*******************
ChildSecond=""
ChildMode=""
for i=1 to Count2
if departcode1(i)=departcode(sindex) then
if ChildStuff<>"" then
ChildStuff=ChildStuff+","+stuffnum(i)
Childname=Childname+","+stuffname(i)
else
ChildStuff=ChildStuff+stuffnum(i)
Childname=Childname+stuffname(i)
end if
end if
next
ChildStuff=Split(ChildStuff,",")
Childname=Split(Childname,",")
'*****************調整相應的員工編碼和信息*******************
document.forms(0).sales.length=UBound(Childstuff)+2
for i=1 to UBound(Childstuff)+1
document.forms(0).sales.options(i).text=ChildStuff(i-1)+"-"+Childname(i-1)
document.forms(0).sales.options(i).value=ChildStuff(i-1)
next
document.forms(0).sales.selectedindex=0
else
Call DepartCodeIni()
Call StuffIni()
end if
End sub
'改變員工編碼,調整部門編碼
Sub stuffcodeclick()
dim sindex
dim childdepart,childname '表示調整后的部門編碼和名稱
sindex=document.forms(0).sales.selectedindex
if sindex>0 then
'*****************計算相應的部門編碼和名稱*******************
childstuff=document.forms(0).sales.value
for i=1 to count2
if stuffnum(i)=childstuff then
childdepart=departcode1(i)
exit for
end if
next
for i=1 to Count1
if departcode(i)=childdepart then
childname=departname(i)
exit for
end if
next
'*****************調整相應的部門編碼*******************
document.forms(0).departID.length=2
document.forms(0).departID.options(1).text=childdepart+"-"+childname
document.forms(0).departID.options(1).value=childdepart
document.forms(0).departID.selectedindex=1
else
Call DepartCodeIni()
Call StuffIni()
end if
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -