Exemplo n.º 1
0
        //模糊查询
        public static List <ModelSproduct> sproducts(string Sproductname = "", string Sproductcontent = "")
        {
            SqlParameter[] sqlp = new SqlParameter[] {
                new SqlParameter("@Sproductname", Sproductname),
                new SqlParameter("@Sproductcontent", Sproductcontent)
            };
            SqlDataReader reader = DBhelp.slelectProc("Sproduct_sel", sqlp);
            //判断有没有读到数据,hasRows有没有行数据
            List <ModelSproduct> sproducts = new List <ModelSproduct>();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    //读取第一条数据
                    ModelSproduct model = new ModelSproduct();
                    model.Sproductid      = int.Parse(reader["Sproductid"].ToString());
                    model.Sproductname    = reader["Sproductname"].ToString();
                    model.Sproductcontent = reader["Sproductcontent"].ToString();
                    model.Sproductprice   = double.Parse(reader["Sproductprice"].ToString());
                    model.Sproductimg     = reader["Sproductimg"].ToString();
                    sproducts.Add(model);
                }
            }
            return(sproducts);
        }
Exemplo n.º 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text == "")
            {
                Response.Write("<script> alert('商品名字不能为空')</script>");
                return;
            }
            if (TextBox2.Text == "")
            {
                Response.Write("<script> alert('商品简介不能为空')</script>");
                return;
            }
            if (TextBox3.Text == "")
            {
                Response.Write("<script> alert('商品价格不能为空')</script>");
                return;
            }
            ModelSproduct sproduct = new ModelSproduct()
            {
                Sproductimg     = Convert.ToString(FileUpload1.ToString()),
                Sproductname    = Convert.ToString(TextBox1.Text),
                Sproductcontent = Convert.ToString(TextBox2.Text),
                Sproductprice   = Convert.ToDouble(TextBox3.Text)
            };

            if (BllSproducts.insert(sproduct) > 0)
            {
                Response.Write("<script> alert('添加成功!');location.href='Sproduct.aspx' </script>");
            }
        }
Exemplo n.º 3
0
 //删除
 public static int delete(ModelSproduct sproduct)
 {
     SqlParameter[] parter = new SqlParameter[]
     {
         new SqlParameter("Sproductid", sproduct.Sproductid)
     };
     return(DBhelp.NotqueryProc("Sproduct_del", parter));
 }
Exemplo n.º 4
0
 //修改
 public static int update(ModelSproduct sproduct)
 {
     SqlParameter[] parter = new SqlParameter[]
     {
         new SqlParameter("Sproductcontent", sproduct.Sproductcontent),
         new SqlParameter("Sproductprice", sproduct.Sproductprice)
     };
     return(DBhelp.NotqueryProc("Sproduct_upt", parter));
 }
Exemplo n.º 5
0
 //添加
 public static int insert(ModelSproduct sproduct)
 {
     SqlParameter[] parter = new SqlParameter[]
     {
         new SqlParameter("Sproductname", sproduct.Sproductname),
         new SqlParameter("Sproductcontent", sproduct.Sproductcontent),
         new SqlParameter("Sproductprice", sproduct.Sproductprice),
         new SqlParameter("Sproductimg", sproduct.Sproductimg)
     };
     return(DBhelp.NotqueryProc("Sproduct_ins", parter));
 }
Exemplo n.º 6
0
        //查询整表
        public static List <ModelSproduct> SproductList()
        {
            string        sql    = "select * from Sproduct";
            SqlDataReader reader = DBhelp.slelect(sql);
            //判断有没有读到数据,hasRows有没有行数据
            List <ModelSproduct> sproducts = new List <ModelSproduct>();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    //读取第一条数据
                    ModelSproduct model = new ModelSproduct();
                    model.Sproductid      = int.Parse(reader["Sproductid"].ToString());
                    model.Sproductname    = reader["Sproductname"].ToString();
                    model.Sproductcontent = reader["Sproductcontent"].ToString();
                    model.Sproductprice   = double.Parse(reader["Sproductprice"].ToString());
                    model.Sproductimg     = reader["Sproductimg"].ToString();
                    sproducts.Add(model);
                }
            }
            return(sproducts);
        }
Exemplo n.º 7
0
 //添加
 public static int insert(ModelSproduct sproduct)
 {
     return(DalSproduct.insert(sproduct));
 }