Beispiel #1
0
        private void ClickAceptar(object sender, EventArgs e)
        {
            try
            {
                if (DatosValidos())
                {
                    var stock = new Stock();
                    stock.Id       = idStock ?? 0;
                    stock.Cantidad = int.Parse(((TextBox)controles.Find(x => x.Name == "txtCantidad")).Text);

                    var ubicacion = ((ComboBox)controles.Find(x => x.Name == "comboUbicacion")).SelectedItem as Ubicacion;
                    var articulo  = ((ComboBox)controles.Find(x => x.Name == "comboArticulo")).SelectedItem as Articulo;

                    stock.Ubicacion = ubicacion;
                    stock.Articulo  = articulo;

                    if (idStock.HasValue)
                    {
                        stockBLL.Modificacion(stock);
                    }
                    else
                    {
                        stockBLL.Alta(stock);
                    }

                    frm.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }