/** * Busca los registros que coincidan con los datos enviados * @param PERFIL obj * @return Retorna la lista de los registros que coinciden */ public PERFIL[] buscarPERFIL(PERFIL obj) { PERFIL[] result = null; List <PERFIL> lista = null; try { PERFILDao dao = new PERFILDao(); conn = conexion.conection(); lista = dao.search(conn, obj); if (lista != null && lista.Count > 0) { result = lista.ToArray(); } } catch (Exception e) { result = null; } finally { if (conn != null && conn.State == System.Data.ConnectionState.Open) { conn.Close(); } } return(result); }
private List <PERFIL> listQuery(SqlCommand stmt) { List <PERFIL> searchResults = new List <PERFIL>(); SqlDataReader reader = null; try { int intt = 0; long longg = 0; double doublee = 0; float floatt = 0; DateTime datee; byte[] bytee; reader = stmt.ExecuteReader(); while (reader.Read()) { PERFIL temp = createValueObject(); temp.ID = reader["ID"] != null && int.TryParse(reader["ID"].ToString(), out intt) ? intt : 0; temp.NOMBRE = reader["NOMBRE"] != null ? reader["NOMBRE"].ToString() : null; searchResults.Add(temp); } } finally { if (!reader.IsClosed) { reader.Close(); } if (stmt != null) { stmt.Dispose(); } } return(searchResults); }
/** * Inserta nuevo registro en la tabla * @param PERFIL obj * @return Retorna el mismo objeto pero con la llave primaria configurada */ public PERFIL crearPERFIL(PERFIL obj) { List <PERFIL> lista = null; try { PERFILDao dao = new PERFILDao(); conn = conexion.conection(); dao.create(conn, obj); //verificar existencia lista = dao.search(conn, obj); if (lista != null && lista.Count > 0) { obj = (PERFIL)lista[0]; } else { obj.ID = -1; } } catch (Exception e) { obj.ID = -1; } finally { if (conn != null && conn.State == System.Data.ConnectionState.Open) { conn.Close(); } } return(obj); }
public void delete(SqlConnection conn, PERFIL valueObject) { SqlCommand stmt = null; String sql = ""; try { sql = "DELETE FROM PERFIL WHERE ( id = @id )"; stmt = new SqlCommand(sql, conn); stmt.Parameters.AddWithValue("@id", valueObject.ID); int rowcount = databaseUpdate(stmt); if (rowcount == 0) { throw new Exception("Object could not be deleted! (PrimaryKey not found)"); } if (rowcount > 1) { throw new Exception("PrimaryKey Error when updating DB! (Many objects were deleted!)"); } } finally { if (stmt != null) { stmt.Dispose(); } } }
public static void Initialize(Context context) { if (!context.USUARIO.Any() && !context.PERFIL.Any() && !context.PERFIL_USUARIO.Any()) { PERFIL perfil = new PERFIL { PER_NOME = "Master" }; USUARIO user = new USUARIO { USU_NOME = "Master", USU_EMAIL = "*****@*****.**", USU_SENHA = MyUtil.ComputeSha256Hash("master") }; PERFIL_USUARIO perfil_usuario = new PERFIL_USUARIO { PERFIL = perfil, USUARIO = user }; context.Add(perfil_usuario); context.SaveChanges(); } }
public List <PERFIL> ObtenerListaPerfiles() { List <PERFIL> list = new List <PERFIL>(); PERFIL dto = null; try { using (OracleConnection cn = new OracleConnection(strOracle)) { cn.Open(); using (OracleCommand cmd = new OracleCommand("SELECT ID_PERFIL, NOMBRE FROM PERFIL", cn)) { OracleDataReader _reader = cmd.ExecuteReader(); while (_reader.Read()) { dto = new PERFIL(); dto.ID_PERFIL = Convert.ToInt32(_reader["ID_PERFIL"]); dto.NOMBRE = Convert.ToString(_reader["NOMBRE"]); list.Add(dto); } } } } catch (Exception ex) { new Exception("Error en metodo listar" + ex.Message); } return(list); }
public void create(SqlConnection conn, PERFIL valueObject) { String sql = ""; SqlCommand stmt = null; try { sql = "INSERT INTO PERFIL ( ID," + " NOMBRE)" + "VALUES (@ID,@NOMBRE)"; stmt = new SqlCommand(sql, conn); if (!String.IsNullOrEmpty(valueObject.NOMBRE) && valueObject.NOMBRE.Length <= 20) { stmt.Parameters.AddWithValue("@NOMBRE", valueObject.NOMBRE); } else { stmt.Parameters.AddWithValue("@NOMBRE", DBNull.Value); } databaseUpdate(stmt); } finally { if (stmt != null) { stmt.Dispose(); } } }
public PERFIL ListarTipoPerfil(long id) { using (var entities = databaseEntities.GetDB_LaborSafetyEntities()) { PERFIL perfil = entities.PERFIL.First(tipoPerfis => tipoPerfis.CodPerfil == id); return(perfil); } }
internal void delete(int id) { var db = new bibliotecaEntities(); var perfil = new PERFIL(); perfil.id = id; db.Entry(perfil).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); }
public ActionResult Update(PERFIL dto) { if (Session["Perfil"] != null) { NegocioPerfil obj = new NegocioPerfil(); obj.Update(dto); return(RedirectToAction("Read")); } else { return(View("../Mantenedor/LoginProcess")); } }
public ActionResult Update(int ID_PERFIL) { if (Session["Perfil"] != null) { NegocioPerfil obj = new NegocioPerfil(); PERFIL dto = obj.Read().FirstOrDefault(a => a.ID_PERFIL == ID_PERFIL); return(View("Update", dto)); } else { return(View("../Mantenedor/LoginProcess")); } }
public bool InsertPerfil(string Nombre, String Descripcion, String Prefijo) { using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString)) { PERFIL nueva = new PERFIL(); nueva.NOMBRE_PERFIL = Nombre; nueva.DESCRIPCION = Descripcion; nueva.PREFIJO = Prefijo; ctx.PERFIL.InsertOnSubmit(nueva); ctx.SubmitChanges(); } return(true); }
internal void persist(PERFIL perfil) { var db = new bibliotecaEntities(); if (perfil.id != 0) { db.Entry(perfil).State = System.Data.Entity.EntityState.Modified; } else { db.PERFIL.Add(perfil); } db.SaveChanges(); }
public PerfilViewEditar(int id, string nome, int qtdLivros, int diasEmprestimo, decimal valorMulta) : this() { var perfil = new PERFIL(); perfil.id = id; perfil.nome = nome; perfil.qtLivros = qtdLivros; perfil.diasParaEmprestimo = diasEmprestimo; perfil.valorMulta = valorMulta; txtId.Text = perfil.id.ToString(); txtNome.Text = perfil.nome; txtQtdLivros.Text = perfil.qtLivros.ToString(); txtValorMulta.Text = perfil.valorMulta.ToString(); txtDiasEmprestimo.Text = perfil.diasParaEmprestimo.ToString(); }
public bool delete() { try { using (var comun = new Common().modelo) { PERFIL per = comun.PERFIL.First(p => p.PER_ID == this.id); comun.PERFIL.Remove(per); comun.SaveChanges(); return(true); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public bool update() { try { using (var comun = new Common().modelo) { PERFIL per = comun.PERFIL.First(p => p.PER_ID == this.id); per.PER_NOMBRE = nombre; comun.SaveChanges(); return(true); } } catch (Exception ex) { throw new Exception(ex.Message); } }
private void pbSalvar_Click(object sender, EventArgs e) { var perfil = new PERFIL(); if (!txtId.Text.Equals(string.Empty)) { perfil.id = int.Parse(txtId.Text); } perfil.nome = txtNome.Text; perfil.qtLivros = int.Parse(txtQtdLivros.Text); perfil.valorMulta = decimal.Parse(txtValorMulta.Text); perfil.diasParaEmprestimo = int.Parse(txtDiasEmprestimo.Text); PerfilController c = new PerfilController(); c.persist(perfil); this.Close(); }
/*catch * { * return null; * }*/ //} /*WebService.WebServicePruebaSoapClient servicio = new WebService.WebServicePruebaSoapClient(); * DataSet custDS = new DataSet(); * custDS = servicio.getEncontrar(codigo); * if (custDS.Tables["DATOS"].Rows.Count > 0) * { * //foreach (DataSet registro in custDS.Tables) * iRecinto recinto = new iRecinto(); * recinto.Codigo = custDS.Tables["DATOS"].Rows[0]["idRecinto"].ToString(); * //recinto.FotoRecinto = custDS.Tables["DATOS"].Rows[0]["fotoMapa"].ToString(); * recinto.FotoMapa = custDS.Tables["DATOS"].Rows[0]["fotoRecinto"].ToString(); * * return recinto; * } * else * return null;*/ public PerfilBEL buscarUsuario(String usuario_login, String pass_login) { String pass_encryp = _encriptar(pass_login); PERFIL perfil_encontrado = ConexionBLL.getConexion().PERFIL.FirstOrDefault(tempPerfil => (tempPerfil.USUARIO.Equals(usuario_login) && tempPerfil.CONTRASENA.Equals(pass_encryp))); if (perfil_encontrado != null) { PerfilBEL usuario_enc = new PerfilBEL(); usuario_enc.IdPerfil = Convert.ToInt32(perfil_encontrado.ID_PERFIL); usuario_enc.Usuario = perfil_encontrado.USUARIO; usuario_enc.Contrasena = perfil_encontrado.CONTRASENA; usuario_enc.IdTipoPerfil = Convert.ToInt32(perfil_encontrado.ID_TIPO_PERFIL); return(usuario_enc); } return(null); }
public bool save() { try { PERFIL per = new PERFIL(); per.PER_ID = id; per.PER_NOMBRE = nombre; using (var comun = new Common().modelo) { comun.PERFIL.Add(per); comun.SaveChanges(); return(true); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public int agregarPerfil(PerfilBEL perBel) { try { Entidades conexion = ConexionBLL.getConexion(); PERFIL perDALC = new PERFIL(); perDALC.USUARIO = perBel.Usuario; perDALC.CONTRASENA = _encriptar(perBel.Contrasena); perDALC.ID_TIPO_PERFIL = perBel.IdTipoPerfil; conexion.AddToPERFIL(perDALC); conexion.SaveChanges(); conexion.Dispose(); PerfilBEL perfilEnc = buscarUsuario(perBel.Usuario, perBel.Contrasena); return(perfilEnc.IdPerfil); } catch { return(0); } }
/** * Edita un registro en la tabla * @param PERFIL obj * @return boolean indicando si se realizo o no la actualizacion */ public bool editarPERFIL(PERFIL obj) { bool resultado; resultado = false; try { PERFILDao dao = new PERFILDao(); conn = conexion.conection(); dao.save(conn, obj); resultado = true; } catch (Exception e) { resultado = false; } finally { if (conn != null && conn.State == System.Data.ConnectionState.Open) { conn.Close(); } } return(resultado); }
public List <PERFIL> search(SqlConnection conn, PERFIL valueObject) { List <PERFIL> searchResults = new List <PERFIL>(); bool first = true; String sql = "SELECT * FROM PERFIL WHERE 1=1 "; if (!String.IsNullOrEmpty(valueObject.ID.ToString())) { if (first) { first = false; } sql += "AND ID= '" + valueObject.ID + "' "; } if (!String.IsNullOrEmpty(valueObject.NOMBRE.ToString())) { if (first) { first = false; } sql += "AND NOMBRE= '" + valueObject.NOMBRE + "' "; } sql += "ORDER BY id ASC "; if (first) { searchResults = new List <PERFIL>(); } else { searchResults = listQuery(new SqlCommand(sql, conn)); } return(searchResults); }
public void save(SqlConnection conn, PERFIL valueObject) { SqlCommand stmt = null; String sql = ""; try { sql = "UPDATE PERFIL SET ID = @ID ," + " NOMBRE = @NOMBRE WHERE (id = @id)"; stmt = new SqlCommand(sql, conn); if (!String.IsNullOrEmpty(valueObject.NOMBRE) && valueObject.NOMBRE.Length <= 20) { stmt.Parameters.AddWithValue("@NOMBRE", valueObject.NOMBRE); } else { stmt.Parameters.AddWithValue("@NOMBRE", DBNull.Value); } stmt.Parameters.AddWithValue("@id", valueObject.ID); int rowcount = databaseUpdate(stmt); if (rowcount == 0) { throw new Exception("Object could not be saved! (PrimaryKey not found)"); } } finally { if (stmt != null) { stmt.Dispose(); } } }
public PERFIL buscarPrimeroPERFIL(PERFIL obj) { return(gestionPERFIL.buscarPrimeroPERFIL(obj)); }
public bool eliminarPERFIL(PERFIL obj) { return(gestionPERFIL.eliminarPERFIL(obj)); }
public PERFIL[] buscarPERFIL(PERFIL obj) { return(gestionPERFIL.buscarPERFIL(obj)); }
public string Insert(PERFIL dto) { DaoPerfil dao = new DaoPerfil(); return(dao.Insert(dto)); }
public bool editarPERFIL(PERFIL obj) { return(gestionPERFIL.editarPERFIL(obj)); }
public PERFIL crearPERFIL(PERFIL obj) { return(gestionPERFIL.crearPERFIL(obj)); }
public string Update(PERFIL dto) { DaoPerfil dao = new DaoPerfil(); return(dao.Update(dto)); }