473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Best Way to do this

TG
I am trying to figure out how to code for this scenario:

WebFedExZones

WebFedExZoneID int
FedExZone int can have nulls which indicates we cannot
ship there
ZipCodeStart varchar(3)
ZipCodeEnd Varchar(3)
WebFedExRates

WebFedExRateID int
Weight int
FedExZone int corresponds to the FedExZone in WebFexExZones

ShippingCharge money

We only ship to Zones 2 – 8.

To encapsulate this, we need a new class with one function to
determine the shipping charge given a zip code and weight.

This Has to be done in a vb class for asp.net
Nov 18 '05 #1
1 846
Hi,

First: two db design advices:
1. Don't use null for FedExZone to which you don't ship - use 0 or -1
instead.
2. Change ZipCodeStart and ZipCodeEnd to smallint - there are no "less than"
or "bigger than" comparisons on strings (or varchar values in the db for
that matter).

Then you will have to query the DB 2 times:
1. First, you will need to divide (integer division) the zip code for the
dellivery by 100 to get the first 3 digits. Then the select will look like
this:

SELECT FedExZone FROM WebFedExZones WHERE (ZipCodeStart <= @zip AND
ZipCodeEnd >= @zip)

If the FedExZone is ok continue, else return that the shipment isn't
possible.

2. Now you should find the money which the client should pay for the weight.
As I don't know what your WebFedExRates table's entries look like, I presume
the following table:

ID Wgt Zone Charge
1 0 2 10
2 10 2 16
3 20 2 19
4 30 2 21
5 40 2 23
6 50 2 25
................................

I also presume that for package with weight of 8 the client should pay the
price for 0, for 15 - the price of 10, etc. So:

SELECT * FROM WebFedExRates WHERE FedExZone = @zone AND Weight = (SELECT
MAX(Weight) FROM WebFedExRates WHERE FedExZone = @zone AND Weight <= @wgt)

Hope this helps
Martin
"TG" <tj*******@hotmail.com> wrote in message
news:48**************************@posting.google.c om...
I am trying to figure out how to code for this scenario:

WebFedExZones

WebFedExZoneID int
FedExZone int can have nulls which indicates we cannot
ship there
ZipCodeStart varchar(3)
ZipCodeEnd Varchar(3)
WebFedExRates

WebFedExRateID int
Weight int
FedExZone int corresponds to the FedExZone in WebFexExZones

ShippingCharge money

We only ship to Zones 2 - 8.

To encapsulate this, we need a new class with one function to
determine the shipping charge given a zip code and weight.

This Has to be done in a vb class for asp.net

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
3
by: Irene | last post by:
Hi all, I have set up a simple VB program (and later on an ASP interface) to manage an Athletics database. I'm using Access 2000. To simplify, I have the Athlets, the Competitions and the...
5
by: l.woods | last post by:
I want your recommendation on which ASP.NET Shopping Cart software I should buy? Best code Best documentation Best support (if needed. I will buying source code, if possible) TIA, Larry...
24
by: Earl | last post by:
I have all of my data operations in a separate library, so I'm looking for what might be termed "best practices" on a return type from those classes. For example, let's say I send an update from...
9
by: =?Utf-8?B?QW1tZXI=?= | last post by:
I've read many incomplete opinions about the "Best Practice" for securely accessing SQL but what I really need to find the "Best Practice" that fits my applications needs. Currently (alpha...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.