Inheritance: IEntity
        private void FillCatalogsXML(Catalog catalog, XmlDocument xmlDoc, XmlElement rootElement)
        {
            if (catalog != null)
            {
                if (catalog.ParentCalalogID > 0)
                {
                    Catalog parentCatalog = CatalogManager.GetCatalog(catalog.ParentCalalogID, CMSContext.LanguageID);
                    if (parentCatalog != null)
                        FillCatalogsXML(parentCatalog, xmlDoc, rootElement);
                }

                XmlElement catalogElement = xmlDoc.CreateElement("Element");
                rootElement.AppendChild(catalogElement);

                XmlAttribute attr = xmlDoc.CreateAttribute("ID");
                attr.Value = catalog.ID.ToString();
                catalogElement.Attributes.Append(attr);

                attr = xmlDoc.CreateAttribute("Name");
                attr.Value = catalog.Name;
                catalogElement.Attributes.Append(attr);

                attr = xmlDoc.CreateAttribute("Type");
                attr.Value = "Catalog";
                catalogElement.Attributes.Append(attr);
            }
        }
        private TreeNode GetNodesChilds(Catalog catalog, List<Catalog> Catalogs, List<string> toBecheckedNodes)
        {
            TreeNode oNode;
            oNode = new TreeNode(catalog.ID + ": " + catalog.Name, Convert.ToString(catalog.ID));
            oNode.SelectAction = TreeNodeSelectAction.None;

            if (toBecheckedNodes != null && toBecheckedNodes.Contains(oNode.Value))
                oNode.Checked = true;

            List<Catalog> CatalogChilds = Catalogs.Where(m => m.ParentCalalogID == catalog.ID).ToList();
            if (CatalogChilds.Count > 0)
            {
                foreach (AJH.CMS.Core.Entities.Catalog CatalogChild in CatalogChilds)
                {
                    if (toBecheckedNodes != null && toBecheckedNodes.Contains(oNode.Value))
                        oNode.Checked = true;
                    oNode.ChildNodes.Add(GetNodesChilds(CatalogChild, Catalogs, toBecheckedNodes));
                }
            }
            return oNode;
        }
        private TreeNode GetNodesChilds(Catalog catalog, List<Catalog> Catalogs)
        {
            TreeNode oNode;
            oNode = new TreeNode(catalog.ID + ": " + catalog.Name, Convert.ToString(catalog.ID));
            oNode.ImageUrl = CMSWebHelper.GetPublishedImage(catalog.IsPublished);

            if (ViewState[CMSViewStateManager.CatalogID] != null)
            {
                int CatalogSelected = Convert.ToInt32(ViewState[CMSViewStateManager.CatalogID]);
                if (CatalogSelected > 0 && oNode.Value == CatalogSelected.ToString())
                {
                    oNode.Selected = true;
                }
            }

            List<Catalog> CatalogChilds = Catalogs.Where(m => m.ParentCalalogID == catalog.ID).ToList();
            if (CatalogChilds.Count > 0)
            {
                foreach (AJH.CMS.Core.Entities.Catalog CatalogChild in CatalogChilds)
                {
                    oNode.ChildNodes.Add(GetNodesChilds(CatalogChild, Catalogs));
                }
            }

            return oNode;
        }
        void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Catalog catalog = new Catalog();

                catalog.IsDeleted = false;
                catalog.LanguageID = CMSContext.LanguageID;
                catalog.PortalID = CMSContext.PortalID;
                catalog.Description = txtDescription.Text;

                catalog.IsDisplayed = cbIsDisplayed.Checked;
                catalog.IsGalleryOnly = cbIsGalleryOnly.Checked;
                catalog.IsPublished = cbIsPublishedOnslider.Checked;

                catalog.MetaDescription = txtMetaDescription.Text;
                catalog.MetaKeywords = txtMetaKeywords.Text;
                catalog.MetaTitle = txtMetaTitle.Text;
                catalog.ModuleID = (int)CMSEnums.ECommerceModule.Catalog;
                catalog.Name = txtName.Text;

                int catalogOrder = 0;
                int.TryParse(txtCatalogOrder.Text, out catalogOrder);
                catalog.Order = catalogOrder;

                int parentCatalogId = -1;
                int.TryParse(ddlParentCatalog.SelectedValue, out parentCatalogId);

                catalog.ParentCalalogID = parentCatalogId;

                CatalogManager.Add(catalog);

                BeginAddMode();

                FillCatalogTree();
                upnlCatalog.Update();
            }
            catch (Exception ex)
            {
                dvProblems.Visible = true;
                dvProblems.InnerText = ex.ToString();
                upnlCatalog.Update();
            }
        }
        void btnSaveOtherLanguage_Click(object sender, EventArgs e)
        {
            if (ViewState[CMSViewStateManager.CatalogID] != null && ucPortalLanguage.SelectedLanguageID > 0)
            {
                try
                {
                    // Update Info Except Language Info :

                    Catalog catalog =
                        CatalogManager.GetCatalog(Convert.ToInt32(ViewState[CMSViewStateManager.CatalogID]), CMSContext.LanguageID);

                    if (catalog != null)
                    {
                        catalog.IsDisplayed = cbIsDisplayed.Checked;
                        catalog.IsGalleryOnly = cbIsGalleryOnly.Checked;
                        catalog.IsPublished = cbIsPublishedOnslider.Checked;

                        int parentCatalogId = -1;
                        int.TryParse(ddlParentCatalog.SelectedValue, out parentCatalogId);

                        catalog.ParentCalalogID = parentCatalogId;

                        CatalogManager.Update(catalog);

                        //SaveLanguage Info Only :
                        Catalog langCatalog = new Catalog
                        {
                            ID = Convert.ToInt32(ViewState[CMSViewStateManager.CatalogID]),
                            Name = txtName.Text,
                            Description = txtDescription.Text,
                            MetaTitle = txtMetaTitle.Text,
                            MetaDescription = txtMetaDescription.Text,
                            MetaKeywords = txtMetaKeywords.Text,
                            LanguageID = ucPortalLanguage.SelectedLanguageID,
                            ModuleID = (int)CMSEnums.ECommerceModule.Catalog,
                        };

                        CatalogManager.AddOtherLanguage(langCatalog);
                        BeginAddMode();
                        FillCatalogTree();
                        upnlCatalog.Update();
                        upnlCatalogItem.Update();
                    }
                }
                catch (Exception ex)
                {
                    dvProblems.Visible = true;
                    dvProblems.InnerText = ex.ToString();
                    upnlCatalog.Update();
                }
            }
        }
 public static void AddOtherLanguage(Catalog catalog)
 {
     CatalogDataMapper.AddOtherLanguage(catalog);
 }
 public static void Update(Catalog catalog)
 {
     CatalogDataMapper.Update(catalog);
 }
        private static void SetAttributeCatalogNode(XmlDocument xmldoc, XmlElement xmlEle, Catalog CatalogItem)
        {
            XmlAttribute xmlAtt = xmlEle.OwnerDocument.CreateAttribute("ID");
            xmlAtt.Value = CatalogItem.ID.ToString();
            xmlEle.Attributes.Append(xmlAtt);

            xmlAtt = xmlEle.OwnerDocument.CreateAttribute("Name");
            xmlAtt.Value = CatalogItem.Name;
            xmlEle.Attributes.Append(xmlAtt);

            xmlAtt = xmlEle.OwnerDocument.CreateAttribute("ParentID");
            xmlAtt.Value = CatalogItem.ParentCalalogID.ToString();
            xmlEle.Attributes.Append(xmlAtt);

            xmlAtt = xmlEle.OwnerDocument.CreateAttribute("Description");
            xmlAtt.Value = CatalogItem.Description;
            xmlEle.Attributes.Append(xmlAtt);

            xmlAtt = xmlEle.OwnerDocument.CreateAttribute("IsPublishedCatalog");
            xmlAtt.Value = CatalogItem.IsPublished.ToString();
            xmlEle.Attributes.Append(xmlAtt);

            List<CatalogImage> catalogImages = CatalogImageManager.GetCatalogImagesByCatalogID(CatalogItem.ID);
            if (catalogImages != null && catalogImages.Count > 0)
            {
                foreach (CatalogImage catalogImage in catalogImages)
                {
                    XmlElement imageElement = xmldoc.CreateElement("CatalogImage");
                    XmlAttribute attri = xmldoc.CreateAttribute("ID");

                    attri.Value = catalogImage.ID.ToString();
                    imageElement.Attributes.Append(attri);

                    attri = xmldoc.CreateAttribute("IsCoverImage");
                    attri.Value = catalogImage.IsCoverImage.ToString();
                    imageElement.Attributes.Append(attri);

                    attri = xmldoc.CreateAttribute("ImageName");
                    attri.Value = catalogImage.Image;
                    imageElement.Attributes.Append(attri);

                    xmlEle.AppendChild(imageElement);
                }
            }
        }
        public static XmlDocument GenerateCatalogXmlDoc(Catalog catalog)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
            XmlElement xmlRoot = xmlDoc.CreateElement("Catalogs");
            xmlDoc.AppendChild(xmlRoot);

            XmlElement xmlEle = xmlDoc.CreateElement("Catalog");
            xmlRoot.AppendChild(xmlEle);
            SetAttributeCatalogNode(xmlDoc, xmlEle, catalog);

            return xmlDoc;
        }
Beispiel #10
0
 public static int Add(Catalog catalog)
 {
     return CatalogDataMapper.Add(catalog);
 }
        internal static void FillFromReaderByProduct(Catalog catalog, SqlDataReader reader)
        {
            int colIndex = 0;
            colIndex = reader.GetOrdinal(CN_CATALOG_ID);
            if (!reader.IsDBNull(colIndex))
                catalog.ID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_NAME);
            if (!reader.IsDBNull(colIndex))
                catalog.Name = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_CATALOG_PARENT_CATALOG_ID);
            if (!reader.IsDBNull(colIndex))
                catalog.ParentCalalogID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_CATALOG_IS_PUBLISHED);
            if (!reader.IsDBNull(colIndex))
                catalog.IsPublished = reader.GetBoolean(colIndex);
        }
        internal static void FillFromReader(Catalog catalog, SqlDataReader reader)
        {
            int colIndex = 0;
            colIndex = reader.GetOrdinal(CN_CATALOG_ID);
            if (!reader.IsDBNull(colIndex))
                catalog.ID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_CATALOG_IS_DISPLAYED);
            if (!reader.IsDBNull(colIndex))
                catalog.IsDisplayed = reader.GetBoolean(colIndex);

            colIndex = reader.GetOrdinal(CN_CATALOG_IS_GALLERY_ONLY);
            if (!reader.IsDBNull(colIndex))
                catalog.IsGalleryOnly = reader.GetBoolean(colIndex);

            colIndex = reader.GetOrdinal(CN_CATALOG_PARENT_CATALOG_ID);
            if (!reader.IsDBNull(colIndex))
                catalog.ParentCalalogID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_CATALOG_PORTAL_ID);
            if (!reader.IsDBNull(colIndex))
                catalog.PortalID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_NAME);
            if (!reader.IsDBNull(colIndex))
                catalog.Name = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_LAN_ID);
            if (!reader.IsDBNull(colIndex))
                catalog.LanguageID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_DESC);
            if (!reader.IsDBNull(colIndex))
                catalog.Description = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_NAME2);
            if (!reader.IsDBNull(colIndex))
                catalog.MetaTitle = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_DESC2);
            if (!reader.IsDBNull(colIndex))
                catalog.MetaDescription = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_KEYWORD);
            if (!reader.IsDBNull(colIndex))
                catalog.MetaKeywords = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_CATALOG_IS_DELETED);
            if (!reader.IsDBNull(colIndex))
                catalog.IsDeleted = reader.GetBoolean(colIndex);

            colIndex = reader.GetOrdinal(CN_CATALOG_ORDER);
            if (!reader.IsDBNull(colIndex))
                catalog.Order = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_CATALOG_IS_PUBLISHED);
            if (!reader.IsDBNull(colIndex))
                catalog.IsPublished = reader.GetBoolean(colIndex);

        }
        internal static Catalog GetCatalog(List<Catalog> Catalogs, SqlDataReader reader)
        {
            int colIndex = 0;
            colIndex = reader.GetOrdinal(CN_CATALOG_ID);
            int value = reader.GetInt32(colIndex);

            Catalog catalog = Catalogs.Where(c => c.ID == value).FirstOrDefault();
            if (catalog == null)
            {
                catalog = new Catalog();
                Catalogs.Add(catalog);
            }
            return catalog;
        }
        internal static Catalog GetCatalog(int id, int languageID)
        {
            Catalog Catalog = null;

            using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString))
            {
                SqlCommand sqlCommand = new SqlCommand(SN_CATALOG_GET_BY_ID, sqlConnection);
                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;

                SqlParameter sqlParameter = null;
                sqlParameter = new SqlParameter(PN_CATALOG_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = id;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(ECommerceDataMapperBase.PN_MODULE_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = (int)CMSEnums.ECommerceModule.Catalog;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(ECommerceDataMapperBase.PN_ECO_LAN_LAN_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = languageID;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlCommand.Connection.Open();
                using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                {
                    while (sqlDataReader.Read())
                    {
                        if (Catalog == null)
                            Catalog = new Catalog();

                        FillFromReader(Catalog, sqlDataReader);
                    }

                    sqlDataReader.Close();
                    sqlCommand.Connection.Close();
                }
            }
            return Catalog;
        }