Example #1
0
 protected void btnSalvaChangeFoto_OnClick(object sender, EventArgs e)
 {
     //hfIdFoto.Value = foto.idFoto.ToString();
     //hfModifica.Value = vedi.ToString();
     try
     {
         var cn = new GestioneCowBoy(ConnectionString);
         cn.SalvaModificheFoto(Convert.ToInt32(hfIdFoto.Value), hfModifica.Value == "2");
         var lstFoto = cn.GetFoto(Convert.ToInt32(hfIdAnagrafica.Value));
         PopolaFoto(lstFoto.OrderByDescending(f => f.Principale).ToList(), Convert.ToInt32(hfIdAnagrafica.Value));
     }
     catch (Exception ex)
     {
         this.GetAlert(this.GetType(), ex.Message);
     }
 }
Example #2
0
        protected void btnSaveNewFoto_OnClick(object sender, EventArgs e)
        {
            try
            {
                string baseImageLocation = ConfigurationManager.AppSettings["PercorsoSalvataggioFoto"];
                var    cn     = new GestioneCowBoy(ConnectionString);
                byte[] myData = null;


                Foto fotoFiglio = null;

                if (fuNewFoto.PostedFile != null &&
                    fuNewFoto.PostedFile.FileName.Trim() != string.Empty)
                {
                    var nomeFoto = Path.GetFileName(fuNewFoto.PostedFile.FileName);
                    myData = fuNewFoto.FileBytes;

                    fotoFiglio = new Foto()
                    {
                        Nome         = nomeFoto,
                        Principale   = chNewPrincipaleFoto.Checked,
                        idAnagrafica = Convert.ToInt32(hfIdAnagrafica.Value)
                    };
                    cn.SaveFoto(fotoFiglio, myData, baseImageLocation);
                    //aggiorno la griglia delle foto
                    var lstFoto = cn.GetFoto(Convert.ToInt32(hfIdAnagrafica.Value));
                    PopolaFoto(lstFoto.OrderByDescending(f => f.Principale).ToList(), Convert.ToInt32(hfIdAnagrafica.Value));
                }
                else
                {
                    this.GetAlert(this.GetType(), "Il file immagine non รจ stato trovato");
                }
            }
            catch (Exception ex)
            {
                this.GetAlert(this.GetType(), ex.Message);
            }
            //SaveFotoList
        }