26.1.11

Calling web service using jQuery in ASP.NET

Calling web service using jQuery in ASP.NET

http://codeasp.net/articles/asp-net/217/calling-web-service-using-jquery-in-asp-net

Introduction to WCF Service, remoting,webservice

http://beyondrelational.com/blogs/dinesh/archive/2010/07/11/introduction-to-wcf-service.aspx


ASP.NET and Ajax - using XmlHttpRequest

http://aspdotnetcodebook.blogspot.com/2009/04/aspnet-and-ajax-using-xmlhttprequest.html

Implement: Paging in Repeater or Datalist Control

http://codeasp.net/articles/asp-net/140/implement-paging-in-repeater-or-datalist-control

9.1.11

Add Cart

namespace Ecommerce.BLL
{
public class AddCart
{


public void BLL_AddItem( Products objBol)
{
ShoppingCart cart = new ShoppingCart();
String cartID = cart.GetShoppingCartId();
Int16 lintCartItemID = 0;

//Declare a datatable to be used as shopping cart
DataTable objDT;
DataRow objDR;

if (System.Web.HttpContext.Current.Session["SessionCart"] == null)
{
//Data table to be used as cart
objDT = new DataTable("Cart");

//Declaring Primary Key For Table
objDT.Columns.Add("ID", System.Type.GetType("System.Int32"));
DataColumn[] ldataColPK = new DataColumn[2];
ldataColPK[0] = objDT.Columns["ID"];
ldataColPK[0].AutoIncrement = true;
ldataColPK[0].AutoIncrementSeed = 1;
objDT.PrimaryKey = ldataColPK;

//Adding columns to datatable
objDT.Columns.Add("CartID", System.Type.GetType("System.String"));
objDT.Columns.Add("ProductID", System.Type.GetType("System.Int32"));
objDT.Columns.Add("Products_Name", System.Type.GetType("System.String"));
objDT.Columns.Add("Model", System.Type.GetType("System.String"));
objDT.Columns.Add("Size", System.Type.GetType("System.String"));
objDT.Columns.Add("Colour", System.Type.GetType("System.String"));
objDT.Columns.Add("ImageUrl", System.Type.GetType("System.String"));
objDT.Columns.Add("Price", System.Type.GetType("System.Double"));
objDT.Columns.Add("Description", System.Type.GetType("System.String"));
objDT.Columns.Add("Quantity", System.Type.GetType("System.Int32"));
objDT.Columns.Add("Stock", System.Type.GetType("System.Int32"));
objDT.Columns.Add("Amount", System.Type.GetType("System.Double"));
objDT.Columns["Amount"].Expression = "Price * Quantity";
}
else
{
objDT = (DataTable)System.Web.HttpContext.Current.Session["SessionCart"];
}

objDR = objDT.NewRow();
objDR["CartID"] = cartID;
objDR["ProductID"] = objBol.ProductsID;
objDR["Products_Name"] = objBol.Products_Name;
objDR["Model"] = objBol.Model;
objDR["Size"] = objBol.attributes_values_name;
objDR["Colour"] = objBol.Colour_name;
objDR["ImageUrl"] = objBol.Icon_image;
objDR["Price"] = objBol.Price;
objDR["Description"] = objBol.Products_Description;
objDR["Quantity"] = objBol.Quantity;
objDR["Stock"] = objBol.Stock;
System.Web.HttpContext.Current.Session["CartItemID"] = objDR["ID"].ToString();
lintCartItemID = Convert.ToInt16(objDR["ID"]);
objDT.Rows.Add(objDR);

//Add the datatable in a session variable
System.Web.HttpContext.Current.Session["SessionCart"] = objDT;

}
=======================================
shopping cart:

public String GetShoppingCartId()
{

// Obtain current HttpContext of ASP+ Request
System.Web.HttpContext context = System.Web.HttpContext.Current;

// If the user is authenticated, use their customerId as a permanent shopping cart id
if (context.User.Identity.Name != "")
{
return context.User.Identity.Name.ToString();
}

// If user is not authenticated, either fetch (or issue) a new temporary cartID
if (context.Request.Cookies["ASPNETCommerce_CartID"] != null)
{
return context.Request.Cookies["ASPNETCommerce_CartID"].Value;
}
else
{
// Generate a new random GUID using System.Guid Class
Guid tempCartId = Guid.NewGuid();

// Send tempCartId back to client as a cookie
context.Response.Cookies["ASPNETCommerce_CartID"].Value = tempCartId.ToString();

// Return tempCartId
return tempCartId.ToString();
}
}

Save Image as small, medium and large

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Drawing;
using System.Web.UI;
using System.Drawing.Imaging;


namespace Ecommerce.BLL
{
public class ImagesManager
{
///
/// This method is used to upload images according to height width
///

///
///
///
///
public void Bll_UploadImages(string FileName,int width, int height, string SaveName)
{

Bitmap oCounter;
Graphics oGraphics;
oCounter = new Bitmap(width ,height);
oGraphics = Graphics.FromImage(oCounter);
FileStream fs = new FileStream(FileName, FileMode.OpenOrCreate);
fs.ReadByte();
Bitmap objImage = new Bitmap(fs);
oGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
oGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
oGraphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
oGraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
oGraphics.DrawImage(objImage, 0, 0, width, height);
oCounter.Save(SaveName);
objImage.Dispose();
oCounter.Dispose();
fs.Dispose();
File.Delete(FileName);

}
}
}
================================================================
protected void imgSubmit_Click(object sender, ImageClickEventArgs e)
{

if (ViewState["ImageID"].ToString() == "")
{
objBol.Products_imageID = -1;
}
else
{
objBol.Products_imageID = Convert.ToInt32(ViewState["ImageID"]);
}
objBol.ProductsID = Convert.ToInt32(ViewState["ProductsID"]);
objBol.ColourID = Convert.ToInt32(DropColour.SelectedValue);
objBol.Colour_name = DropColour.SelectedItem.Text;
objBol.Icon_image = "";
objBol.Medium_image = "";
objBol.Large_image = "";
objBol.default_style = false;
int retval= objBll.BLL_InsUpdProductsImages (objBol);
if (retval > 0)
{
string strImagePath, strSavepath;

strImagePath = retval.ToString() + "1.jpg";
strSavepath = retval.ToString() + ".jpg";
if (ProductImageUpload .FileName != "")
{
// small icon
string strsmalliconPath = Server.MapPath("~/ProductsImages/Small/" + strImagePath);
string strsmalliconsavePath = Server.MapPath("~/ProductsImages/Small/" + strSavepath);
ProductImageUpload.SaveAs(strsmalliconPath);
objImg.Bll_UploadImages(strsmalliconPath, 50, 50, strsmalliconsavePath);
//icon image
string striconPath = Server.MapPath("~/ProductsImages/Icon/" + strImagePath);
string striconsavePath = Server.MapPath("~/ProductsImages/Icon/" + strSavepath);
ProductImageUpload.SaveAs(striconPath);
objImg.Bll_UploadImages(striconPath, 120, 120, striconsavePath);
//medium image
string strMediumPath = Server.MapPath("~/ProductsImages/Medium/" + strImagePath);
string strMediumsavePath = Server.MapPath("~/ProductsImages/Medium/" + strSavepath);
ProductImageUpload.SaveAs(strMediumPath);
objImg.Bll_UploadImages(strMediumPath,288, 360, strMediumsavePath);
//large image
string strLargePath = Server.MapPath("~/ProductsImages/Large/" + strImagePath);
string strLargesavePath = Server.MapPath("~/ProductsImages/Large/" + strSavepath);
ProductImageUpload.SaveAs(strLargePath);
objImg.Bll_UploadImages(strLargePath, 576, 720, strLargesavePath);
}
}
DisplayProductsImages();
ViewState["ImageID"] = "";
}