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(); } }
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(); }
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."; } }
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(); } }
public string EliminarPerfil(T_C_Perfil perfil) { return perfilAccess.EliminarPerfil(perfil); }
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(); } }
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(); } }