public static VOPersona ConsultarPersona(int idPersona)
        {
            VOPersona     persona  = null;
            Conexion      conexion = new Conexion();
            SqlConnection cnn      = new SqlConnection(conexion.CadenaConexion);
            SqlDataReader datos;

            try
            {
                cnn.Open();
                SqlCommand cmd = new SqlCommand("SP_ConsultarPersona", cnn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@IdPersona", SqlDbType.Int).Value = idPersona;
                datos = cmd.ExecuteReader();
                while (datos.Read())
                {
                    persona = new VOPersona(Convert.ToInt32(datos.GetValue(0).ToString()),
                                            datos.GetValue(1).ToString(), datos.GetValue(2).ToString(),
                                            datos.GetValue(3).ToString(), datos.GetValue(4).ToString(),
                                            Convert.ToInt32(datos.GetValue(5).ToString()),
                                            Convert.ToBoolean(datos.GetValue(6).ToString()), datos.GetValue(7).ToString());
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException("No se pudo completar la busqueda");
            }
            finally
            {
                cnn.Close();
            }
            return(persona);
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Enumeradores.EnumToListBox(typeof(CargoPersona), ddlCargo, true);

                if (Request.QueryString["id"] == null)
                {
                    Response.Redirect("ListarPersonas.aspx");
                }
                else
                {
                    bool      disponibilidad = true;
                    string    idPersona      = Request.QueryString["id"].ToString();
                    VOPersona persona        = BLLPersona.ConsultarPersona(idPersona);
                    CargarFormulario(persona);
                    disponibilidad = (bool)persona.Disponibilidad;
                    if (disponibilidad)
                    {
                        lblIdPersona.ForeColor = System.Drawing.Color.Green;
                    }
                    else
                    {
                        lblIdPersona.ForeColor = System.Drawing.Color.Red;
                    }
                }
            }
        }
        public static void Actualizar(VOPersona persona)
        {
            Conexion      conexion = new Conexion();
            SqlConnection cnn      = new SqlConnection(conexion.CadenaConexion);
            int           r        = 0;

            try
            {
                cnn.Open();
                SqlCommand cmd = new SqlCommand("SP_ActualizarPersona", cnn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@IdPersona", SqlDbType.VarChar).Value  = persona.IdPersona;
                cmd.Parameters.Add("@Nombre", SqlDbType.VarChar).Value     = persona.Nombre;
                cmd.Parameters.Add("@Direccion", SqlDbType.VarChar).Value  = persona.Direccion;
                cmd.Parameters.Add("@Telefono", SqlDbType.VarChar).Value   = persona.Telefono;
                cmd.Parameters.Add("@Correo", SqlDbType.VarChar).Value     = persona.Correo;
                cmd.Parameters.Add("@Cargo", SqlDbType.Int).Value          = persona.Cargo;
                cmd.Parameters.Add("@UrlFoto", SqlDbType.VarChar).Value    = persona.UrlFoto;
                cmd.Parameters.Add("@Disponibilidad", SqlDbType.Bit).Value = persona.Disponibilidad;
                r = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new ArgumentException("No se pudo actualizar el registro en la base de datos " + ex.Message);
            }
            finally
            {
                cnn.Close();
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["id"] == null)
         {
             Response.Redirect("ListarPersonas.aspx");
         }
         else
         {
             bool      disponibilidad = true;
             string    idPersona      = Request.QueryString["id"].ToString();
             VOPersona persona        = BLLPersona.ConsultarPersona(idPersona);
             CargarFormulario(persona);
             CargarGrid(idPersona);
             disponibilidad = (bool)persona.Disponibilidad;
             if (disponibilidad)
             {
                 lblIdPersona.ForeColor = System.Drawing.Color.Green;
                 btnEliminar.Visible    = true;
             }
             else
             {
                 lblIdPersona.ForeColor = System.Drawing.Color.Red;
                 btnEliminar.Visible    = false;
             }
         }
     }
 }
 public void CargarFormulario(VOPersona persona)
 {
     lblIdPersona.Text            = persona.IdPersona.ToString();
     lblNombre.Text               = persona.Nombre;
     lblDireccion.Text            = persona.Direccion;
     lblTelefono.Text             = persona.Telefono;
     lblCorreo.Text               = persona.Correo;
     lblCargo.Text                = Enum.GetName(typeof(CargoPersona), (int)persona.Cargo);
     chkPersonaDisponible.Checked = (bool)persona.Disponibilidad;
     imgFotoPersona.ImageUrl      = persona.UrlFoto;
 }
Example #6
0
 public void CargarFormulario(VOPersona persona)
 {
     lblIdPersona.Text       = persona.IdPersona.ToString();
     txtNombre.Text          = persona.Nombre;
     txtDireccion.Text       = persona.Direccion;
     txtTelefono.Text        = persona.Telefono;
     txtCorreo.Text          = persona.Correo;
     ddlCargo.SelectedIndex  = (int)persona.Cargo;
     lblUrlFoto.InnerText    = persona.UrlFoto;
     imgFotoPersona.ImageUrl = persona.UrlFoto;
 }
Example #7
0
 public static void Actualizar(VOPersona persona)
 {
     try
     {
         DALPersona.Actualizar(persona);
     }
     catch
     {
         throw new ArgumentException("No se pudo actualizar el dato");
     }
 }
Example #8
0
 public static void Insertar(VOPersona persona)
 {
     try
     {
         DALPersona.Insertar(persona);
     }
     catch
     {
         throw new ArgumentException("No se pudo insertar el dato");
     }
 }
Example #9
0
 protected void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         VOPersona persona = new VOPersona(int.Parse(lblIdPersona.Text), txtTelefono.Text, txtDireccion.Text, txtNombre.Text, txtCorreo.Text, int.Parse(ddlCargo.SelectedValue), null, lblUrlFoto.InnerText);
         BLLPersona.Actualizar(persona);
         LimpiarFormulario();
         Response.Redirect("ListarPersonas.aspx", false);
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterClientScriptBlock(this, GetType(), "Mensaje de Error", "alert('Se registró un error al realizar la operación');", true);
     }
 }
Example #10
0
 public static void InsertarSalida(VOSalida salida)
 {
     try
     {
         VOPersona capitan = new VOPersona(salida.IdCapitan, null, null, null, null, null, false, null);
         BLLPersona.Actualizar(capitan);
         VOBarco barco = new VOBarco(salida.IdBarco, null, null, null, null, null, null, false);
         BLLBarco.Actualizar(barco);
         DALSalida.InsertarSalida(salida);
     }
     catch (Exception ex)
     {
         throw new ArgumentException("Error al insertar el registro de salida");
     }
 }