public void borrarFoto(TOFoto foto) { try { string insert = "delete from foto_ficha_doctor where urlfoto = @url and id_consulta = @id"; SqlCommand insertar = new SqlCommand(insert, conexion); insertar.Parameters.AddWithValue("@url", foto.url); insertar.Parameters.AddWithValue("@id", foto.idDoctor); if (conexion.State != System.Data.ConnectionState.Open) { conexion.Open(); } insertar.ExecuteNonQuery(); if (conexion.State != System.Data.ConnectionState.Closed) { conexion.Close(); } } catch (SqlException) { throw; } catch (Exception) { throw; } finally { conexion.Close(); } }
public void insertarFoto(TOFoto foto) { try { string insert = "insert into Foto_Ficha_Doctor (URLFoto, ID_CONSULTA) values (@url, @id)"; SqlCommand insertar = new SqlCommand(insert, conexion); insertar.Parameters.AddWithValue("@url", foto.url); insertar.Parameters.AddWithValue("@id", foto.idDoctor); if (conexion.State != System.Data.ConnectionState.Open) { conexion.Open(); } insertar.ExecuteNonQuery(); if (conexion.State != System.Data.ConnectionState.Closed) { conexion.Close(); } } catch (SqlException) { throw; } catch (Exception) { throw; } finally { conexion.Close(); } }
public List <TOFoto> consultarFoto(int idConsulta) { try { TOFoto to = new TOFoto(); string select = "select * from foto_ficha_doctor where id_Consulta = @idConsulta;"; SqlCommand sentencia = new SqlCommand(select, conexion); sentencia.Parameters.AddWithValue("@idConsulta", idConsulta); DataTable table = new DataTable(); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = sentencia; adapter.Fill(table); List <TOFoto> lista = new List <TOFoto>(); for (int x = 0; x < table.Rows.Count; x++) { TOFoto foto = new TOFoto(); foto.url = Convert.ToString(table.Rows[x]["URLFOTO"]); foto.idDoctor = Convert.ToInt32(table.Rows[x]["ID_CONSULTA"]); lista.Add(foto); } return(lista); } catch (SqlException) { throw; } catch (Exception) { throw; } finally { conexion.Close(); } }
public BLFoto convert(TOFoto foto) { return(new BLFoto(foto.url, foto.idDoctor)); }