Exemplo n.º 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox2.Text == "")
            {
                Response.Write("<script>alert('请输入商品名')</script>");
            }
            if (TextBox1.Text == "")
            {
                Response.Write("<script>alert('请输入商品简介')</script>");
            }
            if (TextBox3.Text == "")
            {
                Response.Write("<script>alert('请输入商品价格')</script>");
            }
            //if (TextBox4.Text=="")
            //{
            //    Response.Write("<script>alert('请输入用户id')</script>");
            //}
            //var qq = Session["User"] as ModelUsers;
            ModelProviderProduct ins = new ModelProviderProduct()
            {
                Productname    = TextBox2.Text,
                Productcontent = TextBox1.Text,
                Productprice   = Convert.ToDouble(TextBox3.Text),
                //Userid = qq.Userid
            };

            if (BllProviderProduct.insert(ins) > 0)
            {
                Response.Write("<script>alert('添加成功');location.href='ProviderProduct.aspx'</script>");
            }
        }
        /// <summary>
        /// To the model.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        internal static ModelProviderProduct ToModel(this EntityProviderProduct entity)
        {
            var model = new ModelProviderProduct();

            model.Id = entity.Id;

            return(model);
        }
        /// <summary>
        /// To the entity.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        internal static EntityProviderProduct ToEntity(this ModelProviderProduct model)
        {
            var entity = new EntityProviderProduct();

            entity.Id = model.Id;


            return(entity);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int delete(ModelProviderProduct model)
        {
            string sql = "delete from ProviderProduct where Productid=@Productid";

            SqlParameter[] sqlpar = new SqlParameter[]
            {
                new SqlParameter("@Productid", model.Productid)
            };
            return(DBhelp.Notquery(sql, sqlpar));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <returns></returns>
        public static int insert(ModelProviderProduct model)
        {
            string sql = "insert into ProviderProduct values(@Productname ,@Productcontent ,@Productprice ,@Productimg ,@Userid)";

            SqlParameter[] sqlpar = new SqlParameter[]
            {
                new SqlParameter("@Productname", model.Productname),
                new SqlParameter("@Productcontent", model.Productcontent),
                new SqlParameter("@Productprice", model.Productprice),
                new SqlParameter("@Productimg", model.Productimg),
                new SqlParameter("@Userid", model.Userid)
            };
            return(DBhelp.Notquery(sql, sqlpar));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int update(ModelProviderProduct model)
        {
            string sql = "update ProviderProduct set Productname=@Productname,Productcontent=@Productcontent,Productprice=@Productprice,Productimg=@Productimg,Userid=@Userid where Productid=@Productid";

            SqlParameter[] sqlpar = new SqlParameter[]
            {
                new SqlParameter("@Productname", model.Productname),
                new SqlParameter("@Productcontent", model.Productcontent),
                new SqlParameter("@Productprice", model.Productprice),
                new SqlParameter("@Productimg", model.Productimg),
                new SqlParameter("@Userid", model.Userid),
                new SqlParameter("@Productid", model.Productid)
            };
            return(DBhelp.Notquery(sql, sqlpar));
        }
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            //获取前台comm的方法名
            string name = e.CommandName;
            //存储model值
            ModelProviderProduct model = new ModelProviderProduct()
            {
                Productid = Convert.ToInt32(e.CommandArgument)
            };

            //判断方法名来进行相对的操作
            if (name == "delete")
            {
                //执行删除(软删除 将值进行隐藏)
                int num = BllProviderProduct.delete(model);
                if (num > 0)
                {
                    Response.Write("<script>alert('删除成功');location.href='ProviderProduct.aspx'</script>");
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 查询供应商商品表
        /// </summary>
        /// <returns></returns>
        public static List <ModelProviderProduct> select()
        {
            string sql = "select * from ProviderProduct ";
            //此处是多条件查询(根据商品名来进行模糊查询)
            //string sql = "select * from ProviderProduct where Providername like''%'+@Providername+'%'''";
            SqlDataReader sdr = DBhelp.slelect(sql);
            List <ModelProviderProduct> list = new List <ModelProviderProduct>();

            if (sdr.HasRows)
            {
                while (sdr.Read())
                {
                    ModelProviderProduct model = new ModelProviderProduct();
                    model.Productid      = Convert.ToInt32(sdr["Productid"]);
                    model.Productname    = sdr["Productname"].ToString();
                    model.Productcontent = sdr["Productcontent"].ToString();
                    model.Productprice   = Convert.ToDouble(sdr["Productprice"]);
                    model.Productimg     = sdr["Productimg"].ToString();
                    model.Userid         = Convert.ToInt32(sdr["Userid"]);
                    list.Add(model);
                }
            }
            return(list);
        }
Exemplo n.º 9
0
 public static int insert(ModelProviderProduct model)
 {
     return(DalProviderProduct.insert(model));
 }
Exemplo n.º 10
0
 public static int update(ModelProviderProduct model)
 {
     return(DalProviderProduct.update(model));
 }
Exemplo n.º 11
0
 public static int delete(ModelProviderProduct model)
 {
     return(DalProviderProduct.delete(model));
 }