Beispiel #1
0
        /// <summary>
        /// SearchByCategory函数的功能:根据类型查找商品
        /// </summary>
        /// <param name="category">商品的类型</param>
        /// <returns>根据商品的类型查询的商品的信息的Linq查询结果的集合</returns>
        public object SearchByCategory(string category)
        {
            product_Entity P = new product_Entity();

            P.P_category = category;
            return(Date.searchByCategory(P));
        }
Beispiel #2
0
        //--搜索模块--

        /// <summary>
        /// 1.SearchByProName函数的功能:根据商品名称查找商品
        /// </summary>
        /// <param name="name">商品的名称</param>
        /// <returns>根据商品名称查询的商品的信息的Linq查询结果的集合</returns>
        public object SearchByProName(string name)
        {
            product_Entity P = new product_Entity();

            P.P_name = name;
            return(Date.searchByProName(P));
        }
Beispiel #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            SellService    a = new SellService();
            product_Entity b = new product_Entity();

            b.S_account  = Session["UserAccount"].ToString().Trim();
            b.P_name     = txtProduct_name.Text;
            b.P_category = txtProduct_category.Text;
            b.P_price    = double.Parse(txtProduct_price.Text);
            b.P_cNum     = int.Parse(txtProduct_number.Text);
            b.P_photo    = FileUpload1.FileName;
            a.add(b, FileUpload1);
            Response.Write(MessagesBox.showMessages("添加成功"));
        }
        /// <summary>
        /// 添加商品
        /// </summary>
        /// <param name="sellAccount"></param>
        /// <param name="product"></param>
        public void addProduct(product_Entity product, FileUpload e)
        {
            product_T productT = new product_T();

            productT.s_account  = product.S_account;
            productT.p_name     = product.P_name;
            productT.p_category = product.P_category;
            productT.p_price    = (decimal)product.P_price;
            productT.p_cNum     = product.P_cNum;
            productT.p_photo    = "~/Images/" + product.S_account + "/" + e.FileName + "";
            sellDB.product_T.InsertOnSubmit(productT);
            upLoadPhoto(e, product.S_account);
            sellDB.SubmitChanges();
        }
        //以下是商品模块功能
        public product_Entity inquireProById(string account, int ProId)
        {
            product_T      product   = new product_T();
            product_Entity product_E = new product_Entity();

            product              = sellDB.product_T.Where(c => c.s_account.Equals(account) && c.p_Id.Equals(ProId)).First();
            product_E.P_Id       = product.p_Id;
            product_E.P_name     = product.p_name;
            product_E.P_photo    = product.p_photo;
            product_E.P_price    = (double)product.p_price;
            product_E.P_cNum     = product.p_cNum;
            product_E.P_saleNum  = product.p_saleNum;
            product_E.P_category = product.p_category;
            return(product_E);
        }
Beispiel #6
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            SellService    a = new SellService();
            product_Entity b = new product_Entity();

            b.P_Id       = int.Parse(Request.QueryString["id"].ToString());
            b.S_account  = Session["UserAccount"].ToString().Trim();
            b.P_name     = txtProduct_name.Text.Trim();
            b.P_category = txtProduct_category.Text.Trim();
            b.P_price    = double.Parse(txtProduct_price.Text.Trim());
            b.P_cNum     = int.Parse(txtProduct_number.Text.Trim());
            b.P_photo    = "~/Images/" + Session["UserAccount"].ToString().Trim() + "/" + FileUpload1.FileName;
            if (a.updateProInfo(Session["UserAccount"].ToString().Trim(), b, FileUpload1))
            {
                Response.Write(MessagesBox.showMessages("更改成功!"));
            }
            else
            {
                Response.Write(MessagesBox.showMessages("更改失败!"));
            }
        }
Beispiel #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["UserAccount"] == null)
     {
         Response.Redirect("../login.aspx");
     }
     //这里我改了,时间2016.12.17.22.05
     //else if (Session["UserAccount"].Equals(Request.QueryString["account"])==false)
     //{
     //    Response.Redirect("../login.aspx");
     //}
     if (!IsPostBack)
     {
         product_Entity product = new product_Entity();
         product = dt.inquireProById(Session["UserAccount"].ToString(), int.Parse(Request.QueryString["id"]));
         txtProduct_name.Text     = product.P_name;
         txtProduct_number.Text   = product.P_cNum.ToString();
         txtProduct_price.Text    = product.P_price.ToString();
         txtProduct_category.Text = product.P_category;
         Image1.ImageUrl          = product.P_photo;
     }
 }
        public bool updateProInfo(string sellerAccount, product_Entity product, FileUpload e)
        {
            var results = sellDB.product_T.Where(c => c.p_Id.Equals(product.P_Id) && c.s_account.Equals(sellerAccount));

            if (results.Count() > 0)
            {
                if (e.FileName != "")
                {
                    foreach (product_T p in results)
                    {
                        p.p_name     = product.P_name;
                        p.p_price    = decimal.Parse(product.P_price.ToString());
                        p.p_cNum     = product.P_cNum;
                        p.p_category = product.P_category;
                        upLoadPhoto(e, sellerAccount);
                    }
                    sellDB.SubmitChanges();
                }
                else
                {
                    foreach (product_T p in results)
                    {
                        p.p_name     = product.P_name;
                        p.p_price    = decimal.Parse(product.P_price.ToString());
                        p.p_cNum     = product.P_cNum;
                        p.p_category = product.P_category;
                    }
                    sellDB.SubmitChanges();
                }
                return(true);
            }
            else
            {
                return(true);
            }
        }
Beispiel #9
0
        /// <summary>
        /// searchByCategory函数的功能:访问数据库根据商品的分类查找出商品的信息
        /// </summary>
        /// <param name="product">商品对象</param>
        /// <returns>LINQ查询结果的集合</returns>
        public object searchByCategory(product_Entity product)
        {
            var Category = buyerDB.product_T.Where(r => r.p_category == product.P_category).Select(r => r);

            return((object)Category);
        }
Beispiel #10
0
        //--搜索模块--

        /// <summary>
        /// searchByProName函数的功能:访问数据库根据商品的名称查找出商品的信息
        /// </summary>
        /// <param name="product">商品对象</param>
        /// <returns>LINQ查询结果的集合</returns>
        public object searchByProName(product_Entity product)
        {
            var Name = buyerDB.product_T.Where(n => n.p_name == product.P_name).Select(n => n);

            return((object)Name);
        }
 /// <summary>
 /// 添加商品
 /// </summary>
 /// <param name="a"></param>
 /// <param name="e"></param>
 public void add(product_Entity a, FileUpload e)
 {
     /*product_T b = new product_T();*/
     db.addProduct(a, e);
 }
 /// <summary>
 /// 修改商品
 /// </summary>
 /// <param name="a"></param>
 /// <param name="s_account"></param>
 /// <param name="e"></param>
 public bool updateProInfo(string sellerAccount, product_Entity product, FileUpload e)
 {
     return(db.updateProInfo(sellerAccount, product, e));
 }