double: missing assembly referencemanquant référence assemblage
Salut tout le monde s'il vous plaît aidez-moi
mon fichier Shopping.cs est donné ci-dessous
using System;
using System.Data;
using MyWebsite.Commerce;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml.Serialization;
namespace MyWebsite.Commerce
{
[Serializable]
public class CartItem
{
private int _productID;
private string _productName;
private string _productURL;
private int _quantity;
private double _price;
private double _lineTotal;
public void New()
{
}
public void New(int ProductID, string ProductName, string ProductURL, int Quantity, double Price)
{
_productID = ProductID;
_productName = ProductName;
_productURL = ProductURL;
_quantity = Quantity;
_price = Price;
_lineTotal = Quantity * Price;
}
public int ProductID { get; set; }
public string ProductName { get; set; }
public string ProductURL { get; set; }
public int Quantity { get; set; }
public double Price { get; set; }
public double LineTotal { get; set; }
[Serializable]
public class ShoppingCart
{
private DateTime _dateCreated;
private DateTime _lastUpdate;
private List<CartItem> _items;
public ShoppingCart()
{
if (this._items = null)
{
this._items = new List<CartItem>();
this._dateCreated = DateTime.Now;
}
}
public List<CartItem> Items
{ get; set; }
public void Insert(int ProductID, string ProductName, string ProductURL, int Quantity, double Price)
{
int ItemIndex = ItemIndexOfID(ProductID);
if (ItemIndex == -1)
{
CartItem NewItem = new CartItem();
NewItem.ProductID = ProductID;
NewItem.ProductName = ProductName;
NewItem.ProductURL = ProductURL;
NewItem.Price = Price;
NewItem.Quantity = Quantity;
_items.Add(NewItem);
}
else
{
_items[ItemIndex].Quantity += 1;
}
_lastUpdate = DateTime.Now;
}
public void Update(int RowID, int ProductID, int Quantity, double Price)
{
CartItem Item = _items[RowID];
Item.ProductID = ProductID;
Item.Quantity = Quantity;
Item.Price = Price;
_lastUpdate = DateTime.Now;
}
public void DeleteItem(int rowID)
{
_items.RemoveAt(rowID);
_lastUpdate = DateTime.Now;
}
private int ItemIndexOfID(int ProductID)
{
int index = 0;
foreach (CartItem item in _items)
{
if (item.ProductID == ProductID)
{
return index;
}
index += 1;
}
return -1;
}
public double Total
{
get
{
double t = 0;
if (_items == null)
{
return 0;
}
foreach (CartItem Item in _items)
{
t += Item.LineTotal;
}
return t;
}
}
}
}
}
and then i create a web user control file ShoppingCart.ascx and ShoppingCart.ascx.cs file code are given below of ShoppingCart.ascx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using MyWebsite.Commerce;
public partial class ShoppingCart : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (Profile.Cart == null)
{
Profile.Cart = new MyWebsite.Commerce.ShoppingCart();
}
if (!Page.IsPostBack)
{
BindGrid();
}
if (Profile.Cart.Items == null)
{
TotalLabel.Visible = false;
}
}
protected void CartGrid_RowEditing(object sender, GridViewEditEventArgs e)
{
CartGrid.EditIndex = e.NewEditIndex;
BindGrid();
}
protected void CartGrid_RowUpdating(object sender, GridViewUpdatedEventArgs e)
{
TextBox QuantityTextBox = (TextBox)CartGrid.Rows[e.RowIndex].Cells[2].Controls[0];
int Quantity = Convert.ToString(QuantityTextBox.Text);
if (Quantity == 0)
{
Profile.Cart.Items.RemoveAt(e.RowIndaex);
}
else
{
Profile.Cart.Items[e.RowIndex].Quantity = Quantity;
}
CartGrid.EditIndex = -1;
BindGrid();
}
protected void CartGrid_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
CartGrid.EditIndex = -1;
BindGrid();
}
protected void CartGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
Profile.Cart.Items.RemoveAt(e.RowIndex);
BindGrid();
}
private void BindGrid()
{
CartGrid.DataSource = Profile.Cart.Items;
DataBind();
TotalLabel.Text = string.Format("Total : {0,19:c}", Profile.Cart.Total);
}
}
quand je fais glisser-déposer de fichiers ShoppingCart.ascx à ShoppingCartPage fichier .aspx et exécutez l'application le il y a une erreur s'est produite, quand j'ai cliqué sur l'erreur, je continue sur ce code ci-dessous
Description: Une erreur s'est produite lors de la compilation d'une ressource requise pour traiter cette demande. Veuillez vérifier les détails d'erreur spécifiques suivants et modifier votre code source de manière appropriée.
compilateur Message d'erreur: CS0234: L'espace de noms dans l' 'MyWebsite.Commerce' n'existe pas de type ou le nom namespace 'ShoppingCart' (vous manque une référence d'assemblage?)
Ligne 17 : public class ProfileCommon: System.Web.Profile.ProfileBase {ligne 18: ligne 19: virtuel public MyWebsite.Commerce.ShoppingCart panier { ligne 20: get {ligne 21:
retour ((Ma Website.Commerce.ShoppingCart) (this.GetPropertyValue ("Cart")));
s'il vous plaît aidez-moi ..................
vous avez posté la même question hier. – Shoban