protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { string id = e.CommandArgument.ToString(); if (e.CommandName == "Delete")//删除数据 { Users_Bll.DeleteList(id); if (Appraise_Bll.GetRecordCount("UserID='" + id + "'") != 0) { Appraise_Bll.DeleteList2(id); } if (ShoppingCart_Bll.GetRecordCount("UserID='" + id + "'") != 0) { ShoppingCart_Bll.DeleteList2(id); } if (OrderDetail_Bll.GetRecordCount("UserID='" + id + "'") != 0) { OrderDetail_Bll.DeleteList2(id); } if (Orders_Bll.GetRecordCount("UserID='" + id + "'") != 0) { Orders_Bll.DeleteList2(id); } RadGrid1.Rebind(); } }
protected void RadLV_splb_ItemCommand(object sender, Telerik.Web.UI.RadListViewCommandEventArgs e) { string Collectid = e.CommandArgument.ToString(); if (e.CommandName == "Delete") { string AppriseID1; AppriseID1 = e.CommandArgument.ToString(); Appraise_Bll.DeleteList(e.CommandArgument.ToString()); RadLV_splb.Rebind();//删除 } if (e.CommandName == "Join") { string CommodityID1; CommodityID1 = e.CommandArgument.ToString(); Maticsoft.Model.Commodity modelCommodity = Commodity_Bll.GetModel(CommodityID1.ToString()); if (ShoppingCart_Bll.GetRecordCount(" CommodityID='" + CommodityID1 + "' and UserID='" + UsersInfo.UserID + "' ") > 0) { Maticsoft.Model.ShoppingCart modelShoppingCart = ShoppingCart_Bll.GetModel(CommodityID1.ToString()); string id = ShoppingCart_Bll.GetList(" CommodityID='" + CommodityID1 + "' and UserID='" + UsersInfo.UserID + "' ").Tables[0].Rows[0]["ShoppingCartID"].ToString(); modelShoppingCart = ShoppingCart_Bll.GetModel(id); modelShoppingCart.ShoppingCartID = modelShoppingCart.ShoppingCartID; modelShoppingCart.UserID = UsersInfo.UserID; modelShoppingCart.CommodityID = modelCommodity.CommodityID; modelShoppingCart.OrderNumber = modelShoppingCart.OrderNumber + 1; if (modelShoppingCart.OrderNumber > modelCommodity.Stock) { RadAjaxManager1.Alert("库存不足!"); return; } ShoppingCart_Bll.Update(modelShoppingCart); } else { Maticsoft.Model.Users modelusers = Users_Bll.GetModel(UsersInfo.UserID); decimal discount1; if (modelusers.UserGrade == "VIP") { discount1 = Convert.ToDecimal(0.95); } else { discount1 = Convert.ToDecimal(1); } ShoppingCart_Mol.ShoppingCartID = DateTime.Now.ToString("yyyyMMddhhmmss"); ShoppingCart_Mol.UserID = UsersInfo.UserID; ShoppingCart_Mol.CommodityID = CommodityID1; ShoppingCart_Mol.OrderNumber = 1; ShoppingCart_Mol.Subtotal = ((ShoppingCart_Mol.OrderNumber * modelCommodity.VIPPrice) * discount1).ToString(); ShoppingCart_Bll.Add(ShoppingCart_Mol); } RadAjaxManager1.Alert("已添加到购物车!"); } }
protected void Button1_Click(object sender, EventArgs e) { //if (UsersInfo.UserID == "") //{ // Response.Write("<script> alert('请先登录!'); window.location.href='../Login.aspx' </script>"); // return; //} decimal discount; Commodity_Mol = Commodity_Bll.GetModel(Request.QueryString["ID"].ToString()); if (UsersInfo.UserID == "") { discount = Convert.ToDecimal(1); ShoppingItem ShoppingItem = new ShoppingItem(); if (ShoppingCar.ShoppingList.Where(x => x.CommodityID == Request.QueryString["ID"].ToString()).Count() > 0) //判断是否购买商品 { ShoppingItem = ShoppingCar.ShoppingList.Where(x => x.CommodityID == Request.QueryString["ID"].ToString()).SingleOrDefault(); //获取ID if (Commoditynum.Text == "") { RadAjaxManager1.Alert("请输入数量!"); return; } int goodsnum = ShoppingItem.OrderNumber + Convert.ToInt32(Commoditynum.Text);//数量 if (goodsnum > Commodity_Mol.Stock) { RadAjaxManager1.Alert("库存不足!"); return; } ShoppingItem.CommodityID = Request.QueryString["ID"].ToString(); //商品ID ShoppingItem.CommodityImage = Commodity_Mol.CommodityImage; //商品图片 ShoppingItem.CommodityName = Commodity_Mol.CommodityName; //商品名称 ShoppingItem.VIPPrice = Convert.ToDecimal(Commodity_Mol.VIPPrice); //商品会员价 ShoppingItem.Subtotal = goodsnum * Convert.ToDecimal(Commodity_Mol.VIPPrice) * discount; //商品小计 //ShoppingCar.ShoppingList.Remove(ShoppingCar.ShoppingList.Where(x => x.CommodityID == Request.QueryString["ID"].ToString()).SingleOrDefault());//移除 //ShoppingCar.ShoppingList.Add(ShoppingItem); RadAjaxManager1.Alert("已加入购物车!"); } else { discount = Convert.ToDecimal(1); ShoppingItem.ShoppingCartID = DateTime.Now.ToString("yyyyMMddHHmmssms");//购物车ID if (Commoditynum.Text == "") { RadAjaxManager1.Alert("请输入数量!"); return; } ShoppingItem.OrderNumber = Convert.ToInt32(Commoditynum.Text);//购物车数量 if (ShoppingItem.OrderNumber > Commodity_Mol.Stock) { RadAjaxManager1.Alert("库存不足!"); return; } ShoppingItem.CommodityID = Request.QueryString["ID"].ToString(); //商品ID ShoppingItem.CommodityImage = Commodity_Mol.CommodityImage; //商品图片 ShoppingItem.CommodityName = Commodity_Mol.CommodityName; //商品名称 ShoppingItem.VIPPrice = Convert.ToDecimal(Commodity_Mol.VIPPrice); //商品会员价 ShoppingItem.Subtotal = Convert.ToDecimal(Commoditynum.Text) * Convert.ToDecimal(Commodity_Mol.VIPPrice) * discount; //商品小计 ShoppingCar.ShoppingList.Add(ShoppingItem); //添加 RadAjaxManager1.Alert("添加成功!"); return; } } else { Maticsoft.Model.Users modelusers = Users_Bll.GetModel(UsersInfo.UserID); decimal discount1; if (modelusers.UserGrade == "VIP") { discount1 = Convert.ToDecimal(0.95); } else { discount1 = Convert.ToDecimal(1); } if (num > Convert.ToInt32(Label7.Text)) { RadAjaxManager1.Alert("数量不能超过库存!"); return; } if (ShoppingCart_Bll.GetRecordCount(" CommodityID='" + Request.QueryString["ID"] + "' and UserID='" + UsersInfo.UserID + "' ") > 0) { Maticsoft.Model.Commodity modelCommodity = Commodity_Bll.GetModel(Request.QueryString["ID"].ToString()); Maticsoft.Model.ShoppingCart modelShoppingCart = ShoppingCart_Bll.GetModel(Request.QueryString["ID"].ToString()); string id = ShoppingCart_Bll.GetList(" CommodityID='" + Request.QueryString["ID"] + "' and UserID='" + UsersInfo.UserID + "' ").Tables[0].Rows[0]["ShoppingCartID"].ToString(); ShoppingCart_Mol = ShoppingCart_Bll.GetModel(id); ShoppingCart_Mol.ShoppingCartID = ShoppingCart_Mol.ShoppingCartID; ShoppingCart_Mol.UserID = UsersInfo.UserID; ShoppingCart_Mol.CommodityID = modelCommodity.CommodityID; if (Commoditynum.Text == "") { RadAjaxManager1.Alert("请输入数量!"); return; } ShoppingCart_Mol.OrderNumber = Convert.ToInt32(Commoditynum.Text) + ShoppingCart_Mol.OrderNumber; if (ShoppingCart_Mol.OrderNumber > modelCommodity.Stock) { RadAjaxManager1.Alert("库存不足!"); return; } ShoppingCart_Mol.Subtotal = (ShoppingCart_Mol.OrderNumber * Convert.ToInt32(modelCommodity.VIPPrice) * discount1).ToString();//商品小计 ShoppingCart_Bll.Update(ShoppingCart_Mol); } else { Maticsoft.Model.Commodity modelCommodity = Commodity_Bll.GetModel(Request.QueryString["ID"].ToString()); ShoppingCart_Mol.ShoppingCartID = DateTime.Now.ToString("yyyyMMddhhmmss"); ShoppingCart_Mol.UserID = UsersInfo.UserID; ShoppingCart_Mol.CommodityID = Request.QueryString["ID"]; ShoppingCart_Mol.OrderNumber = Convert.ToInt32(Commoditynum.Text); ShoppingCart_Mol.Subtotal = (Convert.ToInt32(Commoditynum.Text) * Convert.ToInt32(modelCommodity.VIPPrice) * discount1).ToString();//商品小计 ShoppingCart_Mol.OrderNumber = Convert.ToInt32(Commoditynum.Text); if (ShoppingCart_Mol.OrderNumber > modelCommodity.Stock) { RadAjaxManager1.Alert("库存不足!"); return; } ShoppingCart_Bll.Add(ShoppingCart_Mol); } RadAjaxManager1.Alert("已添加到购物车!"); } }
protected void Button1_Click(object sender, EventArgs e) { string username = "******"; Regex rxusername = new Regex(username); Label1.Text = ""; Label2.Text = ""; Label3.Text = ""; if (RadTextBox1.Text == "") { Label1.Text = "账户不能为空"; Label1.Visible = true; return; } if (RadTextBox3.Text == "") { Label2.Text = "密码不能为空"; Label2.Visible = true; return; } if (RadTextBox2.Text == "") { Label3.Text = "验证码不能为空"; Label3.Visible = true; return; } if (!rxusername.IsMatch(RadTextBox1.Text)) { Label1.Text = "账户格式错误"; Label1.Visible = true; return; } if (User_Bll.GetRecordCount(" Username='******' ") == 0) { Label1.Text = "该账户不存在"; Label1.Visible = true; return; } if (!rxusername.IsMatch(RadTextBox3.Text)) { Label1.Text = "密码格式错误"; Label1.Visible = true; return; } if (User_Bll.GetRecordCount(" Username='******' and UserPassword='******'") == 0) { Label2.Text = "密码错误"; Label2.Visible = true; return; } if (Session["CheckCode"].ToString().ToLower() != RadTextBox2.Text.ToLower()) { Label3.Text = "验证码错误"; Label3.Visible = true; return; } DataSet ds = User_Bll.GetList(" Username='******' "); UsersInfo.UserID = ds.Tables[0].Rows[0]["UserID"].ToString(); UsersInfo.UserRole = ds.Tables[0].Rows[0]["UserIdentity"].ToString(); UsersInfo.UserName = ds.Tables[0].Rows[0]["Username"].ToString(); if (ds.Tables[0].Rows[0]["UserIdentity"].ToString() == "管理员") { RadAjaxManager1.Alert("该账户无效!"); RadTextBox1.Text = ""; RadTextBox2.Text = ""; RadTextBox3.Text = ""; return; } if (ShoppingCar.ShoppingList.Count != 0) { Users_Mol = User_Bll.GetModel(UsersInfo.UserID); decimal discount1; if (Users_Mol.UserGrade == "VIP") { discount1 = Convert.ToDecimal(0.95); } else { discount1 = Convert.ToDecimal(1); } if (ShoppingCar.ShoppingList.Count != 0) //泛型中有数据 { int i = 0; foreach (var item in ShoppingCar.ShoppingList) { Commodity_Mol = Commodity_Bll.GetModel(item.CommodityID); if (ShoppingCart_Bll.GetRecordCount(" UserID ='" + UsersInfo.UserID + "' and CommodityID ='" + item.CommodityID + "' ") != 0) { string basketid = ShoppingCart_Bll.GetList(" UserID ='" + UsersInfo.UserID + "' and CommodityID ='" + item.CommodityID + "' ").Tables[0].Rows[0]["ShoppingCartID"].ToString(); ShoppingCart_Mol = ShoppingCart_Bll.GetModel(basketid); ShoppingCart_Mol.OrderNumber = ShoppingCart_Mol.OrderNumber + item.OrderNumber; if (ShoppingCart_Mol.OrderNumber > Commodity_Mol.Stock) { ShoppingCart_Mol.OrderNumber = Commodity_Mol.Stock; } ShoppingCart_Mol.Subtotal = (Convert.ToDecimal(ShoppingCart_Mol.OrderNumber) * Convert.ToDecimal(item.VIPPrice) * discount1).ToString("F2"); ShoppingCart_Bll.Update(ShoppingCart_Mol); } else { ShoppingCart_Mol.ShoppingCartID = DateTime.Now.ToString("yyyyMMddHHmmss") + i.ToString(); i++; ShoppingCart_Mol.UserID = UsersInfo.UserID; ShoppingCart_Mol.CommodityID = item.CommodityID; ShoppingCart_Mol.OrderNumber = item.OrderNumber; if (ShoppingCart_Mol.OrderNumber > Commodity_Mol.Stock) { ShoppingCart_Mol.OrderNumber = Commodity_Mol.Stock; } ShoppingCart_Mol.Subtotal = (item.Subtotal * discount1).ToString("F2"); ShoppingCart_Bll.Add(ShoppingCart_Mol); } } ShoppingCar.ShoppingList.Clear(); } } Response.Redirect("HomePage.aspx"); }
protected void RadLV_splb_ItemCommand(object sender, Telerik.Web.UI.RadListViewCommandEventArgs e) { if (e.CommandName == "buy") { string CommodityID1; CommodityID1 = e.CommandArgument.ToString(); decimal discount1 = Convert.ToDecimal(1); Maticsoft.Model.Users modelusers = Users_Bll.GetModel(UsersInfo.UserID); Maticsoft.Model.Commodity Commoditymol = Commodity_Bll.GetModel(CommodityID1); if (UsersInfo.UserID == "") { ShoppingItem ShoppingItem = new ShoppingItem(); if (ShoppingCar.ShoppingList.Where(x => x.CommodityID == CommodityID1).Count() > 0) //判断是否购买商品 { ShoppingItem = ShoppingCar.ShoppingList.Where(x => x.CommodityID == CommodityID1).SingleOrDefault(); //获取ID ShoppingItem.CommodityID = CommodityID1; //商品ID ShoppingItem.CommodityImage = Commoditymol.CommodityImage; //商品图片 ShoppingItem.CommodityName = Commoditymol.CommodityName; //商品名称 ShoppingItem.VIPPrice = Convert.ToDecimal(Commoditymol.VIPPrice); //商品会员价 ShoppingItem.OrderNumber = ShoppingItem.OrderNumber + 1; //数量 if (ShoppingItem.OrderNumber > Commoditymol.Stock) { ShoppingItem.OrderNumber = Convert.ToInt32(Commoditymol.Stock); RadAjaxManager1.Alert("库存不足!"); return; } ShoppingItem.Subtotal = ShoppingItem.OrderNumber * Convert.ToDecimal(Commoditymol.VIPPrice) * discount1; //商品小计 ShoppingCar.ShoppingList.Remove(ShoppingCar.ShoppingList.Where(x => x.CommodityID == CommodityID1).SingleOrDefault()); //移除 ShoppingCar.ShoppingList.Add(ShoppingItem); RadAjaxManager1.Alert("已加入购物车!"); } else { ShoppingItem.ShoppingCartID = DateTime.Now.ToString("yyyyMMddHHmmssms"); //购物车ID ShoppingItem.CommodityID = CommodityID1; //商品ID ShoppingItem.CommodityImage = Commoditymol.CommodityImage; //商品图片 ShoppingItem.CommodityName = Commoditymol.CommodityName; //商品名称 ShoppingItem.VIPPrice = Convert.ToDecimal(Commoditymol.VIPPrice); //商品会员价 ShoppingItem.OrderNumber = 1; //商品数量 if (ShoppingItem.OrderNumber > Commoditymol.Stock) { RadAjaxManager1.Alert("库存不足!"); return; } ShoppingItem.Subtotal = Convert.ToDecimal(Commoditymol.VIPPrice) * discount1; //商品小计 ShoppingCar.ShoppingList.Add(ShoppingItem); //添加 RadAjaxManager1.Alert("添加成功!"); return; } } else if (ShoppingCart_Bll.GetRecordCount(" CommodityID='" + CommodityID1 + "' and UserID='" + UsersInfo.UserID + "' ") > 0) { if (modelusers.UserGrade == "VIP") { discount1 = Convert.ToDecimal(0.95); } else { discount1 = Convert.ToDecimal(1); } Maticsoft.Model.Commodity modelCommodity = Commodity_Bll.GetModel(CommodityID1); string id = ShoppingCart_Bll.GetList(" CommodityID='" + CommodityID1 + "' and UserID='" + UsersInfo.UserID + "' ").Tables[0].Rows[0]["ShoppingCartID"].ToString(); ShoppingCart_Mol = ShoppingCart_Bll.GetModel(id); ShoppingCart_Mol.ShoppingCartID = ShoppingCart_Mol.ShoppingCartID; ShoppingCart_Mol.UserID = UsersInfo.UserID; ShoppingCart_Mol.CommodityID = modelCommodity.CommodityID; ShoppingCart_Mol.OrderNumber = ShoppingCart_Mol.OrderNumber + 1; ShoppingCart_Mol.Subtotal = (Convert.ToInt32(modelCommodity.VIPPrice) * discount1).ToString();//商品小计 if (ShoppingCart_Mol.OrderNumber > modelCommodity.Stock) { Response.Write("<script>alert('库存不足!')</script>"); return; } ShoppingCart_Bll.Update(ShoppingCart_Mol); Response.Write("<script>alert('已添加到购物车!')</script>"); } else { Maticsoft.Model.Commodity modelCommodity = Commodity_Bll.GetModel(CommodityID1); ShoppingCart_Mol.ShoppingCartID = DateTime.Now.ToString("yyyyMMddhhmmss"); ShoppingCart_Mol.UserID = UsersInfo.UserID; ShoppingCart_Mol.CommodityID = e.CommandArgument.ToString(); ShoppingCart_Mol.OrderNumber = 1; ShoppingCart_Mol.Subtotal = (1 * Convert.ToInt32(modelCommodity.VIPPrice) * discount1).ToString();//商品小计 ShoppingCart_Bll.Add(ShoppingCart_Mol); Response.Write("<script>alert('已添加到购物车!')</script>"); } } }