Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public int Add(ROYcms.Sys.Model.ROYcms_product_order model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + PubConstant.date_prefix + "product_order(");
            strSql.Append("order_id,user_id,order_status,order_price,order_payment,order_rec_name,order_rec_address,order_rec_code,order_rec_phone,order_rec_tel,order_shipping,order_freight,order_deliveryTime,create_time,ifdefault)");
            strSql.Append(" values (");
            strSql.Append("@order_id,@user_id,@order_status,@order_price,@order_payment,@order_rec_name,@order_rec_address,@order_rec_code,@order_rec_phone,@order_rec_tel,@order_shipping,@order_freight,@order_deliveryTime,@create_time,@ifdefault)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@order_id",           SqlDbType.Char,      16),
                new SqlParameter("@user_id",            SqlDbType.Char,      10),
                new SqlParameter("@order_status",       SqlDbType.Char,       4),
                new SqlParameter("@order_price",        SqlDbType.Decimal,    9),
                new SqlParameter("@order_payment",      SqlDbType.NVarChar,  20),
                new SqlParameter("@order_rec_name",     SqlDbType.NVarChar,  10),
                new SqlParameter("@order_rec_address",  SqlDbType.NVarChar,  50),
                new SqlParameter("@order_rec_code",     SqlDbType.Char,       6),
                new SqlParameter("@order_rec_phone",    SqlDbType.Char,      11),
                new SqlParameter("@order_rec_tel",      SqlDbType.VarChar,   15),
                new SqlParameter("@order_shipping",     SqlDbType.NVarChar,  50),
                new SqlParameter("@order_freight",      SqlDbType.Decimal,    9),
                new SqlParameter("@order_deliveryTime", SqlDbType.NVarChar,  20),
                new SqlParameter("@create_time",        SqlDbType.DateTime),
                new SqlParameter("@ifdefault",          SqlDbType.Bit, 1)
            };
            parameters[0].Value  = model.order_id;
            parameters[1].Value  = model.user_id;
            parameters[2].Value  = model.order_status;
            parameters[3].Value  = model.order_price;
            parameters[4].Value  = model.order_payment;
            parameters[5].Value  = model.order_rec_name;
            parameters[6].Value  = model.order_rec_address;
            parameters[7].Value  = model.order_rec_code;
            parameters[8].Value  = model.order_rec_phone;
            parameters[9].Value  = model.order_rec_tel;
            parameters[10].Value = model.order_shipping;
            parameters[11].Value = model.order_freight;
            parameters[12].Value = model.order_deliveryTime;
            parameters[13].Value = model.create_time;
            parameters[14].Value = model.ifdefault;

            object obj = ROYcms.DB.DbHelpers.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="orderId">订单号</param>
        /// <param name="orderAmount">价格 </param>
        /// <param name="productName">产品名称</param>
        /// <param name="productNum">数量</param>
        /// <param name="k">k</param>
        protected void Order_add(string orderId, string orderAmount, string productName, string productNum, string k)
        {
            string order_id = orderId;

            string   user_id            = ROYcms.Common.Session.Get("user_id"); //用户id
            string   order_status       = "1";                                  //订单状态 默认未支付0代表已经支付
            decimal  order_price        = decimal.Parse(orderAmount);           //订单金额
            string   order_payment      = "";                                   // 支付方式
            string   order_rec_name     = "";                                   //收件人
            string   order_rec_address  = "";                                   //收件人地址
            string   order_rec_code     = "";                                   //邮编
            string   order_rec_phone    = "";                                   //手机
            string   order_rec_tel      = "";                                   //固话
            string   order_shipping     = "";                                   //配送方式
            decimal  order_freight      = 0;                                    //运费
            string   order_deliveryTime = DateTime.Now.ToString();              //送货时间
            DateTime create_time        = DateTime.Now;                         //订单创建时间
            bool     ifdefault          = true;                                 //默认地址

            ROYcms.Sys.Model.ROYcms_product_order model = new ROYcms.Sys.Model.ROYcms_product_order();
            model.order_id           = order_id;
            model.user_id            = user_id;
            model.order_status       = order_status;
            model.order_price        = order_price;
            model.order_payment      = order_payment;
            model.order_rec_name     = order_rec_name;
            model.order_rec_address  = order_rec_address;
            model.order_rec_code     = order_rec_code;
            model.order_rec_phone    = order_rec_phone;
            model.order_rec_tel      = order_rec_tel;
            model.order_shipping     = order_shipping;
            model.order_freight      = order_freight;
            model.order_deliveryTime = order_deliveryTime;
            model.create_time        = create_time;
            model.ifdefault          = ifdefault;

            ROYcms.Sys.BLL.ROYcms_product_order bll = new ROYcms.Sys.BLL.ROYcms_product_order();
            NewXml(bll.Add(model));



            Response.Redirect("/administrator/Payment/99bill/99bill.aspx?orderId=" + orderId + "&orderAmount=" + orderAmount + "&productName=" + productName + "&productNum=" + productNum + "&k=" + k);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Order_Button_Click(object sender, EventArgs e)
        {
            string order_id = Label_order_id.Text.Trim();

            string   user_id            = ROYcms.Common.Session.Get("user_id");                                       //用户id
            string   order_status       = "1";                                                                        //订单状态 默认未支付0代表已经支付
            decimal  order_price        = decimal.Parse(Label_order_price.Text == "" ? "0" : Label_order_price.Text); //订单金额
            string   order_payment      = DropDownList_order_payment.SelectedValue;                                   // 支付方式
            string   order_rec_name     = this.txtorder_rec_name.Text;                                                //收件人
            string   order_rec_address  = this.txtorder_rec_address.Text;                                             //收件人地址
            string   order_rec_code     = this.txtorder_rec_code.Text;                                                //邮编
            string   order_rec_phone    = this.txtorder_rec_phone.Text;                                               //手机
            string   order_rec_tel      = this.txtorder_rec_tel.Text;                                                 //固话
            string   order_shipping     = DropDownList_order_shipping.SelectedValue.ToString();                       //配送方式
            decimal  order_freight      = 0;                                                                          //运费
            string   order_deliveryTime = this.txtorder_deliveryTime.Text;                                            //送货时间
            DateTime create_time        = DateTime.Now;                                                               //订单创建时间
            bool     ifdefault          = this.chkifdefault.Checked;                                                  //默认地址

            ROYcms.Sys.Model.ROYcms_product_order model = new ROYcms.Sys.Model.ROYcms_product_order();
            model.order_id           = order_id;
            model.user_id            = user_id;
            model.order_status       = order_status;
            model.order_price        = order_price;
            model.order_payment      = order_payment;
            model.order_rec_name     = order_rec_name;
            model.order_rec_address  = order_rec_address;
            model.order_rec_code     = order_rec_code;
            model.order_rec_phone    = order_rec_phone;
            model.order_rec_tel      = order_rec_tel;
            model.order_shipping     = order_shipping;
            model.order_freight      = order_freight;
            model.order_deliveryTime = order_deliveryTime;
            model.create_time        = create_time;
            model.ifdefault          = ifdefault;

            ROYcms.Sys.BLL.ROYcms_product_order bll = new ROYcms.Sys.BLL.ROYcms_product_order();
            NewXml(bll.Add(model));

            //   Response.Redirect("/administrator/Payment/99bill/99bill.aspx?orderId=" + orderId + "&orderAmount=" + orderAmount + "&productName=" + productName + "&productNum=" + productNum);
        }
Esempio n. 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ROYcms.Sys.Model.ROYcms_product_order model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + PubConstant.date_prefix + "product_order set ");
            strSql.Append("order_id=@order_id,");
            strSql.Append("user_id=@user_id,");
            strSql.Append("order_status=@order_status,");
            strSql.Append("order_price=@order_price,");
            strSql.Append("order_payment=@order_payment,");
            strSql.Append("order_rec_name=@order_rec_name,");
            strSql.Append("order_rec_address=@order_rec_address,");
            strSql.Append("order_rec_code=@order_rec_code,");
            strSql.Append("order_rec_phone=@order_rec_phone,");
            strSql.Append("order_rec_tel=@order_rec_tel,");
            strSql.Append("order_shipping=@order_shipping,");
            strSql.Append("order_freight=@order_freight,");
            strSql.Append("order_deliveryTime=@order_deliveryTime,");
            strSql.Append("create_time=@create_time,");
            strSql.Append("ifdefault=@ifdefault");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@order_id",           SqlDbType.Char,      16),
                new SqlParameter("@user_id",            SqlDbType.Char,      10),
                new SqlParameter("@order_status",       SqlDbType.Char,       4),
                new SqlParameter("@order_price",        SqlDbType.Decimal,    9),
                new SqlParameter("@order_payment",      SqlDbType.NVarChar,  20),
                new SqlParameter("@order_rec_name",     SqlDbType.NVarChar,  10),
                new SqlParameter("@order_rec_address",  SqlDbType.NVarChar,  50),
                new SqlParameter("@order_rec_code",     SqlDbType.Char,       6),
                new SqlParameter("@order_rec_phone",    SqlDbType.Char,      11),
                new SqlParameter("@order_rec_tel",      SqlDbType.VarChar,   15),
                new SqlParameter("@order_shipping",     SqlDbType.NVarChar,  50),
                new SqlParameter("@order_freight",      SqlDbType.Decimal,    9),
                new SqlParameter("@order_deliveryTime", SqlDbType.NVarChar,  20),
                new SqlParameter("@create_time",        SqlDbType.DateTime),
                new SqlParameter("@ifdefault",          SqlDbType.Bit,        1),
                new SqlParameter("@id",                 SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.order_id;
            parameters[1].Value  = model.user_id;
            parameters[2].Value  = model.order_status;
            parameters[3].Value  = model.order_price;
            parameters[4].Value  = model.order_payment;
            parameters[5].Value  = model.order_rec_name;
            parameters[6].Value  = model.order_rec_address;
            parameters[7].Value  = model.order_rec_code;
            parameters[8].Value  = model.order_rec_phone;
            parameters[9].Value  = model.order_rec_tel;
            parameters[10].Value = model.order_shipping;
            parameters[11].Value = model.order_freight;
            parameters[12].Value = model.order_deliveryTime;
            parameters[13].Value = model.create_time;
            parameters[14].Value = model.ifdefault;
            parameters[15].Value = model.id;

            int rows = ROYcms.DB.DbHelpers.NonQuery(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }