Example #1
0
        protected void btn_Add_Cateogry_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                ProductMgr myProductMgr = new ProductMgr();

                if (myProductMgr.Chk_Product_Mapping(_productid, CategoryTree_Product.Selected_CategoryID))
                {
                    Nexus.Core.Tools.AlertMessage.Show_Alert(this.Page, "<h4>Your product is already been under this category.</h4>", "Action failed!");
                }
                else
                {
                    // Add to Product Mapping
                    e2Data[] UpdateData_Mapping =
                    {
                        new e2Data("ProductID",  _productid),
                        new e2Data("CategoryID", CategoryTree_Product.Selected_CategoryID),
                        new e2Data("IsFeatured", false.ToString()),
                        new e2Data("SortOrder",  "1")
                    };

                    myProductMgr.Add_Product_Mapping(UpdateData_Mapping);

                    // Add Item to Category
                    CategoryMgr myCategoryMgr = new CategoryMgr();
                    myCategoryMgr.Add_ComponentInCategory_Item(
                        CategoryTree_Product.Selected_CategoryID,
                        "B131F545-F494-447E-8B55-9F24AFADC417");

                    Control_Init();
                }
            }
        }
Example #2
0
        protected void lbtn_Delete_Command(object sender, CommandEventArgs e)
        {
            if (!DataEval.IsEmptyQuery(e.CommandArgument.ToString()))
            {
                ProductMgr myProductMgr = new ProductMgr();

                int count = myProductMgr.Count_Product_Mapping(_productid);

                if (myProductMgr.Count_Product_Mapping(_productid) <= 1)
                {
                    Nexus.Core.Tools.AlertMessage.Show_Alert(this.Page, "<h4>Your product need to be under at least one category.</h4>", "Action failed!");
                }
                else
                {
                    // Remove Product from mapping
                    myProductMgr.Remove_Product_Mapping(e.CommandArgument.ToString());

                    Product_Mapping myProduct_Mapping = myProductMgr.Get_Product_Mapping(e.CommandArgument.ToString());

                    // Remove Item from Category
                    CategoryMgr myCategoryMgr = new CategoryMgr();
                    myCategoryMgr.Delete_ComponentInCategory_Item(
                        myProduct_Mapping.CategoryID,
                        "B131F545-F494-447E-8B55-9F24AFADC417");

                    Control_Init();
                }
            }
        }
Example #3
0
        protected void lbtn_SetDefault_Media_Command(object sender, CommandEventArgs e)
        {
            if (!DataEval.IsEmptyQuery(e.CommandArgument.ToString()))
            {
                ProductMgr myProductMgr = new ProductMgr();

                WebMedia myWebMedia = myProductMgr.Get_WebMedium(e.CommandArgument.ToString());

                if (myWebMedia.Media_Type == Media_Type.Picture)
                {
                    e2Data[] UpdateData =
                    {
                        new e2Data("ProductID",  _productid),
                        new e2Data("WebMediaID", e.CommandArgument.ToString())
                    };

                    myProductMgr.Edit_Product(UpdateData);

                    Img_Default_Photo.ImageUrl = myWebMedia.Media_Value;
                }
                else
                {
                    Nexus.Core.Tools.AlertMessage.Show_Alert(this.Page, "<h4>You can only set a picture type as product default photo. </h4>", "Action failed!");
                }
            }
        }
Example #4
0
        public JsonResult DeleteById(int id)
        {
            bool       success = ProductMgr.DeleteById(id);
            StateModel state   = new StateModel(success);

            return(Json(state, JsonRequestBehavior.AllowGet));
        }
Example #5
0
        public void AddProductTest()
        {
            //  dbSetUp();
            ProductMgr target = new ProductMgr(); // TODO: Initialize to an appropriate value

            // Target product-------------
            Product product = new Product();

            product.ProductID        = "CB-100";
            product.ProductName      = "Corned Beef";
            product.UnitID           = 1;
            product.QuantityReceived = 12;
            product.UnitPrice        = 30;
            product.CategoryID       = 1;
            product.Description      = "Canned Beef";
            product.SupplierCode     = "MT-100";

            //-------------
            try
            {
                target.AddProduct(product);
            }
            catch (ProductMgrException e)
            {
                Assert.Fail(e.ToString());//force fail of test
            }
        }
        public IEnumerable <Product> GetAll()
        {
            try
            {
                ProductMgr     mgr    = new ProductMgr(_context);
                List <Product> result = mgr.GetAll();
                //if (result != null)
                //    for (int i=0; i< result.Count; i++)
                //    {
                //        result[i].ShoppingListItem.Clear();
                //      //  result[i].ProductGroup = null;

                //    }


                return(result);
            }
            catch (Exception ex)
            {
                List <Product> result = new List <Product>();
                Product        p      = new Product();
                p.Id   = 1;
                p.Name = ex.ToString();
                result.Add(p);
                return(result);
            }
            //return null;
        }
Example #7
0
        protected void GridView_Product_Variants_Sorting(object sender, GridViewSortEventArgs e)
        {
            ProductMgr myProductMgr = new ProductMgr();

            GridView_Manufacturers.DataSource = myProductMgr.Get_Manufacturers(e.SortExpression);
            GridView_Manufacturers.DataBind();
        }
Example #8
0
        private void ItemList_DataBind()
        {
            ProductMgr myProductMgr = new ProductMgr();

            ListView_ProductIndex_List.DataSource = myProductMgr.Get_ProductIndexes(tbx_Filter_ProductIndex_Title.Text, droplist_Filter_OrderBy.SelectedValue, droplist_Filter_Direction.SelectedValue);
            ListView_ProductIndex_List.DataBind();
        }
Example #9
0
        protected void lbtn_Delete_Command(object sender, CommandEventArgs e)
        {
            if (!DataEval.IsEmptyQuery(e.CommandArgument.ToString()))
            {
                if (e.CommandArgument.ToString() == "2394DE12-D859-4D38-B8C7-87E33399820C")
                {
                    Nexus.Core.Tools.AlertMessage.Show_Alert(this.Page, "<h4>Sorry you can not delete system default manufacturer.</h4>", "Action failed!");
                }
                else
                {
                    ProductMgr myProductMgr = new ProductMgr();

                    if (myProductMgr.Chk_Manufacturer_usage(e.CommandArgument.ToString()))
                    {
                        Nexus.Core.Tools.AlertMessage.Show_Alert(this.Page, "<h4>Selected manufacturer already used <br /> Please remove them before apply this action.</h4>", "Action failed!");
                    }
                    else
                    {
                        myProductMgr.Remove_Manufacturer(e.CommandArgument.ToString());

                        Control_Init();
                    }
                }
            }
        }
        public void AddProductTest()
        {
            //  dbSetUp();
            ProductMgr target = new ProductMgr(); // TODO: Initialize to an appropriate value

            // Target product-------------
            Product product = new Product();
            product.ProductID = "CB-100";
            product.ProductName = "Corned Beef";
            product.UnitID = 1;
            product.QuantityReceived = 12;
            product.UnitPrice = 30;
            product.CategoryID = 1;
            product.Description = "Canned Beef";
            product.SupplierCode = "MT-100";

            //-------------
            try
            {
               target.AddProduct(product);
            }
            catch (ProductMgrException e)
            {
                Assert.Fail(e.ToString());//force fail of test
            }
        }
Example #11
0
        protected void btn_IsActive_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                for (int i = 0; i < ListView_Product_List.Items.Count; i++)
                {
                    CheckBox chk_Selected = (CheckBox)ListView_Product_List.Items[i].FindControl("chk_Selected");
                    if (chk_Selected.Checked)
                    {
                        string ProductID = ListView_Product_List.DataKeys[i].Values["ProductID"].ToString();

                        ProductMgr myProductMgr = new ProductMgr();

                        Product.Product myProduct = myProductMgr.Get_Product(ProductID);

                        e2Data[] UpdateData =
                        {
                            new e2Data("ProductID", myProduct.ProductID),
                            new e2Data("IsActive",  rbtn_IsActive.SelectedValue)
                        };

                        myProductMgr.Edit_Product(UpdateData);
                    }
                }

                // Refresh List view after action.
                ItemList_DataBind();
            }
        }
Example #12
0
        /// <summary>
        /// 用于校验产品id是否重复
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult CheckProductById(int id)
        {
            bool       isExist = ProductMgr.CheckProductById(id);
            StateModel state   = new StateModel(isExist);

            return(Json(state, JsonRequestBehavior.AllowGet));
        }
Example #13
0
        protected void btn_Add_WebMedia_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                ProductMgr myProductMgr = new ProductMgr();

                string WebMediaID = Nexus.Core.Tools.IDGenerator.Get_New_GUID_PlainText();

                e2Data[] UpdateData =
                {
                    new e2Data("WebMediaID",        WebMediaID),
                    new e2Data("ProductID",         _productid),
                    new e2Data("Media_Type",        droplist_Media_Type.SelectedValue),
                    new e2Data("Media_Title",       tbx_Media_Title.Text),
                    new e2Data("Media_Value",       tbx_ImageURL.Text),
                    new e2Data("Media_Description", tbx_Description.Text),
                    new e2Data("SortOrder",         "0")
                };

                myProductMgr.Add_WebMedia(UpdateData);

                Control_Init();

                MultiView_WebMediaForm.SetActiveView(View_Button);
            }
        }
Example #14
0
        protected void lbtn_Delete_Media_Command(object sender, CommandEventArgs e)
        {
            if (!DataEval.IsEmptyQuery(e.CommandArgument.ToString()))
            {
                ProductMgr myProductMgr = new ProductMgr();

                Product.Product myProduct = myProductMgr.Get_Product(_productid);

                if (e.CommandArgument.ToString() == myProduct.WebMediaID)
                {
                    e2Data[] UpdateData =
                    {
                        new e2Data("ProductID",  _productid),
                        new e2Data("WebMediaID", "")
                    };

                    myProductMgr.Edit_Product(UpdateData);

                    Img_Default_Photo.ImageUrl = "/App_Control_Style/Nexus_Shop/Images/NoImg.png";
                }

                myProductMgr.Remove_WebMedia(e.CommandArgument.ToString());
                Control_Init();
            }
        }
Example #15
0
        protected void btn_Update_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                ProductMgr myProductMgr = new ProductMgr();

                e2Data[] UpdateData =
                {
                    new e2Data("ProductID",         _productid),
                    new e2Data("Product_Title",     tbx_Product_Title.Text),
                    new e2Data("Title_Type",        rbtn_Product_Title_Type.SelectedValue),
                    new e2Data("Product_SKU",       tbx_Product_SKU.Text),
                    new e2Data("ManufacturerID",    droplist_Product_ManufacturerID.SelectedValue),
                    new e2Data("Manufacturer_SKU",  tbx_Product_Manufacturer_SKU.Text),
                    new e2Data("CurrencyID",        droplist_Product_CurrencyID.SelectedValue),
                    new e2Data("RRP_Price",         RadNumericTextBox_Product_RRP.Text),
                    new e2Data("IsActive",          chkbox_Product_IsActive.Checked.ToString()),
                    new e2Data("LastUpdate_Date",   DateTime.Now.ToString()),
                    new e2Data("LastUpdate_UserID", Security.Users.UserStatus.Current_UserID(this.Page))
                };
                myProductMgr.Edit_Product(UpdateData);

                // Product Specification
                ProductVariantMgr myProductVariantMgr = new ProductVariantMgr();
                myProductVariantMgr.Edit_Product_Properties(PlaceHolder_Product_Spec, _product_variantid, ProductID);

                Panel_Updated.Visible = true;
            }
        }
Example #16
0
        public void GetProductById(HttpContext context)
        {
            int     id     = int.Parse(context.Request["ProductID"]);
            Product entity = ProductMgr.GetProductById(id);

            context.Response.Write(JsonConvert.SerializeObject(entity));
        }
Example #17
0
        /// <summary>
        /// 批量删除产品
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public JsonResult BatchDelete(string ids)
        {
            StateModel state = new StateModel();

            state.Status = ProductMgr.BatchDelete(ids);
            return(Json(state));
        }
Example #18
0
        public void CheckProductById(HttpContext context)
        {
            int        id      = int.Parse(context.Request["ProductID"]);
            bool       isExist = ProductMgr.CheckProductById(id);
            StateModel state   = new StateModel(isExist);

            context.Response.Write(JsonConvert.SerializeObject(state));
        }
Example #19
0
        public void GetList(HttpContext context)
        {
            List <Product> list = ProductMgr.GetList();

            string json = JsonConvert.SerializeObject(list);

            context.Response.Write(json);
        }
Example #20
0
        public void BatchDelete(HttpContext context)
        {
            string     ids   = context.Request["ids"];
            StateModel state = new StateModel();

            state.Status = ProductMgr.BatchDelete(ids);
            context.Response.Write(JsonConvert.SerializeObject(state));
        }
Example #21
0
        public void DeleteById(HttpContext context)
        {
            int        id      = int.Parse(context.Request["ProductID"]);
            bool       success = ProductMgr.DeleteById(id);
            StateModel state   = new StateModel(success);

            context.Response.Write(JsonConvert.SerializeObject(state));
        }
Example #22
0
        public void GetProdFail()
        {
            IProdRepo       repo = new InvalidProd();
            ProductMgr      pm   = new ProductMgr(repo);
            ProductResponse resp = pm.GetProduct("Wood");

            Assert.AreEqual(false, resp.Success);
        }
Example #23
0
        public void GetProd()
        {
            IProdRepo       repo = new TestProdRepo();
            ProductMgr      pm   = new ProductMgr(repo);
            ProductResponse resp = pm.GetProduct("wood");
            Product         prod = resp.Product;

            Assert.IsNotNull(prod);
        }
Example #24
0
        private void Control_Init()
        {
            ProductMgr myProductMgr = new ProductMgr();

            ListView_Product_Category.DataSource = myProductMgr.Get_Product_Mappings(_productid, true);
            ListView_Product_Category.DataBind();

            CategoryTree_Product.LoadCategoryRoot();
        }
Example #25
0
        private void Control_Init()
        {
            ProductMgr myProductMgr = new ProductMgr();

            GridView_Manufacturers.DataSource = myProductMgr.Get_Manufacturers();
            GridView_Manufacturers.DataBind();

            MultiView_Manufacturer.SetActiveView(View_Add);
        }
 public void Update([FromBody] Product item)
 {
     try
     {
         ProductMgr mgr = new ProductMgr(_context);
         mgr.Update(item);
     }
     catch (Exception ex)
     {
     }
 }
 public void Remove(int id)
 {
     try
     {
         ProductMgr mgr = new ProductMgr(_context);
         mgr.Remove(id);
     }
     catch (Exception ex)
     {
     }
 }
Example #28
0
        /// <summary>
        /// 新增产品
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public JsonResult SaveProduct(Product entity)
        {
            bool       success = ProductMgr.AddProduct(entity);
            StateModel state   = new StateModel(success);

            if (!state.Status)
            {
                state.Message = "新增发生异常,请重新添加!";
            }
            return(Json(state));
        }
Example #29
0
        /// <summary>
        /// 更新产品实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public JsonResult UpdateProduct(Product entity)
        {
            bool       success = ProductMgr.Update(entity);
            StateModel state   = new StateModel(success);

            if (!state.Status)
            {
                state.Message = "更新失败,请重新更新!";
            }
            return(Json(state));
        }
Example #30
0
        public void Control_FillData()
        {
            ProductMgr myProductMgr = new ProductMgr();

            ProductIndex myProductIndex = myProductMgr.Get_ProductIndex(_product_indexid);

            tbx_Index_Title.Text             = myProductIndex.Title;
            tbx_Index_Short_Description.Text = myProductIndex.Short_Description;
            tbx_Index_Admin_Comment.Text     = myProductIndex.Admin_Comment;
            chkbox_Index_IsActive.Checked    = myProductIndex.IsActive;

            Panel_Updated.Visible = false;
        }
Example #31
0
        public void UpdateProduct(HttpContext context)
        {
            Product entity = GetProductFromRequest(context);

            bool       success = ProductMgr.Update(entity);
            StateModel state   = new StateModel(success);

            if (!state.Status)
            {
                state.Message = "更新失败,请重新更新!";
            }
            context.Response.Write(JsonConvert.SerializeObject(state));
        }
        public void RemoveProductTest()
        {
            // Product product = new Product();

            ProductMgr target = new ProductMgr(); // TODO: Initialize to an appropriate value
            try
            {

               target.RemoveProduct("CB-100");

            }
            catch (ProductMgrException e)
            {
                Assert.Fail(e.ToString());//force fail of test
            }
        }
        public void UpdateProductTest()
        {
            ProductMgr target = new ProductMgr(); // TODO: Initialize to an appropriate value

            // Target product-------------
            Product product = new Product();
            product.ProductID = "CB-100";
            product.ProductName = "CB Chicken";
            product.UnitID = 1;
            product.QuantityReceived = 12;
            product.UnitPrice = 30;
            product.CategoryID = 1;
            product.Description = "Chicken";
            //-------------
            try
            {
             target.UpdateProduct(product);

            }
            catch (ProductMgrException e)
            {
                Assert.Fail(e.ToString());//force fail of test
            }
        }