public Products RetrieveProductById(int ID) { var BL = new BLL.Product(); var Result = BL.RetrieveById(ID); return(Result); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { List <Model.ProductType> Typelist = new BLL.ProductType().GetList(0, "Lang='zh_cn' and IsPass=1 ", "Sort asc"); head1.Typelist = Typelist; rptfootlist.DataSource = Typelist; rptfootlist.DataBind(); string key = Server.UrlDecode(base.QueryString("key")); head1.Key = key; BLL.Product bll = new BLL.Product(); rptIsSearchProduct.DataSource = bll.GetList("IsDelete=0 and IsPass=1 and IsSearch=1 and ClassID in (Select ClassID from TB_ProductType where IsPass=1 and Lang='zh_cn')"); rptIsSearchProduct.DataBind(); List <Model.Product> list = bll.GetList(0, " IsDelete=0 and IsPass=1 and ProName like'%" + key + "%' or Contents like '%" + key + "%'", " Sort asc"); if (list != null && list.Count > 0) { lit_Menu.Text = "<div class=\"tab-box\"><p class=\"breadcrumb fullpage-inside\"><a href=\"/cn/\">首页</a>>><a href=\"javascript:void(0)\">全部结果</a>>><a class=\"bc-result\" href=\"javascript:void(0)\">" + key + "</a></p></div>"; BindSearchProduct(list); } else { lit_Search.Text = "<div class=\"search-no-shild\"><p class=\"search-no-tit\">抱歉, 没有搜索到与\"<span>" + key + "</span>\"相关的商品</p><p>请检查您的输入是否有误</p><p>您可以尝试以下搜索:<span><a href=\"/cn/Search/?key=" + Server.UrlEncode("通讯类") + "\">通讯类</a></span>|<span><a href=\"/cn/Search/?key=" + Server.UrlEncode("电力类") + "\">电力类</a></span>|<span><a href=\"/cn/Search/?key=" + Server.UrlEncode("家具类") + "\">家具类</a></span>|<span><a href=\"/cn/Search/?key=" + Server.UrlEncode("金融类") + "\">金融类</a></span>|<span><a href=\"/cn/Search/?key=" + Server.UrlEncode("精密机床") + "\">精密机床</a></span>|<span><a href=\"/cn/Search/?key=" + Server.UrlEncode("新能源类") + "\">新能源类</a></span>|<span><a href=\"/cn/Search/?key=" + Server.UrlEncode("精密加工") + "\">精密加工</a></span></p></div>"; } } }
private void AddItem_Load(object sender, EventArgs e) { DosageForm doFrm = new DosageForm(); doFrm.GetDosageForSupply(); doFrm.Sort = "Form"; cboDosageForm.Properties.DataSource = doFrm.DefaultView; Unit un = new Unit(); un.LoadAll(); un.Sort = "Unit"; cboUnit.Properties.DataSource = un.DefaultView; Product pInn = new Product(); pInn.GetInnForSupply(); pInn.Sort = "IIN"; cboIIN.Properties.DataSource = pInn.DefaultView; //if (categoryId != 0) //{ // SubCategory cat = new SubCategory(); // DataTable dtProd = cat.GetSubCategoryByID(categoryId); // string[] categor = { dtProd.Rows[0]["CategoryName"].ToString(), dtProd.Rows[0]["SubCategoryName"].ToString() }; // ListViewItem listCat = new ListViewItem(categor); // listCat.Tag = dtProd.Rows[0]["ID"]; // lstCat.Items.Add(listCat); // //txtCatCode.Text = dtProd.Rows[0]["CategoryCode"].ToString() + "-" + dtProd.Rows[0]["SubCategoryCode"].ToString(); //} if(_categoryId == 0) { PopulateFields(); } }
public bool UpdateProduct(Products ProductToUpdate) { var BL = new BLL.Product(); var Result = BL.Update(ProductToUpdate); return(Result); }
public List <Products> FilterProductByCategoryID(int ID) { var BL = new BLL.Product(); var result = BL.FilterByCategoryID(ID); return(result); }
public Products CreateProduct(Products newProduct) { var BL = new BLL.Product(); var NewProduct = BL.Create(newProduct); return(NewProduct); }
private void productBind() { Model.Product model = new BLL.Product().GetModelBystrWhere("ID=" + id + " and IsDelete=0 and IsPass=1 "); if (model == null) { MessageBox.ShowRedirect("参数错误!", "/cn/product"); } lit_Contents.Text = model.Contents; if (!String.IsNullOrEmpty(model.PageTitle)) { this.Title = model.PageTitle; } if (!String.IsNullOrEmpty(model.Matedescription)) { base.MateDescription = model.Matedescription; } if (!String.IsNullOrEmpty(model.Matekeyword)) { base.MetaKeywords = model.Matekeyword; } lit_list.Text = "<a href='Default.aspx?classid=" + model.ClassID.Value + "'>返回列表</a>"; rptlistBind(model); }
private void PopulateCatTree() { ProductTree.Nodes.Clear(); if (Convert.ToInt32(lkCommodityTypes.EditValue) == BLL.Type.Constants.Pharmacuticals) { Category cat = new Category(); SubCategory subCat = new SubCategory(); Product prod = new Product(); cat.LoadAll(); cat.Sort = "CategoryName"; ProductTree.Nodes.Add("All0", "All"); foreach (DataRowView dv in cat.DefaultView) { TreeNode nodes = new TreeNode(); nodes.Name = "cat" + dv["ID"].ToString(); nodes.Text = dv["CategoryName"].ToString() + " (" + dv["CategoryCode"].ToString() + ")"; nodes.ToolTipText = "Double Click to List"; subCat.GetSubCategory(Convert.ToInt32(dv["ID"])); subCat.Sort = "SubCategoryName"; foreach (DataRowView subDv in subCat.DefaultView) { TreeNode subNodes = new TreeNode(); subNodes.Name = "sub" + subDv["ID"].ToString(); subNodes.Text = subDv["SubCategoryName"].ToString() + " (" + subDv["SubCategoryCode"].ToString() + ")"; subNodes.ToolTipText = "Double Click to List"; nodes.Nodes.Add(subNodes); } ProductTree.Nodes[0].Nodes.Add(nodes); } ProductTree.Nodes[0].Expand(); } else { SupplyCategory scat = new SupplyCategory(); scat.LoadAll(); scat.Sort = "Name"; ProductTree.Nodes.Add("Als0", "All"); foreach (DataRowView dv in scat.DefaultView) { TreeNode nodes = new TreeNode(); nodes.Name = "sup" + dv["ID"].ToString(); nodes.Text = dv["Name"].ToString(); nodes.ToolTipText = "Double Click to List"; ProductTree.Nodes[0].Nodes.Add(nodes); } ProductTree.Nodes[0].Expand(); } }
protected void BtnSaveProduct_Click(object sender, EventArgs e) { Product prod = new Product(); if (productID>0) { prod.LoadByPrimaryKey(productID); } else { prod.AddNew(); } prod.NameEn = txtProdName.Text; prod.CatID = int.Parse(Session["CategoryID"].ToString()); prod.DescriptionEn = txtProdDesc.Text; if (FileUploadMainImg.HasFile) { Bitmap UpImg = (Bitmap)Bitmap.FromStream(FileUploadMainImg.PostedFile.InputStream); string path = "UploadedFiles/Products/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + FileUploadMainImg.FileName; UpImg.Save(MapPath(path), System.Drawing.Imaging.ImageFormat.Png); prod.MainImagePath = path; } prod.YouTubeLink = txtVidLink.Text; prod.AppearInHome = chkAvailHome.Checked; prod.IsActive = chkActive.Checked; prod.Save(); Response.Redirect("Products.aspx?cid=" + Session["CategoryID"]); }
//private void GrdBind() //{ // Product prod = new Product(); // prod.LoadAll(); // GrdViewProducts.DataSource = prod.DefaultView; // GrdViewProducts.DataBind(); //} private void GrdCatsBind() { Product prod = new Product(); prod.Where.CatID.Value = int.Parse(Request.QueryString["Cid"]); prod.Where.CatID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal; prod.Query.Load(); GrdViewProducts.DataSource = prod.DefaultView; GrdViewProducts.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["Cid"])) { Session["CategoryID"] = int.Parse(Request.QueryString["Cid"]); lblCatNameTitle.Text = "Category : " + getCatName(); GrdCatsBind(); } if (!string.IsNullOrEmpty(Request.QueryString["NewProd"])) { PlaceHolderEditProd.Visible = true; PlaceHolderFiles.Visible = false; PlaceHolderGrd.Visible = false; PlaceHolderImgs.Visible = false; lblCatName.Text = getCatName(); } else if (productID > 0) { if (!string.IsNullOrEmpty(Request.QueryString["EditProd"])) { PlaceHolderEditProd.Visible = true; PlaceHolderFiles.Visible = false; PlaceHolderGrd.Visible = false; PlaceHolderImgs.Visible = false; RequiredFieldValidator4.Enabled = false; BtnSaveProduct.Text = "Update Product"; Product prod = new Product(); prod.LoadByPrimaryKey(productID); txtProdName.Text = prod.NameEn; txtProdDesc.Text = prod.DescriptionEn; txtVidLink.Text = prod.YouTubeLink; if (!string.IsNullOrWhiteSpace(prod.MainImagePath)) { ProdImg.Src = prod.MainImagePath; } chkAvailHome.Checked = prod.AppearInHome; chkActive.Checked = prod.IsActive; } else if (!string.IsNullOrEmpty(Request.QueryString["AddFiles"])) { PlaceHolderEditProd.Visible = false; PlaceHolderFiles.Visible = true; PlaceHolderGrd.Visible = false; PlaceHolderImgs.Visible = false; FilesGrdBind(); } else if (!string.IsNullOrEmpty(Request.QueryString["AddImgs"])) { PlaceHolderEditProd.Visible = false; PlaceHolderFiles.Visible = false; PlaceHolderGrd.Visible = false; PlaceHolderImgs.Visible = true; galleryBind(); } else { PlaceHolderGrd.Visible = true; } } else { PlaceHolderGrd.Visible = true; } } }
protected void GrdViewProducts_RowCommand(object sender, GridViewCommandEventArgs e) { switch (e.CommandName.ToString()) { case "EditProduct": Response.Redirect("Products.aspx?EditProd=" + e.CommandArgument.ToString()); break; case "AddFiles": Response.Redirect("Products.aspx?AddFiles=" + e.CommandArgument.ToString()); break; case "AddImgs": Response.Redirect("Products.aspx?AddImgs=" + e.CommandArgument.ToString()); break; case "DeleteProduct": Product delProd = new Product(); delProd.LoadByPrimaryKey(int.Parse(e.CommandArgument.ToString())); delProd.MarkAsDeleted(); delProd.Save(); GrdCatsBind(); break; default: break; } }
private void ManageItems_Load(object sender, EventArgs e) { Category cat = new Category(); SubCategory subCat = new SubCategory(); Product prod = new Product(); cat.LoadAll(); cat.Sort = "CategoryName"; lblCategory.Text = "Products By Category"; ProductTree.Nodes.Add("All0","All"); foreach (DataRowView dv in cat.DefaultView) { TreeNode nodes = new TreeNode(); nodes.Name = "cat" + dv["ID"].ToString(); nodes.Text = dv["CategoryName"].ToString() + " (" + dv["CategoryCode"].ToString() + ")"; nodes.ToolTipText = "Double Click to List"; subCat.GetSubCategory(Convert.ToInt32(dv["ID"])); subCat.Sort = "SubCategoryName"; foreach (DataRowView subDv in subCat.DefaultView) { TreeNode subNodes = new TreeNode(); subNodes.Name = "sub" + subDv["ID"].ToString(); subNodes.Text = subDv["SubCategoryName"].ToString() + " (" + subDv["SubCategoryCode"].ToString() + ")"; subNodes.ToolTipText = "Double Click to List"; nodes.Nodes.Add(subNodes); } ProductTree.Nodes[0].Nodes.Add(nodes); } ProductTree.Nodes[0].Expand(); Stores stor = new Stores(); stor.GetActiveStores(); cboStores.DataSource = stor.DefaultView; }
public ActionResult ProductAdminHome(Product product, FormCollection FC) { Session["ControllerName"] = "Product"; string subClassification = FC["SubClassification"].ToString(); string SubCategory = FC["SubCategory"].ToString(); Session["ControllerName"] = "ProductAdminHome"; // getDdlsForProduct(); if (Session["loginDetails"] != null) { ProductAdminBLL bll = new ProductAdminBLL(); LoadCategoryDDL(); getDdlsForProduct(); product.SubClassification = subClassification; product.SubCategory = SubCategory; ViewBag.DDLBrand = new SelectList(ddlbrand, "Value", "Text").ToList(); //ViewBag.SubCategory = new SelectList(ddlSubCategory, "Value", "Text").ToList(); if (ModelState.IsValid) { int res = bll.insertProduct(product); if (res > 0) { return RedirectToAction("ProductAdminHome"); } } return View(); } else { return RedirectToAction("Error"); } }
private void PopulateFields() { try { if (_itemId == 0) return; Items itm = new Items(); itm.LoadByPrimaryKey(_itemId); SubCategory cat = new SubCategory(); DataTable dtCat = cat.GetSubCategoryOfItem(_itemId); foreach (DataRow drcat in dtCat.Rows) { DataTable dtProd = cat.GetSubCategoryByID(Convert.ToInt32(drcat["SubCategoryID"])); //txtCategory.Text = dtProd.Rows[0]["CategoryName"].ToString(); //txtSubCategory.Text = dtProd.Rows[0]["SubCategoryName"].ToString(); string[] categor = { dtProd.Rows[0]["CategoryName"].ToString(), dtProd.Rows[0]["SubCategoryName"].ToString() }; ListViewItem listCat = new ListViewItem(categor) { Tag = dtProd.Rows[0]["ID"] }; lstCat.Items.Add(listCat); } cboIIN.SelectedValue = itm.IINID.ToString(); Product nInn = new Product(); nInn.LoadByPrimaryKey(itm.IINID); //txtATC.Text = nInn.ATC; txtStrength.Text = itm.Strength; ckIsDiscontinued.Checked = itm.IsDiscontinued; ckIsEDL.Checked = itm.EDL; ckIsFree.Checked = itm.IsFree; ckIsPedatric.Checked = itm.Pediatric; ckIsRefrigerated.Checked = itm.Refrigeratored; cboDosageForm.SelectedValue = itm.DosageFormID.ToString(); cboUnit.SelectedValue = itm.UnitID.ToString(); string code = itm.StockCode; txtStockCode.Text = code; txtStock2.Text = itm.Code; txtStock3.Text = itm.StockCodeDACA; } catch { } }