private void button9_Click(object sender, EventArgs e) { try { List <Cliente> clientes = this.checkedListBox1.CheckedItems.OfType <Cliente>().ToList(); foreach (Cliente cliente in clientes) { biblioteca.EliminarCliente(cliente); this.checkedListBox1.Items.Remove(cliente); } } catch (Exception ex) { FormException formException = new FormException("Error", ex.Message); formException.Owner = this; formException.Show(); this.Enabled = false; } //FormException formException = new FormException("Función en desarrollo", "Próximamente esta función será habilitada"); //formException.Owner = this; //formException.Show(); //this.Enabled = false; }
private void button2_Click(object sender, EventArgs e) { try { if (dateTimePicker2.Text != "") { MessageBox.Show("El ejemplar ya fue devuelto"); } else if (DateTime.Now <= dateTimePicker2.Value) { this.biblioteca.ActualizarPrestamo(prestamo); MessageBox.Show("Prestamo modificado"); this.Owner.Enabled = true; this.Close(); } else { MessageBox.Show("La fecha de devolucion debe ser mayor a la fecha actual"); } } catch (Exception d) { FormException formException = new FormException("Error en las fechas ingresadas", d.Message); formException.Owner = this; formException.Show(); this.Enabled = false; } }
private void button1_Click(object sender, EventArgs e) { try { this.biblioteca.IngresarLibro(this.textBox1.Text, this.textBox2.Text, int.Parse(this.textBox3.Text), this.textBox4.Text, int.Parse(this.textBox5.Text), this.textBox6.Text); MessageBox.Show(string.Format("Se registró con éxito el libro \"{0}\".", this.textBox1.Text)); this.Owner.Enabled = true; this.Close(); } catch (Exception ex) { FormException formException = new FormException("ERROR", ex.Message); formException.Owner = this; formException.Show(); this.Enabled = false; } }
private void clickGuardar(object sender, EventArgs e) { try { activo = true; this.biblioteca.IngresarCliente(this.txtboxNombre.Text, this.txtboxApellido.Text, DateTime.Parse(this.dateTimePicker1.Text), this.txtboxDirec.Text, this.txtboxTel.Text, this.txtboxMail.Text, this.activo, int.Parse(this.textBox1.Text)); MessageBox.Show(string.Format("Se registró con éxito el cliente \"{0} {1}\".", this.txtboxNombre.Text, this.txtboxApellido.Text)); this.Owner.Enabled = true; this.Close(); } catch (Exception ex) { FormException formException = new FormException("ERROR", ex.Message); formException.Owner = this; formException.Show(); this.Enabled = false; } }
public FormAltaPrestamo(BibliotecaNegocio biblioteca) { InitializeComponent(); _biblioteca = biblioteca; try { foreach (Ejemplar ejemplar in _biblioteca.Ejemplares) { if (ejemplar.Prestado == false && ejemplar.IdLibro != 0) { comboBox1.Items.Add(ejemplar); } } foreach (Cliente cliente in _biblioteca.Clientes) { if (cliente.Activo) { comboBox2.Items.Add(cliente); } } textBox2.Enabled = false; textBox3.Enabled = false; textBox4.Enabled = false; textBox5.Enabled = false; textBox6.Enabled = false; //comboBox1.Enabled = false; } catch (SinClientesException ex) { FormException formException = new FormException("No hay clientes", ex.Message); formException.Owner = this; formException.Show(); this.Enabled = false; } catch (SinLibrosException ex) { FormException formException = new FormException("No hay libros", ex.Message); formException.Owner = this; formException.Show(); this.Enabled = false; } }
private void clickGuardarEjemplar(object sender, EventArgs e) { try { Libro libroSeleccionado = (Libro)this.comboBox1.SelectedItem; libroId = libroSeleccionado.Id; fechaAlta.ToShortDateString(); this.biblioteca.IngresarEjemplar(this.libroId, this.textBox5.Text, int.Parse(textBox6.Text), this.fechaAlta); MessageBox.Show(string.Format("Se registró con éxito el ejemplar del libro \"{0}\".", libroSeleccionado.Titulo)); this.Owner.Enabled = true; this.Close(); } catch (Exception ex) { FormException formException = new FormException("ERROR", ex.Message); formException.Owner = this; formException.Show(); this.Enabled = false; } }
private void button1_Click(object sender, EventArgs e) { try { if ((comboBox1.SelectedItem as Ejemplar) != null && (comboBox2.SelectedItem as Cliente) != null && numericUpDown1.Value > 0 && dateTimePicker1.Value > DateTime.Now) { _biblioteca.IngresarPrestamo(_cliente.Id, (comboBox1.SelectedItem as Ejemplar).Id, Decimal.ToInt32(numericUpDown1.Value), DateTime.Now, dateTimePicker1.Value); MessageBox.Show("Prestamo creado"); this.Owner.Enabled = true; this.Close(); } else { MessageBox.Show("Debe completar los campos antes de continuar"); } } catch (Exception ex) { FormException formException = new FormException("Error", ex.Message); formException.Owner = this; formException.Show(); this.Enabled = false; } }