Example #1
0
    protected void btnKayitOl_Click(object sender, EventArgs e)
    {
        char cinsiyet;

        if (radioErkek.Checked)
        {
            cinsiyet = 'E';
        }
        else
        {
            cinsiyet = 'K';
        }

        Database db = new Database();

        //Girilen kullanıcı bilgileri Kullanicilar tablosuna eklenir.
        string query = string.Format("INSERT INTO Kullanicilar(Isim, Soyisim, Cinsiyet, DogumTarihi, KullaniciAdi, Sifre, Mail) VALUES('{0}','{1}', '{2}', '{3}', '{4}', '{5}', '{6}')",
                                     txtAd.Text, txtSoyad.Text, cinsiyet, txtDogumTarihi.Text, txtKullaniciAdi.Text, txtParolaTekrar.Text, txtMail.Text);

        db.ExecuteNonQuery(query);

        //Kullanıcıların profil fotoğrafı proje klasöründe 'Kullaniciadi.png' formatında saklanır.
        string filename = txtKullaniciAdi.Text + ".png";

        FileUploadFoto.SaveAs(Server.MapPath("Resimler/Kullanicilar/" + filename));

        lblSonuc.Text = txtKullaniciAdi.Text + " sisteme hoşgeldiniz.";
    }
Example #2
0
    protected void ButtonUploadFoto_Click(object sender, EventArgs e)
    {
        string pathFotoFromConfig = Utility.SearchConfigValue("pathFotoNews");
        string fileName           = Server.HtmlEncode(FileUploadFoto.FileName);
        string filePath           = Server.MapPath(pathFotoFromConfig.Replace("/", "\\"));
        string extension          = System.IO.Path.GetExtension(fileName);

        //string filePath = Server.MapPath("~\\img\\FotoArticoli\\");
        // controlliamo se il controllo FileUploadFoto contiene un file da caricare
        if (FileUploadFoto.HasFile)
        {
            if ((extension.ToUpper() == ".JPG") || (extension.ToUpper() == ".PNG"))
            {
                int fileSize = FileUploadFoto.PostedFile.ContentLength;
                // consento l'upload di file con dimensione < di 1mb!
                if (fileSize < 1100000)
                {
                    // se si, aggiorniamo il path del file
                    filePath += FileUploadFoto.FileName;
                    // salviamo il file nel percorso calcolato
                    FileUploadFoto.SaveAs(filePath);
                    Session["UrlFotoHome"]   = pathFotoFromConfig.Remove(0, 2) + FileUploadFoto.FileName;
                    imgFotoArticolo.ImageUrl = pathFotoFromConfig + FileUploadFoto.FileName;
                    lnkCancFoto.Visible      = true;
                    imgFotoArticolo.Visible  = true;
                    FileUploadFoto.Visible   = false;
                    ButtonUploadFoto.Visible = false;
                    previewFoto.HRef         = "../img/foto/" + FileUploadFoto.FileName;
                }
                else
                {
                    LabelError.Text    = "Attenzione: La foto eccede le dimensioni massime consentite (1Mb).";
                    DivSuccess.Visible = false;
                    DivError.Visible   = true;
                }
            }
            else
            {
                DivSuccess.Visible = false;
                DivError.Visible   = true;
                LabelError.Text    = "Attenzione: Verificare che la foto sia nel formato *.jpg oppure *.png";
            }
        }
        else
        {
            DivSuccess.Visible = false;
            DivError.Visible   = true;
            LabelError.Text    = "Attenzione: Devi prima selezionare una foto attraverso il tasto 'Sfoglia'.";
        }
    }
Example #3
0
        protected void ButtonInsertProducto_Click(object sender, EventArgs e)
        {
            Producto p = new Producto();

            p.Nombre      = TextBoxNombreProducto.Text;
            p.Descripcion = TextBoxDescripcion.Text;
            p.Precio      = int.Parse(TextBoxPrecio.Text);
            p.Stock       = int.Parse(TextBoxStock.Text);
            p.Foto        = "~/FotoArticulos/" + FileUploadFoto.FileName;
            FileUploadFoto.SaveAs(Server.MapPath("~/FotoArticulos/" + FileUploadFoto.FileName));
            p.IdCategoria = int.Parse(DropDownListCategoria.SelectedValue);
            if (Agregar.AgregarProducto(p))
            {
                this.Page.Response.Write("<script language='JavaScript'>window.alert('se agrego correctamente');</script>");
            }
            else
            {
                this.Page.Response.Write("<script language='JavaScript'>window.alert('error al ingresar producto');</script>");
            }
        }