public object mtdlis(string rol = "") { string bus = ""; if (rol != "") { bus = "Select * From Rol Where Rol = '" + rol + "' "; } else { bus = "Select * From Rol"; } DataTable tblrol = new DataTable(); conex = conexion.mtdconexion(); adaprol = new SqlDataAdapter(bus, conex); conex.Open(); adaprol.Fill(tblrol); conex.Close(); List <EClRol> lista = new List <EClRol>(); foreach (DataRow fila in tblrol.Rows) { EClRol objERol = new EClRol(); objERol.IdRol = Convert.ToInt32(fila["IdRol"].ToString()); objERol.Rol = fila["Rol"].ToString(); lista.Add(objERol); } return(lista); }
public int mtddaros(EClRol objERol) { string agre = "Insert into Rol (Rol) Values ('" + objERol.Rol + "')"; conex = conexion.mtdconexion(); coman = new SqlCommand(agre, conex); conex.Open(); int reg = coman.ExecuteNonQuery(); conex.Close(); return(reg); }