private void BindData()
        {
            int emailid = 0;
            Nop_EmailDirectory email = null;

            if (Request.QueryString["emailid"] != null && int.TryParse(Request.QueryString["emailid"], out emailid))
            {
                email = emailbiz.GetEmailByID(emailid);
            }
            if (email != null)
            {
                txtDescription.Content = email.Description;
                txtEmailAddress.Text   = email.EmailAddress;
                txtFirstName.Text      = email.FirstName;
                txtJobTitle.Text       = email.JobTitle;
                txtLastName.Text       = email.LastName;
                txtPhoneNumber.Text    = email.PhoneNumber;

                Picture Picture = PictureManager.GetPictureById(email.PictureID.Value);
                this.btnRemoveImage.Visible = Picture != null;
                string pictureUrl = PictureManager.GetPictureUrl(Picture, 100);
                this.iPicture.Visible  = true;
                this.iPicture.ImageUrl = pictureUrl;
            }
        }
示例#2
0
        private void BindData()
        {
            int emailid = 0;
            Nop_EmailDirectory email = null;

            if (Request.QueryString["emailid"] != null && int.TryParse(Request.QueryString["emailid"], out emailid))
            {
                email = emailbiz.GetEmailByID(emailid);
            }
            if (email != null)
            {
                lblDescrption.Text   = email.Description;
                lblEmailAddress.Text = email.EmailAddress;
                lblname1.Text        = email.FirstName;
                lblName.Text         = email.FirstName + " " + email.LastName;
                lblName2.Text        = email.FirstName + " " + email.LastName;
                //txtJobTitle.Text = email.JobTitle;
                //txtPhoneNumber.Text = email.PhoneNumber;
                this.lblJobTitle.Text = email.JobTitle;
                this.lblPhone.Text    = email.PhoneNumber;

                Picture Picture = PictureManager.GetPictureById(email.PictureID.Value);
                this.iEmail.Visible = Picture != null;
                string pictureUrl = PictureManager.GetPictureUrl(Picture, 100);
                this.iEmail.ImageUrl = pictureUrl;
            }
        }
 public bool SaveEmail(Nop_EmailDirectory email)
 {
     if (email.EmailID != 0)
     {
         Nop_EmailDirectory cur = dbContent.Nop_EmailDirectory.Where(t => t.EmailID == email.EmailID).First();
         if (cur != null)
         {
             cur.Description  = email.Description;
             cur.EmailAddress = email.EmailAddress;
             cur.FirstName    = email.FirstName;
             cur.LastName     = email.LastName;
             cur.PhoneNumber  = email.PhoneNumber;
             cur.PictureID    = email.PictureID;
         }
         else
         {
             return(false);
         }
     }
     else
     {
         if (email != null)
         {
             dbContent.Nop_EmailDirectory.Add(email);
         }
         else
         {
             return(false);
         }
     }
     dbContent.SaveChanges();
     return(true);
 }
        protected void btnRemoveImage_Click(object sender, EventArgs e)
        {
            Nop_EmailDirectory email = null;
            int emailid = 0;

            if (Request.QueryString["emailid"] != null && int.TryParse(Request.QueryString["emailid"], out emailid))
            {
                email = emailbiz.GetEmailByID(emailid);
            }
            if (email != null)
            {
                PictureManager.DeletePicture(email.PictureID.Value);
                email.PictureID = 0;
                emailbiz.SaveEmail(email);
                BindData();
            }
        }
        private bool save()
        {
            int emailid = 0;
            Nop_EmailDirectory email = null;

            if (Request.QueryString["emailid"] != null && int.TryParse(Request.QueryString["emailid"], out emailid))
            {
                email = emailbiz.GetEmailByID(emailid);
            }

            if (email != null)
            {
                Picture        pic         = PictureManager.GetPictureById(email.PictureID.Value);
                HttpPostedFile PictureFile = fuPicture.PostedFile;
                if ((PictureFile != null) && (!String.IsNullOrEmpty(PictureFile.FileName)))
                {
                    byte[] categoryPictureBinary = PictureManager.GetPictureBits(PictureFile.InputStream, PictureFile.ContentLength);
                    if (pic != null)
                    {
                        pic = PictureManager.UpdatePicture(pic.PictureId, categoryPictureBinary, PictureFile.ContentType, true);
                    }
                    else
                    {
                        pic = PictureManager.InsertPicture(categoryPictureBinary, PictureFile.ContentType, true);
                    }
                }
                int PictureId = 0;
                if (pic != null)
                {
                    PictureId = pic.PictureId;
                }

                email.Description  = this.txtDescription.Content;
                email.EmailAddress = txtEmailAddress.Text;
                email.FirstName    = txtFirstName.Text;
                email.LastName     = txtLastName.Text;
                email.PhoneNumber  = txtPhoneNumber.Text;
                email.PictureID    = PictureId;
                email.JobTitle     = txtJobTitle.Text;
                bool b = emailbiz.SaveEmail(email);
                BindData();
                return(b);
            }
            else
            {
                Picture        pic         = null;
                HttpPostedFile PictureFile = fuPicture.PostedFile;
                if ((PictureFile != null) && (!String.IsNullOrEmpty(PictureFile.FileName)))
                {
                    byte[] PictureBinary = PictureManager.GetPictureBits(PictureFile.InputStream, PictureFile.ContentLength);
                    pic = PictureManager.InsertPicture(PictureBinary, PictureFile.ContentType, true);
                }
                int PictureId = 0;
                if (pic != null)
                {
                    PictureId = pic.PictureId;
                }
                Nop_EmailDirectory newemail = new Nop_EmailDirectory();

                newemail.Description  = this.txtDescription.Content;
                newemail.EmailAddress = txtEmailAddress.Text;
                newemail.FirstName    = txtFirstName.Text;
                newemail.LastName     = txtLastName.Text;
                newemail.PhoneNumber  = txtPhoneNumber.Text;
                newemail.PictureID    = PictureId;
                newemail.JobTitle     = txtJobTitle.Text;
                bool b = emailbiz.SaveEmail(newemail);

                Response.Redirect("EmailDirectory.aspx");
                return(b);
            }
        }