public void Eliminar(int id) { TelefonoEntity entidad = new TelefonoEntity(); entidad.IdTelefono = id; EjecutarComando(daComun.TipoComandoEnum.Eliminar, entidad); }
public void Insertar(TelefonoEntity entidad) { daContadores da = new daContadores(); entidad.IdTelefono = da.TraerContador(daComun.Contador.Telefono) + 1; EjecutarComando(daComun.TipoComandoEnum.Insertar, entidad); da.Sumar(daComun.Contador.Telefono); }
private TelefonoEntity CrearEntidad(OdbcDataReader dr) { TelefonoEntity entidad = new TelefonoEntity(); entidad.IdTelefono = Convert.ToInt32(dr["IdTelefono"]); entidad.IdCliente = Convert.ToInt32(dr["IdCliente"]); entidad.Telefono = dr["Telefono"].ToString(); return(entidad); }
private void CrearParametros(OdbcCommand command, TelefonoEntity entidad) { OdbcParameter parameter = null; parameter = command.Parameters.Add("?", OdbcType.Int); parameter.Value = entidad.IdCliente; parameter = command.Parameters.Add("?", OdbcType.VarChar); parameter.Value = entidad.Telefono; }
public static void AgregarTelefono(string telefono, int idcliente) { TelefonoEntity tel = new TelefonoEntity(); tel.IdCliente = idcliente; tel.Telefono = telefono; daTelefono da = new daTelefono(); da.Insertar(tel); }
private void EjecutarComando(daComun.TipoComandoEnum sqlCommandType, TelefonoEntity entidad) { OdbcConnection connection = null; OdbcCommand command = null; try { connection = (OdbcConnection)connectionDA.GetOpenedConnection(); IDataParameter paramId = new OdbcParameter("?", OdbcType.Int); paramId.Value = entidad.IdTelefono; switch (sqlCommandType) { case daComun.TipoComandoEnum.Insertar: command = new OdbcCommand(SQLInsert, connection); command.Parameters.Add(paramId); CrearParametros(command, entidad); break; case daComun.TipoComandoEnum.Actualizar: command = new OdbcCommand(SQLUpdate, connection); command.Parameters.Add(paramId); CrearParametros(command, entidad); break; case daComun.TipoComandoEnum.Eliminar: command = new OdbcCommand(SQLDelete, connection); command.Parameters.Add(paramId); CrearParametros(command, entidad); break; } command.ExecuteNonQuery(); connection.Close(); } catch (Exception ex) { throw new daException(ex); } finally { if (command != null) { command.Dispose(); } if (connection != null) { connection.Dispose(); } } }
public void Actualizar(TelefonoEntity entidad) { EjecutarComando(daComun.TipoComandoEnum.Actualizar, entidad); }
public void Actualizar(TelefonoEntity entidad) { EjecutarComando(TipoComando.Actualizar, entidad); }
public void Insertar(TelefonoEntity entidad) { EjecutarComando(TipoComando.Insertar, entidad); }