ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Base De Datos


Enviado por   •  18 de Junio de 2013  •  680 Palabras (3 Páginas)  •  360 Visitas

Página 1 de 3

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using Dominio;

using Dominio.Observer;

using System.Globalization;

using System.Reflection;

namespace Interfaz

{

public partial class VentanaEditarPieza : Form, IObservador

{

private Stock stock;

private BindingSource bindingSource;

private Parte pieza;

public VentanaEditarPieza()

{

InitializeComponent();

comboBoxMedio.DataSource = Enum.GetValues(typeof(Constantes.Medio));

stock = Stock.ObtenerInstancia();

stock.AgregarObservador(this);

bindingSource = new BindingSource();

bindingSource.DataSource = stock.ModelosPiezas;

comboBoxModelos.DataSource = bindingSource;

}

public void Actualizar(Observable observable)

{

bindingSource.ResetBindings(false);

}

private void buttonGuardar_Click(object sender, EventArgs e)

{

if (!MetodosComunesInterfaz.ValidateFields(this.Controls))

{

MessageBox.Show(Constantes.competarTodosLosCampos);

return;

}

if (MessageBox.Show(Constantes.borrarPiezasConfirmation, "Confirm delete", MessageBoxButtons.YesNo) == DialogResult.Yes)

{

pieza = (Parte)comboBoxModelos.SelectedItem;

Parte p = PiezaFactory.GetParte((Constantes.Medio)comboBoxMedio.SelectedValue);

int cantidadPiezas = stock.GetCantidadPiezas(pieza.Modelo);

MetodosComunesInterfaz.SetObject(this.Controls, p);

stock.EliminarModeloPieza(pieza.Modelo);

stock.AgregarPiezaAListaPiezas(p, cantidadPiezas);

MessageBox.Show(Constantes.piezaModificada);

this.Close();

}

}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

{

if (comboBoxModelos.SelectedItem != null)

{

MetodosComunesInterfaz.SetVisibility(comboBoxMedio.SelectedValue.ToString(), this.Controls);

}

}

private void comboBoxModelos_SelectedIndexChanged(object sender, EventArgs e)

{

...

Descargar como (para miembros actualizados) txt (3 Kb)
Leer 2 páginas más »
Disponible sólo en Clubensayos.com