Example #1
0
        private static XmlNode createNode(CATEGORY category, string encCampaign, XmlDocument doc, XmlNode father, string lang)
        {
            string encCategory;
            XmlNode node = doc.CreateNode(XmlNodeType.Element, "Menu", "");
            XmlAttribute attr;
            // text attribute for Menu name
            attr = doc.CreateAttribute("text");
            if (lang == "en-US")
            {
                attr.Value = category.NameEng;
            }
            else
            {
                attr.Value = category.Name;                
            }
            node.Attributes.Append(attr);

            // value attribute for category id
            attr = doc.CreateAttribute("value");
            attr.Value = category.ID.ToString();
            node.Attributes.Append(attr);

            encCategory = Encryption.Encrypt(category.ID.ToString());
            attr = doc.CreateAttribute("url");
            attr.Value = "/campaign/" + encCampaign + "/cat/" + encCategory + "/";
            node.Attributes.Append(attr);

            father.AppendChild(node);

            return node;
        }
        public void Update(CATEGORY upCategory)
        {
            Context.CATEGORY.Attach(upCategory);


            var entry = Context.ObjectStateManager.GetObjectStateEntry(upCategory);
            entry.SetModifiedProperty("Name");
            entry.SetModifiedProperty("NameEng");
            entry.SetModifiedProperty("Description");

            entry.SetModifiedProperty("AttributeID");
            entry.SetModifiedProperty("Ordering");
        }
Example #3
0
        private void FixupCATEGORY2(CATEGORY previousValue)
        {
            if (previousValue != null && previousValue.CATEGORY1.Contains(this))
            {
                previousValue.CATEGORY1.Remove(this);
            }

            if (CATEGORY2 != null)
            {
                if (!CATEGORY2.CATEGORY1.Contains(this))
                {
                    CATEGORY2.CATEGORY1.Add(this);
                }
                if (ParentID != CATEGORY2.ID)
                {
                    ParentID = CATEGORY2.ID;
                }
            }
            else if (!_settingFK)
            {
                ParentID = null;
            }
        }
 public void Insert(CATEGORY Category)
 {
     _categoryDAO.Insert(Category);
     Context.SaveChanges();
 }
 public List<CATEGORY> Search(CATEGORY Category, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, Util.SortDirection SortDirection)
 {
     return _categoryDAO.Search(Category, PageSize, PageIndex, out TotalRecords, OrderExp, SortDirection);
 }
        public void ImportProducts(int CampaignId, string Path)
        {
            var productList = ProductExcelImporter.ReadProductExcel(Path);
            string encryptedCampId = FashionZone.BL.Util.Encryption.Encrypt(CampaignId.ToString());
            PRODUCT product;

            // preparing categories
            List<CATEGORY> categoriesList = _categoryDAO.GetCategoryListByCampaign(CampaignId);

            int? categoryParentF = null, categoryParentM = null;

            CATEGORY cat, categoryParent = null;
            categoryParent = categoriesList.Where(o => o.NameEng.Contains("Woman")).FirstOrDefault();
            if (categoryParent != null)
            {
                cat = new CATEGORY() { ID = categoryParent.ID };
                categoryParentF = categoryParent.ID;
            }

            categoryParent = categoriesList.Where(o => o.NameEng.Contains("Man")).FirstOrDefault();
            if (categoryParent != null)
            {
                cat = new CATEGORY() { ID = categoryParent.ID };
                categoryParentM = categoryParent.ID;
            }
            var query = (from c in categoriesList
                         select new { c.ID, c.Name, c.NameEng, c.ParentID }).ToList();

            foreach (FZExcelProduct exProd in productList)
            {
                product = new PRODUCT();
                product.Name = exProd.Title;
                product.Code = exProd.Code;
                decimal our, original, suppl = 0;
                if (Decimal.TryParse(exProd.Sell, out our))
                {
                    product.OurPrice = our;
                }
                if (Decimal.TryParse(exProd.Retail, out original))
                {
                    product.OriginalPrice = original;
                }

                if (Decimal.TryParse(exProd.Buy, out suppl))
                {
                    product.SupplierPrice = suppl;
                }

                product.Description = "Produkti <br /><br />" + exProd.Title + "<br /><br />" + exProd.Desc.Replace("\n", "<br />");

                setCategories(CampaignId, query, product, exProd.Category, exProd.Sex, categoryParentF, categoryParentM);

                // inserting the product entity, we are on a "transaction" so everything will
                // be rolled back in case the other statements aren't successful
                Insert(product);
                setAttributes(categoriesList, product, exProd);
                setImages(product, exProd, encryptedCampId);
            }
        }
 public void DeleteById(int id)
 {
     CATEGORY obj = new CATEGORY() { ID = id };
     Delete(obj);
 }
 public void Delete(CATEGORY delCategory)
 {
     Context.CATEGORY.Attach(delCategory);
     Context.DeleteObject(delCategory);
     //Context.SaveChanges();
 }
 public List<CATEGORY> Search(CATEGORY Category, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
 {
     throw new NotImplementedException();
 }
 private static TreeNode addNodeToTree(TreeNode myNode, CATEGORY singleC, ICollection<CATEGORY> cats)
 {
     var node = new TreeNode(singleC.Name, singleC.ID.ToString());
     node.ShowCheckBox = true;
     if (cats != null && cats.Count > 0 && cats.Any(cat => cat.ID == singleC.ID))
         node.Checked = true;
     myNode.ChildNodes.Add(node);
     return node;
 }
 private static void populateTreeView(TreeNode myNode, CATEGORY singleC, ICollection<CATEGORY> cats, List<CATEGORY> allCats)
 {
     var catChChildren = allCats.Where(c => c.ParentID == singleC.ID).OrderBy(c2 => c2.Ordering).ToList();
     TreeNode nFather = addNodeToTree(myNode, singleC, cats);
     if (catChChildren.Count > 0)
     {
         foreach (var c in catChChildren)
             populateTreeView(nFather, c, cats, allCats);
     }
     catChChildren.Clear();
 }
 private bool setCategories(PRODUCT product)
 {
     CATEGORY cat;
     bool subCatChecked = false;
     foreach (TreeNode node in tvCategories.CheckedNodes)
     {
         if (node.Depth == 2)
         {
             subCatChecked = true;
         }
         cat = new CATEGORY() { ID = Int32.Parse(node.Value) };
         product.CATEGORY.Add(cat);
     }
     return subCatChecked;
 }
 private static void DeleteCat(CATEGORY c)
 {
     ApplicationContext.Current.Categories.Delete(c);
     List<CATEGORY> listChildrenCat = ApplicationContext.Current.Categories.GetChildrenCategoryList(c.ID);
     if (listChildrenCat.Count > 0)
         foreach (var cat in listChildrenCat)
             DeleteCat(cat);
 }
 private static TreeNode addNodeToTree(TreeNode myNode, CATEGORY singleC)
 {
     var node = new TreeNode(singleC.Name, singleC.ID.ToString());
     node.ShowCheckBox = true;
     node.SelectAction = TreeNodeSelectAction.Select;
     myNode.ChildNodes.Add(node);
     return node;
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                //Save Categories
                CATEGORY newCat = new CATEGORY();
                int id;
                int idForEdit;
                int.TryParse(hdnIdNode.Value, out idForEdit);
                if (idForEdit != 0)
                    newCat = new CATEGORY() { ID = idForEdit};
                newCat.Name = txtName.Text;
                newCat.NameEng = txtNameEng.Text;
                newCat.Description = txtDesc.Text;

                Int32.TryParse(dll_campain.SelectedValue, out id);
                newCat.CampaignID = id;

                if (!string.IsNullOrWhiteSpace(ddl_Attributes.SelectedValue))
                {
                    Int32.TryParse(ddl_Attributes.SelectedValue, out id);
                    newCat.AttributeID = id;
                }
                if (!string.IsNullOrWhiteSpace(txtOrder.Text))
                {
                    int.TryParse(txtOrder.Text, out id);
                    newCat.Ordering = id;
                }

                switch (TreeView1.CheckedNodes.Count)
                {
                    case 0:
                        resetFields();
                        pnlInfo.Visible = txtName.Visible = txtNameEng.Visible = txtDesc.Visible = txtOrder.Visible = false;
                        break;
                    case 1:
                        TreeNode selectedNode = new TreeNode();
                        selectedNode = TreeView1.CheckedNodes[0];
                        int.TryParse(selectedNode.Value, out id);
                        newCat.ParentID = id;
                        pnlInfo.Visible = txtName.Visible = txtNameEng.Visible = txtDesc.Visible = txtOrder.Visible = true;
                        break;
                    default:
                        sendMsg("Zgjidh vetem NJE kategori!!");
                        break;
                }
                
                if (idForEdit == 0)
                {
                    ApplicationContext.Current.Categories.Insert(newCat);
                    sendMsg("Insert successful!");
                }
                else
                {
                    ApplicationContext.Current.Categories.Update(newCat);
                    sendMsg("Update successful!");
                }
                resetFields();
                popola();
            }
        }
 public void Delete(CATEGORY Category)
 {
     _categoryDAO.Delete(Category);
     Context.SaveChanges();
 }
Example #17
0
     private void FixupCATEGORY2(CATEGORY previousValue)
     {
         if (previousValue != null && previousValue.CATEGORY1.Contains(this))
         {
             previousValue.CATEGORY1.Remove(this);
         }
 
         if (CATEGORY2 != null)
         {
             if (!CATEGORY2.CATEGORY1.Contains(this))
             {
                 CATEGORY2.CATEGORY1.Add(this);
             }
             if (ParentID != CATEGORY2.ID)
             {
                 ParentID = CATEGORY2.ID;
             }
         }
         else if (!_settingFK)
         {
             ParentID = null;
         }
     }
Example #18
0
 public void Insert(CATEGORY newCategory)
 {
     Context.CATEGORY.AddObject(newCategory);
     //Context.SaveChanges();
 }