ASP.NET - Shopping cart calculation

Asked By Vikas on 15-Dec-11 01:37 AM
I have a grid view and which contains the productname , price and the discount . Now i want that the Sales Tax and the Order discount is also shown according to its country and type of order . So how i implemented that.

How we implementes the Order discount menas we have to create a table in that or by any other type
Jitendra Faye replied to Vikas on 15-Dec-11 01:38 AM
Follow these links-

http://www.sitepoint.com/net-shopping-cart-datatables/
http://net.tutsplus.com/tutorials/other/build-a-shopping-cart-in-aspnet/
Riley K replied to Vikas on 15-Dec-11 01:47 AM


Try to place a dropdownlist populated with countries in one of the column

On the selectedindex changed you can populate your data

<asp:TemplateField>
 <ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>

You can populate the ddl like this

protected void grid1_RowDataBound(object sender, GridViewRowEventArgs e)
   {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
       string s2 = "select cname  from Country";
       SqlDataAdapter ada = new SqlDataAdapter(s2, con);
       DataSet ds = new DataSet();
       ada.Fill(ds);
       DropDownList ddl1 = (DropDownList)e.Row.FindControl("ddl1");
       ddl1.DataSource = ds;
       ddl1.DataTextField = "subDivisionName";
       ddl1.DataBind();
    }
   }


In the ddl changed event get the data

protected void ddl1_SelectedIndexChanged1(object sender,EventArgs e)
  {
     
  }


Regards
dipa ahuja replied to Vikas on 15-Dec-11 02:20 AM
That thing you have to decide as per your charges. How much you take as per the countries and how much discount you want to give to them.

Now easy way is to calculate it based on the "Total Amount" of their shopping items.

So to get the total you have to fire the query as :

"SELECT SUM(price) as Total from CART where userid=1;

Now this query will return the total amount of the usrs's shopping list.

Now you can calculate your discount and charges as per your need for ex:

TotalAmount = (TotalAmount + ShippingCharges) - Discount

Hope this info will help you!