protected void BindProductsList() { BPProducts bp = new BPProducts(); DSProducts = bp.SelectActiveByProductCategoryID(ProductCategoryID); foreach (BEProducts.tbl_ProductsRow applications in DSProducts.tbl_Products) { DSProducts.Merge(bp.SelectProductsByID(applications.ProductID)); } rptProductsList.DataBind(); pnlProductsList.Visible = true; }
private string GetProductTitle(int ProductID) { BPProducts bp = new BPProducts(); DSProducts = bp.SelectProductsByID(ProductID); BEProducts.tbl_ProductsRow title; title = DSProducts.tbl_Products.FindByProductID(ProductID); if (DSProducts.tbl_Products.Count > 0) { return title.ProductName; } else { return ""; } }
private void btnDelete_Click(object sender, EventArgs e) { BPProducts bp = new BPProducts(); BEProducts.tbl_ProductsRow Product; DSProducts = bp.SelectProductsByID(ProductID); Product = DSProducts.tbl_Products.FindByProductID(ProductID); Product.Delete(); bp.Update(DSProducts); Response.Redirect("BrowseProducts.aspx"); }
private void btnSubmit_ServerClick(object sender, EventArgs e) { BPProducts bp = new BPProducts(); BEProducts.tbl_ProductsRow Product; DSProducts = new BEProducts(); if (ProductID == 0) { // Add new product Product = DSProducts.tbl_Products.Newtbl_ProductsRow(); hdnProductInventoryLevel.Value = txtProductInventoryLevel.Text; } else { // Edit a Product DSProducts = bp.SelectProductsByID(ProductID); Product = DSProducts.tbl_Products.FindByProductID(ProductID); } //all content to be updated/inserted between here Editor ProductDescription = edtProductDescription; string strProductDescription = Request.Form[ProductDescription.Editor_HiddenField].ToString(); Product.ProductName = txtProductName.Text; Product.ProductDescription = strProductDescription; Product.ProductCategoryID = Convert.ToInt32(ddlProductCategories.SelectedValue); if(Product.ProductCategoryID == -1) { Product.ProductCategoryID = 0; } if(txtProductPrice.Text != "") { Product.ProductPrice = Convert.ToDecimal(txtProductPrice.Text); } else { Product.ProductPrice = 0; } if(txtProductSalePrice.Text != "") { Product.ProductSalePrice = Convert.ToDecimal(txtProductSalePrice.Text); } else { Product.ProductPrice = 0; } if (dtStart.SelectedDate != DateTime.MinValue) { Product.ProductSaleStartDate = Convert.ToDateTime(dtStart.SelectedDate); } else { Product.ProductSaleStartDate = DateTime.Now; } if (dtEnd.SelectedDate != DateTime.MinValue) { Product.ProductSaleEndDate = Convert.ToDateTime(dtEnd.SelectedDate); } else { Product.ProductSaleEndDate = DateTime.Now; } Product.ProductChargeTax = chkProductChargeTax.Checked; Product.ProductSize = txtProductSize.Text; Product.ProductInventoryLevel = Convert.ToInt32(hdnProductInventoryLevel.Value); if(txtProductReorderLevel.Text !="") { Product.ProductReorderLevel = Convert.ToInt32(txtProductReorderLevel.Text); } else { Product.ProductReorderLevel = 0; } if(txtShippingSurcharge.Text != "") { Product.ProductShippingSurcharge = Convert.ToDecimal(txtShippingSurcharge.Text); } else { Product.ProductShippingSurcharge = 0; } ImageWizard ddlImageSelector = Page.FindControl("ddlImageSelector") as ImageWizard; if (ddlImageSelector.SelectedImage > 0) { Product.ProductImageID = Convert.ToInt32(ddlImageSelector.SelectedImage); } else { Product.SetProductImageIDNull(); } Product.ProductActive = chkProductActive.Checked; Product.DateModified = DateTime.Now; Product.ModifiedByAdminID = Convert.ToInt32(CarrielUser.CarrielIdentity.MemberID); //all content to be updated/inserted between here if (ProductID == 0) { //Add new Application Category Product.DateCreated = DateTime.Now; DSProducts.tbl_Products.Addtbl_ProductsRow(Product); } bp.Update(DSProducts); int tmpProductID = Product.ProductID; if (hdnShippingMethodsChanged.Value == "true" || ProductID == 0) { DSProducts.Merge(bp.SelectProductShippingMethodsByProductID(tmpProductID)); hdnShippingMethodsChanged.Value = "false"; BEProducts.tbl_ProductShippingMethodsRow dr; for(int i = 0; i < dlCheckBoxes.Items.Count; i++) { HtmlInputCheckBox tmpChk = dlCheckBoxes.Items[i].FindControl("checkBox") as HtmlInputCheckBox; if (ProductID == 0) { dr = DSProducts.tbl_ProductShippingMethods.Newtbl_ProductShippingMethodsRow(); dr.ProductID = tmpProductID; dr.ShippingMethodID = Convert.ToInt32(tmpChk.Attributes["ShippingMethodID"]); dr.ShippingRegionID = Convert.ToInt32(tmpChk.Attributes["ShippingRegionID"]); dr.ProductShippingMethodActive = tmpChk.Checked; DSProducts.tbl_ProductShippingMethods.Addtbl_ProductShippingMethodsRow(dr); } else { dr = DSProducts.tbl_ProductShippingMethods.FindByProductShippingMethodID(Convert.ToInt32(tmpChk.Attributes["ProductShippingMethodID"])); if(dr.ProductShippingMethodActive != tmpChk.Checked) { dr.ProductShippingMethodActive = tmpChk.Checked; } } } } bp.UpdateProductShippingMethods(DSProducts); //CreateResizedImage(BEImages DSImages, int ImageID, string prefix, int width, int height, Page page) if (!Product.IsProductImageIDNull()) { MWUtility.CreateResizedImage(Product.ProductImageID, "p", "tn", imageSize, thumbSize, this); } //save Document //exit page if (ProductID == 0) { Response.Redirect("EditProducts.aspx?ProductID=" + Product.ProductID); } else { Response.Redirect("BrowseProducts.aspx"); } }
private void Page_Load(object sender, EventArgs e) { this.AuthenticatePage(new string[] {PermissionLevels.EditProducts, PermissionLevels.AddProducts, PermissionLevels.ViewProducts}); if (ProductID > 0) { pnlInventoryManagement.Visible = true; lblInventoryManagement.InnerText = "Inventory Management "; if (this.CarrielUser.RolePermission(PermissionLevels.EditProducts) != 2) { btnSubmit.Visible = false; btnDelete.Visible = false; } else { btnSubmit.Visible = true; btnDelete.Visible = true; } } else { pnlInventoryManagement.Visible = false; lblInventoryManagement.InnerText = "Inventory "; if (this.CarrielUser.RolePermission(PermissionLevels.AddProducts) != 2) { btnSubmit.Visible = false; } } if (hdnGenericProductInformation.Value == "hidden") { pnlGenericProductInformation.CssClass = "panel-closed"; cntGenericProductInformation.Style.Add("display", "none"); hdnGenericProductInformation.Value = "hidden"; } else { pnlGenericProductInformation.CssClass = "panel-open"; cntGenericProductInformation.Style.Add("display", ""); hdnGenericProductInformation.Value = "visible"; } if (hdnRelatedProducts.Value == "hidden") { pnlRelatedProducts.CssClass = "panel-closed"; cntRelatedProducts.Style.Add("display", "none"); hdnRelatedProducts.Value = "hidden"; } else if (hdnRelatedProducts.Value== "visible") { pnlRelatedProducts.CssClass = "panel-open"; cntRelatedProducts.Style.Add("display", ""); hdnRelatedProducts.Value = "visible"; } else { pnlRelatedProducts.CssClass = "panel-closed"; cntRelatedProducts.Style.Add("display", "none"); hdnRelatedProducts.Value = "hidden"; } if (hdnProductAttributes.Value == "hidden") { pnlProductAttributes.CssClass = "panel-closed"; cntProductAttributes.Style.Add("display", "none"); hdnProductAttributes.Value = "hidden"; } else if (hdnProductAttributes.Value== "visible") { pnlProductAttributes.CssClass = "panel-open"; cntProductAttributes.Style.Add("display", ""); hdnProductAttributes.Value = "visible"; } else { pnlProductAttributes.CssClass = "panel-closed"; cntProductAttributes.Style.Add("display", "none"); hdnProductAttributes.Value = "hidden"; } if(!IsPostBack) { BindProductCategories(); ViewRelatedProducts(); ViewProductAttributes(); if (ProductID == 0) { lblTitle.Text = "Add Product"; btnDelete.Visible = false; btnSubmit.Value = "Next >"; pnlRelatedProducts.Visible = false; CreateCheckBoxes(); } else { BPProducts bp = new BPProducts(); BEProducts ds = bp.SelectProductsByID(ProductID); BEProducts.tbl_ProductsRow Product = ds.tbl_Products.FindByProductID(ProductID); txtProductName.Text = Product.ProductName; lblTitle.Text = "Edit Product - " + Product.ProductName; if (! Product.IsProductDescriptionNull()) { edtProductDescription.TextBoxText = Product.ProductDescription; } if (ddlProductCategories.Items.FindByValue(Product.ProductCategoryID.ToString()) != null) { ddlProductCategories.SelectedValue = Product.ProductCategoryID.ToString(); } if (Product.IsProductDocumentIDNull()==false) { ddlDocumentSelector.SelectedDocument = Product.ProductDocumentID; } if (Product.IsProductImageIDNull()==false) { ddlImageSelector.SelectedImage = Product.ProductImageID; } txtProductPrice.Text = Product.ProductPrice.ToString("#,##0.00"); txtProductSalePrice.Text = Product.ProductSalePrice.ToString("#,##0.00"); dtStart.SelectedDate = Product.ProductSaleStartDate; dtEnd.SelectedDate = Product.ProductSaleEndDate; chkProductChargeTax.Checked = Product.ProductChargeTax; txtProductSize.Text = Product.ProductSize; lblProductInventoryLevel.InnerText = Product.ProductInventoryLevel.ToString(); txtProductReorderLevel.Text = Product.ProductReorderLevel.ToString(); hdnProductInventoryLevel.Value = Product.ProductInventoryLevel.ToString(); txtShippingSurcharge.Text = Product.ProductShippingSurcharge.ToString("#,##0.00"); chkProductActive.Checked = Product.ProductActive; FillCheckBoxes(); } } else { if (edtProductDescription != null) { if (Request.Form["edtProductDescriptionHidden"] == null) { edtProductDescription.TextBoxText = ViewState["edtProductDescriptionHidden"].ToString(); } else { edtProductDescription.TextBoxText = Request.Form["edtProductDescriptionHidden"].ToString(); ViewState["edtProductDescriptionHidden"] = Request.Form["edtProductDescriptionHidden"].ToString(); } } else { if (Request.Form["edtProductDescriptionHidden"] != null) { ViewState["edtProductDescriptionHidden"] = Request.Form["edtProductDescriptionHidden"].ToString(); } } } }
// private void lstActive_SelectedIndexChanged(object sender, System.EventArgs e) // { // int active; // if (lstActive != null) // { // active = Convert.ToInt32(lstActive.SelectedValue); // } // else // { // active = -1; // } // } protected void txtInv_TextChanged(object sender, EventArgs e) { lblError.Text = string.Empty; lblError.Visible = false; try { int prodID = Convert.ToInt32(((LinkButton)((TextBox)sender).Parent.Parent.FindControl("lnkName")).CommandArgument); BPProducts bp = new BPProducts(); BEProducts.tbl_ProductsRow product; DSProducts = new BEProducts(); DSProducts = bp.SelectProductsByID(prodID); product = DSProducts.tbl_Products.FindByProductID(prodID); product.ProductInventoryLevel = Convert.ToInt32(((TextBox)sender).Text); bp.Update(DSProducts); } catch (FormatException) { lblError.Text = "Please enter a number under unit count."; lblError.Visible = true; } }