Ejemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtOrderDetailID.Text.Trim().Length == 0)
            {
                strErr += "OrderDetailID不能为空!\\n";
            }
            if (this.txtOrderID.Text.Trim().Length == 0)
            {
                strErr += "OrderID不能为空!\\n";
            }
            if (this.txtCommodityID.Text.Trim().Length == 0)
            {
                strErr += "CommodityID不能为空!\\n";
            }
            if (this.txtUserID.Text.Trim().Length == 0)
            {
                strErr += "UserID不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtOrderNumber.Text))
            {
                strErr += "OrderNumber格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtAppraiseGrade.Text))
            {
                strErr += "AppraiseGrade格式错误!\\n";
            }
            if (this.txtSubtotal.Text.Trim().Length == 0)
            {
                strErr += "Subtotal不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string OrderDetailID = this.txtOrderDetailID.Text;
            string OrderID       = this.txtOrderID.Text;
            string CommodityID   = this.txtCommodityID.Text;
            string UserID        = this.txtUserID.Text;
            int    OrderNumber   = int.Parse(this.txtOrderNumber.Text);
            int    AppraiseGrade = int.Parse(this.txtAppraiseGrade.Text);
            string Subtotal      = this.txtSubtotal.Text;

            Maticsoft.Model.OrderDetail model = new Maticsoft.Model.OrderDetail();
            model.OrderDetailID = OrderDetailID;
            model.OrderID       = OrderID;
            model.CommodityID   = CommodityID;
            model.UserID        = UserID;
            model.OrderNumber   = OrderNumber;
            model.AppraiseGrade = AppraiseGrade;
            model.Subtotal      = Subtotal;

            Maticsoft.BLL.OrderDetail bll = new Maticsoft.BLL.OrderDetail();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Ejemplo n.º 2
0
        protected void Linkbtn_buyall_word_Click(object sender, EventArgs e)
        {
            Maticsoft.Model.Users       modelUsers       = Users_Bll.GetModel(UsersInfo.UserID);
            Maticsoft.Model.Orders      modelOrders      = new Maticsoft.Model.Orders();
            Maticsoft.Model.OrderDetail modelOrderDetail = new Maticsoft.Model.OrderDetail();

            if (UsersInfo.UserID != "")
            {
                DataSet dsbasket = new DataSet();
                dsbasket = ShoppingCart_Bll.GetList(" UserID ='" + UsersInfo.UserID + "' ");
                foreach (DataRow drbasket in dsbasket.Tables[0].Rows)
                {
                    Commodity_Mol = Commodity_Bll.GetModel(drbasket["CommodityID"].ToString());
                    if (Convert.ToInt32(drbasket["OrderNumber"]) >= Commodity_Mol.Stock)
                    {
                        RadAjaxManager1.Alert("库存不足!");
                        return;
                    }
                }

                if (modelUsers.UserRealName == "" && modelUsers.Address1 == "")
                {
                    Response.Write("<script> alert('请完善个人信息!'); window.location.href='ForeVIP.aspx' </script>");
                }
                else
                {
                    modelOrders.OrderID = DateTime.Now.ToString("yyyyMMddHHmmss");   //订单号

                    modelOrders.UserID     = UsersInfo.UserID;                       //用户ID
                    modelOrders.OrderDate  = DateTime.Now;                           //下单时间
                    modelOrders.OrderState = "待付款";
                    modelOrders.TotalMoney = Convert.ToDecimal(Lbl_totalprice.Text); //总金额

                    modelOrders.AddresseeName    = modelUsers.UserRealName;
                    modelOrders.AddresseePhone   = modelUsers.Phone;
                    modelOrders.AddresseeAddress = modelUsers.Province + modelUsers.City + modelUsers.Address1;

                    Orders_Bll.Add(modelOrders); //订单表

                    DataSet ds = new DataSet();
                    ds = ShoppingCart_Bll.GetList(" UserID='" + UsersInfo.UserID + "' ");
                    string id = DateTime.Now.ToString("yyyyMMddHHmmss");
                    int    i  = 0;
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        i++;
                        modelOrderDetail.OrderDetailID = id + i.ToString();
                        modelOrderDetail.OrderID       = modelOrders.OrderID;
                        modelOrderDetail.UserID        = UsersInfo.UserID;
                        modelOrderDetail.CommodityID   = dr["CommodityID"].ToString();
                        modelOrderDetail.OrderNumber   = Convert.ToInt32(dr["OrderNumber"]);
                        modelOrderDetail.Subtotal      = dr["Subtotal"].ToString();
                        OrderDetail_Bll.Add(modelOrderDetail);
                        Commodity_Mol = Commodity_Bll.GetModel(dr["CommodityID"].ToString());
                        if (ShoppingCart_Mol.OrderNumber > Commodity_Mol.Stock)
                        {
                            RadAjaxManager1.Alert("库存不足!");
                            return;
                        }
                        Commodity_Mol.Stock = Commodity_Mol.Stock - Convert.ToInt32(dr["OrderNumber"]);


                        if (Commodity_Mol.Stock <= 0)
                        {
                            Commodity_Mol.CommodityState = "下架";
                        }

                        Commodity_Bll.Update(Commodity_Mol);
                    }



                    ShoppingCart_Bll.DeleteList2(UsersInfo.UserID);
                    hidden();
                    RadListView1.Rebind();
                    Response.Write("<script> alert('下单成功!'); window.location.href='ForeOrdersDetail.aspx?OrderID=" + modelOrders.OrderID + "' </script>");
                }
            }
            else
            {
                Response.Write("<script> alert('请先登陆!'); window.location.href='/Login.aspx' </script>");
            }
        }