private void tslAgregar_Click(object sender, EventArgs e) { frmLotesAE frm = new frmLotesAE(this); frm.Text = "Nuevo Lote"; DialogResult dr = frm.ShowDialog(this); if (dr == DialogResult.OK) { try { Lote lote = frm.GetLote(); if (!_servicio.Existe(lote)) { _servicio.Guardar(lote); DataGridViewRow r = ConstruirFila(); SetearFila(r, lote); AñadirFila(r); MessageBox.Show("Registro Agregado"); } else { MessageBox.Show("Lote repetido"); } } catch (Exception exception) { MessageBox.Show(exception.Message); } } }
private void tslEditar_Click(object sender, EventArgs e) { if (dgvDatos.SelectedRows.Count > 0) { DataGridViewRow r = dgvDatos.SelectedRows[0]; Lote lote = (Lote)r.Tag; lote = _servicio.GetLotePorId(lote.LoteId); frmLotesAE frm = new frmLotesAE(); frm.Text = "Editar Lote"; frm.SetLote(lote); DialogResult dr = frm.ShowDialog(this); if (dr == DialogResult.OK) { try { lote = frm.GetLote(); if (!_servicio.Existe(lote)) { _servicio.Guardar(lote); SetearFila(r, lote); MessageBox.Show("Registro Editado"); } else { MessageBox.Show("Lote Repetido"); } } catch (Exception exception) { MessageBox.Show(exception.Message); } } } }