示例#1
0
        //them
        protected void submit_create_Click(object sender, EventArgs e)
        {
            //kiem tra trong
            if (txtTenNoiNgoaiThat.Text == "" || txtMoTaNgan.Text == "" || txtChiTiet.Text == "")
            {
                //ClientScript.RegisterStartupScript(this.GetType(), "vanh", "blank()", true);
                Response.Write("<script>Tất cả các trường các trường cần điền đầy đủ!</script>");
                return;
            }
            //them
            DTO.NoiNgoaiThat nnt = new DTO.NoiNgoaiThat();
            nnt.TenNoiNgoaiThat        = txtTenNoiNgoaiThat.Text;
            nnt.MoTa                   = txtMoTaNgan.Text;
            nnt.ChiTiet                = txtChiTiet.Text;
            nnt.status                 = checkStatus_create.Checked;
            nnt.created_at             = DateTime.Now;
            nnt.DanhMucNoiNgoaiThat_Id = Int32.Parse(ddrDanhMuc.SelectedValue);

            string path = Server.MapPath("../assets/images/NoiNgoaiThat/");

            FileUploadImage.SaveAs(path + FileUploadImage.FileName);
            nnt.Anh         = FileUploadImage.FileName;
            Image2.ImageUrl = path;


            obj.create(nnt);
            //load list
            Response.Redirect(Request.Url.ToString());
        }
示例#2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUploadImage.HasFile)
        {
            try
            {
                string filename = Path.GetFileName(FileUploadImage.FileName);
                FileUploadImage.SaveAs(Server.MapPath("~/MovieImages/") + filename); // מעלה
                string ImagePath = "~/MovieImages/" + filename;                      // מכניס לdb

                /*
                 * string path = Path.GetFileName(FileUploadVideo.FileName);
                 * path = path.Replace(" ", "");
                 * FileUploadVideo.SaveAs(Server.MapPath("~/Videos/") + path);
                 * String link = "MovieVideo/" + path;
                 * string strVideo = "<Video width=400 Controls><Source src=" + link + " type=video/mp4></video>";
                 *
                 *
                 *
                 * string filenamevideo = Path.GetFileName(FileUploadVideo.FileName);
                 * FileUploadVideo.SaveAs(Server.MapPath("~/MovieVideo/") + filenamevideo); // מעלה
                 *
                 * string VideoPath = "~/MovieVideo/" + filenamevideo; // מכניס לdb
                 */
                Movie movie = new Movie(txtNameMovie.Text, int.Parse(DropDownListCategory.SelectedValue), int.Parse(txtLengthMovie.Text), txtActors.Text, ImagePath, TextBoxVideo.Text);
                DAL.InseartMovie(movie);
                lblMessage.Text = "הסרט הועלה בהצלחה";
            }
            catch (Exception ex)
            {
                lblMessage.Text = "לא ניתן להעלות את הקובץ " + ex.Message;
            }
        }
    }
        protected void buttonAddProduct_Click(object sender, EventArgs e)
        {
            using (SqlConnection conn = new SqlConnection(connString))
            {
                string fileName = Path.Combine(Server.MapPath("~/Images"), FileUploadImage.FileName);

                FileUploadImage.SaveAs(fileName);

                SqlCommand cmd = new SqlCommand("INSERT INTO [dbo].[PRODUCT] ([product_name] ,[product_price] ,[product_quantity] ,[product_description] ,[product_category] ,[cost_price_per_unit] ,[product_markup_percentage] ,[reorder_threshold] ,[product_image_path]) VALUES (@productName ,@productPrice,@productQuantity,@productDesc,@productCategory ,@costPricePerUnit,@markUpPercentage,@reorderThreshold,@imagePath)", conn);
                cmd.Parameters.AddWithValue("@productName", textboxProductName.Text);
                cmd.Parameters.AddWithValue("@productPrice", textboxProductPrice.Text);
                cmd.Parameters.AddWithValue("@productQuantity", textboxProductQuantity.Text);
                cmd.Parameters.AddWithValue("@productDesc", textboxProductDescription.Text);
                if (DropDownListCategory.SelectedItem.Text == "New Category")
                {
                    cmd.Parameters.AddWithValue("@productCategory", textboxProductCategory.Text);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@productCategory", DropDownListCategory.SelectedItem.Text);
                }
                cmd.Parameters.AddWithValue("@costPricePerUnit", textboxCostPricePerUnit.Text);
                cmd.Parameters.AddWithValue("@productMarkupPercentage", textboxMarkupPercentage.Text);
                cmd.Parameters.AddWithValue("@reorderThreshold", textboxReorderThreshold.Text);
                cmd.Parameters.AddWithValue("@imagePath", fileName);
                conn.Open();
                cmd.ExecuteNonQuery();
                productAddedStatus.Text = "Product Added Successfully!";
            }
        }
示例#4
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            // Only proceed to save in database if book cover image is valid
            if (IsValidFile())
            {
                b            = new Book();
                b.Title      = txtBookTitle.Text;
                b.CategoryID = Convert.ToInt32(ddCategory.SelectedValue);
                b.ISBN       = txtISBN.Text;
                b.Author     = txtAuthor.Text;
                b.Stock      = Convert.ToInt32(txtStock.Text);
                b.Price      = Convert.ToInt32(txtPrice.Text);
                FileUploadImage.SaveAs(Server.MapPath("~/images/" + b.ISBN + System.IO.Path.GetExtension(FileUploadImage.FileName).ToLower()));

                try
                {
                    context.Books.Add(b);
                    context.SaveChanges();
                    Response.Write("<script>confirm('Success!'); window.location = 'OwnerAddBook.aspx';</script>");
                }
                catch (Exception a)
                {
                    Response.Write("<script> if(confirm('Book add was unsuccessful...Would you like to add new book?'))" +
                                   "{window.location = 'OwnerAddBook.aspx';} else {window.location = 'BookSearch.aspx';} </script>");
                }
            }
        }
    protected void ButtonAdd_Click(object sender, EventArgs e)
    {
        string  Error    = "";
        DBHotel hotelObj = new DBHotel();
        string  path     = Server.MapPath("~/HotelImage/");
        string  fileName = FileUploadImage.FileName;
        string  DBPath   = "";

        if (fileName.Trim().Equals(""))
        {
            DBPath = ImageHotel.ImageUrl;
        }
        else
        {
            string FullPath = path + fileName;

            FileUploadImage.SaveAs(FullPath);
            DBPath = "~/HotelImage/" + fileName;
        }
        int CityID  = Convert.ToInt32(DropDownListCity.SelectedValue);
        int HotelID = Convert.ToInt32(Session["HotelID"].ToString());

        hotelObj.updateHotel(HotelID, CityID, TextBoxName.Text, TextBoxAdd.Text, TextBoxState.Text, TextBoxPhone.Text, TextBoxDesc.Text, TextBoxEmail.Text, DBPath, ref Error);

        if (Error != "")
        {
            Response.Write(Error);
        }
        else
        {
            fillHotel();
        }
    }
示例#6
0
        //them
        protected void submit_create_Click(object sender, EventArgs e)
        {
            //kiem tra trong
            if (txtTenTinTuc.Text == "" || txtMoTaNgan.Text == "" || txtChiTiet.Text == "")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "vanh", "blank()", true);
                return;
            }
            //them
            DTO.TinTuc tint = new DTO.TinTuc();
            tint.TenTinTuc  = txtTenTinTuc.Text;
            tint.MoTa       = txtMoTaNgan.Text;
            tint.ChiTiet    = txtChiTiet.Text;
            tint.NguoiDang  = txtNguoiDang.Text;
            tint.LuotXem    = Int32.Parse(txtLuotXem.Text);
            tint.Status     = checkStatus_create.Checked;
            tint.Created_at = Convert.ToString(DateTime.Now);
            string path = Server.MapPath("../assets/images/TinTucs/");

            FileUploadImage.SaveAs(path + FileUploadImage.FileName);
            tint.Anh = FileUploadImage.FileName;
            tint.DanhMucTinTuc_Id = Int32.Parse(ddrDanhMuc.SelectedValue);
            obj.create(tint);
            //load list
            Response.Redirect(Request.Url.ToString());
        }
示例#7
0
    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
        String        con        = "Server=.;Database=OnlineNoteBook; Integrated Security=true";
        SqlConnection connection = new SqlConnection(con);

        if (FileUploadImage.HasFile)
        {
            FileUploadImage.SaveAs(Server.MapPath("~/RegImage/") + Path.GetFileName(FileUploadImage.FileName));
            string link = "~/RegImage/" + Path.GetFileName(FileUploadImage.FileName);

            connection.Open();
            string _queryString;
            _queryString = "Insert into Registration(Name, Email,Phone,Address,Image,Password,RegistrationDate) values('" + TextBoxName.Text + "','" + TextBoxEmail.Text + "', '" + TextBoxPhone.Text + "', '" + TextBoxAddress.Text + "', '" + link + "', '" + TextBoxCPassword.Text + "','" + DateTime.UtcNow.Date.ToString("yyyy-M-d") + "');";
            SqlCommand cmd = new SqlCommand(_queryString, connection);
            cmd.ExecuteNonQuery();
            Response.Write("Registation Successful");
            string email = TextBoxEmail.Text.ToString();
            Response.Redirect("Home.aspx");
        }
        else
        {
            Label1.Text      = "Image is required";
            Label1.ForeColor = System.Drawing.Color.Red;
        }
    }
示例#8
0
        protected void btnImageInsert_OnClick(object sender, EventArgs e)
        {
            if (txtImage.Text == string.Empty || FileUploadImage.FileName == string.Empty)
            {
                Label.Text    = "Lütfen Tüm Alanları Doldurunuz.";
                Label.Visible = true;
            }
            else
            {
                //FileUploadThumbnail.SaveAs(MapPath("~/images/thumbnail/")+FileUploadThumbnail.FileName);

                FileUploadImage.SaveAs(MapPath("~/images/image/") + FileUploadImage.FileName);
                System.Drawing.Image img       = System.Drawing.Image.FromFile(MapPath("~/images/image/") + FileUploadImage.FileName);
                System.Drawing.Image thumbnail = img.GetThumbnailImage(364, 273, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
                thumbnail.Save(MapPath("~/images/thumbnail/") + FileUploadImage.FileName);

                var db    = new EmerseDbEntities();
                var image = new Data.Image();
                image.name         = txtImage.Text;
                image.category     = Convert.ToInt32(dropDownList.SelectedValue);
                image.thumbnailUrl = "~/images/thumbnail/" + FileUploadImage.FileName;
                image.url          = "~/images/image/" + FileUploadImage.FileName;
                image.createDate   = DateTime.Now;

                db.Image.Add(image);
                db.SaveChanges();
                Response.Redirect("~/Admin/GalleryContent.aspx");
            }
        }
示例#9
0
        private string StartUploadImage()
        {
            if (string.IsNullOrEmpty(FileUploadImage.FileName))
            {
                return(string.Empty);
            }

            string tag = _tag + "[StartUploadImage]";

            try
            {
                string folder = DateTime.Now.ToString("MMddyyyy");
                string result = string.Format("{0}/{1}", folder, FileUploadImage.FileName);

                string dir = Path.Combine(Utilities.GetDirectory("ImagesDir"), folder);
                dir = Server.MapPath("~/" + dir);

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                FileUploadImage.SaveAs(Path.Combine(dir, FileUploadImage.FileName));

                return(result);
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
                return(string.Empty);
            }
        }
示例#10
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string ProductId    = Request.QueryString["Id"];
            string filename     = ProductId + ".jpg";
            string savelocation = Server.MapPath("~/ProductImages/" + filename);

            FileUploadImage.SaveAs(savelocation);
        }
示例#11
0
 protected void ButtonImage_Click(object sender, EventArgs e)
 {
     if (FileUploadImage.HasFile)
     {
         FileUploadImage.SaveAs(Server.MapPath("/Pictures/" + FileUploadImage.FileName));
         LabelMessages.Text = FileUploadImage.FileName + " has been uploaded.";
     }
     else
     {
         LabelMessages.Text = "Wrong file name!";
     }
 }
示例#12
0
        protected void BtnAddProduct_Click(object sender, EventArgs e)
        {
            string productSize = "";

            for (int i = 0; i < CheckBoxListProductSize.Items.Count; i++)
            {
                if (CheckBoxListProductSize.Items[i].Selected == true)
                {
                    productSize += CheckBoxListProductSize.Items[i].Text + ", ";
                }
            }
            if (productSize != string.Empty)
            {
                productSize = productSize.Substring(0, productSize.Length - 2);
            }

            HttpPostedFile postedFile    = FileUploadImage.PostedFile;
            string         fileName      = Path.GetFileName(postedFile.FileName);
            string         fileExtention = Path.GetExtension(fileName);
            int            fileSize      = postedFile.ContentLength;

            if (fileExtention == ".jpg" || fileExtention == ".png" || fileExtention == ".gif" || fileExtention == ".bmp" || fileExtention == ".JPG" || fileExtention == ".PNG" || fileExtention == ".GIF" || fileExtention == ".BMP")
            {
                string filepath = Server.MapPath("~/uploads");
                if (FileUploadImage.HasFile)
                {
                    FileUploadImage.SaveAs(filepath + "\\" + FileUploadImage.FileName);
                }

                string        conStr = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
                SqlConnection conn   = new SqlConnection(conStr);
                string        query  = "INSERT INTO ProductDetails VALUES (" + TextBoxProductId.Text + ",'" + TextBoxProductName.Text + "','" + TextBoxProductCode.Text + "'," + DropDownListProductCategory.SelectedValue + ",'" + productSize + "','" + TextBoxProductColor.Text + "','" + TextBoxProductPrice.Text + "','" + "uploads/" + fileName + "','" + DateTime.Now + "')";
                SqlCommand    cmd    = new SqlCommand(query, conn);
                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('New Product Added')", true);
                }
                catch (Exception exc)
                {
                    Response.Write(exc.ToString());
                }
                finally
                {
                    conn.Close();
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Select an Image File')", true);
            }
        }
示例#13
0
        //protected void BtnSubmit_Click(object sender, EventArgs e)
        //{
        //    if(inputTitle.Text == null){
        //        labelVerification.Text = "Please enter a topic!";
        //        labelVerification.ForeColor = Color.Red;
        //    }
        //}

        private String UploadImage()
        {
            string imgName = FileUploadImage.FileName;
            string imgPath = "images/" + imgName;
            int    imgSize = FileUploadImage.PostedFile.ContentLength;

            if (FileUploadImage.PostedFile != null && FileUploadImage.PostedFile.FileName != "")
            {
                FileUploadImage.SaveAs(Server.MapPath(imgPath));
                imgPicture.ImageUrl = "~/" + imgPath;
                return(imgPath);
            }
            return(String.Empty);
        }
        //uploading image
        private Boolean UploadImage()
        {
            Boolean imageSaved = false;

            if (FileUploadImage.HasFile == true)
            {
                HttpPostedFile postedFile = FileUploadImage.PostedFile;
                ImageName      = Path.GetFileName(postedFile.FileName);
                ImageExtension = Path.GetExtension(ImageName);
                ImageSize      = postedFile.ContentLength;
                ImagePath      = "~/Uploaded/" + ImageName;

                if (ImageExtension.ToLower() == ".jpg" || ImageExtension.ToLower() == ".bmp" ||
                    ImageExtension.ToLower() == ".png" || ImageExtension.ToLower() == ".jpeg")
                {
                    if (ImageSize < 102400)
                    {
                        System.Drawing.Image image = System.Drawing.Image.FromStream(postedFile.InputStream);
                        int height = image.Height;
                        int width  = image.Width;

                        if (height <= 600 && width <= 600)
                        {
                            FileUploadImage.SaveAs(Server.MapPath("~/Uploaded/") + ImageName + ".jpg");
                            ImageRegistration.ImageUrl = "~/Uploaded/" + ImageName + ".jpg";
                            //string ImageData = "Uploaded/" + ImageName + ".jpg";
                            imageSaved = true;
                        }
                        else
                        {
                            ImageMsgID.Text = "Kindly Upload Image in Proper Dimensions 200 x 200";
                        }
                    }
                    else
                    {
                        ImageMsgID.Text = "File Size exceeds 100 KB - Please Upload File Size Maximum 100 KB";
                    }
                }
                else
                {
                    ImageMsgID.Text = "Only JPEG/JPG/PNG/BMP Image File Acceptable - Please Upload Image File Again";
                }
            }
            else
            {
                ImageMsgID.Text = "You have not selected any file - Browse and Select File First";
            }

            return(imageSaved);
        }
示例#15
0
    protected void ButtonSave_Click(object sender, EventArgs e)
    {
        String        con        = "Server=.;Database=OnlineNoteBook; Integrated Security=true";
        SqlConnection connection = new SqlConnection(con);

        FileUploadImage.SaveAs(Server.MapPath("~/Image/") + Path.GetFileName(FileUploadImage.FileName));
        string link = "~/Image/" + Path.GetFileName(FileUploadImage.FileName);

        connection.Open();
        string _queryString;

        _queryString = "Insert into Contact(Name,PhoneNo,Email,Image,UserEmail) values('" + TextBoxName.Text + "','" + TextBoxPhone.Text + "','" + TextBoxEmail.Text + "', '" + link + "','" + Session["email"].ToString() + "');";
        SqlCommand cmd = new SqlCommand(_queryString, connection);

        cmd.ExecuteNonQuery();
        Response.Redirect("Contact.aspx");
        Label4.Text = "Save successfully";
    }
示例#16
0
        protected void btnImageEdit_OnClick(object sender, EventArgs e)
        {
            var db            = new EmerseDbEntities();
            int id            = int.Parse(Request.QueryString["ID"]);
            var currentRecord = db.Image.Find(id);

            FileUploadImage.SaveAs(MapPath("~/images/image/") + FileUploadImage.FileName);
            System.Drawing.Image img       = System.Drawing.Image.FromFile(MapPath("~/images/image/") + FileUploadImage.FileName);
            System.Drawing.Image thumbnail = img.GetThumbnailImage(364, 273, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
            thumbnail.Save(MapPath("~/images/thumbnail/") + FileUploadImage.FileName);

            currentRecord.name         = txtImage.Text;
            currentRecord.category     = Convert.ToInt32(dropDownList.SelectedValue);
            currentRecord.thumbnailUrl = "~/images/thumbnail/" + FileUploadImage.FileName;
            currentRecord.url          = "~/images/image/" + FileUploadImage.FileName;
            currentRecord.updateDate   = DateTime.Now;
            db.SaveChanges();
            Response.Redirect("GalleryContent.aspx");
        }
示例#17
0
    protected void ButtonGem_Click(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
        SqlCommand    cmd  = new SqlCommand();

        cmd.Connection = conn;

        cmd.CommandText = @"UPDATE pages SET page_text = @text, page_headings = @heading, opening_hours = @opening_hours, page_images = @p_image, opening_changes = @opening_changes, contact_info = @contact_info WHERE page_id = @page_id";
        cmd.Parameters.AddWithValue("@page_id", ViewState["page_id"]);
        cmd.Parameters.AddWithValue("@heading", TextBoxTitle.Text);
        cmd.Parameters.AddWithValue("@text", TextBoxDescription.Text.Replace(Environment.NewLine, "<br>"));
        cmd.Parameters.AddWithValue("@opening_changes", TextBoxOpeningChanges.Text.Replace(Environment.NewLine, "<br>"));
        cmd.Parameters.AddWithValue("@opening_hours", TextBoxOpeningHours.Text.Replace(Environment.NewLine, "<br>"));
        cmd.Parameters.AddWithValue("@contact_info", TextBoxContactInfo.Text.Replace(Environment.NewLine, "<br>"));


        #region Image 1
        string product_image1 = HiddenFieldGem.Value;
        if (FileUploadImage.HasFile)
        {
            //NewGuid danner uniq navn for billeder
            product_image1 = Guid.NewGuid() + Path.GetExtension(FileUploadImage.FileName);
            // Opret
            String UploadeMappe = Server.MapPath("~/images/frontpage/");
            String Filnavn      = DateTime.Now.ToFileTime() + FileUploadImage.FileName;
            product_image1 = Filnavn;

            FileUploadImage.SaveAs(UploadeMappe + Filnavn);

            string old_img = HiddenFieldGem.Value;
            if (File.Exists(Server.MapPath("~/images/frontpage/") + old_img))
            {
                File.Delete(Server.MapPath("~/images/frontpage/") + old_img);
            }
        }
        cmd.Parameters.AddWithValue("@p_image", product_image1);
        #endregion
        conn.Open();
        cmd.ExecuteNonQuery();
        conn.Close();
        Response.Redirect("FrontpageEditing.aspx");
    }
示例#18
0
 protected void ButtonAddPost_Click(object sender, EventArgs e)
 {
     database.StartConnection();
     if (FileUploadImage.HasFile)
     {
         FileUploadImage.SaveAs("C:/Users/Alex/source/repos/BlogWork/BlogWork/Resources/" + FileUploadImage.FileName);
         database.AddPost(TextBoxTheme.Text, TextBoxDescription.Text, PostBody.InnerText,
                          "~/Resources/" + FileUploadImage.FileName, FormsAuthentication.Decrypt(Request.Cookies["AuthCookie"].Value).Name);
         database.LoadPosts();
         Response.Redirect("~/WebForms/Default.aspx?CurrentPost=" + database.LastPostIndex());
         database.CloseConnection();
     }
     else
     {
         database.AddPost(TextBoxTheme.Text, TextBoxDescription.Text, PostBody.InnerText,
                          null, FormsAuthentication.Decrypt(Request.Cookies["AuthCookie"].Value).Name);
         database.LoadPosts();
         Response.Redirect("~/WebForms/Default.aspx?CurrentPost=" + database.LastPostIndex());
         database.CloseConnection();
     }
 }
 protected void btnUpload_Click(object sender, EventArgs e)
 {
     if (FileUploadImage.HasFile)
     {
         if (FileUploadImage.HasFile)
         {
             try
             {
                 string filename = Path.GetFileName(FileUploadImage.FileName);
                 Session["imgName"] = filename;
                 FileUploadImage.SaveAs(Server.MapPath("~/") + filename);
                 ImageUpload.ImageUrl = "~/images/" + filename;
                 LabelPath.Text       = "Upload status: File uploaded!";
             }
             catch (Exception ex)
             {
                 LabelPath.Text = "Upload status: The file could not be uploaded. The following error occured: ";
             }
         }
     }
 }
 private string GravarUploadDisco()
 {
     if (FileUploadImage.HasFile)
     {
         try
         {
             var caminho  = $"{AppDomain.CurrentDomain.BaseDirectory}Content\\imagensJogo\\";
             var fileName = $"{DateTime.Now.ToString("yyyyMMddhhmmss")}_{FileUploadImage.FileName}";
             FileUploadImage.SaveAs($"{caminho}{fileName}");
             return(fileName);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
     else
     {
         return(null);
     }
 }
示例#21
0
    protected void ButtonAdd_Click(object sender, EventArgs e)
    {
        string  Error    = "";
        DBHotel hotelObj = new DBHotel();
        string  path     = Server.MapPath("~/HotelImage/");
        string  fileName = FileUploadImage.FileName;
        string  FullPath = path + fileName;

        FileUploadImage.SaveAs(FullPath);
        string DBPath = "~/HotelImage/" + fileName;
        int    CityID = Convert.ToInt32(DropDownListCity.SelectedValue);

        hotelObj.addHotel(TextBoxName.Text, TextBoxAdd.Text, TextBoxState.Text, TextBoxPhone.Text, TextBoxDesc.Text, TextBoxEmail.Text, DBPath, CityID, ref Error);
        if (Error != "")
        {
            Response.Write(Error);
        }
        else
        {
        }
    }
示例#22
0
    protected void ButtonUpload_Click(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection();

        conn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
        SqlCommand cmd = new SqlCommand();

        cmd.Connection = conn;

        cmd.CommandText = @"INSERT INTO pages (page_text, page_images, page_headings, opening_hours, opening_changes, contact_info) VALUES (@p_text, @p_image, @p_heading, @opening_hours, @opening_changes, @contact_info)";
        cmd.Parameters.AddWithValue("@p_heading", TextBoxTitle.Text);
        cmd.Parameters.AddWithValue("@p_text", TextBoxDescription.Text.Replace(Environment.NewLine, "<br>"));
        cmd.Parameters.AddWithValue("@opening_changes", TextBoxOpeningChanges.Text.Replace(Environment.NewLine, "<br>"));
        cmd.Parameters.AddWithValue("@opening_hours", TextBoxOpeningHours.Text.Replace(Environment.NewLine, "<br>"));
        cmd.Parameters.AddWithValue("@contact_info", TextBoxContactInfo.Text.Replace(Environment.NewLine, "<br>"));

        #region image1
        //database sti til billede
        string bill_sti = "intetbillede.jpg";
        if (FileUploadImage.HasFile)
        {
            //NewGuid danner uniq navn for billeder
            bill_sti = Guid.NewGuid() + Path.GetExtension(FileUploadImage.FileName);
            // Opret
            String UploadeMappe = Server.MapPath("~/images/frontpage/");
            String Filnavn      = DateTime.Now.ToFileTime() + FileUploadImage.FileName;
            bill_sti = Filnavn;
            //Gem det orginale Billede
            FileUploadImage.SaveAs(UploadeMappe + Filnavn);
        }
        // Tildel parameter-værdierne, fra input felterne.
        cmd.Parameters.AddWithValue("@p_image", bill_sti);
        #endregion

        conn.Open();
        cmd.ExecuteNonQuery();
        conn.Close();
        Response.Redirect("FrontpageEditing.aspx");
    }
示例#23
0
    protected string renameFilePath()
    {
        string str       = "";
        int    index     = Session["User_ID"].ToString().IndexOf("@");
        String imageName = Session["User_ID"].ToString().Substring(0, index);

        if (FileUploadImage.HasFile)
        {
            string relativePath = @"/propertyImages/" + imageName + Path.GetExtension(FileUploadImage.FileName);
            FileUploadImage.SaveAs(Server.MapPath(relativePath));

            //FileUploadImage.SaveAs("~/propertyImages/" + Session["User_ID"].ToString() + ".png");
            //str += "/propertyImages/" + Session["User_ID"].ToString() + ".jpg";
            return(relativePath);
        }
        else
        {
            str += "/propertyImages/error.png";
        }

        return(str);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        String        con        = "Server=.;Database=OnlineNoteBook; Integrated Security=true";
        SqlConnection connection = new SqlConnection(con);

        if (FileUploadImage.HasFile)
        {
            FileUploadImage.SaveAs(Server.MapPath("~/Gallery/") + Path.GetFileName(FileUploadImage.FileName));
            string link = "~/Gallery/" + Path.GetFileName(FileUploadImage.FileName);

            connection.Open();
            string _queryString;
            _queryString = "Insert into ImagGallery(Date,Location,ShortDerscription,Image,UserEmail) values('" + DateTime.UtcNow.Date.ToString("yyyy-M-d") + "','" + TextBoxLocation.Text + "','" + TextBoxShortDescription.Text + "', '" + link + "','" + Session["email"].ToString() + "');";
            SqlCommand cmd = new SqlCommand(_queryString, connection);
            cmd.ExecuteNonQuery();
            Response.Redirect("ImageGallery.aspx");
            Label5.Text = "Save successfully";
        }
        else
        {
            Label4.Text = "Image is required";
        }
    }
示例#25
0
        protected void BtAddDish_Click(object sender, EventArgs e)
        {
            bool state = true;

            if (TxtState.Text.ToLower().Trim() == "habilitado")
            {
                state = true;
            }
            else
            {
                state = false;
            }
            BLDish newDish = new BLDish(TxtName.Text.Trim(), TxtDescription.Text.Trim(), decimal.Parse(TxtPrice.Text.ToLower().Trim()), state, FileUploadImage.FileName);

            FileUploadImage.SaveAs(Server.MapPath("../DishesPicture/").ToString() + FileUploadImage.FileName);
            newDish.addDish(newDish);

            addDishForm.Visible = false;
            String css    = successRegistration.Attributes["class"];
            String newCss = css.Replace("hidden", "");

            successRegistration.Attributes.Add("class", newCss);
        }
示例#26
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        String        con        = "Server=.;Database=OnlineNoteBook; Integrated Security=true";
        SqlConnection connection = new SqlConnection(con);

        if (FileUploadImage.HasFile)
        {
            FileUploadImage.SaveAs(Server.MapPath("~/RegImage/") + Path.GetFileName(FileUploadImage.FileName));
            string link = "~/RegImage/" + Path.GetFileName(FileUploadImage.FileName);
            connection.Open();
            //updating the record
            SqlCommand cmd = new SqlCommand("Update Registration set Name='" + TextBoxName.Text + "', Phone='" + TextBoxPhone.Text + "',Address='" + TextBoxAddress.Text + "', Image='" + link + "' where Email='" + Session["email"].ToString() + "'", connection);
            cmd.ExecuteNonQuery();
            connection.Close();
        }
        else
        {
            connection.Open();
            //updating the record
            SqlCommand cmd = new SqlCommand("Update Registration set Name='" + TextBoxName.Text + "', Phone='" + TextBoxPhone.Text + "',Address='" + TextBoxAddress.Text + "' where Email='" + Session["email"].ToString() + "'", connection);
            cmd.ExecuteNonQuery();
            connection.Close();
        }
    }
示例#27
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtFoodname.Text != null && txtPrice.Text != null && ddlMenuCategory.SelectedIndex != -1 && txtDescription.Text != null)
         {
             string ext = System.IO.Path.GetExtension(this.FileUploadImage.PostedFile.FileName).ToLower();
             if (!(ext.Equals(".jpg") || ext.Equals(".png") || ext.Equals(".gif") || ext.Equals(".jpeg")))
             {
                 //if (ext != ".jpg" || ext != ".png" || ext != ".gif" || ext != ".jpeg")
                 Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Alert", "alert('Please choose only .jpg, .png and .gif image types!')", true);
             }
             else
             {
                 if (btnSubmit.Text != "Update")
                 {
                     DataTable dt = menu.CheckImageInDatabase(FileUploadImage.FileName);
                     if (dt.Rows.Count != 0)
                     {
                         ltlMsg.Text = "There is another image with same name ! ";
                     }
                     else
                     {
                         int i = menu.CreateMenu(txtFoodname.Text, Convert.ToInt32(ddlMenuCategory.SelectedItem.Value), Convert.ToDecimal(txtPrice.Text), FileUploadImage.FileName, txtDescription.Text);
                         if (i > 0)
                         {
                             FileUploadImage.SaveAs(Server.MapPath("~/MenuImages/" + FileUploadImage.FileName));
                             ltlMsg.Text = "Successfully added menu.";
                             ClearFields();
                         }
                         else
                         {
                             ltlMsg.Text = "Failed to add menu.";
                             ClearFields();
                         }
                     }
                 }
                 else
                 {
                     DataTable dt = menu.CheckImageInDatabase(FileUploadImage.FileName);
                     if (dt.Rows.Count != 0)
                     {
                         ltlMsg.Text = "There is another image with same name !";
                     }
                     else
                     {
                         string fileName;
                         string oldfileName = "";
                         if (FileUploadImage.HasFile)
                         {
                             DataTable dtImage = menu.GetFileName(Convert.ToInt32(HiddenField1.Value));
                             oldfileName = dtImage.Rows[0]["Image"].ToString();
                             fileName    = FileUploadImage.FileName;
                         }
                         else
                         {
                             fileName = lblImageName.Text;
                         }
                         int i = menu.UpdateMenu(txtFoodname.Text, Convert.ToInt32(ddlMenuCategory.SelectedItem.Value), Convert.ToDecimal(txtPrice.Text), fileName, txtDescription.Text, Convert.ToInt32(HiddenField1.Value));
                         if (i > 0)
                         {
                             if (oldfileName != null && oldfileName != fileName)
                             {
                                 if (File.Exists(Server.MapPath("~/Images/" + oldfileName)))
                                 {
                                     File.Delete(Server.MapPath("~/Images/" + oldfileName));
                                 }
                             }
                             ltlMsg.Text = "Successfully Updated.";
                             ClearFields();
                         }
                         else
                         {
                             ltlMsg.Text = "Failed to update.";
                             ClearFields();
                         }
                     }
                 }
             }
         }
         else
         {
             ltlMsg.Text = "All fields required.";
         }
     }
     catch (Exception ex)
     {
         throw (ex);
     }
 }
        private void Save(string strLink = "")
        {
            try
            {
                var Product = _ProductRepo.GetById(id);
                if (id > 0 && Product != null)
                {
                    Product.CODE       = txtCode.Text;
                    Product.SHAPE_CODE = ddlShape.SelectedValue;
                    if (FileUploadImage.Visible && FileUploadImage.HasFile)
                    {
                        string imgName     = Product.IMAGE;
                        string productPath = Server.MapPath(Cost.PRODUCTPATH) + imgName;
                        if (File.Exists(productPath))
                        {
                            File.Delete(productPath);
                        }

                        imgName     = Product.ID + Path.GetExtension(FileUploadImage.FileName);
                        productPath = Server.MapPath(Cost.PRODUCTPATH) + imgName;
                        FileUploadImage.SaveAs(productPath);

                        Product.IMAGE = imgName;
                    }
                    _ProductRepo.Update(Product);

                    strLink = string.IsNullOrEmpty(strLink) ? "chi-tiet-san-pham.aspx?id=" + id : strLink;
                }
                else
                {
                    Product            = new PRODUCT();
                    Product.CODE       = txtCode.Text;
                    Product.SHAPE_CODE = ddlShape.SelectedValue;
                    //Product.CREATOR_ID = Utils.CIntDef(Session["Userid"]);
                    //Product.CREATED_DATE = DateTime.Now;
                    _ProductRepo.Create(Product);

                    Product = _ProductRepo.GetById(Product.ID);
                    if (Product.ID > 0 && Product != null)
                    {
                        if (FileUploadImage.Visible && FileUploadImage.HasFile)
                        {
                            string imgName = Product.ID + Path.GetExtension(FileUploadImage.FileName);
                            FileUploadImage.SaveAs(Server.MapPath(Cost.PRODUCTPATH) + imgName);

                            Product.IMAGE = imgName;

                            _ProductRepo.Update(Product);
                        }
                    }
                    strLink = string.IsNullOrEmpty(strLink) ? "chi-tiet-san-pham.aspx?id=" + Product.ID : strLink;
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (!string.IsNullOrEmpty(strLink))
                {
                    Response.Redirect(strLink);
                }
            }
        }
示例#29
0
        protected void btn_Update_Click(object sender, EventArgs e)
        {
            lbl_intro.ForeColor = Color.Red;

            if (TextBoxTitle.Text.Length == 0 || TextBoxTitle.Text.Length > 50)
            {
                lbl_intro.Text = "Length of Title should be 1-50";
                return;
            }

            if (ddl_category.SelectedIndex == -1)
            {
                lbl_intro.Text = "Please Choose Category!";
                return;
            }

            if (TextBoxAuthor.Text.Length < 3)
            {
                lbl_intro.Text = "Author is too short!";
                return;
            }
            int year;
            if (!int.TryParse(TextBoxYear.Text, out year))
            {
                lbl_intro.Text = "Please enter year correctly!";
                return;
            }
            if (year > DateTime.Now.Year || year < 1600)
            {
                lbl_intro.Text = "Year should be 1600-" + DateTime.Now.Year.ToString();
                return;
            }

            if (TextBoxPublisher.Text.Length < 3)
            {
                lbl_intro.Text = "Publisher is too short!";
                return;
            }

            if (TextBoxDesc.Text.Length < 50)
            {
                lbl_intro.Text = "Desc is too short!";
                return;
            }

            if (!regexValidator.IsValid)
            {
                lbl_intro.Text = "Please Choose only .jpg .jpeg .png";
                return;
            }


            string id = Request.QueryString["bid"];
            var item = from u in db.tbl_Books
                       where u.BookId == int.Parse(id)
                       select u;
            foreach (var z in item)
            {
                z.Author = TextBoxAuthor.Text;
                z.BookDesc = TextBoxDesc.Text;
                z.BookTitle = TextBoxTitle.Text;
                z.CategoryID = int.Parse(ddl_category.SelectedValue.ToString());
                z.Publisher = TextBoxPublisher.Text;
                z.Year = year;
                if (FileUploadImage.HasFile)
                {
                    z.ImagePath = "~/images/" + FileUploadImage.FileName;
                    FileUploadImage.SaveAs(Server.MapPath("~/images/" + FileUploadImage.FileName));
                }
                db.SubmitChanges();

                lbl_intro.ForeColor = Color.Green;
                lbl_intro.Text = z.BookTitle + " Has Been Updated Successfully";
            }


            
            
        }
示例#30
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtFirstName.Text != null && txtFirstName.Text != null && txtDOB.Text != null && ddlGender.SelectedIndex != 0 && ddlClass.SelectedIndex != 0)
            {
                if (FileUploadImage.HasFile)
                {
                    string ext = System.IO.Path.GetExtension(this.FileUploadImage.PostedFile.FileName).ToLower();
                    if (!(ext.Equals(".jpg") || ext.Equals(".png") || ext.Equals(".gif") || ext.Equals(".jpeg")))
                    {
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Alert", "alert('Please choose only .jpg, .png and .gif image types!')", true);
                        return;
                    }
                }
                if (btnSubmit.Text != "Update")
                {
                    if (string.IsNullOrEmpty(this.FileUploadImage.PostedFile.FileName))
                    {
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Alert", "alert('Please upload image')", true);
                        return;
                    }
                    //DataTable dt = _bllMenu.CheckFoodNameInDatabase(txtFoodname.Text);
                    //if (dt.Rows.Count != 0)
                    //{
                    //    ltlMsg.ForeColor = Color.Red;
                    //    ltlMsg.Text = "The Food Name with same name already exists.";
                    //}
                    else
                    {
                        string imageExtension = System.IO.Path.GetExtension(FileUploadImage.FileName).ToLower();
                        cc.SaveChild(txtFirstName.Text, txtLastName.Text, txtDOB.Text, ddlGender.Text, ddlClass.Text, txtFirstName.Text.Replace("", "-") + imageExtension);
                        string s = Server.MapPath("~/ChildImages/");
                        FileUploadImage.SaveAs(Path.Combine(s, txtFirstName.Text.Replace(" ", "-") + imageExtension));
                        ltlMsg.ForeColor = Color.Green;
                        ltlMsg.Text      = "Child Successfully Added.";
                        ClearFields();
                    }
                }
            }
            else
            {
                string oldImageName = lblImageName.Text;
                string imageName    = lblImageName.Text;

                if (FileUploadImage.HasFile)
                {
                    var    name           = txtFirstName.Text.Replace(" ", "-");
                    string imageExtension = System.IO.Path.GetExtension(FileUploadImage.FileName).ToLower();
                    imageName = name + imageExtension;
                    int value = Convert.ToInt16(HiddenField1.Value);
                    cc.UpdateChild(value, txtFirstName.Text, txtLastName.Text, txtDOB.Text, ddlGender.Text, ddlClass.Text, txtFirstName.Text.Replace("", "-") + imageExtension);
                    string s = Server.MapPath("~/ChildImages/");
                    if (File.Exists(Path.Combine(s, oldImageName)))
                    {
                        File.Delete(Path.Combine(s, oldImageName));
                    }
                    FileUploadImage.SaveAs(Path.Combine(s, imageName));
                    ltlMsg.Text = "Child Successfully Updated.";
                    ClearFields();
                }
            }
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Alert", "alert(" + ex.Message + ");window.location.replace('Child.aspx');", true);
        }
    }