/// <summary> /// Dispara el form para la modificación de un suplemento /// </summary> /// <param name="sender"> de tipo object </param> /// <param name="e"> de tipo EventArgs </param> private void buttonModificarSuplemento_Click(object sender, EventArgs e) { if (this.dataGridSuplementos.Rows.Count > 0) { int indice = this.dataGridSuplementos.SelectedRows[0].Index; DataRow fila = this.dtSuplementos.Rows[indice]; Suplemento sup = new Suplemento(int.Parse(fila[0].ToString()), fila["nombre"].ToString(), fila["tipo"].ToString(), float.Parse(fila["precio"].ToString()), fila["formato"].ToString(), fila["empaque"].ToString()); FrmSuplemento frm = new FrmSuplemento(sup); frm.StartPosition = FormStartPosition.CenterScreen; try { if (frm.ShowDialog() == DialogResult.OK) { fila["nombre"] = frm.SuplementoDelForm.Nombre; fila["tipo"] = frm.SuplementoDelForm.Tipo; fila["precio"] = frm.SuplementoDelForm.Precio; fila["formato"] = frm.SuplementoDelForm.Formato; fila["empaque"] = frm.SuplementoDelForm.Empaque; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
/// <summary> /// Dispara el form para la carga de un suplemento /// </summary> /// <param name="sender"> de tipo object </param> /// <param name="e"> de tipo EventArgs </param> private void buttonCargarSuplemento_Click(object sender, EventArgs e) { FrmSuplemento frmSup = new FrmSuplemento(); frmSup.StartPosition = FormStartPosition.CenterScreen; try { if (frmSup.ShowDialog() == DialogResult.OK) { DataRow fila = this.dtSuplementos.NewRow(); fila["nombre"] = frmSup.SuplementoDelForm.Nombre; fila["tipo"] = frmSup.SuplementoDelForm.Tipo; fila["precio"] = frmSup.SuplementoDelForm.Precio; fila["formato"] = frmSup.SuplementoDelForm.Formato; fila["empaque"] = frmSup.SuplementoDelForm.Empaque; this.dtSuplementos.Rows.Add(fila); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Dispara el form para la eliminación de un suplemento /// </summary> /// <param name="sender"> de tipo object </param> /// <param name="e"> de tipo EventArgs </param> private void buttonEliminarSuplemento_Click(object sender, EventArgs e) { if (this.dataGridSuplementos.Rows.Count > 0) { int indice = this.dataGridSuplementos.SelectedRows[0].Index; DataRow fila = this.dtSuplementos.Rows[indice]; Suplemento sup = new Suplemento(int.Parse(fila[0].ToString()), fila["nombre"].ToString(), fila["tipo"].ToString(), float.Parse(fila["precio"].ToString()), fila["formato"].ToString(), fila["empaque"].ToString()); FrmSuplemento frm = new FrmSuplemento(sup); frm.StartPosition = FormStartPosition.CenterScreen; if (frm.ShowDialog() == DialogResult.OK && fila.RowState != DataRowState.Deleted) { fila.Delete(); } } }