Пример #1
0
 public static void obtenerSocio(string busquedaComboBox, string busquedaTextBox)
 {
     ds.Socio.Clear();
     try
     {
         SqlConnection sqlConnection = new SqlConnection(conexion);
         StringBuilder sql           = new StringBuilder();
         sql.AppendFormat("Select * from socio where {0} ='{1}'", busquedaComboBox, busquedaTextBox);
         SqlDataAdapter adapter = new SqlDataAdapter(sql.ToString(), conexion);
         adapter.Fill(ds.Socio);
         if (ds.Socio.Count() == 1)
         {
             socio = ds.Socio[0];
         }
         else
         {
             socio = null;
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("Ha ocurrido un error", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         error = null;
     }
 }
Пример #2
0
 public static void devolverPrestamo(string busquedaSocioComboBox, string busquedaSocioTextBox, string busquedaLibroComboBox, string busquedaLibroTextBox)
 {
     ds.Socio.Clear();
     ds.Libro.Clear();
     ds.Ejemplar.Clear();
     obtenerSocio(busquedaSocioComboBox, busquedaSocioTextBox);
     obtenerLibro(busquedaLibroComboBox, busquedaLibroTextBox);
     try
     {
         SqlConnection sqlConnection = new SqlConnection(conexion);
         StringBuilder sql           = new StringBuilder();
         sql.AppendFormat("Select * from ejemplar where CodigoLibro='{0}' and Estado='P'", libro.CodigoLibro);
         SqlDataAdapter adapter = new SqlDataAdapter(sql.ToString(), conexion);
         adapter.Fill(ds.Ejemplar);
         if (ds.Socio.Count() == 1)
         {
             if (ds.Libro.Count() == 1)
             {
                 if (ds.Ejemplar.Count() != 0)
                 {
                     ejemplar = ds.Ejemplar[0];
                 }
                 else
                 {
                     ejemplar = null;
                 }
             }
             else
             {
                 libro = null;
             }
         }
         else
         {
             socio = null;
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("Ha ocurrido un error", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         error = null;
     }
 }