Wykorzystanie BAL w architekturze trójwarstwowej - Jak wywoływać metody z DAL do BAL
Jestem nowicjuszem w architekturze 3-warstwowej i poniżej jest mój kod DAL
public static int Insert(string firstname, string lastname, DateTime dob, string gender,string email, string password)
{
// bool flag = false;
SqlParameter pid;
SqlParameter result;
SqlConnection con = Generic.DBConnection.OpenConnection();
try
{
SqlCommand cmd1 = new SqlCommand("Insertreg", con);
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.AddWithValue("@FirstName", firstname);
cmd1.Parameters.AddWithValue("@LastName", lastname);
cmd1.Parameters.AddWithValue("@Dob", dob);
cmd1.Parameters.AddWithValue("@Gender", gender);
cmd1.Parameters.AddWithValue("@EmailId", email);
cmd1.Parameters.AddWithValue("@Password", password);
result = cmd1.Parameters.Add("@result", System.Data.SqlDbType.Int);
result.Direction = System.Data.ParameterDirection.Output;
pid = cmd1.Parameters.Add("@id", System.Data.SqlDbType.Int);
pid.Direction = System.Data.ParameterDirection.Output;
return cmd1.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
throw ex;
}
}
to w BAL
public int insert(string firstname,string lastname,DateTime dob,string gender,string email,string password)
{
ProfileMasterDAL dal=new ProfileMasterDAL();
try
{
return ProfileMasterDAL.Insert(firstname, lastname, dob, gender,email, password);
}
catch (Exception ex)
{
throw ex;
}
finally
{
dal = null;
}
}
I mój interfejs użytkownika
ProfileMasterBLL pmBLL = new ProfileMasterBLL();
pmBLL.insert(firstname, lastname, dob, gender, mobile, country, state, email, password);
Czy jest to poprawny sposób na kodowanie w 3 warstwach? Mam na myśli, jak wywoływać metody z DAL do BAL i do interfejsu użytkownika? Jeśli nie, zasugeruj mi jakiś dobry sposób.