Example #1
0
    //--------------------------------------------------------
    #endregion

    #region --------------GetCategoryText--------------
    //---------------------------------------------------------
    //GetCategoryText
    //---------------------------------------------------------
    public string GetCategoryText(object catID)
    {
        int categoryID = Convert.ToInt32(catID);

        if (categoryID > 0)
        {
            Languages            langID   = SiteSettings.GetCurrentLanguage();
            ItemCategoriesEntity category = ItemCategoriesFactory.GetObject(categoryID, langID, OwnerID);
            if (category != null)
            {
                ItemCategoriesDetailsEntity pd = null;
                if (category.Details.Contains(Languages.Ar))
                {
                    pd = (ItemCategoriesDetailsEntity)category.Details[Languages.Ar];
                }
                else
                {
                    pd = (ItemCategoriesDetailsEntity)category.Details[Languages.En];
                }
                if (pd != null)
                {
                    return(pd.Title);
                }
            }
        }
        return("");
    }
Example #2
0
    //--------------------------------------------------------------------------------

    #region --------------dgItemCategories_DeleteCommand--------------
    //---------------------------------------------------------
    //dgItemCategories_DeleteCommand
    //---------------------------------------------------------
    protected void dgItemCategories_DeleteCommand(object source, DataGridCommandEventArgs e)
    {
        //Check Delete permission
        //-------------------------------------------------------------------------------

        int categoryID = Convert.ToInt32(dgItemCategories.DataKeys[e.Item.ItemIndex]);

        bool status = ItemCategoriesFactory.Delete(categoryID);

        if (status)
        {
            lblResult.CssClass = "lblResult_Done";
            lblResult.Text     = Resources.AdminText.DeletingOprationDone;
            //if one item in datagrid

            /*if (dgItemCategories.Items.Count == 1)
             * {
             *  --pager.CurrentPage;
             * }*/
            LoadData();
        }
        else
        {
            lblResult.CssClass = "lblResult_Faild";
            lblResult.Text     = Resources.AdminText.DeletingOprationFaild;
        }
    }
Example #3
0
    //-----------------------------------------------
    #endregion

    #region ---------------LoadParents---------------
    //-----------------------------------------------
    //LoadParents
    //-----------------------------------------------
    private void LoadParents()
    {
        int categoriesDepth = currentModule.CategoryLevel;//NewsSiteSettings.Instance.CategoriesDepth;
        int depthLevel      = categoriesDepth - 1;

        if (depthLevel < -1)
        {
            depthLevel = -1;
        }

        /*if (!currentModule.CategoryHasCategoryID)
         * {
         *  Response.Redirect("/admincp");
         * }
         * else*/
        if (categoriesDepth == 1)
        {
            trParents.Visible = false;
        }
        else
        {
            ParentChildDropDownList n = new ParentChildDropDownList();
            DataTable dtSource        = ItemCategoriesFactory.GetAllInDataTable(ModuleTypeID, Languages.Unknowen, false, OwnerID);
            n.DataBind(ddlParents, depthLevel, dtSource, "ParentID", "CategoryID", "Title");
            ddlParents.Items.Insert(0, new ListItem(Resources.AdminText.Choose, "0"));
        }
    }
Example #4
0
    //--------------------------------------------------------------------------------

    #region --------------dgItemCategories_DeleteCommand--------------
    //---------------------------------------------------------
    //dgItemCategories_DeleteCommand
    //---------------------------------------------------------
    protected void dgItemCategories_DeleteCommand(object source, DataGridCommandEventArgs e)
    {
        //Check Delete permission
        //-------------------------------------------------------------------------------

        int categoryID = Convert.ToInt32(dgItemCategories.DataKeys[e.Item.ItemIndex]);

        bool status = ItemCategoriesFactory.Delete(categoryID);

        if (status)
        {
            General.MakeAlertSucess(lblResult, Resources.AdminText.DeletingOprationDone);
            //if one item in datagrid

            /*if (dgItemCategories.Items.Count == 1)
             * {
             *  --pager.CurrentPage;
             * }*/
            LoadData();
        }
        else
        {
            General.MakeAlertError(lblResult, Resources.AdminText.DeletingOprationFaild);
        }
    }
Example #5
0
    //-----------------------------------------------
    #endregion
    //-------------------------------------------------------
    #region ---------------LoadCategories---------------
    //-----------------------------------------------
    //LoadCategories
    //-----------------------------------------------
    private void LoadCategories()
    {
        int categoriesDepth       = currentModule.CategoryLevel;//NewsSiteSettings.Instance.CategoriesDepth;
        ParentChildDropDownList n = new ParentChildDropDownList();
        DataTable dtSource        = ItemCategoriesFactory.GetAllInDataTable(ModuleTypeID, Languages.Ar, false, OwnerID);

        n.DataBind(ddlCategoryID, categoriesDepth, dtSource, "ParentID", "CategoryID", "Title");
        ddlCategoryID.Items.Insert(0, new ListItem(Resources.AdminText.Choose, "-1"));
    }
Example #6
0
        //-----------------------------------------------------------


        #region --------------LoadData--------------
        //---------------------------------------------------------
        //LoadData
        //---------------------------------------------------------
        public new void LoadData()
        {
            List <ItemCategoriesEntity> categoriesList = ItemCategoriesFactory.GetAll(ModuleTypeID, ParentID, true, OwnerID);
            Repeater r = (Repeater)this.FindControl(TemplateID);

            if (categoriesList != null && categoriesList.Count > 0)
            {
                r.DataSource = categoriesList;
                r.DataBind();
            }
        }
Example #7
0
        //-----------------------------------------------------------


        #region --------------LoadData--------------
        //---------------------------------------------------------
        //LoadData
        //---------------------------------------------------------
        public new void LoadData()
        {
            pager.PageSize = currentModule.CategoryPageItemCount_UserDefault;
            List <ItemCategoriesEntity> categoriesList = ItemCategoriesFactory.GetAll(ModuleTypeID, ParentID, true, pager.CurrentPage, pager.PageSize, out totalRecords, OwnerID);

            Control  c;
            DataList dl;
            Repeater r;

            c = this.FindControl(TemplateID);
            if (c is DataList)
            {
                dl = (DataList)c;
                LoadDataList(dl, categoriesList);
            }
            else
            {
                r = (Repeater)c;
                LoadRepeater(r, categoriesList);
            }
        }
Example #8
0
    //-----------------------------------------------
    #endregion

    //---------------------------------------------------------------------------
    #region --------------LoadData--------------
    //---------------------------------------------------------
    //LoadData
    //---------------------------------------------------------
    private void LoadData()
    {
        //--------------------------------------------------------------------
        Languages langID = Languages.Unknowen;

        if (SiteSettings.Languages_HasMultiLanguages)
        {
            langID = (Languages)Convert.ToInt32(ddlLanguages.SelectedValue);
        }
        //--------------------------------------------------------------------
        dtSource = ItemCategoriesFactory.GetAllInDataTable(ModuleTypeID, langID, false, OwnerID);
        if (dtSource != null && dtSource.Rows.Count > 0)
        {
            categoriesDepth = currentModule.CategoryLevel;
            parent          = "ParentID";
            child           = "CategoryID";
            text            = "Title";
            BuildList();

            dgItemCategories.DataSource   = tempDataTable;
            dgItemCategories.DataKeyField = "CategoryID";
            dgItemCategories.AllowPaging  = false;
            dgItemCategories.DataBind();
            dgItemCategories.Visible = true;
            //-------------------------------------------------------------------------------
            //Security Premession
            //--------------------------
            ZecurityManager.HideGridColumn(dgItemCategories, CommandName.Delete, dgItemCategories.Columns.Count - 1);
            ZecurityManager.HideGridColumn(dgItemCategories, CommandName.Edit, dgItemCategories.Columns.Count - 2);
            /*End Secu*/
            //-------------------------------------------------------------------------------
        }
        else
        {
            dgItemCategories.Visible = false;
            lblResult.CssClass       = "lblResult_Faild";
            lblResult.Text           = Resources.AdminText.ThereIsNoData;
        }
    }
Example #9
0
    //--------------------------------------------------------
    #endregion

    #region ---------------SaveFiles---------------
    //-----------------------------------------------
    //SaveFiles
    //-----------------------------------------------
    protected void SaveFiles(ItemCategoriesEntity itemCategoriesObject)
    {
        #region Save uploaded photo
        //Photo-----------------------------
        if (fuPhoto.HasFile)
        {
            //------------------------------------------------
            //Save new original photo
            fuPhoto.PostedFile.SaveAs(DCServer.MapPath(DCSiteUrls.GetPath_ItemCategoriesPhotoOriginals(itemCategoriesObject.OwnerName, itemCategoriesObject.ModuleTypeID, itemCategoriesObject.CategoryID)) + itemCategoriesObject.Photo);
            //Create new thumbnails
            MoversFW.Thumbs.CreateThumb(DCSiteUrls.GetPath_ItemCategoriesPhotoNormalThumbs(itemCategoriesObject.OwnerName, itemCategoriesObject.ModuleTypeID, itemCategoriesObject.CategoryID), ItemCategoriesFactory.CreateItemCategoriesPhotoName(itemCategoriesObject.CategoryID), fuPhoto.PostedFile, SiteSettings.Photos_NormalThumnailWidth, SiteSettings.Photos_NormalThumnailHeight);
            MoversFW.Thumbs.CreateThumb(DCSiteUrls.GetPath_ItemCategoriesPhotoBigThumbs(itemCategoriesObject.OwnerName, itemCategoriesObject.ModuleTypeID, itemCategoriesObject.CategoryID), ItemCategoriesFactory.CreateItemCategoriesPhotoName(itemCategoriesObject.CategoryID), fuPhoto.PostedFile, SiteSettings.Photos_BigThumnailWidth, SiteSettings.Photos_BigThumnailHeight);
            //-------------------------------------------------------
        }
        #endregion

        #region Save uploaded file
        //File-----------------------------
        if (fuFile.HasFile)
        {
            //Save new original file
            fuFile.PostedFile.SaveAs(DCServer.MapPath(DCSiteUrls.GetPath_ItemCategoriesFiles(itemCategoriesObject.OwnerName, itemCategoriesObject.ModuleTypeID, itemCategoriesObject.CategoryID)) + itemCategoriesObject.File);
        }
        #endregion

        #region Save uploaded video
        //Video-----------------------------
        if (fuVideo.HasFile)
        {
            fuVideo.PostedFile.SaveAs(DCServer.MapPath(DCSiteUrls.GetPath_ItemCategoriesFiles(itemCategoriesObject.OwnerName, itemCategoriesObject.ModuleTypeID, itemCategoriesObject.CategoryID)) + itemCategoriesObject.Video);
        }
        #endregion

        #region Save uploaded audio
        //Audio-----------------------------
        if (fuAudio.HasFile)
        {
            fuAudio.PostedFile.SaveAs(DCServer.MapPath(DCSiteUrls.GetPath_ItemCategoriesFiles(itemCategoriesObject.OwnerName, itemCategoriesObject.ModuleTypeID, itemCategoriesObject.CategoryID)) + itemCategoriesObject.Audio);
        }
        #endregion

        #region Save uploaded photo2
        //-------------------------------------------------------------------------------------
        //Photo2-----------------------------
        if (fuPhoto2.HasFile)
        {
            fuPhoto2.PostedFile.SaveAs(DCServer.MapPath(DCSiteUrls.GetPath_ItemCategoriesFiles(itemCategoriesObject.OwnerName, itemCategoriesObject.ModuleTypeID, itemCategoriesObject.CategoryID)) + itemCategoriesObject.Photo2);
        }
        #endregion
    }
Example #10
0
    //-----------------------------------------------
    #endregion


    #region ---------------btnSave_Click---------------
    //-----------------------------------------------
    //btnSave_Click
    //-----------------------------------------------
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid || (currentModule.CategoryHasItemDate && !ucItemDate.IsValid))
        {
            return;
        }
        //--------------------------------------------------
        ItemCategoriesEntity itemCategoriesObject = new ItemCategoriesEntity();

        //--------------------------------------------------
        #region Item Files properties

        // uploaded files extenssions
        string uploadedPhotoExtension  = Path.GetExtension(fuPhoto.FileName);
        string uploadedFileExtension   = Path.GetExtension(fuFile.FileName);
        string uploadedVideoExtension  = Path.GetExtension(fuVideo.FileName);
        string uploadedAudioExtension  = Path.GetExtension(fuAudio.FileName);
        string uploadedPhoto2Extension = Path.GetExtension(fuPhoto2.FileName);
        //---------------------------------------------------------------------

        #region Uploaded Files checks
        #region Uploaded photo file checks
        if (fuPhoto.HasFile)
        {
            if (!MoversFW.Photos.CheckIsImage(fuPhoto.PostedFile))
            {
                General.MakeAlertError(lblResult, Resources.AdminText.InvalidPhotoFile);
                return;
            }

            /*
             * //Check suported extention
             * if (!SiteSettings.CheckUploadedFileExtension(uploadedPhotoExtension, currentModule.CategoryPhotoAvailableExtension))
             * {
             *
             *   General.MakeAlertError(lblResult, Resources.AdminText.NotSuportedFileExtention + currentModule.CategoryPhotoAvailableExtensio);
             *
             *  return;
             * }*/
            //Check max length
            if (!SiteSettings.CheckUploadedFileLength(fuPhoto.PostedFile.ContentLength, currentModule.CategoryPhotoMaxSize))
            {
                General.MakeAlertError(lblResult, Resources.AdminText.UploadedFileGreaterThanMaxLength + currentModule.CategoryPhotoMaxSize);

                return;
            }
            //--------------------------------------------------------------------
        }
        #endregion
        #region Uploaded file checks
        //File
        if (fuFile.HasFile)
        {/*
          * //Check suported extention
          * if (!SiteSettings.CheckUploadedFileExtension(uploadedFileExtension, currentModule.CategoryFileAvailableExtension))
          * {
          *
          *     General.MakeAlertError(lblResult, Resources.AdminText.NotSuportedFileExtention + currentModule.CategoryFileAvailableExtension);
          *
          *     return;
          * }*/
            //Check max length
            if (!SiteSettings.CheckUploadedFileLength(fuFile.PostedFile.ContentLength, currentModule.CategoryFileMaxSize))
            {
                General.MakeAlertError(lblResult, Resources.AdminText.UploadedFileGreaterThanMaxLength + currentModule.CategoryFileMaxSize);
            }
        }
        //-----------------------------------------------------------------
        #endregion
        #region Uploaded video file checks
        //Video
        if (fuVideo.HasFile)
        {/*
          * //Check suported extention
          * if (!SiteSettings.CheckUploadedFileExtension(uploadedVideoExtension, currentModule.CategoryVideoAvailableExtension))
          * {
          *
          *     General.MakeAlertError(lblResult, Resources.AdminText.NotSuportedVideoExtention + currentModule.CategoryVideoAvailableExtension);
          *
          *     return;
          * }*/
            //Check max length
            if (!SiteSettings.CheckUploadedFileLength(fuVideo.PostedFile.ContentLength, currentModule.CategoryVideoMaxSize))
            {
                General.MakeAlertError(lblResult, Resources.AdminText.UploadedVideoGreaterThanMaxLength + currentModule.CategoryVideoMaxSize);
                return;
            }
        }
        //-----------------------------------------------------------------
        #endregion
        #region Uploaded audio file checks
        //Audio
        if (fuAudio.HasFile)
        {/*
          * //Check suported extention
          * if (!SiteSettings.CheckUploadedFileExtension(uploadedAudioExtension, currentModule.CategoryAudioAvailableExtension))
          * {
          *
          *     General.MakeAlertError(lblResult, Resources.AdminText.NotSuportedAudioExtention + currentModule.CategoryAudioAvailableExtension);
          *
          *     return;
          * }*/
            //Check max length
            if (!SiteSettings.CheckUploadedFileLength(fuAudio.PostedFile.ContentLength, currentModule.CategoryAudioMaxSize))
            {
                General.MakeAlertError(lblResult, Resources.AdminText.UploadedAudioGreaterThanMaxLength + currentModule.CategoryAudioMaxSize);

                return;
            }
        }
        //-----------------------------------------------------------------
        #endregion
        #region Uploaded photo2 file checks
        //-----------------------------------------------------------------
        //Photo2
        if (fuPhoto2.HasFile)
        {
            if (!MoversFW.Photos.CheckIsImage(fuPhoto2.PostedFile))
            {
                General.MakeAlertError(lblResult, Resources.AdminText.InvalidPhotoFile);
                return;
            }/*
              * //Check suported extention
              * if (!SiteSettings.CheckUploadedFileExtension(uploadedPhoto2Extension, currentModule.CategoryPhoto2AvailableExtension))
              * {
              *
              * General.MakeAlertError(lblResult, Resources.AdminText.NotSuportedFileExtention + currentModule.CategoryPhoto2AvailableExtension);
              *
              * return;
              * }*/
            //Check max length
            if (!SiteSettings.CheckUploadedFileLength(fuPhoto2.PostedFile.ContentLength, currentModule.CategoryPhoto2MaxSize))
            {
                General.MakeAlertError(lblResult, Resources.AdminText.UploadedFileGreaterThanMaxLength + currentModule.CategoryPhoto2MaxSize);

                return;
            }
            //--------------------------------------------------------------------
        }
        //-----------------------------------------------------------------
        #endregion
        #endregion
        //-------------------------------------------------------------------------------------------
        #region Set properties
        //items files
        itemCategoriesObject.PhotoExtension  = uploadedPhotoExtension;
        itemCategoriesObject.FileExtension   = uploadedFileExtension;
        itemCategoriesObject.VideoExtension  = uploadedVideoExtension;
        itemCategoriesObject.AudioExtension  = uploadedAudioExtension;
        itemCategoriesObject.Photo2Extension = uploadedPhoto2Extension;

        #endregion
        //-------------------------------------------------------------------------------------------
        #endregion
        //-------------------------------------------------------------------------------------------
        if (trParents.Visible)
        {
            itemCategoriesObject.ParentID = Convert.ToInt32(ddlParents.SelectedValue);
        }
        //-------------------------------------------------------------------------------------------
        itemCategoriesObject.TypeID = TypeID;
        //-------------------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------------------
        if (currentModule.CategoryHasPriority)
        {
            itemCategoriesObject.Priority = Convert.ToInt32(ddlPriority.SelectedValue);
        }
        //-------------------------------------------------------------------------------------------
        if (currentModule.CategoryHasHeight)
        {
            itemCategoriesObject.Height = Convert.ToInt32(txtHeight.Text);
        }
        if (currentModule.CategoryHasWidth)
        {
            itemCategoriesObject.Width = Convert.ToInt32(txtWidth.Text);
        }
        //-------------------------------------------------------------------------------------------
        //if (currentModule.CategoryHasItemDate && !string.IsNullOrEmpty(txtItemDate.Text)) itemCategoriesObject.ItemDate = Convert.ToDateTime(txtItemDate.Text);
        if (currentModule.CategoryHasItemDate && ucItemDate.Date != DateTime.MinValue)
        {
            itemCategoriesObject.ItemDate = ucItemDate.Date;
        }
        //-------------------------------------------------------------------------------------------
        //Check is  available
        // logic of is available "if the module hasn't IsAvailable -> then  All items ara vailable "
        if (currentModule.CategoryHasIsAvailable)
        {
            itemCategoriesObject.IsAvailable = cbIsAvailable.Checked;
        }
        else
        {
            itemCategoriesObject.IsAvailable = true;
        }
        //-------------------------------------------------------------------------------------------
        itemCategoriesObject.IsMain = CbIsMain.Checked;
        //-------------------------------------------------------------------------------------------
        itemCategoriesObject.ModuleTypeID = ModuleTypeID;
        //-------------------------------------------------------------------------------------------
        itemCategoriesObject.YoutubeCode = txtYoutubeCode.Text;
        //-------------------------------------------------------------------------------------------
        if (currentModule.CategoryHasGoogleLatitude)
        {
            itemCategoriesObject.GoogleLatitude = Convert.ToDouble(txtGoogleLatitude.Text);
        }
        //-------------------------------------------------------------------------------------------
        if (currentModule.CategoryHasGoogleLongitude)
        {
            itemCategoriesObject.GoogleLongitude = Convert.ToDouble(txtGoogleLongitude.Text);
        }
        //-------------------------------------------------------------------------------------------
        itemCategoriesObject.OnlyForRegisered = cbOnlyForRegisered.Checked;
        //-------------------------------------------------------------------------------------------
        //Files publishing
        itemCategoriesObject.PublishPhoto  = cbPublishPhoto.Checked;
        itemCategoriesObject.PublishPhoto2 = cbPublishPhoto2.Checked;
        itemCategoriesObject.PublishFile   = cbPublishFile.Checked;
        itemCategoriesObject.PublishAudio  = cbPublishAudio.Checked;
        itemCategoriesObject.PublishVideo  = cbPublishVideo.Checked;
        itemCategoriesObject.PublishYoutbe = cbPublishYoutbe.Checked;
        //-------------------------------------------------------------------------------------------
        if (OwnerID != null)
        {
            itemCategoriesObject.OwnerID = (Guid)OwnerID;
        }
        //Details //---------------------------------------------------------------------------------
        AddDetails(itemCategoriesObject);
        //-------------------------------------------------------------------------------------------
        ExecuteCommandStatus status = ItemCategoriesFactory.Create(itemCategoriesObject, currentModule);
        //-------------------------------------------------------------------------------------------
        if (status == ExecuteCommandStatus.Done)
        {
            //------------------------------------------------------------------------
            SaveFiles(itemCategoriesObject);
            //------------------------------------------------------------------------
            General.MakeAlertSucess(lblResult, Resources.AdminText.AddingOperationDone);

            ClearControls();
            //------------------------------------------------------------------------
        }
        else if (status == ExecuteCommandStatus.AllreadyExists)
        {
            General.MakeAlertError(lblResult, Resources.AdminText.DuplicateItem);
        }
        else
        {
            General.MakeAlertError(lblResult, Resources.AdminText.AddingOperationFaild);
        }
    }
Example #11
0
    //-----------------------------------------------
    #endregion

    #region ---------------LoadPriorities---------------
    //-----------------------------------------------
    //LoadPriorities
    //-----------------------------------------------
    protected void LoadPriorities()
    {
        int categoriesCount = ItemCategoriesFactory.GetCount(currentModule.ModuleTypeID, OwnerID);

        OurDropDownList.LoadPriorities(ddlPriority, categoriesCount, true);
    }