Exemple #1
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        String savePath = @"C:\inetpub\wwwroot\ASP_Project2\request_img\";

        if (ImageUpload.HasFile)
        {
            string fileName = ImageUpload.FileName;  // imgUp 에있는 파일평 따오기
            savePath = savePath + fileName;          // 지역변수 설정
            ImageUpload.SaveAs(savePath);            // 설정한 지역변수값 등록
        }
        //파일 업로드 구문 끝

        MySqlConnection connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["mariadb"].ConnectionString);

        connection.Open();
        string       InsertQuery = "Insert Into notice(name,title,contents,image,readcount,writedate) Values(@name,@title,@contents,@image,0,writedate)";
        MySqlCommand cmd         = new MySqlCommand(InsertQuery, connection);

        cmd.Parameters.AddWithValue("@name", nickname.Text);
        cmd.Parameters.AddWithValue("@title", title.Text);
        cmd.Parameters.AddWithValue("@contents", content.Text);
        cmd.Parameters.AddWithValue("@writedate", DateTime.Now.ToString());
        //cmd.Parameters.AddWithValue("@writedate", DateTime.Now.ToString("yy.MM.dd :: HH:mm:ss"));
        cmd.Parameters.AddWithValue("@image", ImageUpload.FileName);

        cmd.ExecuteNonQuery();
        connection.Close();

        Response.Redirect("~/ASP_Project2/notice_Board.aspx");
    }
Exemple #2
0
    protected void FileUploadedCompleted(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        try
        {
            Byte[] imgByte = null;
            if (ImageUpload.HasFile && ImageUpload.PostedFile != null)
            {
                HttpPostedFile File = ImageUpload.PostedFile;

                imgByte = new Byte[File.ContentLength];

                string uploadedFileName = Path.GetFileName(ImageUpload.FileName);
                ImageUpload.SaveAs(Server.MapPath("~/temp/") + uploadedFileName);
                if (Image1.ImageUrl == "")
                {
                    Image1.ImageUrl = "~/temp/" + uploadedFileName;
                }
                else if (Image2.ImageUrl == "")
                {
                    Image2.ImageUrl = "~/temp/" + uploadedFileName;
                }
                if (Image3.ImageUrl == "")
                {
                    Image3.ImageUrl = "~/temp/" + uploadedFileName;
                }
                else
                {
                    Image4.ImageUrl = "~/temp/" + uploadedFileName;
                }

                //Image1.ImageUrl = byteArrayToImage(imgByte);
            }
        }
        catch { }
    }
Exemple #3
0
    protected void btnWrite_Click(object sender, EventArgs e)
    {
        //파일 업로드 구문 시작
        String savePath = @"C:\inetpub\wwwroot\ASP_Project2\Images\";

        if (ImageUpload.HasFile)
        {
            string fileName = ImageUpload.FileName;  // imgUp 에있는 파일평 따오기
            savePath = savePath + fileName;          // 지역변수 설정
            ImageUpload.SaveAs(savePath);            // 설정한 지역변수값 등록
        }
        //파일 업로드 구문 끝
        MySqlConnection connection = new MySqlConnection("Server=ec2-13-125-252-165.ap-northeast-2.compute.amazonaws.com;Database=2020Project;Uid=root;Pwd=qwer1234;");

        connection.Open();
        string InsertQuery = "INSERT INTO sellpost (name,email,title,contents,writedate,readcount,image,price) values(@name,@email,@title,@contents,@writedate,0,@image,@price)";
        //string InsertQuery2 = "Insert Into reply (postnumber) Values (0)";

        MySqlCommand cmd = new MySqlCommand(InsertQuery, connection);

        //MySqlCommand cmd2 = new MySqlCommand(InsertQuery2, connection);
        cmd.Parameters.AddWithValue("@name", name.Text);
        cmd.Parameters.AddWithValue("@email", email.Text);
        cmd.Parameters.AddWithValue("@title", title.Text);
        cmd.Parameters.AddWithValue("@contents", contents.Text);
        cmd.Parameters.AddWithValue("@price", price.Text);
        cmd.Parameters.AddWithValue("@writedate", DateTime.Now.ToShortDateString());
        cmd.Parameters.AddWithValue("@image", ImageUpload.FileName);

        cmd.ExecuteNonQuery();
        //cmd2.ExecuteNonQuery();

        connection.Close();
        Response.Redirect("~/ASP_Project2/Main.aspx");
    }
        protected void UploadButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (ImageUpload.HasFile)
                {
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    SqlCommand cmd      = new SqlCommand("EXEC USP_FeedBack  @strCommand='ImageName'", conn);
                    string     filename = Convert.ToString(cmd.ExecuteScalar());
                    string     ext      = System.IO.Path.GetExtension(ImageUpload.PostedFile.FileName);
                    //  string filename = Path.GetFileName(ImageUpload.FileName);
                    ImageUpload.SaveAs(Server.MapPath("~/FeedBackImage/") + filename + ext);
                    lblImageName.Text = filename + ext;
                    lblfile.Text      = "Upload status: File uploaded";
                    lblfile.Visible   = true;
                }
                else
                {
                    lblfile.Visible = true;
                    lblfile.Text    = "Upload status: File not uploaded!";
                }
                // mpeFeedBack.Show();
            }
            catch (Exception ex)
            {
                lblfile.Visible = true;
                lblfile.Text    = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;

                // mpeFeedBack.Show();
            }
        }
        //Add a new product to the products xml
        protected void AddCake_Click(object sender, EventArgs e)
        {
            //Gets filename and path to save the image to
            var fileName = ImageUpload.FileName;
            var category = CategoryDropDown.SelectedItem.Value;

            if (fileName == "")
            {
                return;
            }

            var path = "~/Images/" + category + "/";

            var tmp = path + fileName;

            decimal tmpDecimal = Convert.ToDecimal(txtBoxCakePrice.Text);

            //if ((tmpDecimal % 1) == 0)
            //    txtBoxCakePrice.Text += ".00";

            productUtil.AddProduct(txtBoxCakeName.Text, Convert.ToDecimal(txtBoxCakePrice.Text), txtBoxCakeDescription.Text, tmp, category);

            ImageUpload.SaveAs(Server.MapPath(path) + fileName);

            txtBoxCakeName.Text        = "";
            txtBoxCakePrice.Text       = "";
            txtBoxCakeDescription.Text = "";

            Response.Redirect("Products.aspx");
        }
Exemple #6
0
    //INSERTS datafields into Database Table
    protected void SubButton_Click(object sender, EventArgs e)
    {
        Call_Database callDB = new Call_Database();

        if (ImageUpload.HasFile)
        {
            if (CheckFileType(ImageUpload.FileName))
            {
                string strPath = "../Images/dbImages/" + ImageUpload.FileName;

                ImageUpload.SaveAs(MapPath(strPath));
            }
        }
        if (NameBox.Text != "" && txtProfile.Text != "")
        {
            string Action = "DonorsINSERT";
            callDB.FormINSERT(Action, NameBox.Text, ImageUpload.FileName, txtProfile.Text, null, null, 0, 0, 0, 0);

            NameBox.Text    = String.Empty;
            txtProfile.Text = String.Empty;
            Call_Database update = new Call_Database();
            RepeaterNum.DataSource = update.dbDonors;
            RepeaterNum.DataBind();
        }
    }
 protected void UploadButton_Click(object sender, EventArgs e)
 {
     if (EmptyCheck())
     {
         string name  = ImageUpload.FileName;
         string ipath = Server.MapPath(@"~\Images\") + name;
         ImageUpload.SaveAs(ipath);
         var movie = new Movie()
         {
             MovieTypeId = Convert.ToInt32(MovieTypeList.SelectedValue),
             MovieName   = MovieNameBox.Text,
             Description = DescriptionBox.Text,
             Actor       = ActorBox.Text,
             Image       = @"~\Images\" + name,
             UploadDate  = DateTime.Now,
             IsAudit     = false
         };
         var movieService = new MovieService();
         var result       = movieService.AddMovie(movie);
         if (result == 1)
         {
             Response.Redirect("MovieMaintenance.aspx");
         }
         else
         {
             Response.Write("<script>alert('添加失败')</script>");
         }
     }
 }
        private string getPictureUrl()
        {
            string path = Server.MapPath("Images/");

            if (ImageUpload.HasFile)
            {
                string ext = Path.GetExtension(ImageUpload.FileName);

                if (ext.Equals(".jpg") || ext.Equals(".jpeg") || ext.Equals(".png"))
                {
                    ImageUpload.SaveAs(path + ImageUpload.FileName);
                    string img_name = "~/images/" + ImageUpload.FileName;

                    return(img_name);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Invalid format");
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("No file selected");
            }
            return(null);
        }
Exemple #9
0
    protected void Update_Btn(object sender, EventArgs e)
    {
        //파일 업로드 구문 시작
        String savePath = @"C:\inetpub\wwwroot\ASP_Project2\Images\";

        if (ImageUpload.HasFile)
        {
            string fileName = ImageUpload.FileName;  // imgUp 에있는 파일평 따오기
            savePath = savePath + fileName;          // 지역변수 설정
            ImageUpload.SaveAs(savePath);            // 설정한 지역변수값 등록
        }
        //파일 업로드 구문 끝
        MySqlConnection connection = new MySqlConnection("Server=ec2-13-125-252-165.ap-northeast-2.compute.amazonaws.com;Database=2020Project;Uid=root;Pwd=qwer1234;");

        connection.Open();
        string UpdateQuery = "Update sellpost set title = @title , contents = @contents , image = @image where num = " + Request["No"];

        MySqlCommand cmd = new MySqlCommand(UpdateQuery, connection);

        cmd.Parameters.AddWithValue("@title", title.Text);
        cmd.Parameters.AddWithValue("@contents", Contents.Text);
        cmd.Parameters.AddWithValue("@image", ImageUpload.FileName);

        cmd.ExecuteNonQuery();
        connection.Close();
        Response.Write("<script type='text/javascript'>window.history.go(-2);</script>");
    }
Exemple #10
0
    // 공지사항 게시글 수정
    protected void Update_Btn(object sender, EventArgs e)
    {
        //파일 업로드 구문 시작
        String savePath = @"C:\inetpub\wwwroot\ASP_Project2\Images\";

        if (ImageUpload.HasFile)
        {
            string fileName = ImageUpload.FileName;  // imgUp 에있는 파일평 따오기
            savePath = savePath + fileName;          // 지역변수 설정
            ImageUpload.SaveAs(savePath);            // 설정한 지역변수값 등록
        }
        //파일 업로드 구문 끝
        MySqlConnection connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["mariadb"].ConnectionString);

        connection.Open();
        string UpdateQuery = "Update notice set title = @title , contents = @contents , image = @image where num = " + Request["No"];

        MySqlCommand cmd = new MySqlCommand(UpdateQuery, connection);

        cmd.Parameters.AddWithValue("@title", title.Text);
        cmd.Parameters.AddWithValue("@contents", Contents.Text);
        cmd.Parameters.AddWithValue("@image", ImageUpload.FileName);

        cmd.ExecuteNonQuery();
        connection.Close();
        Response.Write("<script type='text/javascript'>window.history.go(-2);</script>");
    }
Exemple #11
0
    protected void ImageUploadButton_Click(object sender, EventArgs e)
    {
        ImageUpload.SaveAs(Server.MapPath("~/UploadImage/" + ImageUpload.FileName));

        UploadedImage.ImageUrl      = "/UploadImage/" + ImageUpload.FileName;
        UploadedImage.AlternateText = ImageUpload.FileName;
    }
    protected void SubButton_Click(object sender, EventArgs e)
    {
        if (ImageUpload.HasFile)
        {
            StatusLabel.Text = "Loading";
            if (CheckFileType(ImageUpload.FileName))
            {
                if (BackgroundSelect.Items.FindByValue("Home_Page").Selected == true)
                {
                    string strPath = "../Images/Background_Assets/" + "DefaultBackground.jpg";

                    ImageUpload.SaveAs(MapPath(strPath));
                }

                else if (BackgroundSelect.Items.FindByValue("Events_Page").Selected == true)
                {
                    string strPath = "../Images/Background_Assets/" + "EventsBackground.jpg";

                    ImageUpload.SaveAs(MapPath(strPath));
                }

                else if (BackgroundSelect.Items.FindByValue("Gallery_Page").Selected == true)
                {
                    string strPath = "../Images/Background_Assets/" + "GalleryBackground.jpg";

                    ImageUpload.SaveAs(MapPath(strPath));
                }

                else if (BackgroundSelect.Items.FindByValue("History_Page").Selected == true)
                {
                    string strPath = "../Images/Background_Assets/" + "HistoryBackground.jpg";

                    ImageUpload.SaveAs(MapPath(strPath));
                }

                else if (BackgroundSelect.Items.FindByValue("Leadership_Page").Selected == true)
                {
                    string strPath = "../Images/Background_Assets/" + "LeadershipBackground.jpg";

                    ImageUpload.SaveAs(MapPath(strPath));
                }

                else if (BackgroundSelect.Items.FindByValue("Recognition_Page").Selected == true)
                {
                    string strPath = "../Images/Background_Assets/" + "RecognitionBackground.jpg";

                    ImageUpload.SaveAs(MapPath(strPath));
                }

                else if (BackgroundSelect.Items.FindByValue("Testimonials_Page").Selected == true)
                {
                    string strPath = "../Images/Background_Assets/" + "TestimonialsBackground.jpg";

                    ImageUpload.SaveAs(MapPath(strPath));
                }
                StatusLabel.Text = "Uploaded";
            }
        }
    }
        public string CopyFile()
        {
            int    gnum = 0;
            string folderPath = Server.MapPath("~/Files/");
            string path, display = "";

            if (ImageUpload.PostedFile.FileName != "")
            {
                if (!Directory.Exists(folderPath))
                {
                    Directory.CreateDirectory(folderPath);
                }
                if (Session["ClickGroup"] != null)
                {
                    gnum = Convert.ToInt32(Session["ClickGroup"]);
                }
                switch (gnum)
                {
                case 1:
                    path    = folderPath + "Salad/" + Path.GetFileName(ImageUpload.PostedFile.FileName);
                    display = "./Files/Salad/" + Path.GetFileName(ImageUpload.PostedFile.FileName);
                    break;

                case 2:
                    path    = folderPath + "RiceRoll/" + Path.GetFileName(ImageUpload.PostedFile.FileName);
                    display = "./Files/RiceRoll/" + Path.GetFileName(ImageUpload.PostedFile.FileName);
                    break;

                case 3:
                    path    = folderPath + "KoreanFullPackage/" + Path.GetFileName(ImageUpload.PostedFile.FileName);
                    display = "./Files/KoreanFullPackage/" + Path.GetFileName(ImageUpload.PostedFile.FileName);
                    break;

                case 4:
                    path    = folderPath + "Korean-Rice/" + Path.GetFileName(ImageUpload.PostedFile.FileName);
                    display = "./Files/Korean-Rice/" + Path.GetFileName(ImageUpload.PostedFile.FileName);
                    break;

                case 5:
                    path    = folderPath + "Korean-SideDish/" + Path.GetFileName(ImageUpload.PostedFile.FileName);
                    display = "./Files/Korean-SideDish/" + Path.GetFileName(ImageUpload.PostedFile.FileName);
                    break;

                case 6:
                    path    = folderPath + "Sandwich/" + Path.GetFileName(ImageUpload.PostedFile.FileName);
                    display = "./Files/Sandwich/" + Path.GetFileName(ImageUpload.PostedFile.FileName);
                    break;

                default:
                    path    = folderPath + Path.GetFileName(ImageUpload.PostedFile.FileName);
                    display = "";
                    break;
                }
                ImageUpload.SaveAs(path);
            }
            return(display);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ConnectDatabase alayer = new ConnectDatabase();
            SqlDataReader   reader;
            int             num = 0;
            string          GroupNo, MenuName, ImagePath, MenuPrice, MenuDescription;

            if (Request.QueryString["Menu_Name"] != null)
            {
                MenuName = Request.QueryString["Menu_Name"];
            }
            if (Request.QueryString["Menu_Group"] != null)
            {
                GroupNo            = Request.QueryString["Menu_Group"];
                Label_Groupno.Text = GroupNo;
                num = Convert.ToInt32(GroupNo.ToString());
            }
            reader = alayer.GetAllMenuTableFromDB(num);
            if (reader != null)
            {
                while (reader.HasRows)
                {
                    MenuName  = reader.GetName(0);
                    MenuPrice = reader.GetName(1);

                    while (reader.Read())
                    {
                        MenuName        = reader.GetString(0);
                        MenuPrice       = reader.GetString(1);
                        ImagePath       = reader.GetString(2);
                        MenuDescription = reader.GetString(3);

                        ImagePath       = ImagePath.Trim();
                        MenuDescription = MenuDescription.Trim();

                        Label3.Text       = MenuName;
                        Image1.ImageUrl   = ImagePath;
                        txtMenuName.Text  = MenuName;
                        txtMenuPrice.Text = MenuPrice;
                        ImageUpload.SaveAs(ImagePath);
                        txtMenuDescription.Text = MenuDescription;
                    }
                    reader.NextResult();
                }
            }
            else
            {
                Response.Write("<script>alert('Can not get data from database');</script>");
            }
            reader.Close();
        }
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (ImageUpload.HasFile)
     {
         fileName         = ImageUpload.FileName;
         MyImage.ImageUrl = "~/images/" + fileName;
         ImageUpload.SaveAs(Server.MapPath("~/images/" + fileName));
         MakeOCRRequest(Server.MapPath("~/images/" + fileName));
     }
     else
     {
         ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('Image is required!')", true);
     }
 }
        private bool saveImages(string userId)
        {
            bool Bool;

            if (ImageUpload.HasFile)
            {
                ImageUpload.SaveAs(Server.MapPath("~/Photo/" + userId + ImageUpload.FileName));
                lblStatus.Text = "Photo Is Saved";
                Bool           = true;
            }
            else
            {
                Bool = false;
            }
            return(Bool);
        }
Exemple #17
0
        public string Upload()
        {
            if (ImageUpload.HasFile)
            {
                if (defaulFormats.Any(ImageUpload.PostedFile.ContentType.Contains))
                {
                    if (ImageUpload.PostedFile.ContentLength < this.MaxFileSize)
                    {
                        var guidName  = Guid.NewGuid();
                        var extension = Path.GetExtension(ImageUpload.FileName);

                        string fileName = string.Format("{0}.{1}", guidName, extension);

                        string path = Server.MapPath(this.PathValue);
                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }

                        ImageUpload.SaveAs(path + fileName);

                        return(this.PathValue + fileName);
                    }
                    else
                    {
                        var maxSizeInMB = (this.MaxFileSize / 1024) / 1024;
                        throw new InvalidOperationException(string.Format("Upload status: The file has to be less than {0} mb!", maxSizeInMB));
                    }
                }
                else
                {
                    StringBuilder allowedFormats = new StringBuilder();
                    foreach (var format in this.ImageFormats)
                    {
                        allowedFormats.AppendFormat("{0} ", format);
                    }

                    throw new InvalidOperationException(string.Format("Upload status: Only {0} files are accepted!", allowedFormats.ToString()));
                }
            }

            return(string.Empty);
        }
Exemple #18
0
        protected void btn_submit_Click(object sender, EventArgs e)
        {
            if (tb_title.Text != null && tb_description.Text != null && tb_location.Text != null)
            {
                string   title         = tb_title.Text;
                string   description   = tb_description.Text;
                string   type          = rb_type.SelectedValue;
                string   partner       = lb_pc.Text;
                string   partner_email = lb_pc_email.Text;
                string   location      = tb_location.Text;
                DateTime?date          = null;
                if (type == "Activity")
                {
                    date = Convert.ToDateTime(tb_date.Text);
                }
                Service1Client client = new DBServiceReference.Service1Client();
                if (tb_title.Text is null)
                {
                    lb_uploadstatus.Text      = "Gem title must be entered before banner upload can be attempted";
                    lb_uploadstatus.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    if (ImageUpload.HasFile)
                    {
                        var filename = tb_title.Text + System.IO.Path.GetExtension(Server.HtmlEncode(ImageUpload.FileName));
                        ImageUpload.SaveAs(Request.PhysicalApplicationPath + "/Images/Gem/" + filename);
                        lb_uploadstatus.Text      = "File Successfully Uploaded";
                        lb_uploadstatus.ForeColor = System.Drawing.Color.Green;
                        string image  = filename;
                        int    result = client.CreateGem(partner_email, title, description, type, location, date, "Pending", 0, partner, image);
                    }
                    else
                    {
                        lb_uploadstatus.Text      = "Please Select Your File";
                        lb_uploadstatus.ForeColor = System.Drawing.Color.Red;
                    }
                }
            }


            Response.Redirect("Partner_Gem_List.aspx");
        }
Exemple #19
0
 protected void imageUploadingBtn_Click(object sender, EventArgs e)
 {
     if (ImageUpload.HasFile)
     {
         string extension = System.IO.Path.GetExtension(ImageUpload.FileName);
         if (extension == ".jpg" || extension == ".PNG" || extension == ".png" || extension == ".JPG" || extension == ".jpeg" || extension == ".JPEG")
         {
             string filename = Path.GetFileName(ImageUpload.FileName);
             ImageUpload.SaveAs(Server.MapPath("~/temp.PNG"));
             HttpPostedFile z = ImageUpload.PostedFile;
             byte[]         x = ImageUpload.FileBytes;
             ViewState["ImageToSave"] = x;
             Random r = new Random();
             employeeImage.ImageUrl = "temp.PNG" + "?" + r.Next(1, 10000);
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowStatus", "javascript:alert('This is an incorrect file type.');", true);
         }
     }
 }
Exemple #20
0
    protected void UploadImage(object sender, EventArgs e)
    {
        try
        {
            Byte[] imgByte = null;
            if (ImageUpload.HasFile && ImageUpload.PostedFile != null)
            {
                HttpPostedFile File = ImageUpload.PostedFile;

                imgByte = new Byte[File.ContentLength];

                string uploadedFileName = Path.GetFileName(ImageUpload.FileName);
                ImageUpload.SaveAs(Server.MapPath("~/temp/") + uploadedFileName);
                if (Image1.ImageUrl == "")
                {
                    Image1.ImageUrl = "~/temp/" + uploadedFileName;
                }
                else if (Image2.ImageUrl == "")
                {
                    Image2.ImageUrl = "~/temp/" + uploadedFileName;
                }
                else if (Image3.ImageUrl == "")
                {
                    Image3.ImageUrl = "~/temp/" + uploadedFileName;
                }
                else
                {
                    Image4.ImageUrl = "~/temp/" + uploadedFileName;
                }

                //  ImageClass item = new ImageClass();
                // item.Name = uploadedFileName;


                //Image1.ImageUrl = byteArrayToImage(imgByte);
            }
        }
        catch (Exception ex) { }
    }
Exemple #21
0
    protected void SubButton_Click(object sender, EventArgs e)
    {
        Call_Database callDb = new Call_Database();

        if (ImageUpload.HasFile)
        {
            if (CheckFileType(ImageUpload.FileName))
            {
                string strPath = "~/Images/" + ImageUpload.FileName;

                ImageUpload.SaveAs(MapPath(strPath));
            }
        }
        if (NameBox.Text != "" && txtProfile.Text != "")
        {
            callDb.Add(NameBox.Text, ImageUpload.FileName, txtProfile.Text);

            NameBox.Text    = String.Empty;
            txtProfile.Text = String.Empty;
            Response.Redirect(Request.RawUrl);
        }
    }
Exemple #22
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        if (ImageUpload.HasFile)
        {
            // create the path to save file to
            //string fileName = Server.MapPath("Assets/Images/" + ImageUpload.FileName);

            string fileName = Server.MapPath("Assets/Images/" + "vplogo.png");

            if (File.Exists(fileName))
            {
                // Check file existance, if file exists delete file.
                FileInfo fi = new FileInfo(fileName);
                if (fi.Exists)
                {
                    fi.Delete();
                    //save newly uploaded file.
                    ImageUpload.SaveAs(fileName);
                }
            }
        }
    }
    protected void ButtonUpload_Click(object sender, EventArgs e)
    {
        if (ImageUpload.HasFile)
        {
            String fileName = NameUtils.get(ImageUpload.FileName);

            string savePath = Server.MapPath(Constants.IMAGE_UPLOAD_ROOT);

            if (!System.IO.Directory.Exists(savePath))
            {
                System.IO.Directory.CreateDirectory(savePath);
            }

            savePath = savePath + fileName;
            MyLog.v(savePath);
            ImageUpload.SaveAs(savePath);

            String url = Constants.IMAGE_UPLOAD_ROOT + fileName;
            Users.updateHead(getUser().id, url);
            getUser().head = url;
            ImageHead.DataBind();
        }
    }
Exemple #24
0
    protected void btnWrite_Click(object sender, EventArgs e)
    {
        //파일 업로드 구문 시작
        String savePath = @"C:\inetpub\wwwroot\ASP_Project2\Images\";

        if (ImageUpload.HasFile)
        {
            string fileName = ImageUpload.FileName;  // imgUp 에있는 파일평 따오기
            savePath = savePath + fileName;          // 지역변수 설정
            ImageUpload.SaveAs(savePath);            // 설정한 지역변수값 등록
        }
        //파일 업로드 구문 끝


        MySqlConnection connection = new MySqlConnection("Server=ec2-13-125-252-165.ap-northeast-2.compute.amazonaws.com;Database=2020Project;Uid=root;Pwd=qwer1234;");

        connection.Open();
        string InsertQuery = "INSERT INTO qna (nickname, writedate, qna_code, title, contents, image) values(@Nickname,@writedate,@qna_code,@title,@contents,@image)";


        MySqlCommand cmd = new MySqlCommand(InsertQuery, connection);

        cmd.Parameters.AddWithValue("@Nickname", Session["Nickname"].ToString());
        cmd.Parameters.AddWithValue("@title", title.Text);
        cmd.Parameters.AddWithValue("@contents", contents.Text);
        cmd.Parameters.AddWithValue("@writedate", DateTime.Now.ToString());
        cmd.Parameters.AddWithValue("@qna_code", "확인대기");
        cmd.Parameters.AddWithValue("@image", ImageUpload.FileName);



        cmd.ExecuteNonQuery();
        //cmd2.ExecuteNonQuery();

        connection.Close();
        Response.Redirect("~/ASP_Project2/QnA_Board.aspx");
    }
        protected void btn_submit_Click(object sender, EventArgs e)
        {
            string         name          = tb_name.Text;
            string         description   = tb_description.Text;
            string         type          = rb_type.SelectedValue.ToString();
            string         partner       = lb_pc.Text;
            string         partner_email = lb_pc_email.Text;
            int            value         = int.Parse(tb_price.Text);
            Service1Client client        = new DBServiceReference.Service1Client();

            if (tb_name.Text is null)
            {
                lb_uploadstatus.Text      = "Gem title must be entered before banner upload can be attempted";
                lb_uploadstatus.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (ImageUpload.HasFile)
                {
                    var filename = tb_name.Text + System.IO.Path.GetExtension(Server.HtmlEncode(ImageUpload.FileName));
                    ImageUpload.SaveAs(Request.PhysicalApplicationPath + "/Images/Point_Shop_Items/" + filename);
                    lb_uploadstatus.Text      = "File Successfully Uploaded";
                    lb_uploadstatus.ForeColor = System.Drawing.Color.Green;
                    string image  = filename;
                    int    result = client.CreatePointShopItem(name, partner, partner_email, description, value, image, type);
                }
                else
                {
                    lb_uploadstatus.Text      = "Please Select Your File";
                    lb_uploadstatus.ForeColor = System.Drawing.Color.Red;
                }
            }


            Response.Redirect("Partner_Point_Shop_Item_List.aspx");
        }
Exemple #26
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        cmd            = new SqlCommand();
        cmd.Connection = con;
        string path, Gender;

        if (Female.Checked)
        {
            Gender = "Female";
        }
        else
        {
            Gender = "Male";
        }
        if (ImageUpload.HasFile)
        {
            string ext = System.IO.Path.GetExtension(ImageUpload.FileName);
            if (ext.Equals(".jpg") || ext.Equals(".png"))
            {
                path = "~/Picture/" + ImageUpload.FileName;
                ImageUpload.SaveAs(MapPath(path));
                cmd.CommandText = "insert into Student_Info(Id,First_Name,Last_Name,Gender,Department,Hall,Blood_Group,Pass,Image) values ('" + ID.Text + "','" + F_Name.Text + "','" + L_Name.Text + "','" + Gender + "','" + Department.SelectedValue + "','" + Hall.SelectedValue + "','" + Blood_Group.SelectedValue + "','" + Password.Text + "','" + path + "')";
                cmd.ExecuteNonQuery();
                con.Close();
                Response.Redirect("LogIn.aspx");
            }
            else
            {
                Response.Write("<script>alert('Upload correct file')</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('Upload photo');</script>");
        }
    }
Exemple #27
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (Sel_location.SelectedIndex == 1)
        {
            location.Value = Sel_location.SelectedItem.Text;
            loc_code.Value = "1";
        }
        if (Sel_location.SelectedIndex == 2)
        {
            location.Value = Sel_location.SelectedItem.Text;
            loc_code.Value = "2";
        }
        if (Sel_location.SelectedIndex == 3)
        {
            location.Value = Sel_location.SelectedItem.Text;
            loc_code.Value = "3";
        }
        if (Sel_location.SelectedIndex == 4)
        {
            location.Value = Sel_location.SelectedItem.Text;
            loc_code.Value = "4";
        }
        if (Sel_location.SelectedIndex == 5)
        {
            location.Value = Sel_location.SelectedItem.Text;
            loc_code.Value = "5";
        }
        if (Sel_location.SelectedIndex == 6)
        {
            location.Value = Sel_location.SelectedItem.Text;
            loc_code.Value = "6";
        }
        if (Sel_location.SelectedIndex == 7)
        {
            location.Value = Sel_location.SelectedItem.Text;
            loc_code.Value = "7";
        }
        if (Sel_location.SelectedIndex == 8)
        {
            location.Value = Sel_location.SelectedItem.Text;
            loc_code.Value = "8";
        }
        if (Sel_location.SelectedIndex == 9)
        {
            location.Value = Sel_location.SelectedItem.Text;
            loc_code.Value = "9";
        }
        if (Sel_location.SelectedIndex == 10)
        {
            location.Value = Sel_location.SelectedItem.Text;
            loc_code.Value = "10";
        }
        if (Sel_location.SelectedIndex == 11)
        {
            location.Value = Sel_location.SelectedItem.Text;
            loc_code.Value = "11";
        }
        if (Sel_location.SelectedIndex == 12)
        {
            location.Value = Sel_location.SelectedItem.Text;
            loc_code.Value = "12";
        }
        if (Sel_location.SelectedIndex == 13)
        {
            location.Value = Sel_location.SelectedItem.Text;
            loc_code.Value = "13";
        }

        if (gopub_none.Checked)
        {
            gopub.Value = "비공개";
        }
        else if (gopub_all.Checked)
        {
            gopub.Value = "전체공개";
        }
        else if (gopub_mem.Checked)
        {
            gopub.Value = "회원공개";
        }

        String savePath = @"C:\inetpub\wwwroot\ASP_Project2\request_img\";

        if (ImageUpload.HasFile)
        {
            string fileName = ImageUpload.FileName;  // imgUp 에있는 파일평 따오기
            savePath = savePath + fileName;          // 지역변수 설정
            ImageUpload.SaveAs(savePath);            // 설정한 지역변수값 등록
        }
        //파일 업로드 구문 끝

        if (Sel_location.SelectedIndex == 0)
        {
            Response.Write("<script type='text/javascript'>alert('지역선택을 해주세요.'); </script>");
        }
        else
        {
            MySqlConnection connection = new MySqlConnection("Server=ec2-13-125-252-165.ap-northeast-2.compute.amazonaws.com;Database=2020Project;Uid=root;Pwd=qwer1234;");
            connection.Open();
            string       InsertQuery = "Insert Into requestpost (name,email,title,contents,writedate,readcount,image,gopublic,location,loccode,price) Values(@name,@email,@title,@contents,@writedate,0,@image,@gopublic,@location,@loccode,@price)";
            MySqlCommand cmd         = new MySqlCommand(InsertQuery, connection);

            cmd.Parameters.AddWithValue("@name", nickname.Text);
            cmd.Parameters.AddWithValue("@email", email.Text);
            cmd.Parameters.AddWithValue("@title", title.Text);
            cmd.Parameters.AddWithValue("@contents", content.Text);
            cmd.Parameters.AddWithValue("@writedate", DateTime.Now.ToShortDateString());
            cmd.Parameters.AddWithValue("@image", ImageUpload.FileName);
            cmd.Parameters.AddWithValue("@gopublic", gopub.Value);
            cmd.Parameters.AddWithValue("@location", location.Value);
            cmd.Parameters.AddWithValue("@loccode", loc_code.Value);
            cmd.Parameters.AddWithValue("@price", hopeprice.Text);

            cmd.ExecuteNonQuery();
            connection.Close();

            Response.Redirect("~/ASP_Project2/request_Board.aspx");
        }
    }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                string gender;
                if (radioFemale.Checked)
                {
                    gender = "Female";
                }
                else
                {
                    gender = "Male";
                }
                string strExtension = System.IO.Path.GetExtension(ImageUpload.FileName);
                if (strExtension == ".jpg" || strExtension == ".jepg" || strExtension == ".jpg" || strExtension == ".png" || strExtension == ".bmp")
                {
                    string strname  = ImageUpload.FileName.ToString();
                    string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
                    ImageUpload.SaveAs(Server.MapPath("~/Images/") + fileName + strname);
                    string filename      = System.IO.Path.GetFileName(ImageUpload.FileName);
                    UserBO updateProfile = new UserBO
                    {
                        UserId        = Session["UserId"].ToString(),
                        Image         = "~/Images/" + fileName + strname,
                        description   = txtSpecialization.Text,
                        FirstName     = txtBoxFirstName.Text,
                        LastName      = txtBoxLastName.Text,
                        Age           = int.Parse(txtBoxAge.Text),
                        ContactNumber = txtBoxContact.Text,
                        Email         = txtBoxEmailId.Text,
                        DOB           = DateTime.Parse(txtBoxDOB.Text),
                        UpdatedOn     = DateTime.Now,
                        Gender        = gender
                    };
                    UserBAL update = new UserBAL();
                    int     result = update.EditProfileUser(updateProfile);
                    if (result >= 1)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "Popup", "UpdateProfileAlert();", true);
                    }
                }
                else
                {
                    UserBO profile = new UserBO
                    {
                        UserId = Session["UserId"].ToString()
                    };
                    UserBAL profileBAL    = new UserBAL();
                    DataRow dr            = profileBAL.UserProfile(profile);
                    UserBO  updateProfile = new UserBO
                    {
                        UserId        = Session["UserId"].ToString(),
                        Image         = dr["details_image"].ToString(),
                        description   = txtSpecialization.Text,
                        FirstName     = txtBoxFirstName.Text,
                        LastName      = txtBoxLastName.Text,
                        Age           = int.Parse(txtBoxAge.Text),
                        ContactNumber = txtBoxContact.Text,
                        Email         = txtBoxEmailId.Text,
                        DOB           = DateTime.Parse(txtBoxDOB.Text),
                        UpdatedOn     = DateTime.Now,
                        Gender        = gender
                    };
                    UserBAL update = new UserBAL();
                    int     result = update.EditProfileUser(updateProfile);
                    if (result >= 1)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "Popup", "UpdateProfileAlert();", true);
                    }
                    else
                    {
                        lblStatus.Text = "Updated failed";
                    }
                }

                GetData();
            }
            catch (Exception ex)
            {
                lblStatus.Text = ex.Message;
            }
        }
        //method for inserting new asset
        protected void ConfirmInsert_Click(object sender, EventArgs e)
        {
            try
            {
                //if the field has file
                if (ImageUpload.HasFile)
                {
                    //check if the file is valid format
                    string Extension = System.IO.Path.GetExtension(ImageUpload.FileName);
                    if (Extension.ToLower() != ".gif" &&
                        Extension.ToLower() != ".png" &&
                        Extension.ToLower() != ".jpg" &&
                        Extension.ToLower() != ".jpeg")
                    {
                        //if not, tell the user
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Invalid image format');", true);
                    }
                    else
                    {
                        //otherwise, check if the file size exceed the allowed amount
                        int FileSize = ImageUpload.PostedFile.ContentLength;
                        if (FileSize > 1048576)
                        {
                            //if so, tell the user
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Maximum file size exceeded');", true);
                        }
                        else
                        {
                            //if the file is valid, get the value in all fields and store them in string var
                            string file = "Image/" + Path.GetFileName(ImageUpload.PostedFile.FileName);

                            string arNumber    = TextARNumber.Text;
                            string asset       = TextAsset.Text;
                            string campus      = CampusNew.Text;
                            string arrangement = MethodNew.Text;
                            string discription = TextDescriptions.Text;

                            //connect to the daabase
                            string co = System.Configuration.ConfigurationManager.ConnectionStrings["AssetBookingSystemConnectionString"].ConnectionString;
                            //and insert the value to its corresponding column
                            SqlConnection newAssetCon = new SqlConnection(co);
                            string        query       = "INSERT INTO tblAssets (ARNumber, Asset, Campus, ObtainMethod, Descriptions, Images)";
                            query += " VALUES (@arNumber, @asset, @campus, @arrangement, @discription, @file)";

                            SqlCommand insertAsset = new SqlCommand(query, newAssetCon);
                            insertAsset.Parameters.AddWithValue("@arNumber", arNumber);
                            insertAsset.Parameters.AddWithValue("@asset", asset);
                            insertAsset.Parameters.AddWithValue("@campus", campus);
                            insertAsset.Parameters.AddWithValue("@arrangement", arrangement);
                            insertAsset.Parameters.AddWithValue("@discription", discription);
                            insertAsset.Parameters.AddWithValue("@file", file);

                            newAssetCon.Open();
                            insertAsset.ExecuteNonQuery();
                            newAssetCon.Close();
                            //return to the asset page


                            ImageUpload.SaveAs(Server.MapPath("~/Image/" + ImageUpload.FileName));
                            Response.Redirect("AssetsManage.aspx");
                        }
                    }
                }
            }
            catch
            {
                //if unable to insert asset, return to asset page.
                Response.Redirect("AssetsManage.aspx");
            }
        }
        protected void AddConcert_Click(object sender, EventArgs e)
        {
            myDAL    objmyDAl     = new myDAL();
            String   concertVenue = venue.Text;
            String   cTime        = hours.Text + ':' + minutes.Text + ':' + seconds.Text;
            DateTime Date         = CDate.SelectedDate;

            String concertPerformer  = performer.Text;
            String concertOrganizers = organizers.Text;
            int    tickets           = int.Parse(ATickets.Text);
            int    cost      = int.Parse(CCost.Text);
            String imageLink = @"\images\" + ImageUpload.FileName;

            DateTime datetime;

            bool flag = true;

            if (string.IsNullOrWhiteSpace(concertVenue))
            {
                venue.CssClass   = venue.CssClass + " redBorder";
                Message.Text     = "Some Fields are empty!";
                Message.CssClass = "alert alert-danger";
                flag             = false;
            }
            if (string.IsNullOrWhiteSpace(cTime))
            {
                flag             = false;
                hours.CssClass   = hours.CssClass + " redBorder";
                minutes.CssClass = minutes.CssClass + " redBorder";
                seconds.CssClass = seconds.CssClass + " redBorder";
                Message.CssClass = "alert alert-danger";
                Message.Text     = "Some Fields are empty!";
            }
            if (CDate.SelectedDate.Date == DateTime.MinValue)
            {
                flag             = false;
                CDate.CssClass   = CDate.CssClass + " redBorder";
                Message.CssClass = "alert alert-danger";
                Message.Text     = "Release date is not selected";
            }
            if (string.IsNullOrWhiteSpace(concertPerformer))
            {
                performer.CssClass = performer.CssClass + " redBorder";
                Message.Text       = "Some Fields are empty!";
                Message.CssClass   = "alert alert-danger";
                flag = false;
            }
            if (string.IsNullOrWhiteSpace(concertOrganizers))
            {
                organizers.CssClass = organizers.CssClass + " redBorder";
                Message.Text        = "Some Fields are empty!";
                Message.CssClass    = "alert alert-danger";
                flag = false;
            }
            if (int.MinValue == tickets)
            {
                flag = false;
                ATickets.CssClass = ATickets.CssClass + " redBorder";
                Message.CssClass  = "alert alert-danger";
                Message.Text      = "Some Fields are empty!";
            }
            if (int.MinValue == cost)
            {
                flag             = false;
                CCost.CssClass   = CCost.CssClass + " redBorder";
                Message.CssClass = "alert alert-danger";
                Message.Text     = "Some Fields are empty!";
            }

            if (flag)
            {
                StringBuilder sb = new StringBuilder();

                if (ImageUpload.HasFile)
                {
                    try
                    {
                        sb.AppendFormat(" Uploading file: {0}", ImageUpload.FileName);
                        //Showing the file information
                        sb.AppendFormat("<br/> Save As: {0}", ImageUpload.PostedFile.FileName);
                        sb.AppendFormat("<br/> File type: {0}", ImageUpload.PostedFile.ContentType);
                        sb.AppendFormat("<br/> File length: {0}", ImageUpload.PostedFile.ContentLength);
                        sb.AppendFormat("<br/> File name: {0}", ImageUpload.PostedFile.FileName);
                    }
                    catch (Exception ex)
                    {
                        sb.Append("<br/> Error <br/>");
                        sb.AppendFormat("Unable to save file <br/> {0}", ex.Message);
                    }
                }

                datetime = Date.Add(TimeSpan.Parse(cTime));

                int result = 0;
                int found  = 1;
                found = objmyDAl.AddConcert_DAL(concertVenue, datetime, concertPerformer, concertOrganizers, tickets, cost, imageLink, ref result);
                if (found != 1)
                {
                    Message.Text = "Error connecting to server please try later";
                }
                else
                {
                    if (result == 0)
                    {
                        //saving the file
                        ImageUpload.SaveAs(Server.MapPath(@"~\images\" + ImageUpload.FileName));
                        Message.CssClass = "alert alert-success";
                        Message.Text     = "Concert has been added!";
                        Response.AddHeader("REFRESH", "1;URL=/adminHome.aspx");
                    }
                    else if (result == 1)
                    {
                        Message.CssClass = "alert alert-danger";
                        Message.Text     = "Concert already exists.";
                    }
                }
            }
        }