/// <summary> /// Permite agregar un item a la tabla del stock /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAgregar_Click(object sender, EventArgs e) { try { FrmABM frm = new FrmABM(); if (frm.ShowDialog() == DialogResult.OK) { DataRow fila = this.dt.NewRow(); fila["Marca"] = frm.Elec.Marca; fila["Modelo"] = frm.Elec.Modelo; fila["Precio"] = frm.Elec.Precio; fila["Tipo"] = frm.Elec.GetType().Name; this.dt.Rows.Add(fila); } } catch (NullReferenceException ex) { MessageBox.Show("Se intentaron agregar valores nulos"); } catch (ModeloException ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Permite modificar los datos del item seleccionado /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnModificar_Click(object sender, EventArgs e) { try { int indice = this.grillaInventario.CurrentRow.Index; FrmABM frm = new FrmABM(this.dt.Rows[indice]["Marca"].ToString(), this.dt.Rows[indice]["tipo"].ToString(), this.dt.Rows[indice]["Modelo"].ToString(), this.dt.Rows[indice]["Precio"].ToString()); if (frm.ShowDialog() == DialogResult.OK) { this.dt.Rows[indice]["Marca"] = frm.Elec.Marca; this.dt.Rows[indice]["Modelo"] = frm.Elec.Modelo; this.dt.Rows[indice]["Precio"] = frm.Elec.Precio; this.dt.Rows[indice]["Tipo"] = frm.Elec.GetType().Name; } } catch (ModeloException ex) { MessageBox.Show(ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }