Esempio n. 1
0
    protected void btnDeletePhoto_Click(object sender, EventArgs e)
    {
        if (MoversFW.Components.UrlManager.ChechIsValidParameter("id"))
        {
            Guid            userid          = new Guid(Request.QueryString["id"]);
            UsersDataEntity usersDataObject = UsersDataFactory.GetUsersDataObject(userid, OwnerID);
            if (usersDataObject != null)
            {
                //Photo-----------------------------
                if (!string.IsNullOrEmpty(usersDataObject.PhotoExtension))
                {
                    //Delete old original photo
                    File.Delete(DCServer.MapPath(DCSiteUrls.GetPath_UserDataPhotoOriginals(usersDataObject.OwnerName, usersDataObject.ModuleTypeID, usersDataObject.CategoryID, usersDataObject.UserProfileID)) + usersDataObject.Photo);
                    //Delete old Thumbnails
                    File.Delete(DCServer.MapPath(DCSiteUrls.GetPath_UserDataPhotoNormalThumbs(usersDataObject.OwnerName, usersDataObject.ModuleTypeID, usersDataObject.CategoryID, usersDataObject.UserProfileID)) + UsersDataFactory.CreateUserPhotoName(usersDataObject.UserProfileID) + MoversFW.Thumbs.thumbnailExetnsion);
                    File.Delete(DCServer.MapPath(DCSiteUrls.GetPath_UserDataPhotoBigThumbs(usersDataObject.OwnerName, usersDataObject.ModuleTypeID, usersDataObject.CategoryID, usersDataObject.UserProfileID)) + UsersDataFactory.CreateUserPhotoName(usersDataObject.UserProfileID) + MoversFW.Thumbs.thumbnailExetnsion);
                }
                //------------------------------------------------

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

                usersDataObject.PhotoExtension = "";
                bool status = UsersDataFactory.Update(usersDataObject);
                if (status)
                {
                    lblResult.CssClass = "lblResult_Done";
                    lblResult.Text     = Resources.AdminText.DeletingOprationDone;
                }

                else
                {
                    lblResult.CssClass = "lblResult_Faild";
                    lblResult.Text     = Resources.AdminText.DeletingOprationFaild;
                }
            }
        }
    }
Esempio n. 2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (MoversFW.Components.UrlManager.ChechIsValidParameter("id"))
        {
            Guid            userid          = new Guid(Request.QueryString["id"]);
            UsersDataEntity usersDataObject = UsersDataFactory.GetUsersDataObject(userid, OwnerID);

            oldPhotoExtension = usersDataObject.PhotoExtension;
            string uploadedPhotoExtension = Path.GetExtension(fuPhoto.FileName);

            oldEmail  = usersDataObject.Email;
            oldMobile = usersDataObject.Mobile;
            #region Uploaded photo file checks
            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;
                }
                //--------------------------------------------------------------------
            }
            #endregion

            usersDataObject.Name = txtName.Text;
            if (currentModule.CategoryLevel != 0)
            {
                usersDataObject.CategoryID = Convert.ToInt32(ddlCategoryID.SelectedValue);
            }
            if (trEmpNo.Visible && !string.IsNullOrEmpty(txtEmpNo.Text))
            {
                usersDataObject.EmpNo = Convert.ToInt32(txtEmpNo.Text);
            }
            //------------------------------------------------------------
            if (trAgeRang.Visible)
            {
                usersDataObject.AgeRang = Convert.ToInt32(ddlAgeRang.SelectedValue);
            }
            if (trGender.Visible)
            {
                usersDataObject.Gender = (Gender)Convert.ToInt32(ddlGender.SelectedValue);
            }
            if (trBirthDate.Visible)
            {
                usersDataObject.BirthDate = ucDateBirthDate.Date.ToShortDateString();
            }
            if (trSocialStatus.Visible)
            {
                usersDataObject.SocialStatus = Convert.ToInt32(ddlSocialStatus.SelectedValue);
            }
            if (trEducationLevel.Visible)
            {
                usersDataObject.EducationLevel = Convert.ToInt32(ddlEducationLevel.SelectedValue);
            }
            if (trCountryID.Visible)
            {
                usersDataObject.CountryID = Convert.ToInt32(ddlSystemCountries.SelectedValue);
            }
            if (trCityID.Visible)
            {
                usersDataObject.CityID = Convert.ToInt32(ddlCities.SelectedValue);
            }
            //------------------------------------------------------------
            usersDataObject.UserCityName    = txtUserCityName.Text;
            usersDataObject.Tel             = txtTel.Text;
            usersDataObject.Mobile          = txtMobile.Text;
            usersDataObject.HasSmsService   = cbHasSmsService.Checked;
            usersDataObject.HasEmailService = cbHasEmailService.Checked;
            //------------------------------------------------------------
            usersDataObject.Fax     = txtFax.Text;
            usersDataObject.MailBox = txtMailBox.Text;
            usersDataObject.ZipCode = txtZipCode.Text;
            if (trJobID.Visible && !string.IsNullOrEmpty(txtJobID.Text))
            {
                usersDataObject.JobID = Convert.ToInt32(txtJobID.Text);
            }
            usersDataObject.JobText = txtJobText.Text;
            usersDataObject.Url     = txtUrl.Text;
            //------------------------------------------------------------
            usersDataObject.Company = txtCompany.Text;
            if (trActivitiesID.Visible)
            {
                usersDataObject.ActivitiesID = Convert.ToInt32(ddlActivitiesID.SelectedValue);
            }
            //------------------------------------------------------------
            //*--------------------------------------------------------
            //ExtraData
            usersDataObject.ExtraData = txtDetails.Text;
            //*--------------------------------------------------------
            //Photo
            if (fuPhoto.HasFile)
            {
                usersDataObject.PhotoExtension = uploadedPhotoExtension;
            }
            else
            {
                usersDataObject.PhotoExtension = oldPhotoExtension;
            }
            //----------------------------------------------------------------------
            usersDataObject.KeyWordsAr         = txtMetaKeyWordsAr.Text;
            usersDataObject.ShortDescriptionAr = txtShortDescriptionAr.Text;
            //----------------------------------------------------------------------
            bool status = UsersDataFactory.Update(usersDataObject);
            if (status)
            {
                //---------------------------------------------------------------
                //IsConsultant
                //-------------------------
                bool isConsultant = Roles.IsUserInRole(usersDataObject.UserName, DCRoles.ConsultantsRoles);
                if (isConsultant && !cbIsConsultant.Checked)
                {
                    Roles.RemoveUserFromRole(usersDataObject.UserName, DCRoles.ConsultantsRoles);
                }
                else if (!isConsultant && cbIsConsultant.Checked)
                {
                    Roles.AddUserToRole(usersDataObject.UserName, DCRoles.ConsultantsRoles);
                }
                //---------------------------------------------------------------
                SaveFiles(usersDataObject);
                //RegisterInMailList--------------------------------------------------------------//
                if (currentModule.MailListAutomaticRegistration || usersDataObject.HasEmailService)
                {
                    UsersDataFactory.UpdateMailListEmail(oldEmail, usersDataObject);
                }
                //--------------------------------------------------------------------------------//
                //RegisterInSms--------------------------------------------------------------//
                if (currentModule.SmsAutomaticRegistration || usersDataObject.HasSmsService)
                {
                    UsersDataFactory.UpdateSmsMobileNo(oldMobile, usersDataObject);
                }
                //--------------------------------------------------------------------------------//
                Response.Redirect("../" + currentModule.Identifire + "/default.aspx");
            }
            else
            {
                lblResult.CssClass = "operation_error";
                lblResult.Text     = Resources.AdminText.UpdatingOperationFaild;
            }
        }
    }