争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

计算合同内各级别的价格函数

时间:2024/6/29作者:未知来源:争怎路由网人气:

需求:
按月计算合同内各级别物品的总价
给定条件如下:
1.合同内共有四种级别物别,且价格不同;
2.各级别物品价格的定义为每月的价格;
3.每天的价格为各级别物品的价格除以30;
4.要求计算输入的日期段内的价格,(截止日期大于起始日期,如小于不必考虑)
5.如果两日期相差不到一个月,则小于15天的,总价按天数计算;大于等于15天的按月计算
6.如果两日期相差大于一个月,则整月的,总价按月计算;
7.大于一个月且非整月的,则小于15天的,总价按天数计算;大于等于15天的按月计算


实现:
计算指定时间段内的合同总价:<br><br>
<form method="post" action="test.asp?action=1">
  发布起始日期:<input type="text" name="DateStart" value="<%=request("DateStart")%>"><br>
  发布截止日期:<input type="text" name="DateEnd" value="<%=request("DateEnd")%>"><br>
    AA 级价格:<input type="text" name="AA" value="6000"> /月 __ 200.00 /日<br>
    A 级价格:<input type="text" name="A" value="4800"> /月 __ 160.00 /日<br>
    B 级价格:<input type="text" name="B" value="3200"> /月 __ 106.66~/日<br>
    C 级价格:<input type="text" name="C" value="2400"> /月 __ 80.00 /日<br>
          各个级别数量按 10 个计算<br>
            <input type="submit" name="Submit3" value="总 计">
</form>
<%
if request("Action")=1 then
response.write "总价= "&Diff_Month(request("DateStart"),request("DateEnd"),request("AA"),request("A"),request("B"),request("C"),10,10,10,10)
end if
function Diff_Month(StartDate,EndDate,MoneyF_AA,MoneyF_A,MoneyF_B,MoneyF_C,AmountAA,AmountA,AmountB,AmountC)

Different=DateDiff("m",StartDate,EndDate)

'如果在一个月内
if DateDiff("m", StartDate, EndDate)=0 then
if DateDiff("d", StartDate, EndDate)+1<15 then
Diff_Month=(MoneyF_AA/30)*AmountAA*(DateDiff("d", StartDate, EndDate)+1) + (MoneyF_A/30)*AmountA*(DateDiff("d", StartDate, EndDate)+1) + (MoneyF_B/30)*AmountB*(DateDiff("d", StartDate, EndDate)+1) + (MoneyF_C/30)*AmountC*(DateDiff("d", StartDate, EndDate)+1)
end if
if DateDiff("d", StartDate, EndDate)+1>=15 then
Diff_Month=MoneyF_AA*AmountAA + MoneyF_A*AmountA + MoneyF_B*AmountB + MoneyF_C*AmountC
end if
end if

'如果相差大于一个月的整月
if DateDiff("m", StartDate, EndDate)>0 and DateDiff("d", DateAdd("m", Different, StartDate), EndDate)=0 then
Diff_Month=(MoneyF_AA*AmountAA + MoneyF_A*AmountA + MoneyF_B*AmountB + MoneyF_C*AmountC)*Different
end if

'如果形如2002-03-15、2002-05-25
if DateDiff("m", StartDate, EndDate)>0 and DateDiff("d", DateAdd("m", Different, StartDate), EndDate)>0 then
'如果相差大于一个月且<15天
if DateDiff("d", DateAdd("m", Different, StartDate), EndDate)+1<15 then
Diff_Month=(MoneyF_AA*AmountAA + MoneyF_A*AmountA + MoneyF_B*AmountB + MoneyF_C*AmountC)*Different
Diff_Month=Diff_Month+((MoneyF_AA/30)*AmountAA*(DateDiff("d", DateAdd("m", Different, StartDate), EndDate)+1) + (MoneyF_A/30)*AmountA*(DateDiff("d", DateAdd("m", Different, StartDate), EndDate)+1) + (MoneyF_B/30)*AmountB*(DateDiff("d", DateAdd("m", Different, StartDate), EndDate)+1) + (MoneyF_C/30)*AmountC*(DateDiff("d", DateAdd("m", Different, StartDate), EndDate)+1))
end if

'如果相差大于一个月且>=15天
if DateDiff("d", DateAdd("m", Different, StartDate), EndDate)+1>=15 then
Diff_Month=(MoneyF_AA*AmountAA + MoneyF_A*AmountA + MoneyF_B*AmountB + MoneyF_C*AmountC)*(Different+1)
end if
end if

'如果形如2002-03-15、2002-05-01
if DateDiff("m", StartDate, EndDate)>=1 and DateDiff("d", DateAdd("m", Different, StartDate), EndDate)<0 then
Different=DateDiff("m",StartDate,EndDate)-1

'如果相差大于一个月且<15天
if DateDiff("d", DateAdd("m", Different, StartDate), EndDate)<15 then
Diff_Month=(MoneyF_AA*AmountAA + MoneyF_A*AmountA + MoneyF_B*AmountB + MoneyF_C*AmountC)*Different
Diff_Month=Diff_Month+((MoneyF_AA/30)*AmountAA*(DateDiff("d", DateAdd("m", Different, StartDate), EndDate)+1) + (MoneyF_A/30)*AmountA*(DateDiff("d", DateAdd("m", Different, StartDate), EndDate)+1) + (MoneyF_B/30)*AmountB*(DateDiff("d", DateAdd("m", Different, StartDate), EndDate)+1) + (MoneyF_C/30)*AmountC*(DateDiff("d", DateAdd("m", Different, StartDate), EndDate)+1))
end if

'如果相差大于一个月且>=15天
if DateDiff("d", DateAdd("m", Different, StartDate), EndDate)>=15 then
Diff_Month=(MoneyF_AA*AmountAA + MoneyF_A*AmountA + MoneyF_B*AmountB + MoneyF_C*AmountC)*(Different+1)
end if
end if
end function
%>


关键词:计算合同内各级别的价格函数




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版