Ejemplo n.º 1
0
        //------------------------------------------
        #endregion

        #region --------------GetSiteDeparmentsPhotoOriginal--------------
        public static string GetSiteDeparmentsPhotoOriginal(object DepartmentID, object photoExtension, object ownerName)
        {
            if (photoExtension.ToString().Length > 0)
            {
                return(DCSiteUrls.GetPath_SiteDeparmentsPhotoBigThumbs((string)ownerName) + CreateSiteDeparmentsPhotoName((int)DepartmentID) + photoExtension.ToString());
            }
            else
            {
                return(SiteDesign.NoPhotoPath);
            }
        }
Ejemplo n.º 2
0
    //-----------------------------------------------
    #endregion

    #region ---------------LoadData---------------
    //-----------------------------------------------
    //LoadData
    //-----------------------------------------------
    protected void LoadData()
    {
        if (MoversFW.Components.UrlManager.ChechIsValidIntegerParameter("id"))
        {
            int departmentID = Convert.ToInt32(Request.QueryString["id"]);
            SiteDeparmentsEntity siteDepartment = SiteDeparmentsFactory.GetObject(departmentID, Languages.Unknowen);
            if (siteDepartment != null)
            {
                //txtTitle.Text = siteDepartment.Title;
                //txtShortDescription.Text = siteDepartment.ShortDescription;
                if (trParents.Visible)
                {
                    ddlParents.SelectedValue = siteDepartment.ParentID.ToString();
                }
                //-------------------------------
                txtUrl.Text = siteDepartment.Url;
                //-------------------------------
                ddlRelatedModuleTypeID.SelectedValue = siteDepartment.RelatedModuleTypeID.ToString();
                //-------------------------------
                if (siteDepartment.RelatedPageID > 0)
                {
                    Load_ddlRelatedPageID();
                    trDeletePhoto.Visible        = true;
                    siteDepartment.RelatedPageID = Convert.ToInt32(ddlRelatedPageID.SelectedValue);
                }
                //-------------------------------
                LoadDetails(siteDepartment);
                //-------------------------------

                cbIsAvailable.Checked = siteDepartment.IsAvailable;
                if (!string.IsNullOrEmpty(siteDepartment.PhotoExtension))
                {
                    imgPhoto.ImageUrl = DCSiteUrls.GetPath_SiteDeparmentsPhotoNormalThumbs(siteDepartment.OwnerName) + siteDepartment.NormalPhotoThumbs;
                    ancor.HRef        = DCSiteUrls.GetPath_SiteDeparmentsPhotoBigThumbs(siteDepartment.OwnerName) + siteDepartment.BigPhotoThumbs;
                    //imgPhoto.AlternateText = siteDepartment.Title;
                }
                else
                {
                    trPhotoPreview.Visible = false;
                }
                //------------------------------------------
                //------------------------------------------
            }
            else
            {
                Response.Redirect("default.aspx");
            }
        }
        else
        {
            Response.Redirect("default.aspx");
        }
    }
Ejemplo n.º 3
0
    protected void btnDeletePhoto_Click(object sender, EventArgs e)
    {
        int departmentID = Convert.ToInt32(Request.QueryString["id"]);
        SiteDeparmentsEntity siteDepartment = SiteDeparmentsFactory.GetObject(departmentID, Languages.Unknowen);

        if (siteDepartment != null)
        {
            if (trParents.Visible)
            {
                siteDepartment.ParentID = Convert.ToInt32(ddlParents.SelectedValue);
            }
            //Photo-----------------------------
            if (!string.IsNullOrEmpty(siteDepartment.PhotoExtension))
            {
                //Delete old original photo
                File.Delete(DCServer.MapPath(DCSiteUrls.GetPath_SiteDeparmentsPhotoOriginals(siteDepartment.OwnerName)) + siteDepartment.Photo);
                //Delete old Thumbnails
                File.Delete(DCServer.MapPath(DCSiteUrls.GetPath_SiteDeparmentsPhotoNormalThumbs(siteDepartment.OwnerName)) + SiteDeparmentsFactory.CreateSiteDeparmentsPhotoName(siteDepartment.DepartmentID) + MoversFW.Thumbs.thumbnailExetnsion);
                File.Delete(DCServer.MapPath(DCSiteUrls.GetPath_SiteDeparmentsPhotoBigThumbs(siteDepartment.OwnerName)) + SiteDeparmentsFactory.CreateSiteDeparmentsPhotoName(siteDepartment.DepartmentID) + MoversFW.Thumbs.thumbnailExetnsion);
            }
            //------------------------------------------------

            trPhotoPreview.Visible = false;
            //-----------------------------

            siteDepartment.PhotoExtension = "";

            ExecuteCommandStatus status = SiteDeparmentsFactory.Update(siteDepartment);
            if (status == ExecuteCommandStatus.Done)
            {
                lblResult.CssClass = "lblResult_Done";
                lblResult.Text     = Resources.AdminText.DeletingOprationDone;
            }

            else
            {
                lblResult.CssClass = "lblResult_Faild";
                lblResult.Text     = Resources.AdminText.DeletingOprationFaild;
            }
        }
    }
Ejemplo n.º 4
0
    //-----------------------------------------------
    #endregion

    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }
        SiteDeparmentsEntity siteDeparmentsObject = new SiteDeparmentsEntity();

        //siteDeparmentsObject.Title = txtTitle.Text;
        //siteDeparmentsObject.ShortDescription = txtShortDescription.Text;
        siteDeparmentsObject.ModuleTypeID = ModuleTypeID;
        if (trParents.Visible)
        {
            siteDeparmentsObject.ParentID = Convert.ToInt32(ddlParents.SelectedValue);
        }
        //-------------------------------
        siteDeparmentsObject.Url = txtUrl.Text;
        //-------------------------------
        siteDeparmentsObject.TypeID = TypeID;
        //-------------------------------
        siteDeparmentsObject.RelatedModuleTypeID = Convert.ToInt32(ddlRelatedModuleTypeID.SelectedValue);
        //-------------------------------
        if (ddlRelatedPageID.Items.Count > 0)
        {
            siteDeparmentsObject.RelatedPageID = Convert.ToInt32(ddlRelatedPageID.SelectedValue);
        }
        //Details -----------------------
        AddDetails(siteDeparmentsObject);
        //------------------------------
        //-------------
        if (fuPhoto.HasFile)
        {
            if (!MoversFW.Photos.CheckIsImage(fuPhoto.PostedFile))
            {
                General.MakeAlertError(lblResult, Resources.AdminText.InvalidPhotoFile);
                return;
            }

            /*
             * //Check suported extention
             * if (!SiteSettings.CheckUploadedFileExtension(uploadedPhotoExtension, currentModule.PhotoAvailableExtension))
             * {
             *
             *  General.MakeAlertError(lblResult, Resources.AdminText.NotSuportedFileExtention + currentModule.PhotoAvailableExtension);
             *  return;
             * }*/
            //Check max length
            if (!SiteSettings.CheckUploadedFileLength(fuPhoto.PostedFile.ContentLength, currentModule.PhotoMaxSize))
            {
                General.MakeAlertError(lblResult, Resources.AdminText.UploadedFileGreaterThanMaxLength + currentModule.PhotoMaxSize);
                return;
            }
        }
        siteDeparmentsObject.PhotoExtension = Path.GetExtension(fuPhoto.FileName);
        //-----------------------------------------------------------------
        if (currentModule.HasIsAvailable)
        {
            siteDeparmentsObject.IsAvailable = cbIsAvailable.Checked;
        }
        else
        {
            siteDeparmentsObject.IsAvailable = true;
        }
        //-----------------------------------------------------------------
        ExecuteCommandStatus status = SiteDeparmentsFactory.Create(siteDeparmentsObject);

        if (status == ExecuteCommandStatus.Done)
        {
            //Photo-----------------------------
            if (fuPhoto.HasFile)
            {
                //------------------------------------------------
                //Save new original photo
                fuPhoto.PostedFile.SaveAs(DCServer.MapPath(DCSiteUrls.GetPath_SiteDeparmentsPhotoOriginals(siteDeparmentsObject.OwnerName)) + siteDeparmentsObject.Photo);
                //Create new thumbnails
                MoversFW.Thumbs.CreateThumb(DCSiteUrls.GetPath_SiteDeparmentsPhotoNormalThumbs(siteDeparmentsObject.OwnerName), SiteDeparmentsFactory.CreateSiteDeparmentsPhotoName(siteDeparmentsObject.DepartmentID), fuPhoto.PostedFile, SiteSettings.Photos_NormalThumnailWidth, SiteSettings.Photos_NormalThumnailHeight);
                MoversFW.Thumbs.CreateThumb(DCSiteUrls.GetPath_SiteDeparmentsPhotoBigThumbs(siteDeparmentsObject.OwnerName), SiteDeparmentsFactory.CreateSiteDeparmentsPhotoName(siteDeparmentsObject.DepartmentID), fuPhoto.PostedFile, SiteSettings.Photos_BigThumnailWidth, SiteSettings.Photos_BigThumnailHeight);
            }

            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);
        }
    }
Ejemplo n.º 5
0
    //-----------------------------------------------
    #endregion


    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (MoversFW.Components.UrlManager.ChechIsValidIntegerParameter("id"))
        {
            if (!Page.IsValid)
            {
                return;
            }
            int id = Convert.ToInt32(Request.QueryString["id"]);
            SiteDeparmentsEntity siteDepartment = SiteDeparmentsFactory.GetObject(id, Languages.Unknowen);
            if (siteDepartment != null)
            {
                //siteDepartment.Title = txtTitle.Text;
                // siteDepartment.ShortDescription = txtShortDescription.Text;
                if (trParents.Visible)
                {
                    siteDepartment.ParentID = Convert.ToInt32(ddlParents.SelectedValue);
                }
                //-------------------------------
                siteDepartment.Url = txtUrl.Text;
                //-------------------------------
                siteDepartment.RelatedModuleTypeID = Convert.ToInt32(ddlRelatedModuleTypeID.SelectedValue);
                //-------------------------------
                if (ddlRelatedPageID.Items.Count > 0)
                {
                    siteDepartment.RelatedPageID = Convert.ToInt32(ddlRelatedPageID.SelectedValue);
                }
                //-------------------------------
                //Details -----------------------
                AddDetails(siteDepartment);
                //-------------------------------
                //-------------
                string photoExtension = siteDepartment.PhotoExtension;
                if (fuPhoto.HasFile)
                {
                    if (!MoversFW.Photos.CheckIsImage(fuPhoto.PostedFile))
                    {
                        lblResult.CssClass = "lblResult_Faild";
                        lblResult.Text     = Resources.AdminText.InvalidPhotoFile;
                        return;
                    }

                    /*
                     * //Check suported extention
                     * if (!SiteSettings.CheckUploadedFileExtension(uploadedPhotoExtension, currentModule.PhotoAvailableExtension))
                     * {
                     *  lblResult.CssClass = "lblResult_Faild";
                     *  lblResult.Text = Resources.AdminText.NotSuportedFileExtention + currentModule.PhotoAvailableExtension;
                     *  return;
                     * }*/
                    //Check max length
                    if (!SiteSettings.CheckUploadedFileLength(fuPhoto.PostedFile.ContentLength, currentModule.PhotoMaxSize))
                    {
                        lblResult.CssClass = "lblResult_Faild";
                        lblResult.Text     = Resources.AdminText.UploadedFileGreaterThanMaxLength + currentModule.PhotoMaxSize;
                        return;
                    }
                    //--------------------------------------------------------------------
                    siteDepartment.PhotoExtension = Path.GetExtension(fuPhoto.FileName);
                }
                else
                {
                    siteDepartment.PhotoExtension = photoExtension;
                }
                //-----------------------------------------------------------------
                //Check is  available
                // logic of is available "if the module hasn't IsAvailable -> then  All items ara vailable "
                if (currentModule.HasIsAvailable)
                {
                    siteDepartment.IsAvailable = cbIsAvailable.Checked;
                }
                else
                {
                    siteDepartment.IsAvailable = true;
                }
                //------------------------------------------------------------------------------------------
                ExecuteCommandStatus status = SiteDeparmentsFactory.Update(siteDepartment);
                if (status == ExecuteCommandStatus.Done)
                {
                    //Photo-----------------------------
                    if (fuPhoto.HasFile)
                    {
                        //if has an old photo
                        if (photoExtension.Length > 0)
                        {
                            //Delete old original photo
                            File.Delete(DCServer.MapPath(DCSiteUrls.GetPath_SiteDeparmentsPhotoOriginals(siteDepartment.OwnerName)) + SiteDeparmentsFactory.CreateSiteDeparmentsPhotoName(siteDepartment.DepartmentID) + photoExtension);
                            //Delete old Thumbnails
                            File.Delete(DCServer.MapPath(DCSiteUrls.GetPath_SiteDeparmentsPhotoNormalThumbs(siteDepartment.OwnerName)) + SiteDeparmentsFactory.CreateSiteDeparmentsPhotoName(siteDepartment.DepartmentID) + MoversFW.Thumbs.thumbnailExetnsion);
                            File.Delete(DCServer.MapPath(DCSiteUrls.GetPath_SiteDeparmentsPhotoBigThumbs(siteDepartment.OwnerName)) + SiteDeparmentsFactory.CreateSiteDeparmentsPhotoName(siteDepartment.DepartmentID) + MoversFW.Thumbs.thumbnailExetnsion);
                        }
                        //------------------------------------------------
                        //Save new original photo
                        fuPhoto.PostedFile.SaveAs(DCServer.MapPath(DCSiteUrls.GetPath_SiteDeparmentsPhotoOriginals(siteDepartment.OwnerName)) + siteDepartment.Photo);
                        //Create new thumbnails
                        MoversFW.Thumbs.CreateThumb(DCSiteUrls.GetPath_SiteDeparmentsPhotoNormalThumbs(siteDepartment.OwnerName), SiteDeparmentsFactory.CreateSiteDeparmentsPhotoName(siteDepartment.DepartmentID), fuPhoto.PostedFile, SiteSettings.Photos_NormalThumnailWidth, SiteSettings.Photos_NormalThumnailHeight);
                        MoversFW.Thumbs.CreateThumb(DCSiteUrls.GetPath_SiteDeparmentsPhotoBigThumbs(siteDepartment.OwnerName), SiteDeparmentsFactory.CreateSiteDeparmentsPhotoName(siteDepartment.DepartmentID), fuPhoto.PostedFile, SiteSettings.Photos_BigThumnailWidth, SiteSettings.Photos_BigThumnailHeight);
                    }
                    //------------------------------------------------
                    Response.Redirect("default.aspx");
                }
                else if (status == ExecuteCommandStatus.AllreadyExists)
                {
                    lblResult.CssClass = "lblResult_Faild";
                    lblResult.Text     = Resources.AdminText.DuplicateItem;
                }
                else
                {
                    lblResult.CssClass = "lblResult_Faild";
                    lblResult.Text     = Resources.AdminText.UpdatingOperationFaild;
                }
            }
            else
            {
                Response.Redirect("default.aspx");
            }
        }
        else
        {
            Response.Redirect("default.aspx");
        }
    }