Exemplo n.º 1
0
 public string ActualizarPerfil(T_C_Perfil perfil)
 {
     try
     {
         Connection = new SqlConnection(ConnectionString);
         using (Command = new System.Data.SqlClient.SqlCommand("T_C_PerfilUpdate", Connection))
         {
             Command.CommandType = System.Data.CommandType.StoredProcedure;
             Command.Parameters.AddWithValue("@Id_Perfil", perfil.Id_Perfil);
             Command.Parameters.AddWithValue("@Nombre", perfil.Nombre);
             Command.Parameters.AddWithValue("@Descripcion", perfil.Descripcion);
             Command.Parameters.AddWithValue("@Id_Estado", perfil.Id_Estado);
             Connection.Open();
             Command.ExecuteNonQuery();
         }
         return "Registro actualizado satisfactoriamente.";
     }
     catch (Exception ex)
     {
         return ex.Message;
     }
     finally
     {
         Connection.Close();
     }
 }
Exemplo n.º 2
0
 private void btnRegistrar_Click(object sender, RoutedEventArgs e)
 {
     T_C_Perfil perfil = new T_C_Perfil();
     perfil.Nombre = txtNombre.Text;
     perfil.Descripcion = txtDescripción.Text;
     MessageBox.Show(perfilLogic.AgregarPerfil(perfil));
     gvPerfiles.ItemsSource = perfilLogic.ListarPerfiles();
     Limpia();
 }
Exemplo n.º 3
0
 public string AgregarPerfil(T_C_Perfil perfil)
 {
     try
     {
         if (perfil.Nombre == string.Empty)
         {
             throw new Exception();
         }
         return perfilAccess.AgregarPerfil(perfil);
     }
     catch
     {
         return "Error al ingresar datos.";
     }
     
 }
Exemplo n.º 4
0
 public string EliminarPerfil(T_C_Perfil perfil)
 {
     try
     {
         Connection = new SqlConnection(ConnectionString);
         using (Command = new System.Data.SqlClient.SqlCommand("T_C_PerfilDelete", Connection))
         {
             Command.CommandType = System.Data.CommandType.StoredProcedure;
             Command.Parameters.AddWithValue("@Id_Perfil", perfil.Id_Perfil);
             Connection.Open();
             Command.ExecuteNonQuery();
         }
         return "Registro eliminado satisfactoriamente.";
     }
     catch (Exception ex)
     {
         return ex.Message;
     }
     finally
     {
         Connection.Close();
     }
 }
Exemplo n.º 5
0
 public string EliminarPerfil(T_C_Perfil perfil)
 {
     return perfilAccess.EliminarPerfil(perfil);
 }
Exemplo n.º 6
0
        public List<T_C_Perfil> SeleccionarTodosPerfil()
        {
            try
            {
                Connection = new SqlConnection(ConnectionString);
                List<T_C_Perfil> perfiles;
                using (Command = new System.Data.SqlClient.SqlCommand("T_C_PerfilSelectAll", Connection))
                {
                    Command.CommandType = System.Data.CommandType.StoredProcedure;
                    Connection.Open();
                    perfiles = new List<T_C_Perfil>();
                    SqlDataReader reader = Command.ExecuteReader();
                    while (reader.Read())
                    {
                        T_C_Perfil perfil = new T_C_Perfil();
                        perfil.Id_Perfil = Convert.ToInt32(reader.GetValue(reader.GetOrdinal("Id_Perfil")).ToString());
                        perfil.Nombre = reader.GetValue(reader.GetOrdinal("Nombre")).ToString();
                        perfil.Descripcion = reader.GetValue(reader.GetOrdinal("Descripcion")).ToString();
                        perfil.Id_Estado = Convert.ToInt32(reader.GetValue(reader.GetOrdinal("Id_Estado")).ToString());
                        perfil.Estado = estadoAccess.Seleccionar(perfil.Id_Estado);

                        perfiles.Add(perfil);
                    }
                }
                return perfiles;
            }
            catch (Exception ex)
            {
                return null;
            }
            finally
            {
                Connection.Close();
            }
        }
Exemplo n.º 7
0
 public T_C_Perfil Seleccionar(int idPerfil)
 {
     try
     {
         Connection = new SqlConnection(ConnectionString);
         T_C_Perfil perfil = new T_C_Perfil();
         using (Command = new System.Data.SqlClient.SqlCommand("T_C_PerfilSelect", Connection))
         {
             Command.Parameters.AddWithValue("@Id_Estado", idPerfil);
             Command.CommandType = System.Data.CommandType.StoredProcedure;
             Connection.Open();
             SqlDataReader reader = Command.ExecuteReader();
             while (reader.Read())
             {
                 perfil.Id_Estado = Convert.ToInt32(reader.GetValue(reader.GetOrdinal("Id_Estado")).ToString());
                 perfil.Id_Perfil = Convert.ToInt32(reader.GetValue(reader.GetOrdinal("Id_Perfil")).ToString());
                 perfil.Nombre = reader.GetValue(reader.GetOrdinal("Nombre")).ToString();
                 perfil.Descripcion = reader.GetValue(reader.GetOrdinal("Descripcion")).ToString();
             }
         }
         return perfil;
     }
     catch (Exception ex)
     {
         return null;
     }
     finally
     {
         Connection.Close();
     }
 }