Example #1
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 #2
0
        protected void btn_Move_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();
                        string Product_MappingID = ListView_Product_List.DataKeys[i].Values["Product_MappingID"].ToString();

                        ProductMgr myProductMgr = new ProductMgr();

                        Product_Mapping myProductMapping = myProductMgr.Get_Product_Mapping(Product_MappingID);

                        if (myProductMapping.CategoryID != CategoryTree_MoveTo.Selected_CategoryID)
                        {
                            if (myProductMgr.Chk_Product_Mapping(ProductID, CategoryTree_MoveTo.Selected_CategoryID))
                            {
                                myProductMgr.Remove_Product_Mapping(Product_MappingID);

                                // Delete item from Category
                                CategoryMgr myCategoryMgr = new CategoryMgr();
                                myCategoryMgr.Delete_ComponentInCategory_Item(myProductMapping.CategoryID, "B131F545-F494-447E-8B55-9F24AFADC417");
                            }
                            else
                            {
                                e2Data[] UpdateData =
                                {
                                    new e2Data("Product_MappingID", myProductMapping.Product_MappingID),
                                    new e2Data("CategoryID",        CategoryTree_MoveTo.Selected_CategoryID)
                                };

                                myProductMgr.Edit_Product_Mapping(UpdateData);

                                // Switch Category
                                CategoryMgr myCategoryMgr = new CategoryMgr();
                                myCategoryMgr.Move_ComponentInCategory_Item(myProductMapping.CategoryID, CategoryTree_MoveTo.Selected_CategoryID, "B131F545-F494-447E-8B55-9F24AFADC417");
                            }
                        }
                    }
                }

                // Refresh List view after action.
                Control_Init();

                // Trigger Refresh Event
                OnCategoryRefreshed(sender, e);
            }
        }
Example #3
0
 public void SaveProductMaping(AgnosDBContext db, string code, string name)
 {
     try
     {
         var prodmap = db.Product_Mapping.Where(w => w.Product_Code == code).FirstOrDefault();
         if (prodmap == null)
         {
             prodmap = new Product_Mapping();
             prodmap.Product_Code = code;
             prodmap.Product_Name = name;
             db.Product_Mapping.Add(prodmap);
         }
         prodmap.Product_Name = name;
     }
     catch
     {
         throw;
     }
 }