Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
ASP.NET 2.0 / 3.5 / 4.0
Insert nTier e gestione errori
mercoledì 04 aprile 2007 - 19.23
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
squilibrio
Profilo
| Expert
527
messaggi | Data Invio:
mer 4 apr 2007 - 19:23
Ciao, dopo diversi tentativi e dopo aver consultato alcuni esempi sono giunto alla mia conclusione per la gestione in un insert in una struttura nTier.
Vorrei chiedervi se la mia impostazione è corretta (se potete dare uno sguardo veloce) e come potrei gestire, a questo punto, eventuali errori nel DAL (nell'operazione di INSERT) che dovrebbero poi essere visualizzati nello UI (ad esempio in una label). Vorrei quindi capire come gestire i vari Throw nel DAL e nel Manager per poi gestire il cath nella UI.
Grazie per l'aiuto
Entity
public class WebUtente
{
private string _nome;
private string _cognome;
private string _mail;
private string _password;
public string nome
{
get { return _nome; }
set { _nome = value; }
}
public string cognome
{
get { return _cognome; }
set { _cognome = value; }
}
public string mail
{
get { return _mail; }
set { _mail = value; }
}
...
Nella UI
protected void btnConferma_Click(object sender, EventArgs e)
{
WebUtentiManager utenteManager = new WebUtentiManager();
utenteManager.Insert(buildUtente());
}
private WebUtente buildUtente()
{
WebUtente utente = new WebUtente();
utente.nome = tbNome.Text;
utente.cognome = tbCognome.Text;
utente.mail = tbMail.Text;
return utente;
}
Nel DAL
public virtual void Insert(WebUtente item)
{
SqlHelper.ExecuteNonQueryTxt(CommandType.Text,
insertCommandText,
GetParametersByEntity(item));
}
Nel Manager
public class WebUtentiManager
{
public bool Insert(WebUtente utente)
{
WebUtentiData data = new WebUtentiData();
data.Insert(utente);
//a questo punto dovrei intercettare un errore .... come potrei gestire gli errori nel DAL e visualizzarli nella UI (ad esempio tramite un semplice messaggio in una label?)
}
}
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !