62,242
社区成员




protected void Page_Load(object sender, EventArgs e)
{
if (Session["UserName"] == null)
{
//this.ClientScript.RegisterClientScriptBlock(this.GetType(), "key1", "alert('请先登录!')",true);
//Response.Redirect("~/index.aspx");
this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>if(confirm('您尚未登录,请登录后进行此操作!')){self.location='index.aspx';}</script>");
}
else
{
if (!IsPostBack)
{
Profile.shoplist.GetCartItem(Session["UserName"].ToString());
string DressId = Request.QueryString["DressId"];
int Num = Convert.ToInt32(Request.QueryString["num"]);
string size = Request.QueryString["size"];
if (!string.IsNullOrEmpty(DressId))
{
if (Session["flag"].ToString().Equals(""))
{
Profile.shoplist.Add(DressId, size, Num);
Session["flag"] = DressId;
}
}
BingCart(Profile.shoplist);
Profile.shoplist.SetCartItems(Session["UserName"].ToString());
Profile.Save();
}
}
}
public class DressItemInfo
{
string dressId;//服装编号
public string DressId
{
get { return dressId; }
set { dressId = value; }
}
string dressMerchant;//商家
public string DressMerchant
{
get { return dressMerchant; }
set { dressMerchant = value; }
}
decimal unitcost;//成本价
public decimal Unitcost
{
get { return unitcost; }
set { unitcost = value; }
}
decimal marketPrice;//市场价
public decimal MarketPrice
{
get { return marketPrice; }
set { marketPrice = value; }
}
decimal orignial;//吊牌价
public decimal Orignial
{
get { return orignial; }
set { orignial = value; }
}
string dressTitle;//商品标题
public string DressTitle
{
get { return dressTitle; }
set { dressTitle = value; }
}
string dressdetails;//商品介绍
public string Dressdetails
{
get { return dressdetails; }
set { dressdetails = value; }
}
string dressImage;//图片
public string DressImage
{
get { return dressImage; }
set { dressImage = value; }
}
int qty;//库存
public int Qty
{
get { return qty; }
set { qty = value; }
}
string size;//尺寸大小
public string Size
{
get { return size; }
set { size = value; }
}
int quantity;//购买数量
public int Quantity
{
get { return quantity; }
set { quantity = value; }
}
///<summary>
///默认构造
///</summary>
public DressItemInfo() { }
public DressItemInfo(int quantity) { this.quantity = quantity; }
///<summary>
///带参数构造
///</summary>
public DressItemInfo(string DressId, string DressMerchant, decimal Unitcost, decimal MarketPrice, decimal Orignial, string DressTitle, string Dressdetails, string DressImage, int Qty,string Size,int Quantiy)
{
this.dressId = DressId;
this.dressMerchant = DressMerchant;
this.unitcost = Unitcost;
this.marketPrice = MarketPrice;
this.orignial = Orignial;
this.dressTitle = DressTitle;
this.dressdetails = Dressdetails;
this.dressImage = DressImage;
this.qty = Qty;
this.size = Size;
this.quantity = Quantiy;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int num = 4;
DressItemInfo item = new DressItemInfo(num);
Console.WriteLine("Quantity value:" + item.Quantity);
Console.Read();
}
}
public class DressItemInfo
{
string dressId;//服装编号
public string DressId
{
get { return dressId; }
set { dressId = value; }
}
string dressMerchant;//商家
public string DressMerchant
{
get { return dressMerchant; }
set { dressMerchant = value; }
}
decimal unitcost;//成本价
public decimal Unitcost
{
get { return unitcost; }
set { unitcost = value; }
}
decimal marketPrice;//市场价
public decimal MarketPrice
{
get { return marketPrice; }
set { marketPrice = value; }
}
decimal orignial;//吊牌价
public decimal Orignial
{
get { return orignial; }
set { orignial = value; }
}
string dressTitle;//商品标题
public string DressTitle
{
get { return dressTitle; }
set { dressTitle = value; }
}
string dressdetails;//商品介绍
public string Dressdetails
{
get { return dressdetails; }
set { dressdetails = value; }
}
string dressImage;//图片
public string DressImage
{
get { return dressImage; }
set { dressImage = value; }
}
int qty;//库存
public int Qty
{
get { return qty; }
set { qty = value; }
}
string size;//尺寸大小
public string Size
{
get { return size; }
set { size = value; }
}
int quantity;//购买数量
public int Quantity
{
get { return quantity; }
set { quantity = value; }
}
///<summary>
///默认构造
///</summary>
public DressItemInfo() { }
public DressItemInfo(int quantity) { this.quantity = quantity; }
///<summary>
///带参数构造
///</summary>
public DressItemInfo(string DressId, string DressMerchant, decimal Unitcost, decimal MarketPrice, decimal Orignial, string DressTitle, string Dressdetails, string DressImage, int Qty, string Size, int Quantiy)
{
this.dressId = DressId;
this.dressMerchant = DressMerchant;
this.unitcost = Unitcost;
this.marketPrice = MarketPrice;
this.orignial = Orignial;
this.dressTitle = DressTitle;
this.dressdetails = Dressdetails;
this.dressImage = DressImage;
this.qty = Qty;
this.size = Size;
this.quantity = Quantiy;
}
}
}
提示不包含一个参数的方法,可能的问题:
未正确引用 类DressItemInfo ,例如程序中还有另一个 类DressItemInfo(未含带参的构造函数),
或者类DressItemInfo 在另一个项目中,但程序引用的DLL并未及时更新,导致 DressItemInfo 实例化时,并未得到具有带参构造函数的方法。
一句话:再仔细检查
DressItemInfo Info = new DressItemInfo(Num );
DressItemInfo类中 不是写着带参数的构造函数么:
public DressItemInfo(int quantity) { this.quantity = quantity; }
要么换一种:
DressItemInfo Info = new DressItemInfo();
Info.Quantity = Num ;