コード例 #1
0
    //public static string SavePicture(FileUpload FU, string GemHer, int Str)
    public static string SavePicture(HttpPostedFile FU, string GemHer, int Str)
    {
        //hest_2013081212.jpg   //DateTime gør så man kan have flere af det samme billede, men giver den et unikt id, så de ikke overskriver hindanden
        string NytFilNavn = Path.GetFileNameWithoutExtension(FU.FileName) + DateTime.Now.ToString("_yyMMddHHmmssffff") + Path.GetExtension(FU.FileName);

        return(PictureSave.SavePicture(FU, GemHer, Str, NytFilNavn));
    }
コード例 #2
0
    protected void btnConfirm_Click(object sender, EventArgs e)
    {
        objThema._VikingID    = Convert.ToInt32(txtID.Text);
        objThema._Title       = txtTitle.Text;
        objThema._description = txtDesc.Text;


        objThema._img = "";

        if (Path.GetFileName(imgThema.ImageUrl).Length > 0 && !chkDelImg.Checked)
        {
            objThema._img = Path.GetFileName(imgThema.ImageUrl);
        }
        if (fuImg.HasFile)
        {
            objThema._img = PictureSave.SavePicture(fuImg.PostedFile, "img/");
        }

        int totalThemaEdited = objThema.EditThema();

        if (totalThemaEdited > 0)
        {
            litMessage.Text = "<h2>Thema er nu Rettet</h2>";
        }
        else
        {
            litMessage.Text = "<h2>Noget gik gladet!</h2>";
        }
    }
コード例 #3
0
ファイル: Edit.aspx.cs プロジェクト: KasperJuel/MR-Salg
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        if (fuImg.HasFile)
        {
            foreach (var file in fuImg.PostedFiles)
            {
                string imgName = PictureSave.SavePicture(file, "Images/Dele/", 80);
                PictureSave.SavePicture(file, "Images/Dele/", 400, imgName);

                // Dele Update
                objCar._editDelID      = Convert.ToInt32(Request.QueryString["edit"]);
                objCar._editDelNavn    = txtDelNavn.Text;
                objCar._editDelTekst   = txtDelTekst.Text.Replace(Environment.NewLine, "<br />");
                objCar._editDelBillede = imgName;
                objCar._editDelAntal   = Convert.ToInt32(txtDelAntal.Text);
                objCar._editDelPris    = Convert.ToInt32(txtDelPris.Text);

                objCar.Dele();
            }
            litResult.Text = "<b style='color: green'>Indholdet er rettet! (siden refresher om 3 sekunder)</b>";
            Response.AddHeader("REFRESH", "3;URL=" + Request.RawUrl);
        }
        else
        {
            litResult.Text = "<b style='color: red;'>OBS! Du skal uploade et billede!</b>";
        }
    }
コード例 #4
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            string imagename = "foto-paa-vej.jpg";

            if (fuImage.HasFile)
            {
                imagename = PictureSave.SavePicture(fuImage.PostedFile, "Img/News/", 580);
            }

            objNews._image    = imagename;
            objNews._title    = txtTitle.Text;
            objNews._preview  = txtPreview.Text;
            objNews._text     = txtText.Text;
            objNews._datetime = DateTime.Now;
            objNews._typeid   = Convert.ToInt32(ddlNewsType.SelectedValue);

            int addedsubject = objNews.CreateNews();

            if (addedsubject > 0)
            {
                txtTitle.Text   = "";
                txtPreview.Text = "";
                txtText.Text    = "";

                litResult.Text = "<h4>新闻已提交!";
            }
            else
            {
                litResult.Text = "<h4>Error!";
            }
        }
コード例 #5
0
ファイル: PictureSave.cs プロジェクト: rasmus-dybmose/RunIt
    //public static string SavePicture(FileUpload FU, string GemHer, int Str)
    public static string SavePicture(HttpPostedFile FU, string GemHer, int Str)
    {
        //hest_2013081212.jpg
        string NytFilNavn = Path.GetFileNameWithoutExtension(FU.FileName) + Path.GetExtension(FU.FileName);

        return(PictureSave.SavePicture(FU, GemHer, Str, NytFilNavn));
    }
コード例 #6
0
    protected void btnMake_Click(object sender, EventArgs e)
    {
        objThema._Title       = txtName.Text;
        objThema._description = txtDesc.Text;

        if (FuImg.HasFile)
        {
            objThema._img = PictureSave.SavePicture(FuImg.PostedFile, "Ímg/");
        }
        else
        {
            objThema._img = "";
        }
        int totalThema = objThema.CreateThema();

        if (totalThema > 0)
        {
            pnlCreate.Visible = false;
            litCreated.Text   = "Thema Oprette!";
            txtName.Text      = "";
            txtDesc.Text      = "";
        }
        else
        {
            litCreated.Text = "Something Went Wrong! Try Again";
        }
    }
コード例 #7
0
    protected void btnOpret_Click(object sender, EventArgs e)
    {
        string fotonavn = "foto-paa-vej.jpg";

        if (fu1.HasFile)
        {
            fotonavn = PictureSave.SavePicture(fu1.PostedFile, "img/Events/", 800);
        }
        string   dato = cal1.SelectedDate.ToString();
        DateTime DT   = Convert.ToDateTime(dato);

        sb.AppendFormat("{0}-{1}-{2} {3}", DT.Year, DT.Month, DT.Day, ddlTid.SelectedItem);

        objeve._title       = txtEvent.Text;
        objeve._beskrivelse = txtBeskrivelse.Text;
        objeve._region      = ddlRegion.SelectedIndex.ToString();
        objeve._distance    = float.Parse(txtDistance.Text);
        objeve._pris        = Convert.ToInt32(txtPris.Text);
        objeve._img         = fotonavn;
        objeve._pladser     = Convert.ToInt32(txtPladser.Text);
        objeve._dato        = sb.ToString();
        objeve._teaser      = txtTeaser.Text;
        sb.Clear();
        int eventoprettet = objeve.InsertEvent();

        if (eventoprettet > 0)
        {
            Response.Redirect("/OpretEvent");
        }
    }
コード例 #8
0
    protected void btnRedigerDelSubmit_Click(object sender, EventArgs e)
    {
        if (fuImg.HasFile)
        {
            foreach (var file in fuImg.PostedFiles)
            {
                string imgName = PictureSave.SavePicture(file, "Images/Dele/", 80);
                PictureSave.SavePicture(file, "Images/Dele/", 400, imgName);

                objcarfac.updateDele(txtDelNavn.Text,
                                     txtDelTekst.Text.Replace(Environment.NewLine, "<br />"),
                                     imgName,
                                     Convert.ToInt32(txtDelAntal.Text),
                                     Convert.ToInt32(txtDelPris.Text),
                                     Convert.ToInt32(ddlDel.SelectedValue));
            }

            litmsg.Text = "<b style='color: green'>Indholdet er rettet! (siden refresher om 3 sekunder)</b>";
            Response.AddHeader("REFRESH", "3;URL=" + Request.RawUrl + "");
        }
        else
        {
            litmsg.Text = "<b style='color: red;'>OBS! Du skal uploade et billede!</b>";
        }
    }
コード例 #9
0
    /// <summary>
    /// Gemmer et billede optimeret til web og i en ønsket/medsendt width (højden skaleres ift bredden). Tilføjer et timestamp eller guid til filnavn for at undgå dubletter/overskrivning
    /// </summary>
    /// <param name="FU">Fileuploader - postedfile</param>
    /// <param name="GemHer">Sti hvor image skal gemmes fx "img/"</param>
    /// <param name="Width">Ønsket bredde på image</param>
    /// <returns>Imagenavn - æøå erstattet med ae oe aa samt tilføjet et timestamp eller guid (for at undgå dubletter/overskrivning)</returns>
    public static string SavePicture(HttpPostedFile FU, string GemHer, int Width)
    {
        // Undgå images med samme navn - tilføj GUID
        //string NytFilNavn = Path.GetFileNameWithoutExtension(FU.FileName) + Guid.NewGuid().ToString() + Path.GetExtension(FU.FileName);

        // ELLER ... undgå images med samme navn - tilføj TIMESTAMP ... lav evt. om til ("_yyMMddHHmmssffff")
        string NytImageNavn = Path.GetFileNameWithoutExtension(FU.FileName) + DateTime.Now.ToString("_yyMMddHHmmss");

        return(PictureSave.SavePicture(FU, GemHer, Width, NytImageNavn));
    }
コード例 #10
0
    protected void ddl1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string fotonavn = "foto-paa-vej.jpg";

        if (fu1.HasFile)
        {
            fotonavn = PictureSave.SavePicture(fu1.PostedFile, "img/Sponsorer/", 800);
        }

        objspon.Update(Convert.ToInt32(Request.QueryString["id"]), txtSpn.Text, fotonavn, Convert.ToInt32(ddl1.SelectedIndex));

        Response.Redirect("/OpretSponsorer?id=" + Request.QueryString["id"]);
    }
コード例 #11
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            objNews._id = Convert.ToInt32(Request.QueryString["ret"]);
            dt          = objNews.GetNewsByfldID();

            string imagename;


            if ((chbImg.Checked || fuImage.HasFile) && !string.IsNullOrEmpty(dt.Rows[0]["fldImage"].ToString()))
            {
                IOFunctions.DeleteFile(Server.MapPath("../Img/News/") + dt.Rows[0]["fldImage"]);
                imagename = ""; // 图像名称在数据库中将默认删除
            }

            else
            {
                imagename = dt.Rows[0]["fldImage"].ToString();
            }

            if (fuImage.HasFile)
            {
                imagename = PictureSave.SavePicture(fuImage.PostedFile, "Img/News/", 580);
            }
            objNews._image   = imagename;
            objNews._title   = txtTitle.Text;
            objNews._text    = txtText.Text;
            objNews._preview = txtPreview.Text;
            objNews._typeid  = Convert.ToInt32(ddlNewsType.SelectedValue);

            int antalnewsopdateret = objNews.EditNews();

            if (antalnewsopdateret > 0)
            {
                litResult.Text = "<h4>这条新闻已经更新!</h4>";
            }
            else
            {
                litResult.Text = "<h4>更新错误!</h4>";
            }
        }