Exemplo n.º 1
0
        public bool UpdateCount(Model.shop_log model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + databaseprefix + "shop_order ");

            strSql.Append("set quantity=@quantity,");
            strSql.Append("createDate=@createDate");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@quantity",   SqlDbType.Int,      10),
                new SqlParameter("@createDate", SqlDbType.DateTime, 10),
                new SqlParameter("@id",         SqlDbType.Int, 10)
            };
            parameters[0].Value = model.quantity;
            parameters[1].Value = DateTime.Now;
            parameters[2].Value = model.id;


            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.shop_log model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "shop_order(");
            strSql.Append("shop_id,goods_id,user_id,quantity,createDate)");
            strSql.Append(" values (");
            strSql.Append("@shop_id,@goods_id,@user_id,@quantity,@createDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@shop_id",    SqlDbType.Int,      10),
                new SqlParameter("@goods_id",   SqlDbType.Int,      10),
                new SqlParameter("@user_id",    SqlDbType.Int,      10),
                new SqlParameter("@quantity",   SqlDbType.Int,      10),
                new SqlParameter("@createDate", SqlDbType.DateTime, 20)
            };
            parameters[0].Value = model.shop_id;
            parameters[1].Value = model.goods_id;
            parameters[2].Value = model.user_id;
            parameters[3].Value = model.quantity;
            parameters[4].Value = DateTime.Now;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 3
0
        public bool Update(int id, int quantity)
        {
            Model.shop_log model = new Model.shop_log();
            model.id = id;

            model.quantity = quantity;
            return(dal.UpdateCount(model));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.shop_log GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from " + databaseprefix + "shop_order ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.shop_log model = new Model.shop_log();
            DataSet        ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }

                if (ds.Tables[0].Rows[0]["order_id"] != null && ds.Tables[0].Rows[0]["order_id"].ToString() != "")
                {
                    model.shop_id = int.Parse(ds.Tables[0].Rows[0]["linkman"].ToString());
                }
                if (ds.Tables[0].Rows[0]["goods_id"] != null && ds.Tables[0].Rows[0]["goods_id"].ToString() != "")
                {
                    model.goods_id = int.Parse(ds.Tables[0].Rows[0]["goods_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_id"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["shop_name"] != null && ds.Tables[0].Rows[0]["shop_name"].ToString() != "")
                {
                    model.shop_name = ds.Tables[0].Rows[0]["shop_name"].ToString();
                }


                if (ds.Tables[0].Rows[0]["quantity"] != null && ds.Tables[0].Rows[0]["quantity"].ToString() != "")
                {
                    model.quantity = int.Parse(ds.Tables[0].Rows[0]["quantity"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(Model.shop_log model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from " + databaseprefix + "shop_order");
            strSql.Append(" where shop_id=@shop_id ");
            strSql.Append(" and goods_id=@goods_id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@shop_id",  SqlDbType.Int, 10),
                new SqlParameter("@goods_id", SqlDbType.Int, 10)
            };
            parameters[0].Value = model.shop_id;
            parameters[1].Value = model.goods_id;
            return(DbHelperSQL.Exists(strSql.ToString(), parameters));
        }
Exemplo n.º 6
0
        protected void Getstr()
        {
            int tolcount = 0;
            List <Model.shop_log> list = new List <Model.shop_log>();

            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                //  int state = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidState")).Value);

                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    Model.shop_log shop      = new Model.shop_log();
                    Model.users    userModel = new Web.UI.BasePage().GetUserInfo();
                    shop.user_id = userModel.id;

                    int count;
                    if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtQuantity")).Text.Trim(), out count))
                    {
                        count = 0;
                    }
                    shop.quantity = count;
                    shop.goods_id = this.id;
                    shop.shop_id  = id;
                    list.Add(shop);
                    tolcount = tolcount + count;
                }
            }
            string message = "";

            if (quantity == tolcount)
            {
                BLL.shop_log shop = new BLL.shop_log();
                shop.AddList(list);
                message = "true";
            }
            else
            {
                message = "错误:请与加入购物车数量保持一致";
                ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>alert('" + message + "');</script>");
                return;
            }
            ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>setData(" + message + "," + quantity + "," + quantity * price + "," + this.id + ");</script>");//后台调用前台JS
        }
Exemplo n.º 7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.shop_log model)
 {
     return(dal.Add(model));
 }
Exemplo n.º 8
0
 /// <summary>
 /// 是否存在该记录
 /// </summary>
 public bool Exists(Model.shop_log model)
 {
     return(dal.Exists(model));
 }