Beispiel #1
0
        public int count(Model.collect aa)
        {
            String sql = "select count(*) from collect where _userid='" + aa.userid + "'";
            int    i   = Convert.ToInt32(Common.DB.ExecuteScalar(sql));

            return(i);
        }
Beispiel #2
0
        public int deco(Model.collect aa)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("delete from collect where _id=@id");
            SqlParameter[] par =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            par[0].Value = aa.id;
            return(Common.DbHelperSQL.ExecuteSql(sql.ToString(), par));
        }
Beispiel #3
0
        public SqlDataReader drcopr(Model.collect aa)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("select * from collect where _proid=@id");
            SqlParameter[] par =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            par[0].Value = aa.proid;
            return(Common.DbHelperSQL.ExecuteReader(sql.ToString(), par));
        }
Beispiel #4
0
        public int inser(Model.collect aa)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into collect (_userid)values(@id)");
            SqlParameter[] par =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            par[0].Value = aa.userid;
            return(Common.DbHelperSQL.ExecuteSql(sql.ToString(), par));
        }
Beispiel #5
0
        public DataSet drco(int a, int b, Model.collect aa)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("select * from collect  where _userid=@id");
            SqlParameter[] par =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            par[0].Value = aa.userid;
            return(Common.DbHelperSQL.PageQuery(sql.ToString(), a, b, par));
        }
Beispiel #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.collect GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, goods_name, img_url, price, user_id, goods_id, add_time  ");
            strSql.Append("  from td_collect ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.goods_name = ds.Tables[0].Rows[0]["goods_name"].ToString();
                model.img_url    = ds.Tables[0].Rows[0]["img_url"].ToString();
                if (ds.Tables[0].Rows[0]["price"].ToString() != "")
                {
                    model.price = decimal.Parse(ds.Tables[0].Rows[0]["price"].ToString());
                }
                if (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]["goods_id"].ToString() != "")
                {
                    model.goods_id = int.Parse(ds.Tables[0].Rows[0]["goods_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.collect model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update td_collect set ");

            strSql.Append(" goods_name = @goods_name , ");
            strSql.Append(" img_url = @img_url , ");
            strSql.Append(" price = @price , ");
            strSql.Append(" user_id = @user_id , ");
            strSql.Append(" goods_id = @goods_id , ");
            strSql.Append(" add_time = @add_time  ");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",         SqlDbType.Int,        4),
                new SqlParameter("@goods_name", SqlDbType.NVarChar, 100),
                new SqlParameter("@img_url",    SqlDbType.NVarChar, 255),
                new SqlParameter("@price",      SqlDbType.Decimal,    9),
                new SqlParameter("@user_id",    SqlDbType.Int,        4),
                new SqlParameter("@goods_id",   SqlDbType.Int,        4),
                new SqlParameter("@add_time",   SqlDbType.DateTime)
            };

            parameters[0].Value = model.id;
            parameters[1].Value = model.goods_name;
            parameters[2].Value = model.img_url;
            parameters[3].Value = model.price;
            parameters[4].Value = model.user_id;
            parameters[5].Value = model.goods_id;
            parameters[6].Value = model.add_time;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #8
0
        public int inserc(Model.collect aa)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into collect (_userid,_proid,_proname,_proprice,_proimage)values(@userid,@id,@name,@price,@image)");
            SqlParameter[] par =
            {
                new SqlParameter("@userid", SqlDbType.Int,      4),
                new SqlParameter("@id",     SqlDbType.Int,      4),
                new SqlParameter("@name",   SqlDbType.VarChar, 50),
                new SqlParameter("@price",  SqlDbType.Money,   16),
                new SqlParameter("@image",  SqlDbType.VarChar, 50)
            };
            par[0].Value = aa.userid;
            par[1].Value = aa.proid;
            par[2].Value = aa.proname;
            par[3].Value = aa.proprice;
            par[4].Value = aa.proimage;
            return(Common.DbHelperSQL.ExecuteSql(sql.ToString(), par));
        }
Beispiel #9
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.collect model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "collect(");
            strSql.Append("user_id,good_id,title,good_type,good_price,img_url,add_time,is_usable)");
            strSql.Append(" values (");
            strSql.Append("@user_id,@good_id,@title,@good_type,@good_price,@img_url,@add_time,@is_usable)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_id",    SqlDbType.Int,         4),
                new SqlParameter("@good_id",    SqlDbType.Int,         4),
                new SqlParameter("@title",      SqlDbType.NVarChar,  100),
                new SqlParameter("@good_type",  SqlDbType.NVarChar,  100),
                new SqlParameter("@good_price", SqlDbType.Decimal,     5),
                new SqlParameter("@img_url",    SqlDbType.NVarChar,  100),
                new SqlParameter("@add_time",   SqlDbType.DateTime),
                new SqlParameter("@is_usable",  SqlDbType.NChar, 10)
            };
            parameters[0].Value = model.user_id;
            parameters[1].Value = model.good_id;
            parameters[2].Value = model.title;
            parameters[3].Value = model.good_type;
            parameters[4].Value = model.good_price;
            parameters[5].Value = model.img_url;
            parameters[6].Value = model.add_time;
            parameters[7].Value = model.is_usable;

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

            if (obj <= 0)
            {
                return(0);
            }
            else
            {
                return(GetMaxId());
            }
        }
Beispiel #10
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.collect model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into td_collect(");
            strSql.Append("goods_name,img_url,price,user_id,goods_id,add_time");
            strSql.Append(") values (");
            strSql.Append("@goods_name,@img_url,@price,@user_id,@goods_id,@add_time");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@goods_name", SqlDbType.NVarChar, 100),
                new SqlParameter("@img_url",    SqlDbType.NVarChar, 255),
                new SqlParameter("@price",      SqlDbType.Decimal,    9),
                new SqlParameter("@user_id",    SqlDbType.Int,        4),
                new SqlParameter("@goods_id",   SqlDbType.Int,        4),
                new SqlParameter("@add_time",   SqlDbType.DateTime)
            };

            parameters[0].Value = model.goods_name;
            parameters[1].Value = model.img_url;
            parameters[2].Value = model.price;
            parameters[3].Value = model.user_id;
            parameters[4].Value = model.goods_id;
            parameters[5].Value = model.add_time;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #11
0
 public int insertc(Model.collect aa)
 {
     DAL.collect dalcd = new DAL.collect();
     return(dalcd.inser(aa));
 }
Beispiel #12
0
 public int insert(Model.collect aa)
 {
     DAL.collect dac = new DAL.collect();
     return(dac.inser(aa));
 }
Beispiel #13
0
 public DataSet  drco(int a, int b, Model.collect aa)
 {
     DAL.collect dalc = new DAL.collect();
     return(dalc.drco(a, b, aa));
 }
Beispiel #14
0
        private void batch_to_collect(HttpContext context)
        {
            string ids = DTRequest.GetQueryString("ids");
            Model.users model_user = new BasePage().GetUserInfo();
            if (model_user == null)
            {
                context.Response.Write("{\"status\":\"0\", \"msg\":\"请先登录!\"}");
                return;
            }
            BLL.article bll_article = new BLL.article();
            BLL.collect bll_collect = new BLL.collect();
            string[] arr_id = ids.Split(',');
            foreach (string str in arr_id)
            {
                Model.article model_article = bll_article.GetModel(Convert.ToInt32(str));
                DataTable dt = bll_collect.GetList("user_id=" + model_user.id + " and goods_id=" + str).Tables[0];
                if (dt != null && dt.Rows.Count <= 0)
                {
                    if (model_article != null)
                    {
                        Model.collect model_collect = new Model.collect();

                        model_collect.goods_id = model_article.id;
                        model_collect.goods_name = model_article.title;
                        model_collect.img_url = model_article.img_url;
                        model_collect.price = Convert.ToDecimal(model_article.fields["sell_price"]);
                        model_collect.user_id = model_user.id;
                        model_collect.add_time = DateTime.Now;

                        bll_collect.Add(model_collect);
                    }
                }
            }

            context.Response.Write("{\"status\":\"1\", \"msg\":\"加入收藏成功!\"}");
            return;
        }
Beispiel #15
0
 public int insertco(Model.collect aa)
 {
     DAL.collect dcd = new DAL.collect();
     return(dcd.inserc(aa));
 }
Beispiel #16
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.collect model)
 {
     return(dal.Update(model));
 }
Beispiel #17
0
 public int depo(Model.collect aa)
 {
     DAL.collect dalc = new DAL.collect();
     return(dalc.deco(aa));
 }
Beispiel #18
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.collect model)
 {
     return(dal.Add(model));
 }
Beispiel #19
0
 public int count(Model.collect aa)
 {
     DAL.collect dao = new DAL.collect();
     return(dao.count(aa));
 }
Beispiel #20
0
        private void get_collect(HttpContext context)
        {
            int id = DTRequest.GetQueryInt("id");
            BLL.collect bll_collect = new BLL.collect();
            Model.collect model_collect = new Model.collect();
            BLL.article bll = new BLL.article();
            Model.article model = bll.GetModel(id);
            Model.users user_model = new BasePage().GetUserInfo();
            if (user_model == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"收藏商品失败,请您先登录!\"}");
                return;

            }
            //赋值
            model_collect.goods_name = model.title;
            model_collect.img_url = model.img_url;
            model_collect.goods_id = model.id;
            model_collect.user_id = user_model.id;
            model_collect.add_time = DateTime.Now;
            if (bll_collect.Exists1(model.id))
            {

                context.Response.Write("{\"status\":0, \"msg\":\"已收藏该商品!\"}");
                return;
            }
            if (bll_collect.Add(model_collect) > 0)
            {
                context.Response.Write("{\"status\":1, \"msg\":\"收藏商品成功!\"}");
                return;

            }
            else
            {

                context.Response.Write("{\"status\":0, \"msg\":\"收藏失败!\"}");
                return;
            }
        }
Beispiel #21
0
 public SqlDataReader drsco(Model.collect aa)
 {
     DAL.collect das = new DAL.collect();
     return(das.drcopr(aa));
 }
Beispiel #22
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.collect GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select id, goods_name, img_url, price, user_id, goods_id, add_time  ");
            strSql.Append("  from td_collect ");
            strSql.Append(" where id=@id");
                        SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

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

            if(ds.Tables[0].Rows.Count>0)
            {
                                                if(ds.Tables[0].Rows[0]["id"].ToString()!="")
                {
                    model.id=int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                                                                                                                                                model.goods_name= ds.Tables[0].Rows[0]["goods_name"].ToString();
                                                                                                                                model.img_url= ds.Tables[0].Rows[0]["img_url"].ToString();
                                                                                                                if(ds.Tables[0].Rows[0]["price"].ToString()!="")
                {
                    model.price=decimal.Parse(ds.Tables[0].Rows[0]["price"].ToString());
                }
                                                                                                                                if(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]["goods_id"].ToString()!="")
                {
                    model.goods_id=int.Parse(ds.Tables[0].Rows[0]["goods_id"].ToString());
                }
                                                                                                                                if(ds.Tables[0].Rows[0]["add_time"].ToString()!="")
                {
                    model.add_time=DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }

                return model;
            }
            else
            {
                return null;
            }
        }