protected void btnSalvaAnagrafica_OnClick(object sender, EventArgs e) { try { if (hfIdAnagrafica.Value == string.Empty || Convert.ToInt32(hfIdAnagrafica.Value) == 0) { this.GetAlert(this.GetType(), string.Format("Attenzione, ritornare sulla home page e riselezionare il bovino. Se il problema persiste contattare l'amministratore di sistema.")); return; } string baseImageLocation = ConfigurationManager.AppSettings["PercorsoSalvataggioFoto"]; Anagrafica ana = new Anagrafica() { idAnagrafica = Convert.ToInt32(hfIdAnagrafica.Value), Madre = hfCercaMadreVal.Value != String.Empty ? Convert.ToInt32(hfCercaMadreVal.Value) : (int?)null, Padre = hfCercaPadreVal.Value != String.Empty ? Convert.ToInt32(hfCercaPadreVal.Value) : (int?)null, DataNascita = Convert.ToDateTime(txtDataNascita.Text), MatricolaASL = TxtMatricola.Text.Trim().ToUpper(), MatricolaAzienda = txtnNewMatricolaAzienda.Text.Trim().ToUpper(), Nome = txtNome.Text.Trim(), Sesso = chFBovino.Checked == true ? "F" : "M" }; // byte[] myData = null; //Foto fotoFiglio = null; //if (fuAllegatiNewBovino.PostedFile != null && // fuAllegatiNewBovino.PostedFile.FileName.Trim() != string.Empty) //{ // var nomeFoto = Path.GetFileName(fuAllegatiNewBovino.PostedFile.FileName); // myData = fuAllegatiNewBovino.FileBytes; // fotoFiglio = new Foto() // { // Nome = nomeFoto, // Principale = true // }; //} var cow = new GestioneCowBoy(ConnectionString); cow.SaveAnagrafica(ana); } catch (Exception ex) { this.GetAlert(this.GetType(), ex.Message); } }