Really need HELP from a GURU

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Really need HELP from a GURU

    Hi I'm trying to get a page working that calculates the
    total cost of a product by adding a percentage tax amount
    and subtracting a discount or not as the case maybe.

    I have a form which the user enters the
    - Discription
    - number of units,
    - discount in %,
    - unit cost

    The user can then add as meny items as they require:

    EG:
    (Item1)
    Discription = Tree (tmprs("Desc"))
    Unit = 1 (tmprs("Quantity"))
    Discount = 20% (tmprs("Disc"))
    Unit Cost = 100 (tmprs("UnitCost"))

    (Item2)
    Discription = Computer (tmprs("Desc"))
    Unit = 1 (tmprs("Quantity"))
    Discount = 10% (tmprs("Disc"))
    Unit Cost = 1000 (tmprs("UnitCost"))

    I don't know how to get a value I require??? I want to
    get the total discount from this info.

    I tried the code shown below, but it doesn't work for the
    example shown above I get the following result:

    totaldisc = 330 and it should be 120

    Can someone please, please help I don't get it!

    Thanks

    ...:: CODE ::..

    if not (tmprs.eof and tmprs.bof) then
    tmprs.movefirst
    totalcost = 0
    totaldisc = 0
    grandtotal = 0
    while not tmprs.eof
    'response.write (tmprs("disc"))
    totalcost = totalcost + (tmprs("Quantity") * tmprs
    ("UnitCost"))
    'There is a big problem with adding discounts together
    totaldisc = (totalcost / 100 * (totaldisc + (tmprs
    ("disc"))))
    tmprs.movenext
    wend


    MyaTiX Guest

  2. Similar Questions and Discussions

    1. Is there a Mac / Flash guru out there?
      Hi all, I've searched and posted at Mozilla forums, I've searched and posted at Mac forums, but this problem I have seems to be unique and it...
    2. Flash Guru needed
      Interactive promotions company is seeking an experienced Flash Guru. The following describes the ideal candidate: Proficiency in all areas of...
    3. Looking for Contribute Guru
      I have been conducting a tool evaluation of Contribute and a number of other Web Content Management / Web Publishing tools for a work related...
    4. Gradiant Guru - where r u?
      I really don't know if this is possible in any version of Illustrator but I would like to keep this vector if possible. Checkout the logo my client...
    5. Control Guru Needed
      I am having a hard time with setting a property on a custom server control that i am placing in a repeater. The control inherits from...
  3. #2

    Default Re: Really need HELP from a GURU

    If I follow you, if I order 38 items that cost $983 each and I'm getting a
    13% discount (that I get to enter myself, nice!), the way to determine my
    discount is:

    iNumberOfItemsOrdered = 38
    sngCostOfItem = 983.00
    sngRaysDiscount = 0.13 '(13%)

    RaysDiscountedAmount = iNumberOfItemsOrdered * sngCostOfItem *
    sngRaysDiscount
    WhatRayPays = iNumberOfItemsOrdered * sngCostOfItem - RaysDiscountedAmount
    ''or
    WhatRayPays = iNumberOfItemsOrdered * sngCostOfItem * (1-sngRaysDiscount)



    Is that the part you're having problems with or is it some coding issue?

    Ray at work




    "MyaTiX" <anonymous@discussions.microsoft.com> wrote in message
    news:082f01c3c95a$b17f5ea0$a601280a@phx.gbl...
    > Hi I'm trying to get a page working that calculates the
    > total cost of a product by adding a percentage tax amount
    > and subtracting a discount or not as the case maybe.
    >
    > I have a form which the user enters the
    > - Discription
    > - number of units,
    > - discount in %,
    > - unit cost
    >
    > The user can then add as meny items as they require:
    >
    > EG:
    > (Item1)
    > Discription = Tree (tmprs("Desc"))
    > Unit = 1 (tmprs("Quantity"))
    > Discount = 20% (tmprs("Disc"))
    > Unit Cost = 100 (tmprs("UnitCost"))
    >
    > (Item2)
    > Discription = Computer (tmprs("Desc"))
    > Unit = 1 (tmprs("Quantity"))
    > Discount = 10% (tmprs("Disc"))
    > Unit Cost = 1000 (tmprs("UnitCost"))
    >
    > I don't know how to get a value I require??? I want to
    > get the total discount from this info.
    >
    > I tried the code shown below, but it doesn't work for the
    > example shown above I get the following result:
    >
    > totaldisc = 330 and it should be 120
    >
    > Can someone please, please help I don't get it!
    >
    > Thanks
    >
    > ..:: CODE ::..
    >
    > if not (tmprs.eof and tmprs.bof) then
    > tmprs.movefirst
    > totalcost = 0
    > totaldisc = 0
    > grandtotal = 0
    > while not tmprs.eof
    > 'response.write (tmprs("disc"))
    > totalcost = totalcost + (tmprs("Quantity") * tmprs
    > ("UnitCost"))
    > 'There is a big problem with adding discounts together
    > totaldisc = (totalcost / 100 * (totaldisc + (tmprs
    > ("disc"))))
    > tmprs.movenext
    > wend
    >
    >

    Ray at Guest

  4. #3

    Default Re: Really need HELP from a GURU

    OK, that is fine but the percentage discount value in the
    database is stored as 20 not 0.2 how do I convert the 20
    to 0.2

    The other problem is it is quite normal to have 2 items
    of different things like shown in my first email so how
    do I add the two discounts together in the asp code to
    give me a sensiable result.


    Check out my first example about the tree and the
    computer!

    I'm not sure how the code should look when in a loop like
    this???

    ....:: CODE ::..

    if not (tmprs.eof and tmprs.bof) then
    tmprs.movefirst
    totalcost = 0
    totaldisc = 0
    grandtotal = 0
    while not tmprs.eof
    'response.write (tmprs("disc"))
    totalcost = totalcost + (tmprs("Quantity") * tmprs
    ("UnitCost"))
    'There is a big problem with adding discounts together
    totaldisc = (totalcost / 100 * (totaldisc + (tmprs
    ("disc"))))
    tmprs.movenext
    wend


    >-----Original Message-----
    >If I follow you, if I order 38 items that cost $983 each
    and I'm getting a
    >13% discount (that I get to enter myself, nice!), the
    way to determine my
    >discount is:
    >
    >iNumberOfItemsOrdered = 38
    >sngCostOfItem = 983.00
    >sngRaysDiscount = 0.13 '(13%)
    >
    >RaysDiscountedAmount = iNumberOfItemsOrdered *
    sngCostOfItem *
    >sngRaysDiscount
    >WhatRayPays = iNumberOfItemsOrdered * sngCostOfItem -
    RaysDiscountedAmount
    >''or
    >WhatRayPays = iNumberOfItemsOrdered * sngCostOfItem * (1-
    sngRaysDiscount)
    >
    >
    >
    >Is that the part you're having problems with or is it
    some coding issue?
    >
    >Ray at work
    Guest

  5. #4

    Default Re: Really need HELP from a GURU


    <anonymous@discussions.microsoft.com> wrote in message
    news:08a701c3c960$cf5df2f0$a501280a@phx.gbl...
    > OK, that is fine but the percentage discount value in the
    > database is stored as 20 not 0.2 how do I convert the 20
    > to 0.2
    Divide your database value by 100.

    >
    > The other problem is it is quite normal to have 2 items
    > of different things like shown in my first email so how
    > do I add the two discounts together in the asp code to
    > give me a sensiable result.
    >
    I suggest creating a function to simplify things. Do you want the DISCOUNT
    amount or the net total that the person will pay? I'm going to assume you
    want the total discount that a person will get, as that seems to be what
    you're leaning toward.



    Function ReturnDiscount(ItemCost, NumberOfItems, DiscountAmount)
    '''This function assumes that
    '''DiscountAmount is between 0 and 100, not 0.00 and 1.00
    DiscountAmount = DiscountAmount / 100
    ReturnDiscount = ItemCost * NumberOfItems * DiscountAmount
    End Function




    if not tmprs.eof then
    totalcost = 0
    totaldisc = 0
    grandtotal = 0



    while not tmprs.eof
    'response.write (tmprs("disc"))
    iQuantity = tmprs("Quantity")
    sngDiscount = tmprs("disc")
    sngCost = tmprs("UnitCost")

    grandtotal = grandtotal + ReturnDiscount(sngCost, iQuantity,
    sngDiscount)

    tmprs.movenext
    wend

    Response.Write "This customer saved $" & FormatNumber(grandtotal)


    Break things out into smaller pieces when you can't get something working,
    and then when you have it working, put it back together into one big chunk
    if that's how you want it.

    Ray at work



    >
    > Check out my first example about the tree and the
    > computer!
    >
    > I'm not sure how the code should look when in a loop like
    > this???
    >
    > ...:: CODE ::..
    >
    > if not (tmprs.eof and tmprs.bof) then
    > tmprs.movefirst
    > totalcost = 0
    > totaldisc = 0
    > grandtotal = 0
    > while not tmprs.eof
    > 'response.write (tmprs("disc"))
    > totalcost = totalcost + (tmprs("Quantity") * tmprs
    > ("UnitCost"))
    > 'There is a big problem with adding discounts together
    > totaldisc = (totalcost / 100 * (totaldisc + (tmprs
    > ("disc"))))
    > tmprs.movenext
    > wend
    >
    >
    >
    > >-----Original Message-----
    > >If I follow you, if I order 38 items that cost $983 each
    > and I'm getting a
    > >13% discount (that I get to enter myself, nice!), the
    > way to determine my
    > >discount is:
    > >
    > >iNumberOfItemsOrdered = 38
    > >sngCostOfItem = 983.00
    > >sngRaysDiscount = 0.13 '(13%)
    > >
    > >RaysDiscountedAmount = iNumberOfItemsOrdered *
    > sngCostOfItem *
    > >sngRaysDiscount
    > >WhatRayPays = iNumberOfItemsOrdered * sngCostOfItem -
    > RaysDiscountedAmount
    > >''or
    > >WhatRayPays = iNumberOfItemsOrdered * sngCostOfItem * (1-
    > sngRaysDiscount)
    > >
    > >
    > >
    > >Is that the part you're having problems with or is it
    > some coding issue?
    > >
    > >Ray at work
    >

    Ray at Guest

  6. #5

    Default Re: Really need HELP from a GURU

    Thank you very much!

    That worked great.

    but now the my next piece of code doesn't work???

    ...::CODE::..

    Response.Write "This customer saved $" & FormatNumber
    (grandtotal)

    totaltax = ((totalcost-totaldisc)/100) * TaxAmount
    grandtotal = (totalcost + totaltax + numchk(rs
    ("ShipCost")) + numchk(rs("SurCharge"))) - totaldisc
    'error correction
    'On Error Resume Next
    usgrandtotal = ((totalcost/exrate) + (totaltax/exrate) +
    (numchk(rs("ShipCost")/exrate)) + (numchk(rs
    ("SurCharge")/exrate))) - (totaldisc/exrate)
    If Err.Number <> 0 Then

    Else
    MyaTiX Guest

  7. #6

    Default Re: Really need HELP from a GURU

    "MyaTiX" <anonymous@discussions.microsoft.com> wrote in message
    news:0a1a01c3c969$bd4e24f0$a301280a@phx.gbl...
    > Thank you very much!
    >
    > That worked great.
    >
    > but now the my next piece of code doesn't work???
    >
    > ..::CODE::..
    >
    > Response.Write "This customer saved $" & FormatNumber
    > (grandtotal)
    >
    > totaltax = ((totalcost-totaldisc)/100) * TaxAmount
    > grandtotal = (totalcost + totaltax + numchk(rs
    > ("ShipCost")) + numchk(rs("SurCharge"))) - totaldisc
    > 'error correction
    > 'On Error Resume Next
    > usgrandtotal = ((totalcost/exrate) + (totaltax/exrate) +
    > (numchk(rs("ShipCost")/exrate)) + (numchk(rs
    > ("SurCharge")/exrate))) - (totaldisc/exrate)
    > If Err.Number <> 0 Then
    >
    > Else

    "doesn't work" ... could you be more specific?

    What does "numchk()" do?


    Your may want to add ",2" to your first line; as in:

    Response.Write "This customer saved $" & FormatNumber(grandtotal,2)

    to show the pennies.


    McKirahan Guest

  8. #7

    Default Re: Really need HELP from a GURU

    What doesn't work?

    Ray at work

    "MyaTiX" <anonymous@discussions.microsoft.com> wrote in message
    news:0a1a01c3c969$bd4e24f0$a301280a@phx.gbl...
    > Thank you very much!
    >
    > That worked great.
    >
    > but now the my next piece of code doesn't work???
    >
    > ..::CODE::..
    >
    > Response.Write "This customer saved $" & FormatNumber
    > (grandtotal)
    >
    > totaltax = ((totalcost-totaldisc)/100) * TaxAmount
    > grandtotal = (totalcost + totaltax + numchk(rs
    > ("ShipCost")) + numchk(rs("SurCharge"))) - totaldisc
    > 'error correction
    > 'On Error Resume Next
    > usgrandtotal = ((totalcost/exrate) + (totaltax/exrate) +
    > (numchk(rs("ShipCost")/exrate)) + (numchk(rs
    > ("SurCharge")/exrate))) - (totaldisc/exrate)
    > If Err.Number <> 0 Then
    >
    > Else

    Ray at Guest

  9. #8

    Default Re: Really need HELP from a GURU

    percentageDiscount = percentageDiscount/100

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    ************************************************** ********************
    Think Outside the Box!
    ************************************************** ********************
    <anonymous@discussions.microsoft.com> wrote in message
    news:08a701c3c960$cf5df2f0$a501280a@phx.gbl...
    > OK, that is fine but the percentage discount value in the
    > database is stored as 20 not 0.2 how do I convert the 20
    > to 0.2
    >
    > The other problem is it is quite normal to have 2 items
    > of different things like shown in my first email so how
    > do I add the two discounts together in the asp code to
    > give me a sensiable result.
    >
    >
    > Check out my first example about the tree and the
    > computer!
    >
    > I'm not sure how the code should look when in a loop like
    > this???
    >
    > ...:: CODE ::..
    >
    > if not (tmprs.eof and tmprs.bof) then
    > tmprs.movefirst
    > totalcost = 0
    > totaldisc = 0
    > grandtotal = 0
    > while not tmprs.eof
    > 'response.write (tmprs("disc"))
    > totalcost = totalcost + (tmprs("Quantity") * tmprs
    > ("UnitCost"))
    > 'There is a big problem with adding discounts together
    > totaldisc = (totalcost / 100 * (totaldisc + (tmprs
    > ("disc"))))
    > tmprs.movenext
    > wend
    >
    >
    >
    > >-----Original Message-----
    > >If I follow you, if I order 38 items that cost $983 each
    > and I'm getting a
    > >13% discount (that I get to enter myself, nice!), the
    > way to determine my
    > >discount is:
    > >
    > >iNumberOfItemsOrdered = 38
    > >sngCostOfItem = 983.00
    > >sngRaysDiscount = 0.13 '(13%)
    > >
    > >RaysDiscountedAmount = iNumberOfItemsOrdered *
    > sngCostOfItem *
    > >sngRaysDiscount
    > >WhatRayPays = iNumberOfItemsOrdered * sngCostOfItem -
    > RaysDiscountedAmount
    > >''or
    > >WhatRayPays = iNumberOfItemsOrdered * sngCostOfItem * (1-
    > sngRaysDiscount)
    > >
    > >
    > >
    > >Is that the part you're having problems with or is it
    > some coding issue?
    > >
    > >Ray at work
    >

    Cowboy \(Gregory A. Beamer\) Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139