Ejemplo n.º 1
0
        public void InsertImage()
        {
            Images2 aImage = new Images2();

                aImage.ImageName = imageNameTextBox.Text;
                aImage.Description= descriptionTextBox.Text;

                if (imageFileUpload.HasFile)
                {
                    string extension = System.IO.Path.GetExtension(imageFileUpload.FileName);
                    if (extension.ToLower() != ".png" && extension.ToLower() != ".jpg" && extension.ToLower() != ".jpeg")
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "Popup", "alert('Invalid image formet');", true);
                    }
                    else
                    {
                        aImage.ImagePath= "ImageStore/" + Path.GetFileName(imageFileUpload.PostedFile.FileName);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Popup", "alert('Select Image file');", true);
                }
                String message = aImageManager.InsertImage(aImage);
                imageFileUpload.SaveAs(Server.MapPath("~/ImageStore/" + imageFileUpload.FileName));
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Popup", "alert('" + message + "');", true);
               // GetAllImage();
                imageNameTextBox.Text = String.Empty;
                descriptionTextBox.Text = String.Empty;
        }
Ejemplo n.º 2
0
        public string InsertImage(Images2 image)
        {
            int message = aImageGateway.InsertImage(image);

            if (message > 0)
            {
                return "Image saved Successfully.";

            }
            else
            {
                return "Opps !!!!! Error Image is not save";
            }
        }