public FormRegistrarCarga() { InitializeComponent(); fachada = FachadaUISistema.getFachada(); listaCargasRealizadas.Items.Clear(); foreach (Carga c in fachada.getListaCargas()) { listaCargasRealizadas.Items.Add(c); } listaCargasRealizadas.Show(); listaCargasRealizadas.HorizontalScrollbar = true; comboUsuarios.Items.Clear(); foreach (Usuario u in fachada.getListaUsuarios()) { comboUsuarios.Items.Add(u); } comboUsuarios.Show(); comboClientes.Items.Clear(); foreach (Cliente c in fachada.getListaClientes()) { comboClientes.Items.Add(c); } comboClientes.Show(); comboSurtidor.Items.Clear(); foreach (Surtidor s in fachada.getListaSurtidores()) { comboSurtidor.Items.Add(s); } comboSurtidor.Show(); }
private void buttonRealizarCarga_Click(object sender, EventArgs e) { try { if (comboClientes.SelectedItem != null && comboVehiculos.SelectedItem != null && comboUsuarios.SelectedItem != null && comboManguera.SelectedItem != null && comboSurtidor.SelectedItem != null && (textCantidad.Text.Trim().Length > 0) && (textNumero.Text.Trim().Length > 0)) { int numero = Convert.ToInt32(textNumero.Text.Trim()); int cantidad = Convert.ToInt32(textCantidad.Text.Trim()); if (cantidad < 0) { MessageBox.Show("La cantidad no puede ser negativa", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { fachada.realizarCarga((Usuario)comboUsuarios.SelectedItem, (Cliente)comboClientes.SelectedItem, (Vehiculo)comboVehiculos.SelectedItem, (Manguera)comboManguera.SelectedItem, (Surtidor)comboSurtidor.SelectedItem, cantidad, numero); MessageBox.Show("Carga realizada con éxito"); borrarDatos(); } listaCargasRealizadas.Items.Clear(); foreach (Carga c in fachada.getListaCargas()) { listaCargasRealizadas.Items.Add(c); } listaCargasRealizadas.Show(); } else { MessageBox.Show("Faltan datos.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (MiExcepcion es) { MessageBox.Show(es.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error en los datos", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public FormListadoCargas() { InitializeComponent(); fachada = FachadaUISistema.getFachada(); listCargas.Items.Clear(); foreach (Carga carga in fachada.getListaCargas()) { listCargas.Items.Add(carga); } listCargas.Show(); comboSurtidor.Items.Clear(); foreach (Surtidor s in fachada.getListaSurtidores()) { comboSurtidor.Items.Add(s); } comboSurtidor.Show(); dateTimePickerHasta.Value = DateTime.Now; }
private void btnFiltrar_Click(object sender, EventArgs e) { if (dateTimePickerDesde.Value.ToString("dd-MM-yyyy").Equals("01-01-2014") && dateTimePickerHasta.Value.ToString("dd-MM-yyyy").Equals(DateTime.Now.ToString("dd-MM-yyyy")) && textLtsDesde.Text == "" && textLtsHasta.Text == "" && comboSurtidor.Text == "Surtidor" && comboManguera.Text == "Manguera") { listCargas.Items.Clear(); foreach (Carga carga in fachada.getListaCargas()) { listCargas.Items.Add(carga); } listCargas.Show(); } else { DateTime fechaDesde = dateTimePickerDesde.Value; DateTime fechaHasta = dateTimePickerHasta.Value; int litrosDesde; int litrosHasta; Surtidor surtidor; Manguera manguera; if (textLtsDesde.Text == "") { litrosDesde = 0; } else { litrosDesde = Convert.ToInt32(textLtsDesde.Text.Trim()); } if (textLtsHasta.Text == "") { litrosHasta = 0; } else { litrosHasta = Convert.ToInt32(textLtsHasta.Text.Trim()); } if (comboSurtidor.Text == "Surtidor") { surtidor = null; } else { surtidor = (Surtidor)comboSurtidor.SelectedItem; } if (comboManguera.Text == "Manguera") { manguera = null; } else { manguera = (Manguera)comboManguera.SelectedItem; } List <Carga> listaFiltrada = fachada.listaCargaFiltrada(fechaDesde, fechaHasta, litrosDesde, litrosHasta, surtidor, manguera); listCargas.Items.Clear(); foreach (Carga carga in listaFiltrada) { listCargas.Items.Add(carga); } listCargas.Show(); } String litrosTxt; if (textLtsDesde.Text == "" || textLtsHasta.Text == "") { litrosTxt = " sin filtro de litros "; } else { litrosTxt = " entre " + textLtsDesde.Text + " y " + textLtsHasta.Text + " litros "; } lblresumenFiltro.Text = "Se muestran los resultados desde " + dateTimePickerDesde.Value.ToString("dd-MM-yyyy") + " hasta " + dateTimePickerHasta.Value.ToString("dd-MM-yyyy") + litrosTxt + "para los surtidores y mangueras seleccionadas"; textLtsDesde.Text = ""; textLtsHasta.Text = ""; comboSurtidor.Text = "Surtidor"; comboManguera.Text = "Manguera"; }