Ejemplo n.º 1
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            //try
            //{


            if (flUploadDetail.PostedFile != null)
            {
                string ImageName2 = System.IO.Path.GetFileName(flUploadDetail.PostedFile.FileName);
                if (ImageName2 != "")
                {
                    string ext = System.IO.Path.GetExtension(flUploadDetail.FileName);
                    //if (ImageName2 != "" && ext == ".gif" || ext == ".jpg" || ext == ".png" || ext == ".bmp")
                    {
                        System.Drawing.Image image12 = System.Drawing.Image.FromFile(flUploadDetail.PostedFile.FileName);
                        if ((image12.Width > 668) || (image12.Height > 256))
                        {
                            ErrMessage("File Size Not Supported");
                        }
                        else
                        {
                            if (ViewState["ImageName"] != null)
                            {
                                string LogicalPath  = Session["HomePath"] + "StoreData/Baner/" + ViewState["ImageName"].ToString();
                                string physicalPath = ContentManager.GetPhysicalPath(LogicalPath);
                                if (System.IO.File.Exists(physicalPath))
                                {
                                    System.IO.File.Delete(physicalPath);
                                }
                            }
                            string NewImageName = RandomStringsAndNumbers.Generate() + ext;
                            string virtualpath2 = Session["HomePath"] + "StoreData/Baner/" + NewImageName;
                            string fullpath2    = ContentManager.GetPhysicalPath(virtualpath2);
                            {
                                flUploadDetail.PostedFile.SaveAs(fullpath2);
                                ViewState["ImageName"] = NewImageName.ToString();
                                ImgService.Visible     = true;
                                ImgService.ImageUrl    = Session["HomePath"] + "StoreData/Baner/" + NewImageName;
                            }
                        }
                    }
                    //else
                    //{ ErrMessage("File Format Not Supported"); }
                }
                else
                {
                    ErrMessage("You Forgot To Select File Please Select File & Then Try.");
                }
            }
            // }
            //catch (FileNotFoundException e)
            //{
            //    Console.WriteLine(e.Message);

            //}
        }
Ejemplo n.º 2
0
    /* This event is use to Update information */
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            if (flUploadDetail.PostedFile != null)
            {
                string ImageName2 = System.IO.Path.GetFileName(flUploadDetail.PostedFile.FileName);
                if (ImageName2 != "")
                {
                    string ext = System.IO.Path.GetExtension(flUploadDetail.FileName);
                    if (ImageName2 != "" && ext == ".gif" || ext == ".jpg" || ext == ".png" || ext == ".GIF" || ext == ".jpeg" || ext == ".JPEG" || ext == ".PNG" || ext == ".JPG")
                    {
                        if (ViewState["LogoImage"] != null)
                        {
                            string LogicalPath  = Session["HomePath"] + "StoreData/FriendLogo/" + ViewState["LogoImage"].ToString();
                            string physicalPath = ContentManager.GetPhysicalPath(LogicalPath);
                            if (System.IO.File.Exists(physicalPath))
                            {
                                System.IO.File.Delete(physicalPath);
                            }
                        }
                        string NewImageName = RandomStringsAndNumbers.Generate() + ext;
                        string virtualpath2 = Session["HomePath"] + "StoreData/FriendLogo/" + NewImageName;
                        string fullpath2    = ContentManager.GetPhysicalPath(virtualpath2);


                        System.Drawing.Image image = System.Drawing.Image.FromStream(flUploadDetail.PostedFile.InputStream);
                        Bitmap myBitmap            = ResizeImage(flUploadDetail.PostedFile.InputStream, 75, 50);
                        myBitmap.Save(fullpath2, System.Drawing.Imaging.ImageFormat.Jpeg);
                        myBitmap.Dispose();



                        ViewState["LogoImage"] = NewImageName.ToString();
                        Global ObjFriend = new Global();
                        ObjFriend.UpdateFriends(FriendID, txtTitle.Text.Trim(), txtDescription.Text.Trim(), ViewState["LogoImage"].ToString(), txtReferallink.Text.Trim());
                        SuccessMessage("Updated successfully");
                        BindData();
                    }
                    else
                    {
                        ErrorMessage("Sorry, File Format Not Supported.");
                    }
                }
                else
                {
                    Global ObjFriend = new Global();
                    ObjFriend.UpdateFriends(FriendID, txtTitle.Text.Trim(), txtDescription.Text.Trim(), ViewState["LogoImage"].ToString(), txtReferallink.Text.Trim());
                    SuccessMessage("Fritzy's Friend Updated successfully.");
                    BindData();
                }
            }
        }
        catch  { }
    }
Ejemplo n.º 3
0
    /* This event is use to Upload image after verification */
    protected void btnUpload_Click1(object sender, EventArgs e)
    {
        try
        {
            if (flUploadDetail.PostedFile != null)
            {
                string ImageName2 = System.IO.Path.GetFileName(flUploadDetail.PostedFile.FileName);
                if (ImageName2 != "")
                {
                    string ext = System.IO.Path.GetExtension(flUploadDetail.FileName);
                    if (ImageName2 != "" && ext == ".gif" || ext == ".jpg" || ext == ".png" || ext == ".GIF" || ext == ".jpeg" || ext == ".JPEG" || ext == ".PNG" || ext == ".JPG")
                    {
                        string NewImageName = RandomStringsAndNumbers.Generate() + ext;
                        string virtualpath2 = Session["HomePath"] + "StoreData/Images/" + NewImageName;
                        string fullpath2    = ContentManager.GetPhysicalPath(virtualpath2);


                        System.Drawing.Image image = System.Drawing.Image.FromStream(flUploadDetail.PostedFile.InputStream);
                        Bitmap myBitmap            = ResizeImage(flUploadDetail.PostedFile.InputStream, 88, 144);
                        myBitmap.Save(fullpath2, System.Drawing.Imaging.ImageFormat.Jpeg);
                        myBitmap.Dispose();

                        ViewState["ImageName"] = NewImageName.ToString();
                        ImgService.Visible     = true;
                        ImgService.ImageUrl    = Session["HomePath"] + "StoreData/Images/" + NewImageName;
                        divError.Visible       = false;
                    }
                    else
                    {
                        ErrorMessage("File Format Not Supported.");
                    }
                }
                else
                {
                    ErrorMessage("Please upload Image.");
                }
            }
            else
            {
                ErrorMessage("Please upload Image.");
            }
        }
        catch { }
    }
    /* This event is use to add an friend detail to database with image also keep image ratio*/
    protected void AddUser_Click(object sender, EventArgs e)
    {
        if (flUploadDetail.PostedFile != null)
        {
            string ImageName2 = System.IO.Path.GetFileName(flUploadDetail.PostedFile.FileName);
            if (ImageName2 != "")
            {
                string ext = System.IO.Path.GetExtension(flUploadDetail.FileName).ToLower();
                if (ImageName2 != "" && ext == ".gif" || ext == ".jpg" || ext == ".png" || ext == ".GIF" || ext == ".jpeg" || ext == ".JPEG" || ext == ".PNG" || ext == ".JPG")
                {
                    string NewImageName = RandomStringsAndNumbers.Generate() + ext;
                    string virtualpath2 = Session["HomePath"] + "StoreData/FriendLogo/" + NewImageName;
                    string fullpath2    = ContentManager.GetPhysicalPath(virtualpath2);


                    System.Drawing.Image image = System.Drawing.Image.FromStream(flUploadDetail.PostedFile.InputStream);
                    Bitmap myBitmap            = ResizeImage(flUploadDetail.PostedFile.InputStream, 75, 50);
                    myBitmap.Save(fullpath2, System.Drawing.Imaging.ImageFormat.Jpeg);
                    myBitmap.Dispose();



                    Global ObjFriend = new Global();
                    ObjFriend.AddFriend(txtTitle.Text.Trim(), txtDescription.Text.Trim(), NewImageName, txtReferallink.Text.Trim());
                    txtTitle.Text       = "";
                    txtReferallink.Text = "";
                    txtDescription.Text = "";
                    SuccessMessage("Friend  added successfully");
                }
                else
                {
                    ErrorMessage("File Format Not Supported");
                }
            }
            else
            {
                ErrorMessage("You Forgot To Select File Please Select File & Then Try.");
            }
        }
        else
        {
            ErrorMessage("You Forgot To Select File Please Select File & Then Try.");
        }
    }