コード例 #1
0
        public ActionResult GioHang()
        {
            OrderCart model = new OrderCart();

            model.listSanpham = new List <ProductsCart>();
            ProductsBLL _getprod = new ProductsBLL();

            if (Request.Cookies["shopcard"] != null)
            {
                var             _list        = JsonConvert.DeserializeObject <List <Cart> >(Request.Cookies["shopcard"].Value);
                List <Products> _listProduct = new List <Products>();
                _list.ForEach(p => {
                    var _object = _getprod.ProductById(p.ProductId);
                    if (_object != null)
                    {
                        ProductsCart _cart = new ProductsCart();
                        _cart.Id           = _object.Id;
                        _cart.Name         = _object.Name;
                        _cart.Price        = _object.Price;
                        _cart.PriceSale    = _object.PriceSale;
                        _cart.Url          = _object.Url;
                        _cart.Quality      = p.Number;
                        _cart.AllPrice     = (_object.PriceSale == 0 ? (p.Number * _object.Price) : (p.Number * _object.PriceSale));
                        model.listSanpham.Add(_cart);
                    }
                });
                model.TamTinh    = model.listSanpham.Sum(p => p.AllPrice);
                model.AllPayment = model.listSanpham.Sum(p => p.AllPrice);
            }

            return(View(model));
        }
コード例 #2
0
ファイル: ProductAdd.aspx.cs プロジェクト: shoted/Online-Shop
 protected void Page_Load(object sender, EventArgs e)
 {
     categories = categoriesBLL.QueryList(-1, -1, null, "", false);
     if (RequestHelper.IsPostBack(Request))
     {
         ProductsBLL productsBLL = new ProductsBLL();
         Products    products    = new Products
         {
             productName      = Request["pname"],
             productPrice     = Request["pprice"].ToDecimal(),
             productDecribe   = Request["pdesc"],
             productDetail    = Request["pdetail"],
             productInventory = Request["pinventory"].ToInt32(),
             productStatus    = 1,
             productStone     = Request["pstone"].ToInt32(),
             categoryId       = Request["slt"].ToInt32(),
             productIMG       = IMGSave("file-2"),
             add_time         = DateTime.Now,
         };
         if (productsBLL.Insert(products) > 0)
         {
             msg = "上架成功";
             js  = LayerClose();
             return;
         }
         msg = "上架失败";
     }
 }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: alexit2013/PSS
        /// <summary>
        /// 根据商品类别ID查询商品的个数
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult ProductsGetByPTIDCount(int id)
        {
            int count = ProductsBLL.GetAllByPTIDCount(id);
            int page  = count % 10 == 0 ? count / 10 : count / 10 + 1;

            return(Json(new { Count = count, Page = page }));
        }
コード例 #4
0
        public static void Init()
        {
            var fullPath    = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["ProductsXmlFileLocation"]);
            var productsBll = new ProductsBLL(fullPath);

            productsBll.GenerateXML();
        }
コード例 #5
0
        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            ProductsBLL bll = new ProductsBLL();

            if (bll.CheckProductName(shopid, txtProductName.Value) > 0)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('菜品名称已存在')", true);
            }
            else
            {
                Product item = new Product();
                item.ShopId      = shopid;
                item.TypeId      = Convert.ToInt32(ddl_shoptype.SelectedValue);
                item.ProductName = txtProductName.Value;
                item.Price       = Convert.ToDecimal(txtPrice.Value);
                item.Price2      = Convert.ToDecimal(txtPrice2.Value);
                item.ImgSrc      = txtImgSrc.Value;
                item.SortId      = 1;
                item.SellStatus  = 1;
                if (new ProductsBLL().AddItem(item) > 0)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('添加成功')", true);
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('添加失败')", true);
                }
            }
        }
コード例 #6
0
ファイル: 选定套餐.cs プロジェクト: wrj0823/RMS
        private void  定套餐_Load(object sender, EventArgs e)
        {
            //查询所有商品
            List <ProductsMDL> list_cm = ProductsBLL.selectProduct("");

            dataGridView2.AutoGenerateColumns = false;
            dataGridView2.DataSource          = list_cm;
            dataGridView2.Columns[2].Visible  = false;
            dataGridView2.Columns[3].Visible  = false;
            dataGridView2.Columns[4].Visible  = false;
            List <ProductTypeMDL> list_PR = ProductTypeBLL.selectProductType();


            foreach (var item in list_PR)
            {
                TreeNode tr = new TreeNode();
                tr.Text = item.PTName;
                tr.Tag  = item.PTID;
                List <ProductsMDL> list_P = ProductsBLL.selectProducts(item.PTID, "");
                foreach (ProductsMDL item_P in list_P)
                {
                    TreeNode tr_P = new TreeNode();
                    tr_P.Text = item_P.ProductName;
                    tr_P.Tag  = item_P.ProductID;
                    tr_P.Name = item_P.ProductPrice.ToString();
                    tr.Nodes.Add(tr_P);
                }

                treeView1.Nodes.Add(tr);
            }
        }
コード例 #7
0
        public ProductsBLL GetProductIDFromName(string ProductName)
        {
            ProductsBLL   p    = new ProductsBLL();
            SqlConnection conn = new SqlConnection(myconnstrng);
            DataTable     dt   = new DataTable();

            try
            {
                String         sql     = "SELECT id FROM tbl_products WHERE name = '" + ProductName + "'";
                SqlCommand     cmd     = new SqlCommand(sql, conn);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                conn.Open();
                adapter.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    p.id = int.Parse(dt.Rows[0]["id"].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(p);
        }
コード例 #8
0
        public ProductsBLL SearchProductForTransaction(string keyword)
        {
            SqlConnection conn = new SqlConnection(myconnstrng);
            ProductsBLL   p    = new ProductsBLL();
            DataTable     dt   = new DataTable();

            try
            {
                String         sql     = "SELECT name,rate,qty FROM tbl_products WHERE id LIKE '%" + keyword + "%' OR name LIKE '%" + keyword + "%' ";
                SqlCommand     cmd     = new SqlCommand(sql, conn);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                conn.Open();
                adapter.Fill(dt);

                if (dt.Rows.Count > 0)
                {
                    p.name = dt.Rows[0]["name"].ToString();
                    p.rate = decimal.Parse(dt.Rows[0]["rate"].ToString());
                    p.qty  = decimal.Parse(dt.Rows[0]["qty"].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(p);
        }
コード例 #9
0
ファイル: Basics.aspx.cs プロジェクト: sullivankarate/Repo
    protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)
    {
        // Read in the ProductID from the DataKeys collection
        int productID = Convert.ToInt32(DataList1.DataKeys[e.Item.ItemIndex]);

        // Read in the product name and price values
        TextBox productName = (TextBox)e.Item.FindControl("ProductName");
        TextBox unitPrice   = (TextBox)e.Item.FindControl("UnitPrice");

        string productNameValue = null;

        if (productName.Text.Trim().Length > 0)
        {
            productNameValue = productName.Text.Trim();
        }

        decimal?unitPriceValue = null;

        if (unitPrice.Text.Trim().Length > 0)
        {
            unitPriceValue = Decimal.Parse(unitPrice.Text.Trim(), System.Globalization.NumberStyles.Currency);
        }

        // Call the ProductsBLL's UpdateProduct method...
        ProductsBLL productsAPI = new ProductsBLL();

        productsAPI.UpdateProduct(productNameValue, unitPriceValue, productID);


        // Revert the DataList back to its pre-editing state
        DataList1.EditItemIndex = -1;
        DataList1.DataBind();
    }
コード例 #10
0
    protected void SuppliersProducts_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.CompareTo("IncreasePrice") == 0 ||
            e.CommandName.CompareTo("DecreasePrice") == 0)
        {
            // The Increase Price or Decrease Price Button has been clicked

            // Determine the ID of the product whose price was adjusted
            int productID = (int)SuppliersProducts.DataKeys[Convert.ToInt32(e.CommandArgument)].Value;

            // Determine how much to adjust the price
            decimal percentageAdjust;
            if (e.CommandName.CompareTo("IncreasePrice") == 0)
            {
                percentageAdjust = 1.1M;
            }
            else
            {
                percentageAdjust = 0.9M;
            }


            // Adjust the price
            ProductsBLL productInfo = new ProductsBLL();
            productInfo.UpdateProduct(percentageAdjust, productID);
        }
    }
コード例 #11
0
        private void panel3_VisibleChanged(object sender, EventArgs e)
        {
            List <ProductTypeMDL> list = ProductTypeBLL.selectProductType();

            dataGridView1.DataSource = list;

            List <ProductsMDL> list_cm = ProductsBLL.selectProducts(0, "");

            dataGridView2.AutoGenerateColumns = false;
            dataGridView2.DataSource          = list_cm;
            dataGridView2.Columns[3].Visible  = false;
            dataGridView2.Columns[4].Visible  = false;
            dataGridView2.Columns[5].Visible  = false;
            dataGridView2.Columns[6].Visible  = false;
            dataGridView2.Columns[7].Visible  = false;



            List <ProductTypeMDL> list1 = ProductTypeBLL.selectProductType();

            list1.Insert(0, (new ProductTypeMDL {
                PTID = 0, PTName = "全部"
            }));
            comboBox2.DisplayMember = "PTName";
            comboBox2.ValueMember   = "PTID";

            comboBox2.DataSource = list1;
        }
コード例 #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ProductsBLL productLogic = new ProductsBLL();

        GridView1.DataSource = productLogic.GetProducts();
        GridView1.DataBind();
    }
コード例 #13
0
ファイル: Basics.aspx.cs プロジェクト: kjeans/online-shop
    protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)
    {
        // Read in the ProductID from the DataKeys collection
        int productID = Convert.ToInt32(DataList1.DataKeys[e.Item.ItemIndex]);

        // Read in the product name and price values
        TextBox productName = (TextBox)e.Item.FindControl("ProductName");
        TextBox unitPrice = (TextBox)e.Item.FindControl("UnitPrice");

        string productNameValue = null;
        if (productName.Text.Trim().Length > 0)
            productNameValue = productName.Text.Trim();

        decimal? unitPriceValue = null;
        if (unitPrice.Text.Trim().Length > 0)
            unitPriceValue = Decimal.Parse(unitPrice.Text.Trim(), System.Globalization.NumberStyles.Currency);

        // Call the ProductsBLL's UpdateProduct method...
        ProductsBLL productsAPI = new ProductsBLL();
        productsAPI.UpdateProduct(productNameValue, unitPriceValue, productID);

        // Revert the DataList back to its pre-editing state
        DataList1.EditItemIndex = -1;
        DataList1.DataBind();
    }
コード例 #14
0
        protected string GetProductByTypeId(object typeid)
        {
            StringBuilder  strResult = new StringBuilder();
            List <Product> list      = new ProductsBLL().GetListByTypeAndShop(Convert.ToInt32(typeid), shopid);

            if (see_pic == 1)
            {
                strResult.Append("<ul class=\"cdlist\">");
                foreach (Product pitem in list)
                {
                    strResult.Append("<li class=\"pline\"><img src=\"" + pitem.ImgSrc + "\" title=\"" + pitem.ProductName + "\" />");
                    strResult.Append("<div class=\"price\">" + pitem.ProductName + "<br />¥" + pitem.Price + "</div>");
                    strResult.Append("<a href=\"javascript:;\" onclick=\"AddShoppingCar(" + pitem.Id + ")\">要一份</a>");
                    strResult.Append("</li>");
                }
                strResult.Append("</ul>");
            }
            else
            {
                strResult.Append("<ul class=\"cdlist2\">");
                foreach (Product pitem in list)
                {
                    strResult.Append("<li><span class=\"sl\">" + pitem.ProductName + "</span><span class=\"sr\"><span class=\"price\">¥" + pitem.Price + "</span><a href=\"javascript:;\" onclick=\"AddShoppingCar(" + pitem.Id + ")\">要一份</a></span></li>");
                }
                strResult.Append("</ul>");
            }
            return(strResult.ToString());
        }
コード例 #15
0
ファイル: HomeController.cs プロジェクト: alexit2013/PSS
        /// <summary>
        /// 多条件商品查询
        /// </summary>
        /// <param name="ProName">商品名称</param>
        /// <param name="PTID">商品类型</param>
        /// <param name="PUID">商品规格</param>
        /// <param name="PCID">商品颜色</param>
        /// <param name="PSID">商品单位</param>
        /// <param name="PageIndex">当前页</param>
        /// <returns></returns>
        public ActionResult FindProducts(string ProName, int PTID, int PUID, int PCID, int PSID, int PageIndex)
        {
            int             count        = 0;
            List <Products> list         = ProductsBLL.Find(ProName, PTID, PUID, PCID, PSID, out count, PageIndex, 5);
            int             MaxPageIndex = count % 5 == 0 ? count / 5 : count / 5 + 1;

            if (list.Count > 0)
            {
                var listed = from s in list
                             select new
                {
                    s.ProID,
                    s.ProName,
                    s.ProductTypes.PTName,
                    s.ProductUnit.PUName,
                    s.ProductSpec.PSName,
                    s.ProductColor.PCName,
                    s.ProPrice,
                    MaxPageIndex = MaxPageIndex             //最大页数
                };
                return(Json(listed));
            }
            else
            {
                List <object> listed = new List <object>();
                listed.Add(new { ProID = "", MaxPageIndex = 0 });
                return(Json(listed));
            }
        }
コード例 #16
0
        public bool insertAndUpdate(ProductsBLL p)
        {
            bool isSuccess = false;

            try
            {
                SqlCommand cmd = new SqlCommand("USP_InsertProductDetails", AppManager.ConnectionManager);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("id", SqlDbType.Int).Value              = p.id;
                cmd.Parameters.Add("name", SqlDbType.VarChar).Value        = p.name;
                cmd.Parameters.Add("category", SqlDbType.VarChar).Value    = p.category;
                cmd.Parameters.Add("rate", SqlDbType.Decimal).Value        = p.rate;
                cmd.Parameters.Add("qty", SqlDbType.Decimal).Value         = p.qty;
                cmd.Parameters.Add("description", SqlDbType.VarChar).Value = p.description;
                cmd.Parameters.Add("added_date", SqlDbType.DateTime).Value = p.added_date;
                cmd.Parameters.Add("added_by", SqlDbType.Int).Value        = p.added_by;
                int row = cmd.ExecuteNonQuery();
                if (row > 0)
                {
                    isSuccess = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(isSuccess);
        }
コード例 #17
0
 private bool ProductExists(int id)
 {
     using (ProductsBLL bll = new ProductsBLL())
     {
         return(bll.ProductExists(id));
     }
 }
コード例 #18
0
ファイル: FrmProductsX.cs プロジェクト: JacBang/CMS
        /// <summary>
        /// 商品修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.txtjp.Text == "" || this.txtname.Text == "" || this.txtprice.Text == "")
            {
                MessageBox.Show("未插入数据");
            }
            else
            {
                string name = this.txtname.Text;
                string xue  = this.txtjp.Text;
                int    lei  = Convert.ToInt32(this.cbotype.SelectedValue);
                double jia  = Convert.ToDouble(this.txtprice.Text);
                int    id   = Convert.ToInt32(Comm.ProductID);

                Products list = new Products();
                list.ProductID    = id;
                list.ProductName  = name;
                list.ProductJP    = xue;
                list.PTID         = lei;
                list.ProductPrice = jia;
                bool b = ProductsBLL.update(list);
                if (b == true)
                {
                    MessageBox.Show("修改成功");

                    this.Close();
                }
                else
                {
                    MessageBox.Show("修改失败");
                }
            }
        }
コード例 #19
0
        public ProductsBLL SearchDealerAndCustomerForTransaction(string keyword)
        {
            DataTable   dt = new DataTable();
            ProductsBLL p  = new ProductsBLL();

            try
            {
                SqlCommand cmd = new SqlCommand("USP_SearchProductsForTransaction", AppManager.ConnectionManager);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("keyword", SqlDbType.VarChar).Value = keyword;
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                DataSet        ds      = new DataSet();
                adapter.Fill(ds);
                adapter.Dispose();
                dt = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    p.name = Common.ConvertToString(dt.Rows[0]["name"]);
                    p.rate = Common.ConvertToDouble(dt.Rows[0]["rate"]);
                    p.qty  = Common.ConvertToDouble(dt.Rows[0]["qty"]);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(p);
        }
コード例 #20
0
        /// <summary>
        /// 修改商品
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button5_Click(object sender, EventArgs e)
        {
            if (this.lv2.SelectedItems.Count != 1)
            {
                MessageBox.Show("还没选择项");
            }
            else
            {
                string a = this.lv2.SelectedItems[0].Text;
                Comm.ProductID = a;
                //显示简xie
                int      jp = Convert.ToInt32(this.lv2.SelectedItems[0].Text);
                Products f  = ProductsBLL.select(jp);
                Comm.ProductJP = f.ProductJP;

                ////显示其他
                string name = this.lv2.SelectedItems[0].SubItems[1].Text;
                Comm.ProductName = name;
                string jia = this.lv2.SelectedItems[0].SubItems[3].Text;
                Comm.ProductPrice = jia;
                FrmProductsX fm = new FrmProductsX();
                fm.ShowDialog();
                this.lv.Items.Clear();
                sx();
            }
        }
コード例 #21
0
 private void button4_Click(object sender, EventArgs e)
 {
     //删除类别
     if (this.lv2.SelectedItems.Count == 0)
     {
         MessageBox.Show("还没选择项");
     }
     else
     {
         DialogResult dr = MessageBox.Show(this, "确定要删除该条数据吗?", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             string id = this.lv2.SelectedItems[0].Text;
             bool   b  = ProductsBLL.database(id);
             if (b == true)
             {
                 MessageBox.Show(this, "删除成功", "提示");
                 this.lv2.Items.Clear();
                 this.lv.Items.Clear();
                 sx();
             }
             else
             {
                 MessageBox.Show(this, "删除失败", "提示");
             }
         }
     }
 }
コード例 #22
0
        private void button8_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("是否确认删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == System.Windows.Forms.DialogResult.Yes)
            {
                int count = ProductsBLL.DeleteProducts(Convert.ToInt32(dataGridView2.SelectedRows[0].Cells[5].Value));
                if (count > 0)
                {
                    new Warning("删除成功", 图标.Yes).Show();
                    List <ProductsMDL> list_cm = ProductsBLL.selectProducts(Convert.ToInt32(comboBox2.SelectedValue.ToString()), "");
                    dataGridView2.AutoGenerateColumns = false;
                    dataGridView2.DataSource          = list_cm;
                    dataGridView2.Columns[3].Visible  = false;
                    dataGridView2.Columns[4].Visible  = false;
                    dataGridView2.Columns[5].Visible  = false;
                    dataGridView2.Columns[6].Visible  = false;
                    dataGridView2.Columns[7].Visible  = false;
                }
                else
                {
                    new Warning("删除失败", 图标.Erro).Show();
                }
            }
        }
コード例 #23
0
        public bool Delete(ProductsBLL bd)
        {
            SqlConnection con       = new SqlConnection(this.connect.connection);
            bool          isSuccess = false;

            try
            {
                string     sql = "DELETE FROM tblproducts WHERE id=@id";
                SqlCommand cmd = new SqlCommand(sql, con);
                cmd.Parameters.AddWithValue("@id", bd.ID);
                con.Open();
                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.ToString());
            }
            finally {
                con.Close();
            }

            return(isSuccess);
        }
コード例 #24
0
 // GET: api/Products
 public IQueryable <Product> GetProducts()
 {
     using (ProductsBLL bll = new ProductsBLL())
     {
         return(bll.GetProducts());
     }
 }
コード例 #25
0
        public ActionResult ChiTietSanPham(string url)
        {
            ProductsBLL _get = new ProductsBLL();
            var         rs   = _get.SelectProductDetail(url);

            return(View(rs));
        }
コード例 #26
0
        public bool Delete(ProductsBLL p)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstrng);

            try
            {
                String     sql = "DELETE  FROM tbl_products WHERE id=@id";
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@id", p.id);
                conn.Open();
                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
コード例 #27
0
ファイル: Index.aspx.cs プロジェクト: hofmannzhu/bwjs
        public int BackgroundRefreshTime = int.Parse(LinkFun.ConfigString("BackgroundRefreshTime", "7200000")); //背景刷新时间


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ProductIndexRefreshTime = LinkFun.ConfigString("ProductIndexRefreshTime", "7200000"); //LinkFun.getProductIndexRefreshTime();
                ProductsBLL        adHelper            = new ProductsBLL();
                ProductCategoryBLL oProductCategoryBLL = new ProductCategoryBLL();
                oCategoryList = oProductCategoryBLL.GetCardTypeList();
                LoginUserCookie cookie = MerchantFrontCookieBLL.GetMerchantFrontUserCookie();
                magName = cookie.LoginName;
                CompanyBLL opCompanyBLL = new CompanyBLL();

                StringBuilder where = new StringBuilder();
                //where.AppendFormat("IsDeleted=0 and CompanyCategoryId=2 order by OrderId asc");
                //litCompanyNetLoan = opCompanyBLL.GetModelList(where.ToString());

                where = new StringBuilder();
                where.AppendFormat("IsDeleted=0 and CompanyCategoryId=4 order by OrderId asc");
                litCompanyBank = opCompanyBLL.GetModelList(where.ToString());

                where = new StringBuilder();
                where.AppendFormat("IsDeleted=0 and CompanyCategoryId=5 order by OrderId asc");
                litCompanyOther = opCompanyBLL.GetModelList(where.ToString());
            }
        }
コード例 #28
0
ファイル: FrmAddConsumer.cs プロジェクト: wrj0823/RMS
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            List <ProductsMDL> list_cm = ProductsBLL.selectProduct(textBox1.Text);

            dataGridView2.AutoGenerateColumns = false;
            dataGridView2.DataSource          = list_cm;
            dataGridView2.Columns[2].Visible  = false;
        }
コード例 #29
0
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            List <ProductsMDL> list_cm = ProductsBLL.selectProducts(Convert.ToInt32(comboBox2.SelectedValue.ToString()), textBox1.Text);

            dataGridView2.AutoGenerateColumns = false;

            dataGridView2.DataSource = list_cm;
        }
コード例 #30
0
        public ActionResult DanhMucSanPham(string url)
        {
            ProductsBLL _get   = new ProductsBLL();
            var         result = _get.SelectProductByCategory(url);

            ViewBag.url = url;
            return(View(result));
        }
コード例 #31
0
ファイル: frmManageProduct.cs プロジェクト: luan-cs/API
        private void frmManageProduct_Load(object sender, EventArgs e)
        {
            // khởi tạo các đối tượng
            proBLL = new ProductsBLL();

            // load tat ca cac bien tham so lua chon..
            LoadProductType();
        }
コード例 #32
0
ファイル: Basics.aspx.cs プロジェクト: kjeans/online-shop
    protected void DataList1_DeleteCommand(object source, DataListCommandEventArgs e)
    {
        // Read in the ProductID from the DataKeys collection
        int productID = Convert.ToInt32(DataList1.DataKeys[e.Item.ItemIndex]);

        // Delete the data
        ProductsBLL productsAPI = new ProductsBLL();
        productsAPI.DeleteProduct(productID);

        // Rebind the data to the DataList
        DataList1.DataBind();
    }
コード例 #33
0
    protected Northwind.ProductsDataTable GetProductsInCategory(int categoryID)
    {
        // First, see if we've yet to have accessed all of the product information
        if (allProducts == null)
        {
            ProductsBLL productAPI = new ProductsBLL();
            allProducts = productAPI.GetProducts();
        }

        // Return the filtered view
        allProducts.DefaultView.RowFilter = "CategoryID = " + categoryID;
        return allProducts;
    }
コード例 #34
0
    protected void Categories_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "ShowProducts")
        {
            // Determine the CategoryID
            int categoryID = Convert.ToInt32(e.CommandArgument);

            // Get the associated products from the ProudctsBLL and bind them to the BulletedList
            BulletedList products = (BulletedList)e.Item.FindControl("ProductsInCategory");
            ProductsBLL productsAPI = new ProductsBLL();
            products.DataSource = productsAPI.GetProductsByCategoryID(categoryID);
            products.DataBind();
        }
    }
コード例 #35
0
    protected void Suppliers_ItemCommand(object sender, FormViewCommandEventArgs e)
    {
        if (e.CommandName.CompareTo("DiscontinueProducts") == 0)
        {
            // The "Discontinue All Products" Button was clicked.
            // Invoke the ProductsBLL.DiscontinueAllProductsForSupplier(supplierID) method

            // First, get the SupplierID selected in the FormView
            int supplierID = (int)Suppliers.SelectedValue;

            // Next, create an instance of the ProductsBLL class
            ProductsBLL productInfo = new ProductsBLL();

            // Finally, invoke the DiscontinueAllProductsForSupplier(supplierID) method
            productInfo.DiscontinueAllProductsForSupplier(supplierID);
        }
    }
コード例 #36
0
    protected void SuppliersProducts_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.CompareTo("IncreasePrice") == 0 ||
            e.CommandName.CompareTo("DecreasePrice") == 0)
        {
            // The Increase Price or Decrease Price Button has been clicked

            // Determine the ID of the product whose price was adjusted
            int productID = (int)SuppliersProducts.DataKeys[Convert.ToInt32(e.CommandArgument)].Value;

            // Determine how much to adjust the price
            decimal percentageAdjust;
            if (e.CommandName.CompareTo("IncreasePrice") == 0)
                percentageAdjust = 1.1M;
            else
                percentageAdjust = 0.9M;

            // Adjust the price
            ProductsBLL productInfo = new ProductsBLL();
            productInfo.UpdateProduct(percentageAdjust, productID);
        }
    }
コード例 #37
0
    protected void Products_UpdateCommand(object source, DataListCommandEventArgs e)
    {
        // Make sure the page is valid...
        if (!Page.IsValid)
            return;

        // Read in the ProductID from the DataKeys collection
        int productID = Convert.ToInt32(Products.DataKeys[e.Item.ItemIndex]);

        // Read in the product name and price values
        TextBox productName = (TextBox)e.Item.FindControl("ProductName");
        DropDownList categories = (DropDownList)e.Item.FindControl("Categories");
        DropDownList suppliers = (DropDownList)e.Item.FindControl("Suppliers");
        CheckBox discontinued = (CheckBox)e.Item.FindControl("Discontinued");

        string productNameValue = null;
        if (productName.Text.Trim().Length > 0)
            productNameValue = productName.Text.Trim();

        int? categoryIDValue = null;
        if (!string.IsNullOrEmpty(categories.SelectedValue))
            categoryIDValue = Convert.ToInt32(categories.SelectedValue);

        int? supplierIDValue = null;
        if (!string.IsNullOrEmpty(suppliers.SelectedValue))
            supplierIDValue = Convert.ToInt32(suppliers.SelectedValue);

        bool discontinuedValue = discontinued.Checked;

        // Call the ProductsBLL's UpdateProduct method...
        ProductsBLL productsAPI = new ProductsBLL();
        productsAPI.UpdateProduct(productNameValue, categoryIDValue, supplierIDValue, discontinuedValue, productID);

        // Revert the DataList back to its pre-editing state
        Products.EditItemIndex = -1;
        Products.DataBind();
    }
コード例 #38
0
    protected void Products_UpdateCommand(object source, DataListCommandEventArgs e)
    {
        if (!Page.IsValid)
            return;

        // Handle any exceptions raised during the editing process
        try
        {
            // Read in the ProductID from the DataKeys collection
            int productID = Convert.ToInt32(Products.DataKeys[e.Item.ItemIndex]);

            // Read in the product name and price values
            TextBox productName = (TextBox)e.Item.FindControl("ProductName");
            TextBox unitPrice = (TextBox)e.Item.FindControl("UnitPrice");

            string productNameValue = null;
            if (productName.Text.Trim().Length > 0)
                productNameValue = productName.Text.Trim();

            decimal? unitPriceValue = null;
            if (unitPrice.Text.Trim().Length > 0)
                unitPriceValue = Decimal.Parse(unitPrice.Text.Trim(), System.Globalization.NumberStyles.Currency);

            // Call the ProductsBLL's UpdateProduct method...
            ProductsBLL productsAPI = new ProductsBLL();
            productsAPI.UpdateProduct(productNameValue, unitPriceValue, productID);

            // Revert the DataList back to its pre-editing state
            Products.EditItemIndex = -1;
            Products.DataBind();
        }
        catch (Exception ex)
        {
            DisplayExceptionDetails(ex);
        }
    }