コード例 #1
0
ファイル: ForeOrdersDetail.aspx.cs プロジェクト: Jyf524/RunZe
 protected void Page_Load(object sender, EventArgs e)
 {
     if (UsersInfo.UserID == "")
     {
         Response.Write("<script> alert('请先登录!'); window.location.href='../Login.aspx' </script>");
         return;
     }
     if (!IsPostBack)
     {
         Maticsoft.Model.Users  molUsers  = Users_Bll.GetModel(UsersInfo.UserID);
         Maticsoft.Model.Orders molOrders = Orders_Bll.GetModel(Request.QueryString["OrderID"].ToString());
         RadTextBox1.Text = molUsers.UserRealName;
         RadTextBox2.Text = molUsers.Address1;
         ddlcityLoad(molUsers.Province);
         ddlcity.SelectedValue = molUsers.City;
         Score1 = Convert.ToInt32(molOrders.TotalMoney * 100);
         if (RadTextBox5.Text == "")
         {
             RadTextBox5.Text = "0";
         }
         if (Convert.ToInt32(Score1) > molUsers.UserScore)
         {
             Label1.Text = molUsers.UserScore.ToString();
         }
         else
         {
             Label1.Text = Score1.ToString();
         }
         RadTextBox4.Text = molUsers.Phone;
         RadDropDownList1.SelectedValue = "1";
         RadDropDownList2.SelectedValue = "1";
     }
 }
コード例 #2
0
        protected void RadListView1_ItemCommand(object sender, Telerik.Web.UI.RadListViewCommandEventArgs e)
        {
            string OrderID;

            OrderID = e.CommandArgument.ToString();
            Maticsoft.Model.Users molUsers = Users_Bll.GetModel(UsersInfo.UserID);
            if (e.CommandName == "Pay")
            {
                Response.Write("<script>window.location.href='/ForeManagement/ForeOrdersDetail.aspx?OrderID=" + OrderID + "'</script>");
            }
            if (e.CommandName == "Cancel")
            {
                Maticsoft.Model.Orders molOrders = Orders_Bll.GetModel(OrderID);
                molOrders.OrderState = "订单取消";
                Orders_Bll.Update(molOrders);
            }
            if (e.CommandName == "Hurry")
            {
                Response.Write("<script> alert('催单成功!')</script>");
            }
            if (e.CommandName == "Check")
            {
                Orders_Mol = Orders_Bll.GetModel(OrderID);//引用


                DataSet ds = new DataSet();
                ds        = Orders_Bll.GetList2(0, " a.OrderID='" + OrderID + "' ", " OrderDate");
                Users_Mol = Users_Bll.GetModel(UsersInfo.UserID);//引用
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    //增加销售数量
                    Commodity_Mol = Commodity_Bll.GetModel(dr["CommodityID"].ToString());
                    Commodity_Mol.CommoditySaled = Commodity_Mol.CommoditySaled + Convert.ToInt32(dr["OrderNumber"]);
                    Commodity_Bll.Update(Commodity_Mol);//更新
                    //增加积分点数
                    string str = dr["BuyScore"].ToString();
                    string shu = dr["OrderNumber"].ToString();
                    Users_Mol.UserScore += Convert.ToInt32(str) * Convert.ToInt32(shu);
                }
                Users_Mol.UserGrade   = "VIP";
                Orders_Mol.OrderState = "完成";
                Orders_Bll.Update(Orders_Mol); //更新
                Users_Bll.Update(Users_Mol);   //更新
                RadListView1.Rebind();



                Maticsoft.Model.Orders molOrders = Orders_Bll.GetModel(OrderID);
                //Maticsoft.Model.Commodity molCommodity = Commodity_Bll.GetModel(OrderID);
                //int total = Orders_Bll.GetTotal(OrderID);
                //molUsers.UserScore += total;
                //molOrders.OrderState = "完成";
                Orders_Bll.Update(molOrders);
            }
            if (e.CommandName == "Score")
            {
            }
        }
コード例 #3
0
ファイル: ChangePassword.aspx.cs プロジェクト: Jyf524/RunZe
        protected void Btn_Check_Click(object sender, EventArgs e)
        {
            Maticsoft.Model.Users modelnew = Users_Bll.GetModel(UsersInfo.UserID);//引用id所在行的数据
            string path = "^[a-zA-Z0-9_]{6,16}$";
            Regex  rx   = new Regex(path);

            if (RadTextBox1.Text == "")//判断是否为空
            {
                RadAjaxManager1.Alert("请输入原密码!");
            }
            else if (RadTextBox1.Text != modelnew.UserPassword)
            {
                RadAjaxManager1.Alert("原密码错误!");
            }
            else if (RadTextBox2.Text == modelnew.UserPassword)
            {
                RadAjaxManager1.Alert("不能与原密码相同!");
            }
            else if (RadTextBox2.Text == "")
            {
                RadAjaxManager1.Alert("请输入新密码!");
            }
            else if (!rx.IsMatch(RadTextBox2.Text))
            {
                RadTextBox2.Text = "";
                RadAjaxManager1.Alert("密码格式错误!");
            }
            else if (RadTextBox3.Text == "")
            {
                RadAjaxManager1.Alert("请确认密码!");
            }
            else if (RadTextBox2.Text != RadTextBox3.Text)
            {
                RadAjaxManager1.Alert("两次密码输入不一致!");
            }
            else
            {
                User_Model = Users_Bll.GetModel(UsersInfo.UserID);
                User_Model.UserPassword = RadTextBox3.Text; //添加数据
                Users_Bll.Update(User_Model);
                Response.Write("<script>alert('修改成功!');window.location.href='../Login.aspx'</script>");
            }
        }
コード例 #4
0
ファイル: ForeCollect.aspx.cs プロジェクト: Jyf524/RunZe
        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("已添加到购物车!");
            }
        }
コード例 #5
0
ファイル: Backyhxxxx.aspx.cs プロジェクト: Jyf524/RunZe
 protected void Page_Load(object sender, EventArgs e)
 {
     if (UsersInfo.UserID == "")
     {
         Response.Write("<script> alert('请先登录!'); window.location.href='/BackLogin.aspx' </script>");
         return;
     }
     if (!IsPostBack)
     {
         if (!String.IsNullOrEmpty(Request.QueryString["ID"]))
         {
             if (Request.QueryString["ID"] != null)
             {
                 Maticsoft.Model.Users modelnew = Users_Bll.GetModel(Request.QueryString["ID"].ToString()); //引用id所在行的数据
                 Label1.Text      = modelnew.Username;                                                      //添加数据
                 RadTextBox2.Text = modelnew.UserRealName;                                                  //添加数据
                 ddlcityLoad(modelnew.Province);
                 ddlcity.SelectedValue   = modelnew.City;
                 RadTextBox6.Text        = modelnew.Address1;//添加数据
                 RadNumericTextBox1.Text = modelnew.UserScore.ToString();
                 RadTextBox3.Text        = modelnew.UserEmail;
                 if (modelnew.UserSex == "男")
                 {
                     Rad_nan.Checked = true;
                 }
                 else
                 {
                     Rad_nv.Checked = true;
                 }
                 RadDatePicker1.SelectedDate    = modelnew.RegistTime;
                 RadDropDownList1.SelectedValue = modelnew.UserGrade.ToString();    //添加数据
             }
         }
         else
         {
             Response.Redirect("Backhygl.aspx");
         }
     }
 }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (UsersInfo.UserID == "")
            {
                Response.Write("<script> alert('请先登录!'); window.location.href='../Login.aspx' </script>");
                return;
            }

            if (!IsPostBack)
            {
                if (!String.IsNullOrEmpty(UsersInfo.UserID))
                {
                    if (UsersInfo.UserID != null)
                    {
                        Maticsoft.Model.Users modelnew = Users_Bll.GetModel(UsersInfo.UserID); //引用id所在行的数据
                        Label1.Text      = modelnew.Username;                                  //添加数据
                        RadTextBox2.Text = modelnew.UserRealName;                              //添加数据
                        ddlcityLoad(modelnew.Province);
                        ddlcity.SelectedValue = modelnew.City;
                        RadTextBox6.Text      = modelnew.Address1;//添加数据
                        RadTextBox3.Text      = modelnew.UserEmail;
                        if (modelnew.UserSex == "男")
                        {
                            Rad_nan.Checked = true;
                        }
                        else
                        {
                            Rad_nv.Checked = true;
                        }
                        Label2.Text = modelnew.RegistTime.ToString();
                        Label3.Text = modelnew.UserScore.ToString();
                    }
                }
                else
                {
                    Response.Redirect("~/HomePage.aspx");
                }
            }
        }
コード例 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            hidden();
            string UserID1;

            if (UsersInfo.UserID != "")
            {
                UserID1 = UsersInfo.UserID;
                Maticsoft.Model.Users modelUsers = Users_Bll.GetModel(UserID1);
                if (modelUsers.UserGrade == "VIP")
                {
                    Lbl_discount.Text = "0.95";
                }
                if (modelUsers.UserGrade == "会员")
                {
                    Lbl_discount.Text = "1";
                }
            }
            else
            {
                Lbl_discount.Text = "1";
            }
        }
コード例 #8
0
 private void ShowInfo(int Id)
 {
     Maticsoft.BLL.Users   bll   = new Maticsoft.BLL.Users();
     Maticsoft.Model.Users model = bll.GetModel(Id);
     this.lblId.Text           = model.Id.ToString();
     this.lblName.Text         = model.Name;
     this.txtPassword.Text     = model.Password;
     this.txtTrueName.Text     = model.TrueName;
     this.ddlSex.SelectedValue = model.Sex;
     this.txtPhone.Text        = model.Phone;
     //this.txtPhoto.Text=model.Photo;
     this.txtEmail.Text                = model.Email;
     this.txtBirthday.Text             = model.Birthday.ToString();
     this.chkIsActivity.Checked        = model.IsActivity;
     this.ddlFk_Roles_Id.SelectedValue = model.Fk_Roles_Id.ToString();
 }
コード例 #9
0
        private void ShowInfo(int Id)
        {
            Maticsoft.BLL.Users   bll   = new Maticsoft.BLL.Users();
            Maticsoft.Model.Users model = bll.GetModel(Id);
            this.lblId.Text   = model.Id.ToString();
            this.lblName.Text = model.Name;

            this.lblTrueName.Text = model.TrueName;
            this.lblSex.Text      = model.Sex;
            this.lblPhone.Text    = model.Phone;
            this.iPhoto.ImageUrl  = "~/" + model.Photo;
            this.lblEmail.Text    = model.Email;
            this.lblBirthday.Text = model.Birthday.ToString();

            BLL.Roles   BLLRoles   = new BLL.Roles();
            Model.Roles ModelRoles = BLLRoles.GetModel((int)model.Fk_Roles_Id);
            this.lblFk_Roles_Id.Text = ModelRoles.Name;
        }
コード例 #10
0
 private void ShowInfo(string UserID)
 {
     Maticsoft.BLL.Users   bll   = new Maticsoft.BLL.Users();
     Maticsoft.Model.Users model = bll.GetModel(UserID);
     this.lblUserID.Text       = model.UserID;
     this.txtUsername.Text     = model.Username;
     this.txtUserPassword.Text = model.UserPassword;
     this.txtUserRealName.Text = model.UserRealName;
     this.txtUserSex.Text      = model.UserSex;
     this.txtUserEmail.Text    = model.UserEmail;
     this.txtUserGrade.Text    = model.UserGrade;
     this.txtUserScore.Text    = model.UserScore.ToString();
     this.txtProvince.Text     = model.Province;
     this.txtCity.Text         = model.City;
     this.txtAddress1.Text     = model.Address1;
     this.txtUserIdentity.Text = model.UserIdentity;
     this.txtRegistTime.Text   = model.RegistTime.ToString();
     this.txtPhone.Text        = model.Phone;
 }
コード例 #11
0
ファイル: Forespxx.aspx.cs プロジェクト: Jyf524/RunZe
        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("已添加到购物车!");
            }
        }
コード例 #12
0
        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");
        }
コード例 #13
0
ファイル: Foresplb.aspx.cs プロジェクト: Jyf524/RunZe
        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>");
                }
            }
        }