示例#1
0
 /// <summary>
 /// Add update user profile.
 /// </summary>
 /// <param name="objProfile">Object of UserProfileInfo class.</param>
 public static void AddUpdateProfile(UserProfileInfo objProfile)
 {
     try
     {
         UserProfileDataProvider.AddUpdateProfile(objProfile);
     }
     catch (Exception)
     {
         throw;
     }
 }
 public static void AddUpdateProfile(UserProfileInfo objProfile)
 {
     try
     {
         UserProfileDataProvider.AddUpdateProfile(objProfile);
     }
     catch (Exception)
     {
         
         throw;
     }
 }
        public static void AddUpdateProfile(UserProfileInfo objProfile)
        {
            try
            {
                string sp = "[dbo].[usp_AddUpdateUserProfile]";
                SQLHandler SQLH = new SQLHandler();
                List<KeyValuePair<string, object>> ParamCollInput = new List<KeyValuePair<string, object>>();


                ParamCollInput.Add(new KeyValuePair<string, object>("@image", objProfile.Image));
                ParamCollInput.Add(new KeyValuePair<string, object>("@UserName", objProfile.UserName));
                ParamCollInput.Add(new KeyValuePair<string, object>("@FirstName", objProfile.FirstName));
                ParamCollInput.Add(new KeyValuePair<string, object>("@LastName", objProfile.LastName));
                ParamCollInput.Add(new KeyValuePair<string, object>("@FullName", objProfile.FullName));
                ParamCollInput.Add(new KeyValuePair<string, object>("@BirthDate", objProfile.BirthDate));
                ParamCollInput.Add(new KeyValuePair<string, object>("@Gender", objProfile.Gender));

                ParamCollInput.Add(new KeyValuePair<string, object>("@Location", objProfile.Location));
                ParamCollInput.Add(new KeyValuePair<string, object>("@AboutYou", objProfile.AboutYou));
                ParamCollInput.Add(new KeyValuePair<string, object>("@Email", objProfile.Email));
                ParamCollInput.Add(new KeyValuePair<string, object>("@ResPhone", objProfile.ResPhone));
                ParamCollInput.Add(new KeyValuePair<string, object>("@Mobile", objProfile.MobilePhone));

                ParamCollInput.Add(new KeyValuePair<string, object>("@Others", objProfile.Others));
                ParamCollInput.Add(new KeyValuePair<string, object>("@AddedOn", objProfile.AddedOn));
                ParamCollInput.Add(new KeyValuePair<string, object>("@AddedBy", objProfile.AddedBy));
                ParamCollInput.Add(new KeyValuePair<string, object>("@UpdatedOn", objProfile.UpdatedOn));
                ParamCollInput.Add(new KeyValuePair<string, object>("@PortalID", objProfile.PortalID));
                ParamCollInput.Add(new KeyValuePair<string, object>("@UpdatedBy", objProfile.UpdatedBy));


                SQLH.ExecuteNonQuery(sp, ParamCollInput);

            }
            catch (Exception)
            {

                throw;
            }
        }
示例#4
0
        /// <summary>
        /// Connect to database and add update user profile.
        /// </summary>
        /// <param name="objProfile">Object of UserProfileInfo class.</param>
        public static void AddUpdateProfile(UserProfileInfo objProfile)
        {
            try
            {
                string     sp   = "[dbo].[usp_AddUpdateUserProfile]";
                SQLHandler SQLH = new SQLHandler();
                List <KeyValuePair <string, object> > ParamCollInput = new List <KeyValuePair <string, object> >();


                ParamCollInput.Add(new KeyValuePair <string, object>("@image", objProfile.Image));
                ParamCollInput.Add(new KeyValuePair <string, object>("@UserName", objProfile.UserName));
                ParamCollInput.Add(new KeyValuePair <string, object>("@FirstName", objProfile.FirstName));
                ParamCollInput.Add(new KeyValuePair <string, object>("@LastName", objProfile.LastName));
                ParamCollInput.Add(new KeyValuePair <string, object>("@FullName", objProfile.FullName));
                ParamCollInput.Add(new KeyValuePair <string, object>("@BirthDate", objProfile.BirthDate));
                ParamCollInput.Add(new KeyValuePair <string, object>("@Gender", objProfile.Gender));

                ParamCollInput.Add(new KeyValuePair <string, object>("@Location", objProfile.Location));
                ParamCollInput.Add(new KeyValuePair <string, object>("@AboutYou", objProfile.AboutYou));
                ParamCollInput.Add(new KeyValuePair <string, object>("@Email", objProfile.Email));
                ParamCollInput.Add(new KeyValuePair <string, object>("@ResPhone", objProfile.ResPhone));
                ParamCollInput.Add(new KeyValuePair <string, object>("@Mobile", objProfile.MobilePhone));

                ParamCollInput.Add(new KeyValuePair <string, object>("@Others", objProfile.Others));
                ParamCollInput.Add(new KeyValuePair <string, object>("@AddedOn", objProfile.AddedOn));
                ParamCollInput.Add(new KeyValuePair <string, object>("@AddedBy", objProfile.AddedBy));
                ParamCollInput.Add(new KeyValuePair <string, object>("@UpdatedOn", objProfile.UpdatedOn));
                ParamCollInput.Add(new KeyValuePair <string, object>("@PortalID", objProfile.PortalID));
                ParamCollInput.Add(new KeyValuePair <string, object>("@UpdatedBy", objProfile.UpdatedBy));


                SQLH.ExecuteNonQuery(sp, ParamCollInput);
            }
            catch (Exception)
            {
                throw;
            }
        }
        //protected void btnCancelProfile_Click(object sender, EventArgs e)
        //{
        //    tblEditProfile.Visible = false;
        //    LoadUserDetails();
        //    tblViewProfile.Visible = true;
        //    imgProfileEdit.Visible = false;
        //    imgProfileView.Visible = true;
        //    btnDeleteProfilePic.Visible = false;
        //}
        protected void btnDeleteProfilePic_Click(object sender, EventArgs e)
        {
            try
            {
                UserProfileInfo objinfo = new UserProfileInfo();
                objinfo = UserProfileController.GetProfile(hdnEditUsername.Value, GetPortalID);
                if (objinfo.Image != "")
                {
                    string imagePath = ResolveUrl(this.AppRelativeTemplateSourceDirectory) + "UserPic/" + objinfo.Image;
                    string path = Server.MapPath(imagePath);
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }
                }
                UserProfileController.DeleteProfilePic(hdnEditUsername.Value, GetPortalID);
                GetUserDetails();
                LoadUserDetails();
                Session[SessionKeys.UserImage] = null;

            }
            catch (Exception)
            {

                throw;
            }
        }
        public void LoadUserDetails()
        {
            try
            {
                UserProfileInfo objinfo = new UserProfileInfo();
                objinfo = UserProfileController.GetProfile(hdnEditUsername.Value, GetPortalID);
                if (objinfo != null)
                {
                    string[] Emails = objinfo.Email.Split(',');
                    if (objinfo.Image != "")
                    {
                        imgViewImage.ImageUrl = "~/Modules/Admin/UserManagement/UserPic/" + objinfo.Image;
                        imgViewImage.Visible = true;
                    }
                    else
                    {
                        imgViewImage.Visible = false;
                    }
                    lblViewUserName.Text = objinfo.UserName;
                    lblViewFirstName.Text = objinfo.FirstName;
                    lblViewLastName.Text = objinfo.LastName;
                    if (objinfo.FullName != "")
                    {
                        lblviewFullName.Text = objinfo.FullName;
                        trviewFullName.Visible = true;
                    }
                    else { trviewFullName.Visible = false; }
                    if (objinfo.Location != "")
                    {
                        lblViewLocation.Text = objinfo.Location;
                        trViewLocation.Visible = true;
                    }
                    else { trViewLocation.Visible = false; }
                    string AboutYou = objinfo.AboutYou.Replace("\r\n", "<br>");
                    if (AboutYou != "")
                    {
                        lblViewAboutYou.Text = AboutYou;
                        trViewAboutYou.Visible = true;
                    }
                    else { trViewAboutYou.Visible = false; }
                    if (Emails.Length != 0)
                    {
                        lblViewEmail1.Text = Emails[0];
                        lblViewEmail2.Text = Emails.Length == 3 ? Emails[1] : "";
                        lblViewEmail3.Text = Emails.Length == 3 ? Emails[2] : "";
                        trViewEmail.Visible = true;
                    }
                    else { trViewEmail.Visible = false; }
                    if (objinfo.ResPhone != "")
                    {
                        lblViewResPhone.Text = objinfo.ResPhone;
                        trViewResPhone.Visible = true;
                    }
                    else { trViewResPhone.Visible = false; }
                    if (objinfo.Mobile != "")
                    {
                        lblViewMobile.Text = objinfo.Mobile;
                        trViewMobile.Visible = true;
                    }
                    else { trViewMobile.Visible = false; }
                    if (objinfo.Others != "")
                    {
                        lblViewOthers.Text = objinfo.Others;
                        trViewOthers.Visible = true;
                    }
                    else { trViewOthers.Visible = false; }
                    if (objinfo.Gender != -1)
                    {
                        int gender = objinfo.Gender;
                        trviewGender.Visible = false;
                        if (gender == 0)
                        {
                            trviewGender.Visible = true;
                            lblviewGender.Text = "Male";
                        }
                        else if (gender == 1)
                        {
                            trviewGender.Visible = true;
                            lblviewGender.Text = "Female";
                        }
                    }
                    else
                    {
                        trviewGender.Visible = false;
                    }
                    if (objinfo.BirthDate.ToShortDateString() != falseDate && objinfo.BirthDate.ToShortDateString() != defaultDate)
                    {
                        trviewBirthDate.Visible = true;
                        lblviewBirthDate.Text = objinfo.BirthDate.ToShortDateString();
                    }
                    else
                    {
                        trviewBirthDate.Visible = false;
                    }
                }
            }

            catch (Exception)
            {

                throw;
            }
        }
        public void GetUserDetails()
        {
            try
            {
                UserProfileInfo objinfo = new UserProfileInfo();
                objinfo = UserProfileController.GetProfile(hdnEditUsername.Value, GetPortalID);
                if (objinfo != null)
                {
                    string[] Emails = objinfo.Email.Split(',');
                    if (objinfo.Image != "")
                    {
                        imgUser.ImageUrl = "~/Modules/Admin/UserManagement/UserPic/" + objinfo.Image;
                        imgUser.Visible = true;
                        btnDeleteProfilePic.Visible = true;
                        Session[SessionKeys.UserImage] = objinfo.Image;
                        imgProfileEdit.Visible = true;
                    }
                    else
                    {
                        imgUser.Visible = false;
                        btnDeleteProfilePic.Visible = false;
                        imgProfileEdit.Visible = false;
                    }
                    lblDisplayUserName.Text = objinfo.UserName;
                    txtFName.Text = objinfo.FirstName;
                    txtLName.Text = objinfo.LastName;
                    txtFullName.Text = objinfo.FullName;
                    txtLocation.Text = objinfo.Location;
                    txtAboutYou.Text = objinfo.AboutYou;
                    txtEmail1.Text = Emails[0];
                    txtBirthDate.Text = (objinfo.BirthDate.ToShortDateString() == falseDate || objinfo.BirthDate.ToShortDateString() == defaultDate) ? "" : objinfo.BirthDate.ToShortDateString();
                    rdbGender.SelectedIndex = objinfo.Gender;
                    if (Emails.Length == 2)
                    {
                        txtEmail2.Text = Emails[1];
                    }
                    if (Emails.Length == 3)
                    {
                        txtEmail2.Text = Emails[1];
                        txtEmail3.Text = Emails[2];
                    }
                    txtResPhone.Text = objinfo.ResPhone;
                    txtMobile.Text = objinfo.Mobile;
                    txtOthers.Text = objinfo.Others;
                }
            }

            catch (Exception)
            {

                throw;
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                UserProfileInfo objinfo = new UserProfileInfo();
                string filename = "";
                string thumbTarget = Server.MapPath("~/Modules/Admin/UserManagement/UserPic");
                if (!Directory.Exists(thumbTarget))
                {
                    Directory.CreateDirectory(thumbTarget);
                }
                System.Drawing.Image.GetThumbnailImageAbort thumbnailImageAbortDelegate = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
                if (fuImage.HasFile)
                {
                    double fs = fuImage.PostedFile.ContentLength / (1024 * 1024);
                    if (fs > 3)
                    {
                        ShowHideProfile();
                        ShowMessage("", GetSageMessage("UserManagement", "ImageTooLarge"), "", SageMessageType.Alert);
                        return;
                    }
                    else
                    {
                        filename = fuImage.PostedFile.FileName.Substring(fuImage.PostedFile.FileName.LastIndexOf("\\") + 1);
                        imgUser.ImageUrl = "~/Modules/Admin/UserManagement/UserPic/" + filename;
                        using (System.Drawing.Bitmap originalImage = new System.Drawing.Bitmap(fuImage.PostedFile.InputStream))
                        {
                            using (System.Drawing.Image thumbnail = originalImage.GetThumbnailImage(200, 150, thumbnailImageAbortDelegate, IntPtr.Zero))
                            {
                                thumbnail.Save(System.IO.Path.Combine(thumbTarget, fuImage.FileName));
                            }
                        }
                    }
                }
                if (filename == "")
                {
                    if (Session[SessionKeys.UserImage] != null)
                    {
                        filename = Session[SessionKeys.UserImage].ToString();
                    }
                    btnDeleteProfilePic.Visible = false;
                }
                else
                {
                    btnDeleteProfilePic.Visible = true;
                }
                objinfo.Image = filename;
                objinfo.UserName = hdnEditUsername.Value;
                objinfo.FirstName = txtFName.Text;
                objinfo.LastName = txtLName.Text;
                objinfo.FullName = txtFullName.Text;
                objinfo.Location = txtLocation.Text;
                objinfo.AboutYou = txtAboutYou.Text;
                objinfo.Email = txtEmail1.Text + (txtEmail2.Text != "" ? "," + txtEmail2.Text : "") + (txtEmail3.Text != "" ? ',' + txtEmail3.Text : "");
                objinfo.ResPhone = txtResPhone.Text;
                objinfo.MobilePhone = txtMobile.Text;
                objinfo.Others = txtOthers.Text;
                objinfo.AddedOn = DateTime.Now;
                objinfo.AddedBy = GetUsername;
                objinfo.UpdatedOn = DateTime.Now;
                objinfo.PortalID = GetPortalID;
                objinfo.UpdatedBy = GetUsername;
                objinfo.BirthDate = txtBirthDate.Text == string.Empty ? DateTime.Parse(falseDate) : DateTime.Parse(txtBirthDate.Text);
                objinfo.Gender = rdbGender.SelectedIndex;
                UserProfileController.AddUpdateProfile(objinfo);
                LoadUserDetails();
                GetSageUserInfo(hdnEditUsername.Value);
                tblEditProfile.Visible = false;
                //LoadUserDetails();
                tblViewProfile.Visible = true;
                imgProfileEdit.Visible = false;
                imgProfileView.Visible = true;
                btnDeleteProfilePic.Visible = false;
                //ShowHideProfile();
                //btnDeleteProfilePic.Visible = true;
                Session[SessionKeys.UserImage] = null;
                ShowMessage(SageMessageTitle.Information.ToString(), GetSageMessage("UserManagement", "UserProfileSavedSuccessfully"), "", SageMessageType.Success);
            }
            catch (Exception)
            {

                throw;
            }


        }