private void btnGuardar_Click(object sender, RoutedEventArgs e) { ClienteServiceClient servCliente = new ClienteServiceClient(); ClienteBE cliente = new ClienteBE(); cliente.Cedula = lblCedulaCli.Text; cliente.Nombres_Cliente = txtNombres.Text.ToUpper(); cliente.Apellido_1 = txtPrApellido.Text.ToUpper(); cliente.Apellido_2 = txtSgApellido.Text.ToUpper(); UbicacionBE ubicacion = new UbicacionBE(); ubicacion.Direccion = txtDir.Text.ToUpper(); ubicacion.Barrio = txtBarrio.Text.ToUpper(); ubicacion.Telefono_1 = txtTel.Text; CiudadBE ciudad = new CiudadBE(); ciudad.Id_Ciudad = "231"; ubicacion.Ciudad = ciudad; cliente.Ubicacion = ubicacion; servCliente.Registrar_ClienteAsync(cliente); servCliente.Registrar_ClienteCompleted += new EventHandler<Registrar_ClienteCompletedEventArgs>(RegistrarCliente); servCliente.CloseAsync(); }
public UbicacionBE RegistrarUbicacion(UbicacionBE entidad) { int cod = 0; try { using (IDbConnection db = new OracleConnection(CadenaConexion)) { string sp = sPackage + "USP_INS_UBICACION"; var parametros = new OracleParameter[2]; parametros[0] = new OracleParameter("pDescripcion", entidad.DESCRIPCION); parametros[1] = new OracleParameter("pIdUbicacion", OracleDbType.Int32, ParameterDirection.Output); OracleHelper.ExecuteNonQuery(CadenaConexion, CommandType.StoredProcedure, sp, parametros); cod = int.Parse(parametros[1].Value.ToString()); entidad.ID_UBICACION = cod; entidad.OK = true; } } catch (Exception ex) { entidad.extra = ex.Message; Log.Error(ex); } return(entidad); }
public List <Ubicacion_CilindroBE> HistoricoCilindro(string codigo) { List <Ubicacion_CilindroBE> lstResp = new List <Ubicacion_CilindroBE>(); VehiculoBE veh = new VehiculoBE(); ReporteDL rep = new ReporteDL(); VehiculoDL vehDL = new VehiculoDL(); UbicacionBE ubi = new UbicacionBE(); ClienteDL cliDL = new ClienteDL(); try { lstResp = rep.ConsultarHistoricoCilindro(codigo); foreach (Ubicacion_CilindroBE datos in lstResp) { if (datos.Nombre_Ubicacion == "VEHICULO") { veh = vehDL.ConsultaPlacaPorUbicacion(datos.Id_Ubicacion_Cilindro); ubi.Vehiculo = veh; datos.Ubicacion = ubi; } if (datos.Nombre_Ubicacion == "CLIENTE") { ubi = cliDL.ConsultarDirClientePorUbicacion(datos.Id_Ubicacion_Cilindro); datos.Ubicacion = ubi; } } } catch (Exception ex) { } return(lstResp); }
protected void btnGuardar_Click(object sender, EventArgs e) { ClienteServiceClient servCliente = new ClienteServiceClient(); long resp; try { ClienteBE cliente = new ClienteBE(); UbicacionBE ubi = new UbicacionBE(); ubi.Direccion = txtNuevaDireccion.Text; ubi.Barrio = txtNuevoBarrio.Text; ubi.Telefono_1 = txtTelefono.Text; cliente.Ubicacion = ubi; CiudadBE ciucli = new CiudadBE(); ciucli.Id_Ciudad = lstCiudad.SelectedValue; ubi.Ciudad = ciucli; cliente.Cedula = lblCedula.Text; resp = servCliente.Agregar_Ubicacion(cliente); MessageBox.Show("La nueva ubicación fue registrada satisfactoriamente", "Registrar Nueva Ubicación"); } catch (Exception ex) { Response.Redirect("~/About.aspx"); } finally { servCliente.Close(); Response.Redirect("~/Clientes/frmModificarCliente.aspx"); } }
public CilindroBE ConsultarCilindro(string cilindro) { CilindroDL cil = new CilindroDL(); CilindroBE resp = new CilindroBE(); try { resp = cil.ConsultarCilindro(cilindro); if (resp.Tipo_Ubicacion.Nombre_Ubicacion == "VEHICULO") { VehiculoDL veh = new VehiculoDL(); VehiculoBE datVeh = new VehiculoBE(); string var = Convert.ToString(resp.Tipo_Ubicacion.Ubicacion.Id_Ubicacion); datVeh = veh.ConsultaPlacaPorUbicacion(var); resp.Vehiculo = datVeh; } if (resp.Tipo_Ubicacion.Nombre_Ubicacion == "CLIENTE") { ClienteDL cli = new ClienteDL(); UbicacionBE datCli = new UbicacionBE(); string idUbica = resp.Tipo_Ubicacion.Ubicacion.Id_Ubicacion; datCli = cli.ConsultarDirClientePorUbicacion(idUbica); resp.Ubicacion = datCli; string idCliente = resp.Ubicacion.Cliente.Id_Cliente; resp.Cliente = cli.ConsultarCliente(idCliente); } } catch (Exception ex) { } return(resp); }
public List <UbicacionBE> ListarUbicacionPaginado(UbicacionBE entidad) { List <UbicacionBE> Lista = null; try { using (IDbConnection db = new OracleConnection(CadenaConexion)) { string sp = sPackage + "USP_SEL_UBICACION"; var p = new OracleDynamicParameters(); p.Add("pBuscar", entidad.buscar); p.Add("pRegistros", entidad.cantidad_registros); p.Add("pPagina", entidad.pagina); p.Add("pSortColumn", entidad.order_by); p.Add("pSortOrder", entidad.order_orden); p.Add("pRefcursor", dbType: OracleDbType.RefCursor, direction: ParameterDirection.Output); Lista = db.Query <UbicacionBE>(sp, p, commandType: CommandType.StoredProcedure).ToList(); } } catch (Exception ex) { Log.Error(ex); } return(Lista); }
private void btnGuardarModif_Click(object sender, RoutedEventArgs e) { ClienteServiceClient servCliente = new ClienteServiceClient(); ClienteBE cliente = new ClienteBE(); cliente.Cedula = lblCedulaCli2.Text; cliente.Nombres_Cliente = txtNombres2.Text.ToUpper(); cliente.Apellido_1 = txtPrApellido2.Text.ToUpper(); cliente.Apellido_2 = txtSgApellido2.Text.ToUpper(); UbicacionBE ubi = new UbicacionBE(); if (Convert.ToBoolean(lblDireccion.Visibility == System.Windows.Visibility.Visible)) { ubi.Id_Ubicacion = lblIdDir.Text; ubi.Direccion = txtDir.Text.ToUpper(); ubi.Barrio = txtBarrio.Text.ToUpper(); ubi.Telefono_1 = txtTel.Text.ToUpper(); ubi.Ciudad.Id_Ciudad = "231"; btnGuardarModif.Margin = new Thickness(19, 643, 0, 0); btnMenuConsul.Margin = new Thickness(224, 643, 0, 0); servCliente.ModificarDirClienteAsync(ubi); servCliente.ModificarDirClienteCompleted += new EventHandler <ModificarDirClienteCompletedEventArgs>(ModificarUbicacion); } servCliente.ModificarNombreClienteAsync(cliente); servCliente.ModificarNombreClienteCompleted += new EventHandler <ModificarNombreClienteCompletedEventArgs>(ModificarCliente); servCliente.CloseAsync(); }
/// <summary> /// Encargado de recibir un cliente de los canales front de venta y llamar /// al metodo de negocio para modificar el registro de cliente /// </summary> /// <param name="registrar_cli">Objeto de negocio cliente</param> /// <returns>cédula del cliente</returns> public long ModificarDirCliente(UbicacionBE ubicacion) { long resp; ClienteBL ModCliente = new ClienteBL(); resp = ModCliente.ModificarDirCliente(ubicacion); return(resp); }
public static List <UbicacionBE> ListarUbicacionExcel(UbicacionBE entidad) { if (string.IsNullOrEmpty(entidad.buscar)) { entidad.buscar = ""; } return(energ.ListarUbicacionExcel(entidad)); }
public UbicacionBE ConsultarDirPorUbicacion(string idUbica) { UbicacionBE resp = new UbicacionBE(); ClienteDL cli = new ClienteDL(); try { resp = cli.ConsultarDirClientePorUbicacion(idUbica); } catch (Exception ex) { } return(resp); }
protected void btnGuardar_Click(object sender, EventArgs e) { ClienteServiceClient servCliente = new ClienteServiceClient(); long respCliente; long respUbicacion; ClienteBE cliente = new ClienteBE(); try { cliente.Nombres_Cliente = txtNombreCliente.Text; cliente.Apellido_1 = txtPrimerApellido.Text; cliente.Apellido_2 = txtSegundoApellido.Text; cliente.Cedula = txtCedulaCli.Text; respCliente = servCliente.ModificarNombreCliente(cliente); if (txtDireccion.Text != "") { UbicacionBE ubica = new UbicacionBE(); ubica.Id_Ubicacion = lblIdUbica.Text; ubica.Direccion = txtDireccion.Text; ubica.Barrio = txtBarrio.Text; ubica.Telefono_1 = txtTelefono.Text; CiudadBE ciudad = new CiudadBE(); ciudad.Id_Ciudad = lstCiudad.SelectedValue; ubica.Ciudad = ciudad; respUbicacion = servCliente.ModificarDirCliente(ubica); } MessageBox.Show("El cliente fue modificado satisfactoriamente", "Modificar Cliente"); } catch (Exception ex) { Response.Redirect("~/About.aspx"); } finally { servCliente.Close(); Response.Redirect("~/Clientes/frmModificarCliente.aspx"); txtCedula.Focus(); } }
public long ModificarDirCliente(UbicacionBE cliente) { ClienteDL cli = new ClienteDL(); long resp = 0; try { resp = cli.ModificarDirCliente(cliente); } catch (Exception ex) { //guardar exepcion en el log de bd resp = -1; } return(resp); }
protected void btnGuardar_Click(object sender, EventArgs e) { ClienteServiceClient servCliente = new ClienteServiceClient(); long resp; ClienteBE cliente = new ClienteBE(); try { cliente.Cedula = txtCedulaCli.Text; cliente.Nombres_Cliente = txtNombreCliente.Text; cliente.Apellido_1 = txtPrimerApellido.Text; cliente.Apellido_2 = txtSegundoApellido.Text; UbicacionBE ubicacion = new UbicacionBE(); ubicacion.Direccion = txtDireccion.Text; ubicacion.Barrio = txtBarrio.Text; ubicacion.Telefono_1 = txtTelefono.Text; CiudadBE ciucli = new CiudadBE(); ciucli.Id_Ciudad = lstCiudad.SelectedValue; ubicacion.Ciudad = ciucli; cliente.Ubicacion = ubicacion; resp = servCliente.Registrar_Cliente(cliente); if (resp != -1) { MessageBox.Show("El cliente fue registrado satisfactoriamente", "Registrar Cliente"); } else { Response.Redirect("~/About.aspx"); } } catch (Exception ex) { Response.Redirect("~/About.aspx"); } finally { servCliente.Close(); Response.Redirect("~/Clientes/frmRegistrarCliente.aspx"); } }
public UbicacionBE GetUbicacionPorId(UbicacionBE entidad) { try { using (IDbConnection db = new OracleConnection(CadenaConexion)) { string sp = sPackage + "USP_GET_UBICACION"; var p = new OracleDynamicParameters(); p.Add("pIdUbicacion", entidad.ID_UBICACION); p.Add("pRefcursor", dbType: OracleDbType.RefCursor, direction: ParameterDirection.Output); entidad = db.Query <UbicacionBE>(sp, p, commandType: CommandType.StoredProcedure).FirstOrDefault(); } } catch (Exception ex) { Log.Error(ex); } return(entidad); }
public UbicacionBE EliminarUbicacion(UbicacionBE entidad) { try { using (IDbConnection db = new OracleConnection(CadenaConexion)) { string sp = sPackage + "USP_DEL_UBICACION"; var parametros = new OracleParameter[1]; parametros[0] = new OracleParameter("pID_UBICACION", entidad.ID_UBICACION); OracleHelper.ExecuteNonQuery(CadenaConexion, CommandType.StoredProcedure, sp, parametros); entidad.OK = true; } } catch (Exception ex) { entidad.extra = ex.Message; Log.Error(ex); } return(entidad); }
public List <UbicacionBE> ListarUbicacion(UbicacionBE entidad) { List <UbicacionBE> Lista = null; try { using (IDbConnection db = new OracleConnection(CadenaConexion)) { string sp = sPackage + "USP_SEL_LISTA_UBICACION"; var p = new OracleDynamicParameters(); p.Add("pRefcursor", dbType: OracleDbType.RefCursor, direction: ParameterDirection.Output); Lista = db.Query <UbicacionBE>(sp, p, commandType: CommandType.StoredProcedure).ToList(); } } catch (Exception ex) { Log.Error(ex); } return(Lista); }
private void btnGuardar_Click(object sender, RoutedEventArgs e) { ClienteServiceClient servCliente = new ClienteServiceClient(); ClienteBE nuevadir = new ClienteBE(); nuevadir.Cedula = lblCedulaCli2.Text; UbicacionBE ubicacion = new UbicacionBE(); ubicacion.Direccion = txtNuevaDir.Text.ToUpper(); ubicacion.Barrio = txtNuevoBarrio.Text.ToUpper(); ubicacion.Telefono_1 = txtTelefono.Text.ToUpper(); CiudadBE ciu = new CiudadBE(); ciu.Nombre_Ciudad = "231"; ubicacion.Ciudad = ciu; nuevadir.Ubicacion = ubicacion; servCliente.Agregar_UbicacionAsync(nuevadir); servCliente.Agregar_UbicacionCompleted += new EventHandler <Agregar_UbicacionCompletedEventArgs>(AgregarUbiNueva); servCliente.CloseAsync(); }
private void btnGuardarModif_Click(object sender, RoutedEventArgs e) { ClienteServiceClient servCliente = new ClienteServiceClient(); ClienteBE cliente = new ClienteBE(); cliente.Cedula = lblCedulaCli2.Text; cliente.Nombres_Cliente = txtNombres2.Text.ToUpper(); cliente.Apellido_1 = txtPrApellido2.Text.ToUpper(); cliente.Apellido_2 = txtSgApellido2.Text.ToUpper(); UbicacionBE ubi = new UbicacionBE(); if (Convert.ToBoolean(lblDireccion.Visibility == System.Windows.Visibility.Visible)) { ubi.Id_Ubicacion = lblIdDir.Text; ubi.Direccion = txtDir.Text.ToUpper(); ubi.Barrio = txtBarrio.Text.ToUpper(); ubi.Telefono_1 = txtTel.Text.ToUpper(); ubi.Ciudad.Id_Ciudad = "231"; btnGuardarModif.Margin = new Thickness(19, 643, 0, 0); btnMenuConsul.Margin = new Thickness(224, 643, 0, 0); servCliente.ModificarDirClienteAsync(ubi); servCliente.ModificarDirClienteCompleted += new EventHandler<ModificarDirClienteCompletedEventArgs>(ModificarUbicacion); } servCliente.ModificarNombreClienteAsync(cliente); servCliente.ModificarNombreClienteCompleted += new EventHandler<ModificarNombreClienteCompletedEventArgs>(ModificarCliente); servCliente.CloseAsync(); }
private void btnGuardar_Click(object sender, RoutedEventArgs e) { ClienteServiceClient servCliente = new ClienteServiceClient(); ClienteBE nuevadir = new ClienteBE(); nuevadir.Cedula = lblCedulaCli2.Text; UbicacionBE ubicacion = new UbicacionBE(); ubicacion.Direccion = txtNuevaDir.Text.ToUpper(); ubicacion.Barrio = txtNuevoBarrio.Text.ToUpper(); ubicacion.Telefono_1 = txtTelefono.Text.ToUpper(); CiudadBE ciu = new CiudadBE(); ciu.Nombre_Ciudad = "231"; ubicacion.Ciudad = ciu; nuevadir.Ubicacion = ubicacion; servCliente.Agregar_UbicacionAsync(nuevadir); servCliente.Agregar_UbicacionCompleted += new EventHandler<Agregar_UbicacionCompletedEventArgs>(AgregarUbiNueva); servCliente.CloseAsync(); }
public CilindroBE ConsultarCilindro(string cilindro) { CilindroBE cil = new CilindroBE(); try { string nameSP = "ConsultarCilindros"; BaseDatos db = new BaseDatos(); db.Conectar(); db.CrearComandoSP(nameSP); DbParameter[] parametros = new DbParameter[3]; parametros[0] = db.Comando.CreateParameter(); parametros[0].ParameterName = "vrCodigo_Cilindro"; parametros[0].Value = cilindro; parametros[0].Direction = ParameterDirection.Input; db.Comando.Parameters.Add(parametros[0]); parametros[1] = db.Comando.CreateParameter(); parametros[1].ParameterName = "vrCodResult"; parametros[1].Value = 0; parametros[1].Direction = ParameterDirection.Output; db.Comando.Parameters.Add(parametros[1]); parametros[2] = db.Comando.CreateParameter(); parametros[2].ParameterName = "vrDescResult"; parametros[2].Value = ""; parametros[2].Direction = ParameterDirection.Output; parametros[2].Size = 200; parametros[2].DbType = DbType.String; db.Comando.Parameters.Add(parametros[2]); DbDataReader datos = db.EjecutarConsulta(); CilindroBE c = null; while (datos.Read()) { try { c = new CilindroBE(); c.Id_Cilindro = datos.GetValue(0).ToString(); c.Ano = datos.GetString(1); c.Codigo_Cilindro = datos.GetString(2); c.Tipo_Cilindro = datos.GetString(3); c.Serial_Cilindro = datos.GetString(4); c.Fecha = datos.GetDateTime(5); FabricanteBE fab = new FabricanteBE(); fab.Nombre_Fabricante = (datos.GetValue(6).ToString()); c.Fabricante = fab; Tipo_UbicacionBE tipUbi = new Tipo_UbicacionBE(); tipUbi.Nombre_Ubicacion = datos.GetString(7); UbicacionBE ubi = new UbicacionBE(); ubi.Id_Ubicacion = datos.GetValue(8).ToString(); tipUbi.Ubicacion = ubi; c.Tipo_Ubicacion = tipUbi; TamanoBE tam = new TamanoBE(); tam.Tamano = (datos.GetString(9)); c.NTamano = tam; cil = c; } catch (InvalidCastException ex) { throw new Exception("Los tipos no coinciden.", ex); } catch (DataException ex) { throw new Exception("Error de ADO.NET.", ex); } } datos.Close(); db.Desconectar(); } catch (Exception ex) { throw new Exception("Error al acceder a la base de datos para obtener los CilindroBEs."); } return(cil); }
public static UbicacionBE EliminarUbicacion(UbicacionBE entidad) { return(energ.EliminarUbicacion(entidad)); }
public static UbicacionBE ActualizarUbicacion(UbicacionBE entidad) { return(energ.ActualizarUbicacion(entidad)); }
public static UbicacionBE RegistrarUbicacion(UbicacionBE entidad) { return(energ.RegistrarUbicacion(entidad)); }
public static UbicacionBE GetUbicacionPorId(UbicacionBE entidad) { return(energ.GetUbicacionPorId(entidad)); }
public static List <UbicacionBE> ListarUbicacion(UbicacionBE entidad) { return(energ.ListarUbicacion(entidad)); }
public ClienteBE ConsultarCliente(string cliente) { ClienteBE cli = new ClienteBE(); try { string nameSP = "ConsultarClientes"; BaseDatos db = new BaseDatos(); db.Conectar(); db.CrearComandoSP(nameSP); DbParameter[] parametros = new DbParameter[3]; parametros[0] = db.Comando.CreateParameter(); parametros[0].ParameterName = "vrCedula"; parametros[0].Value = cliente; parametros[0].Direction = ParameterDirection.Input; db.Comando.Parameters.Add(parametros[0]); parametros[1] = db.Comando.CreateParameter(); parametros[1].ParameterName = "vrCodResult"; parametros[1].Value = 0; parametros[1].Direction = ParameterDirection.Output; db.Comando.Parameters.Add(parametros[1]); parametros[2] = db.Comando.CreateParameter(); parametros[2].ParameterName = "vrDescResult"; parametros[2].Value = ""; parametros[2].Direction = ParameterDirection.Output; parametros[2].Size = 200; parametros[2].DbType = DbType.String; db.Comando.Parameters.Add(parametros[2]); DbDataReader datos = db.EjecutarConsulta(); List <UbicacionBE> lstUbicaciones = new List <UbicacionBE>(); ClienteBE c = null; while (datos.Read()) { try { c = new ClienteBE(); c.Cedula = datos.GetString(0); c.Nombres_Cliente = datos.GetString(1).ToString(); c.Apellido_1 = (datos.GetString(2)); c.Apellido_2 = (datos.GetString(3)); UbicacionBE ubi = new UbicacionBE(); ubi.Direccion = datos.GetString(4); ubi.Telefono_1 = datos.GetString(5); ubi.Barrio = datos.GetString(6); CiudadBE ciu = new CiudadBE(); ciu.Nombre_Ciudad = datos.GetString(7); ciu.Id_Ciudad = datos.GetValue(8).ToString(); DepartamentoBE dep = new DepartamentoBE(); dep.Nombre_Departamento = datos.GetString(9); dep.Id_Departamento = datos.GetValue(10).ToString(); c.Id_Cliente = datos.GetValue(11).ToString(); ubi.Id_Ubicacion = datos.GetValue(12).ToString(); ciu.Departamento = dep; ubi.Ciudad = ciu; lstUbicaciones.Add(ubi); c.ListaDirecciones = lstUbicaciones; cli = c; } catch (InvalidCastException ex) { throw new Exception("Los tipos no coinciden.", ex); } catch (DataException ex) { throw new Exception("Error de ADO.NET.", ex); } } datos.Close(); db.Desconectar(); } catch (Exception ex) { throw new Exception("Error al acceder a la base de datos para obtener los ClienteBEs."); } return(cli); }
public long ModificarDirCliente(UbicacionBE ubicacion) { long codigo = 0; BaseDatos db = new BaseDatos(); try { db.Conectar(); db.ComenzarTransaccion(); string nameSP = "ModificarUbiCliente"; db.CrearComandoSP(nameSP); DbParameter[] parametros = new DbParameter[7]; parametros[0] = db.Comando.CreateParameter(); parametros[0].ParameterName = "vrIdUbicacion"; parametros[0].Value = ubicacion.Id_Ubicacion; parametros[0].Direction = ParameterDirection.Input; parametros[0].Size = 12; db.Comando.Parameters.Add(parametros[0]); parametros[1] = db.Comando.CreateParameter(); parametros[1].ParameterName = "vrDireccion"; parametros[1].Value = ubicacion.Direccion; parametros[1].Direction = ParameterDirection.Input; parametros[1].Size = 30; db.Comando.Parameters.Add(parametros[1]); parametros[2] = db.Comando.CreateParameter(); parametros[2].ParameterName = "vrBarrio"; parametros[2].Value = ubicacion.Barrio; parametros[2].Direction = ParameterDirection.Input; parametros[2].Size = 30; db.Comando.Parameters.Add(parametros[2]); parametros[3] = db.Comando.CreateParameter(); parametros[3].ParameterName = "vrTelefono"; parametros[3].Value = ubicacion.Telefono_1; parametros[3].Direction = ParameterDirection.Input; parametros[3].Size = 10; db.Comando.Parameters.Add(parametros[3]); parametros[4] = db.Comando.CreateParameter(); parametros[4].ParameterName = "vrId_Ciudad"; parametros[4].Value = ubicacion.Ciudad.Id_Ciudad; parametros[4].Direction = ParameterDirection.Input; parametros[4].Size = 5; db.Comando.Parameters.Add(parametros[4]); parametros[5] = db.Comando.CreateParameter(); parametros[5].ParameterName = "vrCodResult"; parametros[5].Value = 0; parametros[5].Direction = ParameterDirection.Output; db.Comando.Parameters.Add(parametros[5]); parametros[6] = db.Comando.CreateParameter(); parametros[6].ParameterName = "vrDescResult"; parametros[6].Value = ""; parametros[6].Direction = ParameterDirection.Output; parametros[6].Size = 200; parametros[6].DbType = DbType.String; db.Comando.Parameters.Add(parametros[6]); db.EjecutarComando(); codigo = long.Parse(db.Comando.Parameters[5].Value.ToString()); db.ConfirmarTransaccion(); } catch (Exception ex) { db.CancelarTransaccion(); throw new Exception("Error al crear el ClienteBE.", ex); } finally { db.Desconectar(); } return(codigo); }
public UbicacionBE ConsultarDirClientePorUbicacion(string cliente) { UbicacionBE ubicacion = new UbicacionBE(); try { string nameSP = "ConsultarDirClientesPorUbicacion"; BaseDatos db = new BaseDatos(); db.Conectar(); db.CrearComandoSP(nameSP); DbParameter[] parametros = new DbParameter[3]; parametros[0] = db.Comando.CreateParameter(); parametros[0].ParameterName = "vrIdUbica"; parametros[0].Value = cliente; parametros[0].Direction = ParameterDirection.Input; db.Comando.Parameters.Add(parametros[0]); parametros[1] = db.Comando.CreateParameter(); parametros[1].ParameterName = "vrCodResult"; parametros[1].Value = 0; parametros[1].Direction = ParameterDirection.Output; db.Comando.Parameters.Add(parametros[1]); parametros[2] = db.Comando.CreateParameter(); parametros[2].ParameterName = "vrDescResult"; parametros[2].Value = ""; parametros[2].Direction = ParameterDirection.Output; parametros[2].Size = 200; parametros[2].DbType = DbType.String; db.Comando.Parameters.Add(parametros[2]); DbDataReader datos = db.EjecutarConsulta(); UbicacionBE u = null; while (datos.Read()) { try { u = new UbicacionBE(); u.Direccion = datos.GetString(0); u.Telefono_1 = datos.GetString(1); u.Barrio = datos.GetString(2); CiudadBE ciu = new CiudadBE(); ciu.Nombre_Ciudad = datos.GetString(3); ciu.Id_Ciudad = datos.GetValue(4).ToString(); DepartamentoBE dep = new DepartamentoBE(); dep.Nombre_Departamento = datos.GetString(5); dep.Id_Departamento = datos.GetValue(6).ToString(); ClienteBE cli = new ClienteBE(); cli.Id_Cliente = datos.GetValue(7).ToString(); u.Cliente = cli; ciu.Departamento = dep; u.Ciudad = ciu; ubicacion = u; } catch (InvalidCastException ex) { throw new Exception("Los tipos no coinciden.", ex); } catch (DataException ex) { throw new Exception("Error de ADO.NET.", ex); } } datos.Close(); db.Desconectar(); } catch (Exception ex) { throw new Exception("Error al acceder a la base de datos para obtener los ClienteBEs."); } return(ubicacion); }