Exemplo n.º 1
0
        /// <summary>
        /// 查询所有商品
        /// </summary>
        /// <param name="PTID"></param>
        /// <param name="JP"></param>
        /// <returns></returns>
        public static List <ProductsMDL> selectProduct(string ProductJP)
        {
            string sql             = "select * from dbo.Products where 1=1";
            List <SqlParameter> sp = new List <SqlParameter>();

            if (ProductJP != "")
            {
                sql += " and ProductJP like @ProductJP";
                sp.Add(new SqlParameter("@ProductJP", "%" + ProductJP + "%"));
            }

            SqlDataReader      dr   = DBhelper.MySqlDataReader(sql, sp.ToArray());
            List <ProductsMDL> list = new List <ProductsMDL>();

            while (dr.Read())
            {
                ProductsMDL pd = new ProductsMDL();
                pd.ProductID           = Convert.ToInt32(dr[0]);
                pd.ProductName         = dr[1].ToString();
                pd.PTID                = Convert.ToInt32(dr[2]);
                pd.ProductJP           = dr[3].ToString();
                pd.ProductPrice        = Convert.ToDouble(dr[4]);
                pd.ProductPic          = dr[6].ToString();
                pd.ProductIntroduction = dr[5].ToString();
                list.Add(pd);
            }
            dr.Close();
            return(list);
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
            {
                new Warning("信息填写不完整", 图标.Erro).Show();
                return;
            }

            if (OpenType == 1)
            {
                //增加
                ProductsMDL pr = new ProductsMDL();
                pr.ProductName         = textBox1.Text;
                pr.ProductPrice        = Convert.ToInt32(textBox3.Text);
                pr.ProductJP           = textBox2.Text;
                pr.PTID                = Convert.ToInt32(comboBox1.SelectedValue);
                pr.ProductPic          = path;
                pr.ProductIntroduction = textBox4.Text;
                int count = ProductsBLL.AddProducts(pr);
                if (count > 0)
                {
                    new Warning("添加成功", 图标.Yes).Show();
                    this.Close();
                }
                else
                {
                    new Warning("添加失败", 图标.Erro).Show();
                }
            }
            else
            {
                //修改
                this.Text = "修改商品信息";
                ProductsMDL p = new ProductsMDL();
                p.ProductName         = textBox1.Text;
                p.ProductJP           = textBox2.Text;
                p.PTID                = Convert.ToInt32(comboBox1.SelectedValue);
                p.ProductPrice        = Convert.ToDouble(textBox3.Text);
                p.ProductID           = EditProduct.ShopID;
                p.ProductIntroduction = textBox4.Text;
                p.ProductPic          = path;

                int count = ProductsBLL.UpdateProducts(p);
                if (count > 0)
                {
                    new Warning("修改成功", 图标.Yes).Show();
                    this.Close();
                }
                else
                {
                    new Warning("修改成功", 图标.Erro).Show();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 添加商品
        /// </summary>
        /// <param name="p"></param>
        /// <returns>几行受影响</returns>
        public static int AddProducts(ProductsMDL p)
        {
            string sql = "insert into Products values(@ProductName,@PTID,@ProductJP,@ProductPrice,@ProductIntroduction,@ProductPic)";

            SqlParameter[] sp =
            {
                new SqlParameter("@ProductName",         p.ProductName),
                new SqlParameter("@PTID",                p.PTID),
                new SqlParameter("@ProductJP",           p.ProductJP),
                new SqlParameter("@ProductPrice",        p.ProductPrice),
                new SqlParameter("@ProductIntroduction", p.ProductIntroduction),
                new SqlParameter("@ProductPic",          p.ProductPic)
            };
            return(DBhelper.MyExecuteNonQuery(sql, sp));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 修改商品
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public static int UpdateProducts(ProductsMDL p)
        {
            string sql = @" update Products 
 set ProductName=@ProductName,PTID=@PTID,ProductPrice=@ProductPrice,ProductIntroduction=@ProductIntroduction,ProductPic=@ProductPic
 where ProductID=@ProductID";

            SqlParameter[] sp =
            {
                new SqlParameter("@ProductName",         p.ProductName),
                new SqlParameter("@PTID",                p.PTID),
                new SqlParameter("@ProductPrice",        p.ProductPrice),
                new SqlParameter("@ProductID",           p.ProductID),
                new SqlParameter("@ProductIntroduction", p.ProductIntroduction),
                new SqlParameter("@ProductPic",          p.ProductPic)
            };
            return(DBhelper.MyExecuteNonQuery(sql, sp));
        }
Exemplo n.º 5
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public static int UpdateProducts(ProductsMDL p)
 {
     return(ProductsDAL.UpdateProducts(p));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 添加商品
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public static int AddProducts(ProductsMDL p)
 {
     return(ProductsDAL.AddProducts(p));
 }