public Boolean insertHobie(AlpinismoBE hboe) { Boolean b = true; SqlConnection cnx = new SqlConnection(ClaseConexion.ObtenerCadenaMINSURBAS()); SqlCommand cmd = new SqlCommand(); SqlDataReader dr = default(SqlDataReader); var _with1 = cmd; _with1.Connection = cnx; _with1.CommandType = CommandType.StoredProcedure; _with1.CommandText = "inserhobie"; _with1.Parameters.Add("@hobie", SqlDbType.VarChar, 100).Value = hboe.Deporte; _with1.Parameters.Add("@itinerario", SqlDbType.VarChar, 100).Value = hboe.Horario; _with1.Parameters.Add("@tipodedeporte", SqlDbType.VarChar, 100).Value = hboe.Tipo; try { cnx.Open(); //dr = cmd.ExecuteReader(); cmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); b = false; } finally { cnx.Close(); } return b; }
public string insertar(AlpinismoBE hboe) { int cant = hbdo.validaHobie(hboe.Deporte); if (cant > 0) { throw new System.ArgumentException("El Hobbie fue ingresado , Desea registrar otro Hobbie", "original"); } else { hbdo.insertHobie(hboe); return "La Grabacion fue Exitosa"; } }